Main MRPT website > C++ reference for MRPT 1.5.9
Classes | Namespaces | Macros | Variables
CConfigFileBase.h File Reference
#include <mrpt/utils/utils_defs.h>
#include <mrpt/system/string_utils.h>
#include <sstream>
#include <iomanip>
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

struct  mrpt::utils::TEnumType< ENUMTYPE >
 A helper class that can convert an enum value into its textual representation, and viceversa. More...
 
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_CS(variableName, variableType)   MRPT_LOAD_CONFIG_VAR(variableName,variableType,c,s)
 Shortcut for MRPT_LOAD_CONFIG_VAR() for config file object named c and section string named s More...
 
#define MRPT_LOAD_CONFIG_VAR_DEGREES(variableName, configFileObject, sectionNameStr)   { variableName = mrpt::utils::DEG2RAD( configFileObject.read_double(sectionNameStr,#variableName, mrpt::utils::RAD2DEG(variableName)) ); }
 Loads a double variable, stored as radians but entered in the INI-file as degrees. More...
 
#define MRPT_LOAD_CONFIG_VAR_DEGREES_NO_DEFAULT(variableName, configFileObject, sectionNameStr)   { variableName = mrpt::utils::DEG2RAD( configFileObject.read_double(sectionNameStr,#variableName, mrpt::utils::RAD2DEG(variableName),true) ); }
 Loads a double, required, 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_HERE_CONFIG_VAR_DEGREES(variableName, variableType, targetVariable, configFileObject, sectionNameStr)   targetVariable = mrpt::utils::DEG2RAD( configFileObject.read_##variableType(sectionNameStr,#variableName,mrpt::utils::RAD2DEG(targetVariable),false));
 
#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT(variableName, variableType, targetVariable, configFileObject, sectionNameStr)
 
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(variableName, variableType, configFileObject, sectionNameStr)
 
#define MRPT_LOAD_CONFIG_VAR_REQUIRED_CS(variableName, variableType)   MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(variableName,variableType,c,s)
 Shortcut for MRPT_LOAD_CONFIG_VAR_NO_DEFAULT() for REQUIRED variables config file object named c and section string named s More...
 
#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, mrpt::utils::RAD2DEG(variableName)); }
 
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)   { c.write(s,#variableName,variableName,mrpt::utils::MRPT_SAVE_NAME_PADDING, mrpt::utils::MRPT_SAVE_VALUE_PADDING,__comment); }
 
#define MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT(__entryName, __variable, __comment)   { c.write(s,__entryName,mrpt::utils::RAD2DEG(__variable),mrpt::utils::MRPT_SAVE_NAME_PADDING, mrpt::utils::MRPT_SAVE_VALUE_PADDING,__comment); }
 

Variables

int BASE_IMPEXP mrpt::utils::MRPT_SAVE_NAME_PADDING = 50
 
int BASE_IMPEXP mrpt::utils::MRPT_SAVE_VALUE_PADDING = 20
 Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc. More...
 

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 190 of file CConfigFileBase.h.

Referenced by mrpt::maps::CRandomFieldGridMap2D::TInsertionOptionsCommon::internal_loadFromConfigFile_common(), mrpt::hwdrivers::CVelodyneScanner::loadConfig_sensorSpecific(), mrpt::kinematics::CVehicleVelCmd::TVelCmdParams::loadConfigFile(), mrpt::slam::TKLDParams::loadFromConfigFile(), mrpt::nav::CPTG_Holo_Blend::loadFromConfigFile(), mrpt::slam::CMetricMapBuilderICP::TConfigParams::loadFromConfigFile(), mrpt::maps::CPointCloudFilterByDistance::TOptions::loadFromConfigFile(), mrpt::slam::CIncrementalMapPartitioner::TOptions::loadFromConfigFile(), mrpt::slam::CICP::TConfigParams::loadFromConfigFile(), mrpt::hmtslam::CTopLCDetector_FabMap::TOptions::loadFromConfigFile(), mrpt::bayes::TKF_options::loadFromConfigFile(), mrpt::nav::CHolonomicVFF::TOptions::loadFromConfigFile(), mrpt::slam::CMetricMapBuilderRBPF::TConstructionOptions::loadFromConfigFile(), mrpt::maps::TMapGenericParams::loadFromConfigFile(), mrpt::vision::CFeatureExtraction::TOptions::loadFromConfigFile(), mrpt::nav::CHolonomicFullEval::TOptions::loadFromConfigFile(), mrpt::maps::COctoMapBase< octree_t, octree_node_t >::TInsertionOptions::loadFromConfigFile(), mrpt::bayes::CParticleFilter::TParticleFilterOptions::loadFromConfigFile(), mrpt::slam::CGridMapAligner::TConfigParams::loadFromConfigFile(), mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::loadFromConfigFile(), mrpt::maps::CHeightGridMap2D::TInsertionOptions::loadFromConfigFile(), mrpt::nav::CHolonomicND::TOptions::loadFromConfigFile(), mrpt::slam::CRangeBearingKFSLAM2D::TOptions::loadFromConfigFile(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::loadFromConfigFile(), mrpt::maps::CMultiMetricMapPDF::TPredictionParams::loadFromConfigFile(), mrpt::maps::CBeaconMap::TInsertionOptions::loadFromConfigFile(), mrpt::slam::CRangeBearingKFSLAM::TOptions::loadFromConfigFile(), mrpt::maps::COctoMapBase< octree_t, octree_node_t >::TLikelihoodOptions::loadFromConfigFile(), mrpt::maps::CPointsMap::TInsertionOptions::loadFromConfigFile(), mrpt::maps::CPointsMap::TLikelihoodOptions::loadFromConfigFile(), mrpt::maps::CColouredPointsMap::TColourOptions::loadFromConfigFile(), mrpt::maps::COccupancyGridMap2D::TInsertionOptions::loadFromConfigFile(), mrpt::hmtslam::CHMTSLAM::TOptions::loadFromConfigFile(), mrpt::maps::COctoMap::TMapDefinition::loadFromConfigFile_map_specific(), mrpt::maps::CColouredOctoMap::TMapDefinition::loadFromConfigFile_map_specific(), mrpt::maps::CWirelessPowerGridMap2D::TMapDefinition::loadFromConfigFile_map_specific(), mrpt::maps::CHeightGridMap2D_MRF::TMapDefinition::loadFromConfigFile_map_specific(), mrpt::maps::CReflectivityGridMap2D::TMapDefinition::loadFromConfigFile_map_specific(), mrpt::maps::CHeightGridMap2D::TMapDefinition::loadFromConfigFile_map_specific(), mrpt::maps::CGasConcentrationGridMap2D::TMapDefinition::loadFromConfigFile_map_specific(), and mrpt::maps::COccupancyGridMap2D::TMapDefinition::loadFromConfigFile_map_specific().

◆ 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)); }

