Handle configuration files. More...
#include <config.h>
Public Member Functions | |
template<typename T > | |
bool | add (const std::string §ion, const std::string ¶meter, const T &value) |
Added the value(string) of the parameter in the section in the configuration data. The functions will added the parameter and the section if it does not already exist. | |
void | clear () |
Clear the data buffer. | |
Config (const bool bPrintErrorMessages=true) | |
Constructor. | |
bool | parameter_exists (const std::string §ion, const std::string ¶meter) const |
Test to see if a parameter exists within a section. | |
void | print () |
Print the configuration data. | |
short | read_conf (std::ifstream &inconffile) |
Read a configuration file. | |
bool | section_exists (const std::string §ion) const |
Test to see if a section exists. | |
template<typename T > | |
bool | select (const std::string §ion, const std::string ¶meter, T &value) const |
Get a parameter data, of a certain section, into the string value. | |
short | write_conf (std::ofstream &outconffile, const std::string &file_title, const int space_between_column) |
Write the configuration information, contained in conf, on disk. | |
Private Attributes | |
bool | bPrintErrorMessages |
Print error messages on stderr. | |
Conf_data | conf |
Data store from/to configuration file. |
Config::Config | ( | const bool | bPrintErrorMessages = true | ) |
Constructor.
Definition at line 66 of file config.cpp.
bool Config::add | ( | const std::string & | section, |
const std::string & | parameter, | ||
const T & | value | ||
) | [inline] |
void Config::clear | ( | void | ) |
Clear the data buffer.
Definition at line 178 of file config.cpp.
bool Config::parameter_exists | ( | const std::string & | section, |
const std::string & | parameter | ||
) | const |
Test to see if a parameter exists within a section.
Definition at line 214 of file config.cpp.
void Config::print | ( | ) |
Print the configuration data.
Definition at line 184 of file config.cpp.
short Config::read_conf | ( | std::ifstream & | inconffile | ) |
Read a configuration file.
This function reads the configuration file specified in the constructor parameter. The information is stored in the variable conf.
A configuration file contains section(s) (between [ ]), and the section(s) contains parameter(s) with there respective value(s). The section and the parameter are always access via a string. Below is an exemple: one section named PUMA560_mDH, and two parameters.
[PUMA560_mDH] DH: 0 dof: 6
Definition at line 72 of file config.cpp.
bool Config::section_exists | ( | const std::string & | section | ) | const |
Test to see if a section exists.
Definition at line 202 of file config.cpp.
bool Config::select | ( | const std::string & | section, |
const std::string & | parameter, | ||
T & | value | ||
) | const [inline] |
short Config::write_conf | ( | std::ofstream & | outconffile, |
const std::string & | file_title, | ||
const int | space_between_column | ||
) |
Write the configuration information, contained in conf, on disk.
filename,: | Configuration file name. |
file_title,: | Title in the configuration file header. |
space_between_column,: | Number of blanks between : (of a parameter) and it's value. |
Definition at line 226 of file config.cpp.
bool Config::bPrintErrorMessages [private] |
Conf_data Config::conf [private] |