ConfigParser_t Class Reference

#include <cfgparser.h>

List of all members.

Public Member Functions

 ConfigParser_t (void)
 ConfigParser_t (const std::string &fname)
int readFile (const std::string &fname)
int getValue (std::string section, std::string name, std::string *value) const
int getValue (std::string section, std::string name, int *value) const
int getValue (std::string section, std::string name, double *value) const
int getValue (std::string section, std::string name, std::vector< std::string > *value) const
int getValue (std::string section, std::string name, bool *value) const

Private Attributes

std::vector< struct entry_sentry

Classes

struct  entry_s


Detailed Description

This is a config file class. It can read and parse config files in style of M$ windows 3.1 INI-files.


Constructor & Destructor Documentation

ConfigParser_t::ConfigParser_t ( void   ) 

Default constructor. Construct empty config file.

ConfigParser_t::ConfigParser_t ( const std::string &  fname  )  [explicit]

Create config object with content loaded from file. Method reads and parses content of given file. On error throws exception (std::string).

Parameters:
fname File name of config file.


Member Function Documentation

int ConfigParser_t::readFile ( const std::string &  fname  ) 

Read and parse config file.

Returns:
0 on success, -1 on error.
Parameters:
fname File name of config file.

int ConfigParser_t::getValue ( std::string  section,
std::string  name,
std::string *  value 
) const

Get value of given entry name (std::string). If entry is not found then value is left untouched (good for pre-initialization with default value).

Returns:
1=entry found, 0=not found.
Parameters:
section Section in which is the desired entry.
name Name of the entry.
value Buffer for entry value.

int ConfigParser_t::getValue ( std::string  section,
std::string  name,
int *  value 
) const

Get value of given entry name (int). If entry is not found or has invalid integer value, then value param is left untouched (good for pre-initialization with defaults).

Returns:
1=entry found, 0=not found.
Parameters:
section Dection in which is the desired entry.
name Name of the entry.
value Buffer for entry value.

int ConfigParser_t::getValue ( std::string  section,
std::string  name,
double *  value 
) const

Get value of given entry name (double). If entry is not found or has invalid double valus, then value param is left untouched (good for pre-initialization with defaults).

Returns:
1=entry found, 0=not found.
Parameters:
section Section in which is the desired entry.
name Name of the entry.
value Buffer for entry value.

int ConfigParser_t::getValue ( std::string  section,
std::string  name,
std::vector< std::string > *  value 
) const

Get values of given entry name. Returns all occurences of the same section/name entries. If entry is not found then value is left untouched (good for pre-initialization with default value).

Returns:
1=entry found, 0=not found.
Parameters:
section Section in which is the desired entry.
name Name of the entry.
value Vector buffer for entry values.

int ConfigParser_t::getValue ( std::string  section,
std::string  name,
bool *  value 
) const

Get value of given entry name (boolean). If entry is not found then value is left untouched (good for pre-initialization with default value). true: "1", "true", "on", "yes" false: "0", "false", "off", "no" other std::strings are invalid (all comparisions are case insensitive)

Returns:
1=entry found, 0=not found.
Parameters:
section Section in which is the desired entry.
name Name of the entry.
value Buffer for entry value.


Member Data Documentation

std::vector<struct entry_s> ConfigParser_t::entry [private]

Config file entries. An array of entry structures.


The documentation for this class was generated from the following files:
Generated on Wed May 7 13:41:38 2008 for Cfgparser (c) SEZNAM.CZ a.s. by  doxygen 1.5.1