Public Member Functions | Private Attributes
Config Class Reference

Handle configuration files. More...

#include <config.h>

List of all members.

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.
void clear ()
 Clear the data buffer.
 Config (const bool bPrintErrorMessages=true)
 Constructor.
bool parameter_exists (const std::string &section, const std::string &parameter) 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 &section) const
 Test to see if a section exists.
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.
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.

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:
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.


Member Data Documentation

Print error messages on stderr.

Definition at line 190 of file config.h.

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 Thu Jun 6 2019 21:42:35