◆ 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( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \
} }\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
GLsizei const GLchar ** string
Definition: glext.h:3919

Definition at line 240 of file CConfigFileBase.h.

Referenced by mrpt::bayes::CParticleFilter::TParticleFilterOptions::loadFromConfigFile(), mrpt::slam::CGridMapAligner::TConfigParams::loadFromConfigFile(), and mrpt::hmtslam::CHMTSLAM::TOptions::loadFromConfigFile().

◆ MRPT_LOAD_CONFIG_VAR_CS

#define MRPT_LOAD_CONFIG_VAR_CS (   variableName,
  variableType 
)    MRPT_LOAD_CONFIG_VAR(variableName,variableType,c,s)

◆ MRPT_LOAD_CONFIG_VAR_DEGREES

#define MRPT_LOAD_CONFIG_VAR_DEGREES (   variableName,
  configFileObject,
  sectionNameStr 
)    { variableName = mrpt::utils::DEG2RAD( configFileObject.read_double(sectionNameStr,#variableName, mrpt::utils::RAD2DEG(variableName)) ); }

◆ MRPT_LOAD_CONFIG_VAR_DEGREES_NO_DEFAULT

#define MRPT_LOAD_CONFIG_VAR_DEGREES_NO_DEFAULT (   variableName,
  configFileObject,
  sectionNameStr 
)    { variableName = mrpt::utils::DEG2RAD( configFileObject.read_double(sectionNameStr,#variableName, mrpt::utils::RAD2DEG(variableName),true) ); }

Loads a double, required, variable, stored as radians but entered in the INI-file as degrees.

Definition at line 201 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( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \
} }\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
GLsizei const GLchar ** string
Definition: glext.h:3919

Definition at line 229 of file CConfigFileBase.h.

Referenced by mrpt::kinematics::CVehicleVelCmd::TVelCmdParams::loadConfigFile(), mrpt::nav::CPTG_DiffDrive_CC::loadFromConfigFile(), mrpt::nav::CPTG_DiffDrive_CS::loadFromConfigFile(), mrpt::nav::CPTG_DiffDrive_CCS::loadFromConfigFile(), mrpt::nav::CPTG_DiffDrive_C::loadFromConfigFile(), mrpt::nav::CHolonomicFullEval::TOptions::loadFromConfigFile(), mrpt::bayes::CParticleFilter::TParticleFilterOptions::loadFromConfigFile(), mrpt::slam::CGridMapAligner::TConfigParams::loadFromConfigFile(), and mrpt::nav::CParameterizedTrajectoryGenerator::loadFromConfigFile().

◆ MRPT_LOAD_CONFIG_VAR_REQUIRED_CS

#define MRPT_LOAD_CONFIG_VAR_REQUIRED_CS (   variableName,
  variableType 
)    MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(variableName,variableType,c,s)

◆ MRPT_LOAD_HERE_CONFIG_VAR

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

◆ 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 249 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( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \
} }\
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
GLsizei const GLchar ** string
Definition: glext.h:3919

Definition at line 252 of file CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR_DEGREES

#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES (   variableName,
  variableType,
  targetVariable,
  configFileObject,
  sectionNameStr 
)    targetVariable = mrpt::utils::DEG2RAD( configFileObject.read_##variableType(sectionNameStr,#variableName,mrpt::utils::RAD2DEG(targetVariable),false));

◆ MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT

#define MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT (   variableName,
  variableType,
  targetVariable,
  configFileObject,
  sectionNameStr 
)
Value:
{ try { \
targetVariable = mrpt::utils::DEG2RAD( configFileObject.read_##variableType(sectionNameStr,#variableName,targetVariable,true)); \
} catch (std::exception &) { \
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() )); \
} }
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
double DEG2RAD(const double x)
Degrees to radians.
Definition: bits.h:82
GLsizei const GLchar ** string
Definition: glext.h:3919

Definition at line 221 of file CConfigFileBase.h.

Referenced by mrpt::kinematics::CVehicleVelCmd::TVelCmdParams::loadConfigFile(), mrpt::nav::CPTG_Holo_Blend::loadFromConfigFile(), mrpt::nav::CPTG_DiffDrive_alpha::loadFromConfigFile(), mrpt::slam::CMetricMapBuilderRBPF::TConstructionOptions::loadFromConfigFile(), and mrpt::nav::CPTG_DiffDrive_CollisionGridBased::loadFromConfigFile().

◆ 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( mrpt::format( "Value for '%s' not found in config file in section '%s'", static_cast<const char*>(#variableName ), std::string(sectionNameStr).c_str() )); \
} }
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
GLsizei const GLchar ** string
Definition: glext.h:3919

Definition at line 211 of file CConfigFileBase.h.

Referenced by mrpt::nav::CPTG_Holo_Blend::loadFromConfigFile(), mrpt::vision::CCamModel::loadFromConfigFile(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::loadFromConfigFile(), and mrpt::nav::CParameterizedTrajectoryGenerator::loadFromConfigFile().

◆ MRPT_SAVE_CONFIG_VAR

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

Definition at line 261 of file CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR_COMMENT

#define MRPT_SAVE_CONFIG_VAR_COMMENT (   variableName,
  __comment 
)    { c.write(s,#variableName,variableName,mrpt::utils::MRPT_SAVE_NAME_PADDING, mrpt::utils::MRPT_SAVE_VALUE_PADDING,__comment); }

◆ MRPT_SAVE_CONFIG_VAR_DEGREES

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

Definition at line 264 of file CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT

#define MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT (   __entryName,
  __variable,
  __comment 
)    { c.write(s,__entryName,mrpt::utils::RAD2DEG(__variable),mrpt::utils::MRPT_SAVE_NAME_PADDING, mrpt::utils::MRPT_SAVE_VALUE_PADDING,__comment); }



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020