This class implements a config file-like interface over a memory-stored string list.
Use base class CConfigFileBase
's methods read_{int,float,double,string,...}()
and write()
to actually read and write values.
See: Configuration file format in MRPT
Definition at line 28 of file CConfigFileMemory.h.
#include <mrpt/utils/CConfigFileMemory.h>
Public Member Functions | |
CConfigFileMemory () | |
Empty constructor. Upon construction, call any of the "setContent" method. More... | |
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... | |
virtual | ~CConfigFileMemory () |
dtor 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 current contents of the virtual "config file". More... | |
std::string | getContent () const |
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... | |
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). | |
template<typename data_t > | |
void | write (const std::string §ion, const std::string &name, const data_t &value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string()) |
template<typename data_t > | |
void | write (const std::string §ion, const std::string &name, const std::vector< data_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, 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()) |
Read a configuration parameter, launching exception if key name is not found and `failIfNotFound`=true | |
double | read_double (const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const |
float | read_float (const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const |
bool | read_bool (const std::string §ion, const std::string &name, bool defaultValue, bool failIfNotFound=false) const |
int | read_int (const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const |
uint64_t | read_uint64_t (const std::string §ion, const std::string &name, uint64_t defaultValue, bool failIfNotFound=false) const |
std::string | read_string (const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const |
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]". 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... | |
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 | ( | ) |
Empty constructor. Upon construction, call any of the "setContent" method.
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".
|
virtual |
dtor
mrpt::utils::CConfigFileMemory::CConfigFileMemory | ( | const CConfigFileMemory & | o | ) |
Copy constructor.
|
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 current contents of the virtual "config file".
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 43 of file CConfigFileMemory.h.
References getContent(), and MRPT_OVERRIDE.
Referenced by getContent().
CConfigFileMemory& mrpt::utils::CConfigFileMemory::operator= | ( | const CConfigFileMemory & | o | ) |
Copy operator.
|
inherited |
Referenced by mrpt::pbmap::config_heuristics::load_params(), mrpt::graphslam::deciders::CICPCriteriaERD< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::OptimizationParams::loadFromConfigFile(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::GraphVisualizationParams::loadFromConfigFile(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::TLaserParams::loadFromConfigFile(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::TLoopClosureParams::loadFromConfigFile(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::loadParams(), and CGraphSlamHandler< GRAPH_T >::readConfigFname().
|
inherited |
Referenced by mrpt::graphslam::deciders::CFixedIntervalsNRD< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::deciders::CRangeScanOps< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::deciders::CICPCriteriaERD< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::OptimizationParams::loadFromConfigFile(), mrpt::graphslam::deciders::CICPCriteriaNRD< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::GraphVisualizationParams::loadFromConfigFile(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::TLoopClosureParams::loadFromConfigFile(), and mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::loadParams().
|
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 163 of file CConfigFileBase.h.
References MRPT_END, MRPT_START, mrpt::utils::TEnumType< ENUMTYPE >::name2value(), and THROW_EXCEPTION_FMT.
|
inherited |
Referenced by mrpt::pbmap::config_heuristics::load_params().
|
inherited |
Referenced by mrpt::pbmap::config_heuristics::load_params(), mrpt::graphslam::deciders::CICPCriteriaERD< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::OptimizationParams::loadFromConfigFile(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::GraphVisualizationParams::loadFromConfigFile(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::TLaserParams::loadFromConfigFile(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::TLoopClosureParams::loadFromConfigFile(), mrpt::graphslam::deciders::CFixedIntervalsNRD< GRAPH_T >::loadParams(), mrpt::graphslam::deciders::CICPCriteriaNRD< GRAPH_T >::loadParams(), mrpt::graphslam::deciders::CICPCriteriaERD< GRAPH_T >::loadParams(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::loadParams(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::loadParams(), and mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::loadParams().
|
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 126 of file CConfigFileBase.h.
References THROW_EXCEPTION_FMT.
|
inherited |
Referenced by mrpt::pbmap::config_heuristics::load_params(), mrpt::graphslam::deciders::CRangeScanOps< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::deciders::CICPCriteriaERD< GRAPH_T >::TParams::loadFromConfigFile(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::loadParams(), and CGraphSlamHandler< GRAPH_T >::readConfigFname().
|
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)
|
inherited |
|
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 92 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".
|
inlineinherited |
Definition at line 63 of file CConfigFileBase.h.
References exprtk::details::value().
|
inlineinherited |
Definition at line 70 of file CConfigFileBase.h.
|
inherited |
|
inherited |
|
protectedinherited |
Write a generic string with optional padding and a comment field ("// ...") at the end of the line.
|
protectedvirtual |
A virtual method to write a generic string.
Implements mrpt::utils::CConfigFileBase.
|
private |
The IniFile object.
Definition at line 49 of file CConfigFileMemory.h.
Page generated by Doxygen 1.8.13 for MRPT 1.5.3 at Tue Oct 31 07:27:35 UTC 2017 |