2.17 Config class
Config
Syntax
Config(const string & filename, const bool bPrintErrorMessages = true);
Config(const Config & x);
Config & operator=(const Config & x);
Description
This class provides a function to read a configuration.
Return Value
None
Reading and writing
Syntax
short read_conf();
short write_conf(const string filename, const string file_title,
const int space_between_column);
Description
The member function read_conf reads a configuration file (specified by
constructor). The member function write_conf writes the configuration data in a
file. A configuration file is divided in sections, which contain different parameters
with their values. A section starts by [section_name] and contains one or more
parameters an their values: parameter_name: value The “:” is mandatory
between the name of the parameter and it’s value. Lines beginning with a # and
white/empty lines are ignored . The following example contains one section
named PUMA560_mDH.
[PUMA560_mDH]
DH: 0
Fix: 1
MinPara: 0
dof: 6
Motor: 0
Return Value
Status, as a short int.
- 0 successful
- CAN_NOT_OPEN_FILE
select
Syntax
short select(const string section, const string parameter,
string & value) const;
short select(const string section, const string parameter,
bool & value) const;
short select(const string section, const string parameter,
short & value) const;
short select(const string section, const string parameter,
int & value) const;
short select(const string section, const string parameter,
double & value) const;
short select(const string section, const string parameter,
float & value) const;
Description
These member functions are use to assign to the variable value the value of the
parameter parameter from section section section.
Return Value
Status, as a short int.
- 0 successful
- SECTION_OR_PARAMETER_DOES_NOT_EXIST
add
Syntax
void add(const string section, const string parameter,
const string value);
void add(const string section, const string parameter,
const bool value);
void add(const string section, const string parameter,
const short value);
void add(const string section, const string parameter,
const int value);
void add(const string section, const string parameter,
const double value);
void add(const string section, const string parameter,
const float value);
Description
These member functions are use to add data into the data file structure.
They will create the section and the parameter if it does not already
exist.
Return Value
None