This class implements a config file-like interface over a memory-stored string list.
Definition at line 27 of file CConfigFileMemory.h.
#include <mrpt/utils/CConfigFileMemory.h>
Public Member Functions | |
CConfigFileMemory (const utils::CStringList &stringList) | |
Constructor and initialize from a list of strings. More... | |
CConfigFileMemory (const std::string &str) | |
Constructor and initialize from string with the whole "config file". More... | |
CConfigFileMemory () | |
Empty constructor. More... | |
CConfigFileMemory (const CConfigFileMemory &o) | |
Copy constructor. More... | |
CConfigFileMemory & | operator= (const CConfigFileMemory &o) |
Copy operator. More... | |
void | setContent (const utils::CStringList &stringList) |
Changes the contents of the virtual "config file". More... | |
void | setContent (const std::string &str) |
Changes the contents of the virtual "config file". More... | |
void | getContent (std::string &str) const |
Return the currnet contents of the virtual "config file". More... | |
std::string | getContent () const |
Return the currnet contents of the virtual "config file". More... | |
virtual | ~CConfigFileMemory () |
Destructor. More... | |
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". 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". 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". 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". 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". 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) 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. 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... | |
Save a configuration parameter. Optionally pads with spaces up to the desired width in number of characters (-1: no fill), and add a final comment field at the end of the line (a "// " prefix is automatically inserted). | |
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()) |
Protected Member Functions | |
void | writeString (const std::string §ion, const std::string &name, const std::string &str) MRPT_OVERRIDE |
A virtual method to write a generic string. More... | |
std::string | readString (const std::string §ion, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const MRPT_OVERRIDE |
A virtual method to read a generic string. More... | |
void | writeString (const std::string §ion, const std::string &name, const std::string &str, const int name_padding_width, const int value_padding_width, const std::string &comment) |
Write a generic string with optional padding and a comment field ("// ...") at the end of the line. More... | |
Private Attributes | |
void_ptr_noncopy | m_ini |
The IniFile object. More... | |
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 |
Destructor.
|
virtual |
Returs a list with all the keys into a section.
Implements mrpt::utils::CConfigFileBase.
|
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".
|
inline |
Return the currnet contents of the virtual "config file".
Definition at line 70 of file CConfigFileMemory.h.
References getContent().
Referenced by getContent().
CConfigFileMemory& mrpt::utils::CConfigFileMemory::operator= | ( | const CConfigFileMemory & | o | ) |
Copy operator.
|
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. |
Referenced by mrpt::pbmap::config_heuristics::load_params().
|
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. |
|
inlineinherited |
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:
In the config file:
Which can be loaded with:
Definition at line 194 of file CConfigFileBase.h.
References mrpt::format(), MRPT_END, MRPT_START, mrpt::utils::TEnumType< ENUMTYPE >::name2value(), and THROW_EXCEPTION.
|
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. |
Referenced by mrpt::pbmap::config_heuristics::load_params().
|
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. |
Referenced by mrpt::pbmap::config_heuristics::load_params().
|
inlineinherited |
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 157 of file CConfigFileBase.h.
References THROW_EXCEPTION_CUSTOM_MSG1.
|
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. |
Referenced by mrpt::pbmap::config_heuristics::load_params().
|
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. |
|
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. |
|
inlineinherited |
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 122 of file CConfigFileBase.h.
References mrpt::system::tokenize().
|
protectedvirtual |
A virtual method to read a generic string.
Implements mrpt::utils::CConfigFileBase.
|
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".
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
inherited |
|
protectedvirtual |
A virtual method to write a generic string.
Implements mrpt::utils::CConfigFileBase.
|
protectedinherited |
Write a generic string with optional padding and a comment field ("// ...") at the end of the line.
|
private |
The IniFile object.
Definition at line 30 of file CConfigFileMemory.h.
Page generated by Doxygen 1.8.15 for MRPT 1.4.0 SVN: at Sun Mar 24 23:21:48 UTC 2019 |