Main MRPT website > C++ reference for MRPT 1.9.9
Classes | Namespaces | Macros | Functions
config/CConfigFileBase.h File Reference
#include <string>
#include <vector>
#include <type_traits>
#include <mrpt/system/string_utils.h>
#include <mrpt/core/exceptions.h>
#include <mrpt/core/bits_math.h>
Include dependency graph for config/CConfigFileBase.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mrpt::typemeta::TEnumType< ENUMTYPE >
 A helper class that can convert an enum value into its textual representation, and viceversa. More...
 
class  mrpt::config::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::typemeta
 
 mrpt::config
 

Macros

#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
 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)
 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)
 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)
 
#define MRPT_LOAD_HERE_CONFIG_VAR( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
 
#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)
 
#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)
 
#define MRPT_LOAD_HERE_CONFIG_VAR_CAST_NO_DEFAULT( variableName, variableType, variableTypeCast, targetVariable, configFileObject, sectionNameStr)
 
#define MRPT_SAVE_CONFIG_VAR(variableName, configFileObject, sectionNameStr)
 
#define MRPT_SAVE_CONFIG_VAR_DEGREES( variableName, configFileObject, sectionNameStr)
 
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
 
#define MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT( __entryName, __variable, __comment)
 

Functions

int mrpt::config::MRPT_SAVE_NAME_PADDING ()
 Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc. More...
 
int mrpt::config::MRPT_SAVE_VALUE_PADDING ()
 

Macro Definition Documentation

◆ MRPT_LOAD_CONFIG_VAR

#define MRPT_LOAD_CONFIG_VAR (   variableName,
  variableType,
  configFileObject,
  sectionNameStr 
)
Value:
{ \
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 282 of file config/CConfigFileBase.h.

◆ MRPT_LOAD_CONFIG_VAR_CAST

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

Definition at line 315 of file config/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( \
"Value for '%s' not found in config file in section '%s'", \
static_cast<const char*>(#variableName), \
std::string(sectionNameStr).c_str())); \
} \
}

Definition at line 400 of file config/CConfigFileBase.h.

◆ MRPT_LOAD_CONFIG_VAR_CS

#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

Definition at line 291 of file config/CConfigFileBase.h.

◆ MRPT_LOAD_CONFIG_VAR_DEGREES

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

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

Definition at line 296 of file config/CConfigFileBase.h.

◆ MRPT_LOAD_CONFIG_VAR_DEGREES_NO_DEFAULT

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

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

Definition at line 306 of file config/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( \
"Value for '%s' not found in config file in section '%s'", \
static_cast<const char*>(#variableName), \
std::string(sectionNameStr).c_str())); \
} \
}

Definition at line 377 of file config/CConfigFileBase.h.

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

Shortcut for MRPT_LOAD_CONFIG_VAR_NO_DEFAULT() for REQUIRED variables config file object named c and section string named s

Definition at line 397 of file config/CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR

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

Definition at line 324 of file config/CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR_CAST

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

Definition at line 420 of file config/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( \
"Value for '%s' not found in config file in section '%s'", \
static_cast<const char*>(#variableName), \
std::string(sectionNameStr).c_str())); \
} \
}

Definition at line 427 of file config/CConfigFileBase.h.

◆ MRPT_LOAD_HERE_CONFIG_VAR_DEGREES

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

Definition at line 349 of file config/CConfigFileBase.h.

◆ 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::DEG2RAD( \
configFileObject.read_##variableType( \
sectionNameStr, #variableName, targetVariable, true)); \
} \
catch (std::exception&) \
{ \
THROW_EXCEPTION( \
"Value for '%s' not found in config file in section '%s'", \
static_cast<const char*>(#variableName), \
std::string(sectionNameStr).c_str())); \
} \
}

Definition at line 357 of file config/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( \
"Value for '%s' not found in config file in section '%s'", \
static_cast<const char*>(#variableName), \
std::string(sectionNameStr).c_str())); \
} \
}

Definition at line 330 of file config/CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR

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

Definition at line 447 of file config/CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR_COMMENT

#define MRPT_SAVE_CONFIG_VAR_COMMENT (   variableName,
  __comment 
)
Value:
{ \
c.write( \
s, #variableName, variableName, \
}

Definition at line 459 of file config/CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR_DEGREES

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

Definition at line 452 of file config/CConfigFileBase.h.

◆ MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT

#define MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT (   __entryName,
  __variable,
  __comment 
)
Value:
{ \
c.write( \
s, __entryName, mrpt::RAD2DEG(__variable), \
}

Definition at line 466 of file config/CConfigFileBase.h.

s
GLdouble s
Definition: glext.h:3676
mrpt::RAD2DEG
double RAD2DEG(const double x)
Radians to degrees.
Definition: core/include/mrpt/core/bits_math.h:48
mrpt::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
mrpt::config::MRPT_SAVE_VALUE_PADDING
int MRPT_SAVE_VALUE_PADDING()
Definition: CConfigFileBase.cpp:27
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::config::MRPT_SAVE_NAME_PADDING
int MRPT_SAVE_NAME_PADDING()
Default padding sizes for macros MRPT_SAVE_CONFIG_VAR_COMMENT(), etc.
Definition: CConfigFileBase.cpp:26
mrpt::DEG2RAD
double DEG2RAD(const double x)
Degrees to radians.
Definition: core/include/mrpt/core/bits_math.h:42



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST