A wrapper for other CConfigFileBase-based objects that prefixes a given token to every key and/or section.
If, for example, your code expect:
[params1]
foo = 34.0
bar = /dev/ttyUSB0
Using this class with key entries prefix "s1_" will enable the same existing code to transparently parse this file content:
[params1]
s1_foo = 34.0
s1_bar = /dev/ttyUSB0
- See also
- CConfigFileBase
Definition at line 36 of file CConfigFilePrefixer.h.
|
| CConfigFilePrefixer () |
| Unbound constructor: must bind this object to CConfigFileBase before usage with bind() and setPrefixes() More...
|
|
| CConfigFilePrefixer (const CConfigFileBase &o, const std::string &prefix_sections, const std::string &prefix_keys) |
| Construct and bind to (wrap) a given object with given prefix texts. More...
|
|
void | bind (const CConfigFileBase &o) |
| Make this object to wrap the given existing CConfigFileBase object. More...
|
|
void | setPrefixes (const std::string &prefix_sections, const std::string &prefix_keys) |
| Change the prefix for sections and keys. More...
|
|
std::string | getSectionPrefix () const |
|
std::string | getKeyPrefix () const |
|
CConfigFileBase * | getBoundConfigFileBase () const |
| Returns the currently-bounded config source, or NULL if none. More...
|
|
virtual | ~CConfigFilePrefixer () |
|
void | getAllSections (vector_string §ions) const MRPT_OVERRIDE |
| Returns a list with all the section names. More...
|
|
void | getAllKeys (const std::string §ion, vector_string &keys) const MRPT_OVERRIDE |
| Returs a list with all the keys into a section. More...
|
|
bool | sectionExists (const std::string §ion_name) const |
| Checks if a given section exists (name is case insensitive) More...
|
|
double | read_double (const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const |
| Reads a configuration parameter of type "double" - Exceptions
-
std::exception | If the key name is not found and "failIfNotFound" is true. |
More...
|
|
float | read_float (const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const |
| Reads a configuration parameter of type "float" - Exceptions
-
std::exception | If the key name is not found and "failIfNotFound" is true. |
More...
|
|
bool | read_bool (const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const |
| Reads a configuration parameter of type "bool", codified as "1"/"0" or "true"/"false" or "yes"/"no" for true/false, repectively. More...
|
|
int | read_int (const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const |
| Reads a configuration parameter of type "int" - Exceptions
-
std::exception | If the key name is not found and "failIfNotFound" is true. |
More...
|
|
uint64_t | read_uint64_t (const std::string §ion, const std::string &name, uint64_t defaultValue, bool failIfNotFound=false) const |
| Reads a configuration parameter of type "uint64_t": As in all other methods, the numeric value can be in decimal or hexadecimal with the prefix "0x" - Exceptions
-
std::exception | If the key name is not found and "failIfNotFound" is true. |
More...
|
|
std::string | read_string (const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const |
| Reads a configuration parameter of type "string" - Exceptions
-
std::exception | If the key name is not found and "failIfNotFound" is true. |
More...
|
|
std::string | read_string_first_word (const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const |
| Reads a configuration parameter of type "string", and keeps only the first word (this can be used to eliminate possible comments at the end of the line) - Exceptions
-
std::exception | If the key name is not found and "failIfNotFound" is true. |
More...
|
|
template<class VECTOR_TYPE > |
void | read_vector (const std::string §ion, const std::string &name, const VECTOR_TYPE &defaultValue, VECTOR_TYPE &outValues, bool failIfNotFound=false) const |
| Reads a configuration parameter of type vector, stored in the file as a string: "[v1 v2 v3 ... ]", where spaces could also be commas. More...
|
|
template<class MATRIX_TYPE > |
void | read_matrix (const std::string §ion, const std::string &name, MATRIX_TYPE &outMatrix, const MATRIX_TYPE &defaultMatrix=MATRIX_TYPE(), bool failIfNotFound=false) const |
| Reads a configuration parameter as a matrix written in a matlab-like format - for example: "[2 3 4 ; 7 8 9]" This template method can be instantiated for matrices of the types: int, long, unsinged int, unsigned long, float, double, long double - Exceptions
-
std::exception | If the key name is not found and "failIfNotFound" is true. |
More...
|
|
template<typename ENUMTYPE > |
ENUMTYPE | read_enum (const std::string §ion, const std::string &name, const ENUMTYPE &defaultValue, bool failIfNotFound=false) const |
| Reads an "enum" value, where the value in the config file can be either a numerical value or the symbolic name, for example: In the code: More...
|
|
|
void | write (const std::string §ion, const std::string &name, double value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, float value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, int value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, uint32_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, uint64_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, const std::string &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, const std::vector< int > &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, const std::vector< unsigned int > &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, const std::vector< float > &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, const std::vector< double > &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|
void | write (const std::string §ion, const std::string &name, const std::vector< bool > &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
|