ConfigFileReader Class Reference

This class is a wrapper to the Common C++ class used for INI file processing and provides a few additional conveniences for config file management. More...

#include <ConfigFileReader.h>

List of all members.

Public Member Functions

 ConfigFileReader (const string &keyword)
 Constructs an object for reading values of variables from INI files.
const char * getValue (const char *symbol, const char *defaultvalue)
 Get the last set value for a configuration variable as a string.
bool getValue (const char *symbol, bool defaultvalue)
 Get the last set value for a configuration variable as a boolean.
int getValue (const char *symbol, int defaultvalue)
 Get the last set value for a configuration variable as an int.
double getValue (const char *symbol, double defaultvalue)
 Get the last set value for a configuration variable as a double.


Detailed Description

This class is a wrapper to the Common C++ class used for INI file processing and provides a few additional conveniences for config file management.

The class provides methods that give typed access to the variables. Also, undefined variables are handled a bit more gracefully than in the provided interface. If a variable is not found, a suitably typed default return value can be provided rather than NULL. The class will also take care of creating a .bierc file for a user that doesn't have one already.

Typical usage: ConfigFileReader * kd = new ConfigFileReader("cli"); bool mybool = kd->getValue("mybool", true); string mystring = kd->getValue("mystring", "Alistair");


Constructor & Destructor Documentation

ConfigFileReader::ConfigFileReader ( const string &  keyword  ) 

Constructs an object for reading values of variables from INI files.

The section of the INI file must be specified (e.g. "cli" is a section in the .bierc config file). Will also create a ~/.bierc file for users who are missing this file.

Parameters:
section Specifies the file section we want to refer to (e.g. "cli" refers to ~username/.bierc section [cli] followed by the [cli] stanza in a .bierc defined in the working dir, if it exists)


Member Function Documentation

const char* ConfigFileReader::getValue ( const char *  symbol,
const char *  defaultvalue 
)

Get the last set value for a configuration variable as a string.

The value will probably come from a config file. When the variable does not exist, the default value is returned.

bool ConfigFileReader::getValue ( const char *  symbol,
bool  defaultvalue 
)

Get the last set value for a configuration variable as a boolean.

The value will probably come from a config file. When the variable does not exist, the default value is returned.

int ConfigFileReader::getValue ( const char *  symbol,
int  defaultvalue 
)

Get the last set value for a configuration variable as an int.

The value will probably come from a config file. When the variable does not exist, the default value is returned.

double ConfigFileReader::getValue ( const char *  symbol,
double  defaultvalue 
)

Get the last set value for a configuration variable as a double.

The value will probably come from a config file. When the variable does not exist, the default value is returned.


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

Send suggestions, questions, and feedback to WEINBERG at ASTRO dot UMASS dot EDU.
Documentation generated at Fri Mar 26 00:35:11 2010 by doxygen