Main MRPT website > C++ reference
MRPT logo
Classes | Namespaces | Macros
CConfigFileBase.h File Reference
#include <mrpt/utils/utils_defs.h>
#include <mrpt/utils/TEnumType.h>
#include <mrpt/math/CMatrixTemplate.h>
#include <mrpt/system/string_utils.h>
Include dependency graph for CConfigFileBase.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mrpt::utils::CConfigFileBase
 This class allows loading and storing values and vectors of different types from a configuration text, which can be implemented as a ".ini" file, a memory-stored string, etc... More...
 

Namespaces

 mrpt
 This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
 
 mrpt::utils
 Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
 

Macros

#define MRPT_LOAD_CONFIG_VAR(variableName, variableType, configFileObject, sectionNameStr)   { variableName = configFileObject.read_##variableType(sectionNameStr,#variableName,variableName); }
 An useful macro for loading variables stored in a INI-like file under a key with the same name that the variable, and assigning the variable the current value if not found in the config file. More...
 
#define MRPT_LOAD_CONFIG_VAR_DEGREES(variableName, configFileObject, sectionNameStr)   { variableName = DEG2RAD( configFileObject.read_float(sectionNameStr,#variableName, RAD2DEG(variableName)) ); }
 Loads a float variable, stored as radians but entered in the INI-file as degrees: More...
 
#define MRPT_LOAD_CONFIG_VAR_CAST(variableName, variableType, variableTypeCast, configFileObject, sectionNameStr)   { variableName = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,variableName)); }
 
#define MRPT_LOAD_HERE_CONFIG_VAR(variableName, variableType, targetVariable, configFileObject, sectionNameStr)   targetVariable = configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,false);
 
#define MRPT_LOAD_HERE_CONFIG_VAR_NO_DEFAULT(variableName, variableType, targetVariable, configFileObject, sectionNameStr)
 
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(variableName, variableType, configFileObject, sectionNameStr)
 
#define MRPT_LOAD_CONFIG_VAR_CAST_NO_DEFAULT(variableName, variableType, variableTypeCast, configFileObject, sectionNameStr)
 
#define MRPT_LOAD_HERE_CONFIG_VAR_CAST(variableName, variableType, variableTypeCast, targetVariable, configFileObject, sectionNameStr)   targetVariable = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable));
 
#define MRPT_LOAD_HERE_CONFIG_VAR_CAST_NO_DEFAULT(variableName, variableType, variableTypeCast, targetVariable, configFileObject, sectionNameStr)
 
#define MRPT_SAVE_CONFIG_VAR(variableName, configFileObject, sectionNameStr)   { configFileObject.write(sectionNameStr,#variableName,variableName); }
 
#define MRPT_SAVE_CONFIG_VAR_DEGREES(variableName, configFileObject, sectionNameStr)   { configFileObject.write(sectionNameStr,#variableName, RAD2DEG(variableName)); }
 

Macro Definition Documentation

◆ MRPT_LOAD_CONFIG_VAR

#define MRPT_LOAD_CONFIG_VAR (   variableName,
  variableType,
  configFileObject,
  sectionNameStr 
)    { variableName = configFileObject.read_##variableType(sectionNameStr,#variableName,variableName); }

An useful macro for loading variables stored in a INI-like file under a key with the same name that the variable, and assigning the variable the current value if not found in the config file.

The variableType must be the suffix of "read_XXX" functions, i.e. int, bool,...

Definition at line 245 of file CConfigFileBase.h.

Referenced by mrpt::bayes::TKF_options::loadFromConfigFile(), and mrpt::srba::RbaEngine< KF2KF_POSE_TYPE, LM_TYPE, OBS_TYPE, RBA_OPTIONS >::TSRBAParameters::loadFromConfigFile().

◆ MRPT_LOAD_CONFIG_VAR_CAST

#define MRPT_LOAD_CONFIG_VAR_CAST (   variableName,
  variableType,
  variableTypeCast,
  configFileObject,
  sectionNameStr 
)    { variableName = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,variableName)); }

