iRoCS Toolbox
1.1.0
|
#include <StDataASCIIFile.hh>
Public Member Functions | |
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 | load (std::istream &is, int compatibilityFlag=0) |
loads the map from given istream in the style key[space]value[newline], e.g., two_class_type c_svc kernel_type rbf gamma 40 ... More... | |
void | readArraySizeFromStream (std::istream &is, size_t &size) const |
void | save (std::ostream &os, int compatibilityFlag=0) const |
saves the map to given ostream in the style key[space]value[newline], e.g., two_class_type c_svc kernel_type rbf gamma 40 ... More... | |
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 |
Definition at line 58 of file StDataASCIIFile.hh.
void svt::StDataASCIIFile::load | ( | std::istream & | is, |
int | compatibilityFlag = 0 |
||
) |
loads the map from given istream in the style key[space]value[newline], e.g., two_class_type c_svc kernel_type rbf gamma 40 ...
To be compatible with Chih-Jen Lin's libsvm model files set the compatibilityFlag to 1. Attention: the map is not cleared before loading the new key/value pairs!
is | input stream |
compatibilityFlag | 0 or 1 |
LoadError | incompatible file format |
void svt::StDataASCIIFile::save | ( | std::ostream & | os, |
int | compatibilityFlag = 0 |
||
) | const |
saves the map to given ostream in the style key[space]value[newline], e.g., two_class_type c_svc kernel_type rbf gamma 40 ...
To be compatible with Chih-Jen Lin's libsvm model files set the compatibilityFlag to 1
os | output stream |
compatibilityFlag | 0 or 1 |
|
inlineinherited |
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.
|
inlineinherited |
Definition at line 116 of file StDataASCII.hh.
|
inlineinherited |
check wether a value exists for requested key
key | the key |
Definition at line 131 of file StDataASCII.hh.
|
inherited |
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 svt::StDataASCII::valueExists().
|
inherited |
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 svt::StDataASCII::valueExists().
|
inherited |
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 svt::StDataASCII::valueExists().
|
inherited |
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 svt::StDataASCII::asDouble(), svt::StDataASCII::asUint(), svt::StDataCmdLine::getValue(), svt::Model< FV >::saveTrainingInfo(), and svt::StDataASCII::valueExists().
|
inherited |
get size of Array associated with given key.
key | the key for that value |
Referenced by svt::StDataASCII::valueExists().
|
inherited |
get number of Feature vectors in the list associated with that kay
key | the key for that value |
Referenced by svt::StDataASCII::valueExists().
|
inherited |
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 svt::StDataASCII::valueExists().
|
inherited |
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 svt::StDataASCII::valueExists().
|
inlineinherited |
set character to separate elements of vectors within the value-string.
Default is ','
Definition at line 293 of file StDataASCII.hh.
|
inlineinherited |
Definition at line 298 of file StDataASCII.hh.
|
inlineinherited |
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.
|
inlineinherited |
Definition at line 331 of file StDataASCII.hh.
Referenced by svt::Model< FV >::getTrainingInfoValue().
|
inlineinherited |
Definition at line 339 of file StDataASCII.hh.
|
inlineinherited |
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.
|
inlineinherited |
Definition at line 373 of file StDataASCII.hh.
|
inherited |
Referenced by svt::StDataASCII::stringToValue().
|
inlineinherited |
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().
|
inlineinherited |
Definition at line 397 of file StDataASCII.hh.
Referenced by svt::StDataCmdLine::findUnusedParameters(), svt::Model< FV >::saveTrainingInfo(), and svt::Model< FV >::trainingInfoPlainText().
|
inlineinherited |
|
protectedinherited |
Definition at line 469 of file StDataASCII.hh.
Referenced by svt::StDataASCII::asString(), svt::StDataASCII::begin(), svt::StDataASCII::debugPrint(), svt::StDataASCII::end(), and svt::StDataASCII::valueExists().
|
protectedinherited |
Definition at line 470 of file StDataASCII.hh.
Referenced by svt::StDataASCII::debugPrint(), svt::StDataASCII::exceptionFlag(), and svt::StDataASCII::setExceptionFlag().
|
protectedinherited |
Definition at line 471 of file StDataASCII.hh.
Referenced by svt::StDataASCII::separatorChar(), and svt::StDataASCII::setSeparatorChar().