9 #ifndef  CConfigFileBase_H    10 #define  CConfigFileBase_H    52                 virtual void getAllSections( 
vector_string      §ions ) 
const = 0 ;
    58                 bool sectionExists( 
const std::string §ion_name) 
const;
    62                 template <
typename data_t>
    65                         std::stringstream ss; ss.flags(ss.flags() | std::ios::boolalpha);
    67                         writeString(section, 
name, ss.str(), name_padding_width, value_padding_width, comment);
    69                 template <
typename data_t>
    72                         std::stringstream ss; ss.flags(ss.flags() | std::ios::boolalpha);
    74                         writeString(section, 
name, ss.str(), name_padding_width, value_padding_width, comment);
    82                 double  read_double(
const std::string §ion, 
const std::string &
name, 
double defaultValue, 
bool failIfNotFound = 
false) 
const;
    91                 template <
class VECTOR_TYPE>
    95                         const VECTOR_TYPE  & defaultValue,
    96                         VECTOR_TYPE        & outValues,
    97                         bool                 failIfNotFound = 
false)
 const   101                         std::vector<std::string>        tokens;
   104                         if (tokens.size()==0)
   106                                 outValues = defaultValue;
   111                                 const size_t N = tokens.size();
   112                                 outValues.resize( N );
   113                                 for (
size_t i=0;i<N;i++)
   115                                         std::stringstream ss(tokens[i]);
   125                  template <
class MATRIX_TYPE>
   129                         MATRIX_TYPE     &outMatrix,
   130                         const MATRIX_TYPE &defaultMatrix = MATRIX_TYPE(),
   131                         bool failIfNotFound = 
false )
 const   135                                 outMatrix = defaultMatrix;
   139                                 if (!outMatrix.fromMatlabStringFormat(aux))
   162                 template <
typename ENUMTYPE>
   166                         const std::string sVal = read_string_first_word(section,
name,
"",failIfNotFound);
   167                         if (sVal.empty()) 
return defaultValue;
   169                         if (::isdigit(sVal[0]))
   171                                 return static_cast<ENUMTYPE
>(::atoi(&sVal[0]));
   177                                 } 
catch (std::exception &)
   190 #define MRPT_LOAD_CONFIG_VAR(variableName,variableType,configFileObject,sectionNameStr) \   191         { variableName = configFileObject.read_##variableType(sectionNameStr,#variableName,variableName); }   194 #define MRPT_LOAD_CONFIG_VAR_CS(variableName,variableType) MRPT_LOAD_CONFIG_VAR(variableName,variableType,c,s)   197 #define MRPT_LOAD_CONFIG_VAR_DEGREES(variableName,configFileObject,sectionNameStr) \   198         { variableName = mrpt::utils::DEG2RAD( configFileObject.read_double(sectionNameStr,#variableName, mrpt::utils::RAD2DEG(variableName)) ); }   201 #define MRPT_LOAD_CONFIG_VAR_DEGREES_NO_DEFAULT(variableName,configFileObject,sectionNameStr) \   202         { variableName = mrpt::utils::DEG2RAD( configFileObject.read_double(sectionNameStr,#variableName, mrpt::utils::RAD2DEG(variableName),true) ); }   204 #define MRPT_LOAD_CONFIG_VAR_CAST(variableName,variableType,variableTypeCast,configFileObject,sectionNameStr) \   205         { variableName = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,variableName)); }   208 #define MRPT_LOAD_HERE_CONFIG_VAR(variableName,variableType,targetVariable,configFileObject,sectionNameStr) \   209                 targetVariable = configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,false);   211 #define MRPT_LOAD_HERE_CONFIG_VAR_NO_DEFAULT(variableName,variableType,targetVariable,configFileObject,sectionNameStr) \   213                 targetVariable = configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,true); \   214         } catch (std::exception &) { \   215                 THROW_EXCEPTION( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \   218 #define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES(variableName,variableType,targetVariable,configFileObject,sectionNameStr) \   219                 targetVariable = mrpt::utils::DEG2RAD( configFileObject.read_##variableType(sectionNameStr,#variableName,mrpt::utils::RAD2DEG(targetVariable),false));   221 #define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT(variableName,variableType,targetVariable,configFileObject,sectionNameStr) \   223                 targetVariable = mrpt::utils::DEG2RAD( configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,true)); \   224         } catch (std::exception &) { \   225                 THROW_EXCEPTION( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \   229 #define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(variableName,variableType,configFileObject,sectionNameStr) \   231                 variableName = configFileObject.read_##variableType(sectionNameStr,#variableName,variableName,true); \   232     } catch (std::exception &) \   234                 THROW_EXCEPTION( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \   238 #define MRPT_LOAD_CONFIG_VAR_REQUIRED_CS(variableName,variableType) MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(variableName,variableType,c,s)   240 #define MRPT_LOAD_CONFIG_VAR_CAST_NO_DEFAULT(variableName,variableType,variableTypeCast,configFileObject,sectionNameStr) \   242                 variableName = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,variableName,true)); \   243     } catch (std::exception &) \   245                 THROW_EXCEPTION( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \   249 #define MRPT_LOAD_HERE_CONFIG_VAR_CAST(variableName,variableType,variableTypeCast,targetVariable,configFileObject,sectionNameStr) \   250                 targetVariable = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable));   252 #define MRPT_LOAD_HERE_CONFIG_VAR_CAST_NO_DEFAULT(variableName,variableType,variableTypeCast,targetVariable,configFileObject,sectionNameStr) \   254                 targetVariable = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,true)); \   255     } catch (std::exception &) \   257                 THROW_EXCEPTION( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \   261 #define MRPT_SAVE_CONFIG_VAR(variableName,configFileObject,sectionNameStr) \   262         { configFileObject.write(sectionNameStr,#variableName,variableName); }   264 #define MRPT_SAVE_CONFIG_VAR_DEGREES(variableName,configFileObject,sectionNameStr) \   265         { configFileObject.write(sectionNameStr,#variableName, mrpt::utils::RAD2DEG(variableName)); }   267 #define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName,__comment) \   268         { c.write(s,#variableName,variableName,mrpt::utils::MRPT_SAVE_NAME_PADDING, mrpt::utils::MRPT_SAVE_VALUE_PADDING,__comment); }   269 #define MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT(__entryName,__variable,__comment) \   270         { c.write(s,__entryName,mrpt::utils::RAD2DEG(__variable),mrpt::utils::MRPT_SAVE_NAME_PADDING, mrpt::utils::MRPT_SAVE_VALUE_PADDING,__comment); } int BASE_IMPEXP MRPT_SAVE_VALUE_PADDING
Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc. 
 
static ENUMTYPE name2value(const std::string &name)
Gives the numerical name for a given enum text name. 
 
A wrapper for other CConfigFileBase-based objects that prefixes a given token to every key and/or sec...
 
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
 
const Scalar * const_iterator
 
This class allows loading and storing values and vectors of different types from a configuration text...
 
std::vector< std::string > vector_string
A type for passing a vector of strings. 
 
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 ; ...
 
A helper class that can convert an enum value into its textual representation, and viceversa...
 
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 ...
 
GLsizei const GLchar ** string
 
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 symb...
 
unsigned __int64 uint64_t
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
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())
 
GLuint const GLchar * name
 
GLsizei const GLfloat * value
 
void BASE_IMPEXP tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
Tokenizes a string according to a set of delimiting characters. 
 
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())
 
int BASE_IMPEXP MRPT_SAVE_NAME_PADDING