Definition at line 253 of file CConfigFileBase.h.

◆ MRPT_LOAD_CONFIG_VAR_CAST_NO_DEFAULT

#define MRPT_LOAD_CONFIG_VAR_CAST_NO_DEFAULT (   variableName,
  variableType,
  variableTypeCast,
  configFileObject,
  sectionNameStr 
)
Value:
{ try { \
variableName = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,variableName,true)); \
} catch (std::exception &) \
{ \
THROW_EXCEPTION( format( "Value for '%s' not found in config file", static_cast<const char*>(#variableName ) )); \
} }\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.

Definition at line 277 of file CConfigFileBase.h.

◆ MRPT_LOAD_CONFIG_VAR_DEGREES

#define MRPT_LOAD_CONFIG_VAR_DEGREES (   variableName,
  configFileObject,
  sectionNameStr 
)    { variableName = DEG2RAD( configFileObject.read_float(sectionNameStr,#variableName, RAD2DEG(variableName)) ); }

Loads a float variable, stored as radians but entered in the INI-file as degrees:

Definition at line 250 of file CConfigFileBase.h.

◆ MRPT_LOAD_CONFIG_VAR_NO_DEFAULT

#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT (   variableName,
  variableType,
  configFileObject,
  sectionNameStr 
)
Value:
{ try { \
variableName = configFileObject.read_##variableType(sectionNameStr,#variableName,variableName,true); \
} catch (std::exception &) \
{ \
THROW_EXCEPTION( format( "Value for '%s' not found in config file", static_cast<const char*>(#variableName ) )); \
} }\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.

Definition at line 269 of file CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR

#define MRPT_LOAD_HERE_CONFIG_VAR (   variableName,
  variableType,
  targetVariable,
  configFileObject,
  sectionNameStr 
)    targetVariable = configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,false);

Definition at line 257 of file CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR_CAST

#define MRPT_LOAD_HERE_CONFIG_VAR_CAST (   variableName,
  variableType,
  variableTypeCast,
  targetVariable,
  configFileObject,
  sectionNameStr 
)    targetVariable = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable));

Definition at line 286 of file CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR_CAST_NO_DEFAULT

#define MRPT_LOAD_HERE_CONFIG_VAR_CAST_NO_DEFAULT (   variableName,
  variableType,
  variableTypeCast,
  targetVariable,
  configFileObject,
  sectionNameStr 
)
Value:
{ try { \
targetVariable = static_cast<variableTypeCast>(configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,true)); \
} catch (std::exception &) \
{ \
THROW_EXCEPTION( format( "Value for '%s' not found in config file", static_cast<const char*>(#variableName ) )); \
} }\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.

Definition at line 289 of file CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR_NO_DEFAULT

#define MRPT_LOAD_HERE_CONFIG_VAR_NO_DEFAULT (   variableName,
  variableType,
  targetVariable,
  configFileObject,
  sectionNameStr 
)
Value:
{ try { \
targetVariable = configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,true); \
} catch (std::exception &) \
{ \
THROW_EXCEPTION( format( "Value for '%s' not found in config file", static_cast<const char*>(#variableName ) )); \
} }\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.

Definition at line 260 of file CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR

#define MRPT_SAVE_CONFIG_VAR (   variableName,
  configFileObject,
  sectionNameStr 
)    { configFileObject.write(sectionNameStr,#variableName,variableName); }

Definition at line 298 of file CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR_DEGREES

#define MRPT_SAVE_CONFIG_VAR_DEGREES (   variableName,
  configFileObject,
  sectionNameStr 
)    { configFileObject.write(sectionNameStr,#variableName, RAD2DEG(variableName)); }

Definition at line 301 of file CConfigFileBase.h.




Page generated by Doxygen 1.8.14 for MRPT 1.0.2 SVN: at lun oct 28 00:52:41 CET 2019 Hosted on:
SourceForge.net Logo