iRoCS Toolbox
1.1.0
|
The StDataASCII class is a container for "structured data", that is kept completly in memory. More...
#include <StDataASCII.hh>
Public Member Functions | |
StDataASCII () | |
double | asDouble (const std::string &key) const |
const std::string & | asString (const std::string &key) const |
return the associated string to the given key directly More... | |
unsigned int | asUint (const std::string &key) const |
std::map< std::string, std::string >::const_iterator | begin () const |
const access to internal map More... | |
void | debugPrint (std::ostream &os) const |
for debugging print whole internal map More... | |
std::map< std::string, std::string >::const_iterator | end () const |
bool | exceptionFlag () const |
template<typename ForwardIter > | |
void | getArray (const std::string &key, const ForwardIter &arrBegin, int containerSize=-1) const |
getArray. More... | |
size_t | getArraySize (std::string key) const |
get size of Array associated with given key. More... | |
template<typename ForwardIter > | |
void | getFVArray (const std::string &key, const ForwardIter &arrBegin, int containerSize=-1) const |
get a list (or a 1D array) of feature vectors. More... | |
size_t | getFVArraySize (std::string key) const |
get number of Feature vectors in the list associated with that kay More... | |
template<typename T > | |
void | getValue (const std::string &key, T &value) const |
get a value (with arbitrary type) from the internal map<string,string> specified by the given key. More... | |
void | readArraySizeFromStream (std::istream &is, size_t &size) const |
char | separatorChar () const |
template<typename ForwardIter > | |
void | setArray (const std::string &key, const ForwardIter &arrBegin, size_t size) |
setArray writes/adds an array of values (with arbitrary type) to the internal map<string,string>. More... | |
void | setExceptionFlag (bool f) |
Specify, if getValue() should throw expcetions for unknown keys. More... | |
template<typename ForwardIter > | |
void | setFVArray (const std::string &key, const ForwardIter &arrBegin, size_t size) |
setFVPList writes/adds a list (or a 1D array) of feature vectors to the internal map<string,string>. More... | |
void | setSeparatorChar (char c) |
set character to separate elements of vectors within the value-string. More... | |
template<typename T > | |
void | setValue (const std::string &key, const T &value) |
setValue writes/adds a value (with arbitrary type) to the internal map<string,string>. More... | |
template<typename T > | |
void | stringToValue (const std::string &s, T &value) const |
convert any std::string to any type using an std::istringstream. More... | |
void | stringToValue (const std::string &s, std::string &value) const |
bool | valueExists (const std::string &key) const |
check wether a value exists for requested key More... | |
Protected Attributes | |
bool | _exceptionFlag |
std::map< std::string, std::string > | _map |
char | _separatorChar |
The StDataASCII class is a container for "structured data", that is kept completly in memory.
internally it uses a std::map<std::string, std::string> to store the data
Definition at line 83 of file StDataASCII.hh.
|
inline |
Definition at line 87 of file StDataASCII.hh.
|
inline |
Specify, if getValue() should throw expcetions for unknown keys.
f | true: getValue() should throw expcetions for unknown keys |
Definition at line 105 of file StDataASCII.hh.
|
inline |
Definition at line 116 of file StDataASCII.hh.
|
inline |
check wether a value exists for requested key
key | the key |
Definition at line 131 of file StDataASCII.hh.
void svt::StDataASCII::setValue | ( | const std::string & | key, |
const T & | value | ||
) |
setValue writes/adds a value (with arbitrary type) to the internal map<string,string>.
key | the key for that value |
value | the value itself |
Referenced by svt::Model< FV >::setTrainingInfoValue(), and valueExists().
void svt::StDataASCII::setArray | ( | const std::string & | key, |
const ForwardIter & | arrBegin, | ||
size_t | size | ||
) |
setArray writes/adds an array of values (with arbitrary type) to the internal map<string,string>.
key | the key for that value |
arrBegin | begin of container |
size | number of elements |
Referenced by valueExists().
void svt::StDataASCII::setFVArray | ( | const std::string & | key, |
const ForwardIter & | arrBegin, | ||
size_t | size | ||
) |
setFVPList writes/adds a list (or a 1D array) of feature vectors to the internal map<string,string>.
arrBegin must point to the begin of linear array with pointers to the feature vectors, e.g. std::vector<BasicFV*>
key | the key for that value |
arrBegin | begin of container |
size | number of elements in the container |
Referenced by valueExists().
void svt::StDataASCII::getValue | ( | const std::string & | key, |
T & | value | ||
) | const |
get a value (with arbitrary type) from the internal map<string,string> specified by the given key.
If key is not found, the value remains unchanged and depending on exceptionFlag() a KeyNotFoundError exception is thrown.
key | the key for the requested value |
value | (output) returned value. |
KeyNotFoundError | the requested key does not exist |
InvalidDataTypeError | the value string couldn't be converted to the requested type |
Referenced by asDouble(), asUint(), svt::StDataCmdLine::getValue(), svt::Model< FV >::saveTrainingInfo(), and valueExists().
size_t svt::StDataASCII::getArraySize | ( | std::string | key | ) | const |
get size of Array associated with given key.
key | the key for that value |
Referenced by valueExists().
size_t svt::StDataASCII::getFVArraySize | ( | std::string | key | ) | const |
get number of Feature vectors in the list associated with that kay
key | the key for that value |
Referenced by valueExists().
void svt::StDataASCII::getArray | ( | const std::string & | key, |
const ForwardIter & | arrBegin, | ||
int | containerSize = -1 |
||
) | const |
getArray.
The values must be separated by separatorChar(), e.g. mymap["nr_sv"] = "150 120". See getValue() above for further details.
key | the key for the requested value |
arrBegin | iterator pointing to your container, that has enough space to store all values. You can query the required size with getArraySize(). |
containerSize | optional parameter to tell the size of your container, so that an error can be thrown, wenn it would be exeeded. |
KeyNotFoundError | the requested key does not exist |
InvalidDataTypeError | the value string couldn't be converted to the requested type |
Referenced by svt::StDataCmdLine::getArray(), and valueExists().
void svt::StDataASCII::getFVArray | ( | const std::string & | key, |
const ForwardIter & | arrBegin, | ||
int | containerSize = -1 |
||
) | const |
get a list (or a 1D array) of feature vectors.
The Iterator must point to a container with Feature vector pointers. The pointers must point to already allocated feature vectors
key | the key for the requested value |
arrBegin | iterator pointing to your container, that has enough space to store all values. You can query the required size with getFVArraySize(). |
containerSize | optional parameter to tell the size of your container, so that an error can be thrown, wenn it would be exeeded. |
KeyNotFoundError | the requested key does not exist |
InvalidDataTypeError | the value string couldn't be converted to the requested type |
Referenced by valueExists().
|
inline |
set character to separate elements of vectors within the value-string.
Default is ','
Definition at line 293 of file StDataASCII.hh.
|
inline |
Definition at line 298 of file StDataASCII.hh.
|
inline |
return the associated string to the given key directly
key | the key for the requested value |
KeyNotFoundError | the requested key does not exist |
Definition at line 315 of file StDataASCII.hh.
|
inline |
Definition at line 331 of file StDataASCII.hh.
Referenced by svt::Model< FV >::getTrainingInfoValue().
|
inline |
Definition at line 339 of file StDataASCII.hh.
|
inline |
convert any std::string to any type using an std::istringstream.
Has special overload for converting string to string, which does not split it at the first white space
s | string |
val | (output) value |
InvalidDataTypeError | if conversion failed |
Definition at line 360 of file StDataASCII.hh.
|
inline |
Definition at line 373 of file StDataASCII.hh.
void svt::StDataASCII::readArraySizeFromStream | ( | std::istream & | is, |
size_t & | size | ||
) | const |
Referenced by stringToValue().
|
inline |
const access to internal map
Definition at line 392 of file StDataASCII.hh.
Referenced by svt::StDataCmdLine::findUnusedParameters(), svt::Model< FV >::saveTrainingInfo(), and svt::Model< FV >::trainingInfoPlainText().
|
inline |
Definition at line 397 of file StDataASCII.hh.
Referenced by svt::StDataCmdLine::findUnusedParameters(), svt::Model< FV >::saveTrainingInfo(), and svt::Model< FV >::trainingInfoPlainText().
|
inline |
|
protected |
Definition at line 469 of file StDataASCII.hh.
Referenced by asString(), begin(), debugPrint(), end(), and valueExists().
|
protected |
Definition at line 470 of file StDataASCII.hh.
Referenced by debugPrint(), exceptionFlag(), and setExceptionFlag().
|
protected |
Definition at line 471 of file StDataASCII.hh.
Referenced by separatorChar(), and setSeparatorChar().