This class implements a config file-like interface over a memory-stored string list.
#include <mrpt/utils/CConfigFileMemory.h>

Public Member Functions | |||
| CConfigFileMemory (const utils::CStringList &stringList) | |||
| Constructor and initialize from a list of strings. | |||
| CConfigFileMemory (const std::string &str) | |||
| Constructor and initialize from string with the whole "config file". | |||
| CConfigFileMemory () | |||
| Empty constructor. | |||
| CConfigFileMemory (const CConfigFileMemory &o) | |||
| Copy constructor. | |||
| CConfigFileMemory & | operator= (const CConfigFileMemory &o) | ||
| Copy operator. | |||
| void | setContent (const utils::CStringList &stringList) | ||
| Changes the contents of the virtual "config file". | |||
| void | setContent (const std::string &str) | ||
| Changes the contents of the virtual "config file". | |||
| void | getContent (std::string &str) const | ||
| Return the currnet contents of the virtual "config file". | |||
| std::string | getContent () const | ||
| Return the currnet contents of the virtual "config file". | |||
| virtual | ~CConfigFileMemory () | ||
| Destructor. | |||
| virtual void | getAllSections (vector_string §ions) const | ||
| Returns a list with all the section names. | |||
| virtual void | getAllKeys (const std::string section, vector_string &keys) const | ||
| Returs a list with all the keys into a section. | |||
| bool | sectionExists (const std::string §ion_name) const | ||
| Checks if a given section exists (name is case insensitive) | |||
| void | write (const std::string §ion, const std::string &name, double value) | ||
| Save a configuration parameter of type "double". | |||
| void | write (const std::string §ion, const std::string &name, float value) | ||
| Save a configuration parameter of type "float". | |||
| void | write (const std::string §ion, const std::string &name, int value) | ||
| Save a configuration parameter of type "int". | |||
| void | write (const std::string §ion, const std::string &name, unsigned int value) | ||
| Save a configuration parameter of type "unsigned int". | |||
| void | write (const std::string §ion, const std::string &name, const std::string &value) | ||
| Save a configuration parameter of type "string". | |||
| void | write (const std::string §ion, const std::string &name, const std::vector< int > &value) | ||
| Save a configuration parameter of type "std::vector<int>". | |||
| void | write (const std::string §ion, const std::string &name, const std::vector< unsigned int > &value) | ||
| Save a configuration parameter of type "std::vector<unsigned int>". | |||
| void | write (const std::string §ion, const std::string &name, const std::vector< float > &value) | ||
| Save a configuration parameter of type "std::vector<float>". | |||
| void | write (const std::string §ion, const std::string &name, const std::vector< double > &value) | ||
| Save a configuration parameter of type "std::vector<double>". | |||
| void | write (const std::string §ion, const std::string &name, const std::vector< bool > &value) | ||
| Save a configuration parameter of type "std::vector<bool>". | |||
| double | read_double (const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const | ||
Reads a configuration parameter of type "double"
| |||
| float | read_float (const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const | ||
Reads a configuration parameter of type "float"
| |||
| 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. | |||
| int | read_int (const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const | ||
Reads a configuration parameter of type "int"
| |||
| 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"
| |||
| 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"
| |||
| 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)
| |||
| 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. | |||
| 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
| |||
| 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: | |||
Protected Member Functions | |||
| void | writeString (const std::string §ion, const std::string &name, const std::string &str) | ||
| A virtual method to write a generic string. | |||
| std::string | readString (const std::string §ion, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const | ||
| A virtual method to read a generic string. | |||
Private Attributes | |||
| void_ptr_noncopy | m_ini | ||
| The IniFile object. | |||
| mrpt::utils::CConfigFileMemory::CConfigFileMemory | ( | const utils::CStringList & | stringList | ) |
Constructor and initialize from a list of strings.
| mrpt::utils::CConfigFileMemory::CConfigFileMemory | ( | const std::string & | str | ) |
Constructor and initialize from string with the whole "config file".
| mrpt::utils::CConfigFileMemory::CConfigFileMemory | ( | ) |
Empty constructor.
Upon construction, call any of the "setContent" method.
| mrpt::utils::CConfigFileMemory::CConfigFileMemory | ( | const CConfigFileMemory & | o | ) |
Copy constructor.
| virtual mrpt::utils::CConfigFileMemory::~CConfigFileMemory | ( | ) | [virtual] |
Destructor.
| virtual void mrpt::utils::CConfigFileMemory::getAllKeys | ( | const std::string | section, |
| vector_string & | keys | ||
| ) | const [virtual] |
Returs a list with all the keys into a section.
Implements mrpt::utils::CConfigFileBase.
| virtual void mrpt::utils::CConfigFileMemory::getAllSections | ( | vector_string & | sections | ) | const [virtual] |
Returns a list with all the section names.
Implements mrpt::utils::CConfigFileBase.
| void mrpt::utils::CConfigFileMemory::getContent | ( | std::string & | str | ) | const |
Return the currnet contents of the virtual "config file".
Referenced by mrpt::utils::TCamera::dumpAsText().
| std::string mrpt::utils::CConfigFileMemory::getContent | ( | ) | const [inline] |
Return the currnet contents of the virtual "config file".
Definition at line 92 of file CConfigFileMemory.h.
References getContent().
Referenced by getContent().
| CConfigFileMemory& mrpt::utils::CConfigFileMemory::operator= | ( | const CConfigFileMemory & | o | ) |
Copy operator.
| bool mrpt::utils::CConfigFileBase::read_bool | ( | const std::string & | section, |
| const std::string & | name, | ||
| bool | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inherited] |
Reads a configuration parameter of type "bool", codified as "1"/"0" or "true"/"false" or "yes"/"no" for true/false, repectively.
| std::exception | If the key name is not found and "failIfNotFound" is true. Otherwise the "defaultValue" is returned. |
| double mrpt::utils::CConfigFileBase::read_double | ( | const std::string & | section, |
| const std::string & | name, | ||
| double | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inherited] |
Reads a configuration parameter of type "double"
| std::exception | If the key name is not found and "failIfNotFound" is true. |
Otherwise the "defaultValue" is returned.
| ENUMTYPE mrpt::utils::CConfigFileBase::read_enum | ( | const std::string & | section, |
| const std::string & | name, | ||
| const ENUMTYPE & | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inline, inherited] |
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:
enum my_type_t { type_foo=0, type_bar };
In the config file:
[section]
type = type_bar // Use the symbolic name, or
type = 1 // use the numerical value (both lines will be equivalent)
Which can be loaded with:
cfgfile.read_enum<my_type_t>("section","type", type_foo );
Definition at line 238 of file CConfigFileBase.h.
References MRPT_START, THROW_EXCEPTION, mrpt::format(), and MRPT_END.
| float mrpt::utils::CConfigFileBase::read_float | ( | const std::string & | section, |
| const std::string & | name, | ||
| float | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inherited] |
Reads a configuration parameter of type "float"
| std::exception | If the key name is not found and "failIfNotFound" is true. |
Otherwise the "defaultValue" is returned.
| int mrpt::utils::CConfigFileBase::read_int | ( | const std::string & | section, |
| const std::string & | name, | ||
| int | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inherited] |
Reads a configuration parameter of type "int"
| std::exception | If the key name is not found and "failIfNotFound" is true. |
Otherwise the "defaultValue" is returned.
| void mrpt::utils::CConfigFileBase::read_matrix | ( | const std::string & | section, |
| const std::string & | name, | ||
| MATRIX_TYPE & | outMatrix, | ||
| const MATRIX_TYPE & | defaultMatrix = MATRIX_TYPE(), |
||
| bool | failIfNotFound = false |
||
| ) | const [inline, inherited] |
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
| std::exception | If the key name is not found and "failIfNotFound" is true. |
Otherwise the "defaultValue" is returned.
Definition at line 201 of file CConfigFileBase.h.
References THROW_EXCEPTION_CUSTOM_MSG1.
| std::string mrpt::utils::CConfigFileBase::read_string | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::string & | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inherited] |
Reads a configuration parameter of type "string"
| std::exception | If the key name is not found and "failIfNotFound" is true. |
Otherwise the "defaultValue" is returned.
| std::string mrpt::utils::CConfigFileBase::read_string_first_word | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::string & | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inherited] |
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)
| std::exception | If the key name is not found and "failIfNotFound" is true. |
Otherwise the "defaultValue" is returned.
| uint64_t mrpt::utils::CConfigFileBase::read_uint64_t | ( | const std::string & | section, |
| const std::string & | name, | ||
| uint64_t | defaultValue, | ||
| bool | failIfNotFound = false |
||
| ) | const [inherited] |
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"
| std::exception | If the key name is not found and "failIfNotFound" is true. |
Otherwise the "defaultValue" is returned.
| void mrpt::utils::CConfigFileBase::read_vector | ( | const std::string & | section, |
| const std::string & | name, | ||
| const VECTOR_TYPE & | defaultValue, | ||
| VECTOR_TYPE & | outValues, | ||
| bool | failIfNotFound = false |
||
| ) | const [inline, inherited] |
Reads a configuration parameter of type vector, stored in the file as a string: "[v1 v2 v3 ... ]", where spaces could also be commas.
| std::exception | If the key name is not found and "failIfNotFound" is true. Otherwise the "defaultValue" is returned. |
Definition at line 166 of file CConfigFileBase.h.
References mrpt::system::tokenize().
| std::string mrpt::utils::CConfigFileMemory::readString | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::string & | defaultStr, | ||
| bool | failIfNotFound = false |
||
| ) | const [protected, virtual] |
A virtual method to read a generic string.
Implements mrpt::utils::CConfigFileBase.
| bool mrpt::utils::CConfigFileBase::sectionExists | ( | const std::string & | section_name | ) | const [inherited] |
Checks if a given section exists (name is case insensitive)
| void mrpt::utils::CConfigFileMemory::setContent | ( | const utils::CStringList & | stringList | ) |
Changes the contents of the virtual "config file".
| void mrpt::utils::CConfigFileMemory::setContent | ( | const std::string & | str | ) |
Changes the contents of the virtual "config file".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| double | value | ||
| ) | [inherited] |
Save a configuration parameter of type "double".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| float | value | ||
| ) | [inherited] |
Save a configuration parameter of type "float".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| int | value | ||
| ) | [inherited] |
Save a configuration parameter of type "int".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| unsigned int | value | ||
| ) | [inherited] |
Save a configuration parameter of type "unsigned int".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::string & | value | ||
| ) | [inherited] |
Save a configuration parameter of type "string".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::vector< int > & | value | ||
| ) | [inherited] |
Save a configuration parameter of type "std::vector<int>".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::vector< unsigned int > & | value | ||
| ) | [inherited] |
Save a configuration parameter of type "std::vector<unsigned int>".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::vector< float > & | value | ||
| ) | [inherited] |
Save a configuration parameter of type "std::vector<float>".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::vector< double > & | value | ||
| ) | [inherited] |
Save a configuration parameter of type "std::vector<double>".
| void mrpt::utils::CConfigFileBase::write | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::vector< bool > & | value | ||
| ) | [inherited] |
Save a configuration parameter of type "std::vector<bool>".
| void mrpt::utils::CConfigFileMemory::writeString | ( | const std::string & | section, |
| const std::string & | name, | ||
| const std::string & | str | ||
| ) | [protected, virtual] |
A virtual method to write a generic string.
Implements mrpt::utils::CConfigFileBase.
The IniFile object.
Definition at line 51 of file CConfigFileMemory.h.
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |