Public Member Functions | Private Attributes | List of all members
Config Class Reference

Handle configuration files. More...

#include <config.h>

Public Member Functions

template<typename T >
bool add (const std::string &section, const std::string &parameter, 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. More...
 
void clear ()
 Clear the data buffer. More...
 
 Config (const bool bPrintErrorMessages=true)
 Constructor. More...
 
bool parameter_exists (const std::string &section, const std::string &parameter) const
 Test to see if a parameter exists within a section. More...
 
void print ()
 Print the configuration data. More...
 
short read_conf (std::ifstream &inconffile)
 Read a configuration file. More...
 
bool section_exists (const std::string &section) const
 Test to see if a section exists. More...
 
template<typename T >
bool select (const std::string &section, const std::string &parameter, T &value) const
 Get a parameter data, of a certain section, into the string value. More...
 
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. More...
 

Private Attributes

bool bPrintErrorMessages
 Print error messages on stderr. More...
 
Conf_data conf
 Data store from/to configuration file. More...
 

Detailed Description

Handle configuration files.

Definition at line 97 of file config.h.

Constructor & Destructor Documentation

Config::Config ( const bool  bPrintErrorMessages = true)

Constructor.

Definition at line 66 of file config.cpp.

Member Function Documentation

template<typename T >
bool Config::add ( const std::string &  section,
const std::string &  parameter,
const T &  value 
)
inline

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.

Definition at line 137 of file config.h.

void Config::clear ( )

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.

Returns
true if parameter is found within 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.

Returns
true if section is found

Definition at line 202 of file config.cpp.

template<typename T >
bool Config::select ( const std::string &  section,
const std::string &  parameter,
T &  value 
) const
inline

Get a parameter data, of a certain section, into the string value.

Returns
false if the data can not be found and true otherwise.

Definition at line 109 of file config.h.

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.

Parameters
filenameConfiguration file name.
file_titleTitle in the configuration file header.
space_between_columnNumber of blanks between : (of a parameter) and it's value.

Definition at line 226 of file config.cpp.

Member Data Documentation

bool Config::bPrintErrorMessages
private

Print error messages on stderr.

Definition at line 190 of file config.h.

Conf_data Config::conf
private

Data store from/to configuration file.

Definition at line 189 of file config.h.


The documentation for this class was generated from the following files:


kni
Author(s): Martin Günther
autogenerated on Fri Jan 3 2020 04:01:17