ConfigFile Class Reference

The configuration file parser. More...

Inherited by VoicemanConfigFile.

List of all members.

Public Member Functions

void checkParams () const
 Checks read values type matching.
 ConfigFile ()
 The default constructor.
const ConfigFileSectionfindSection (const std::string &name) const
 Returns the reference to the section object by the section name.
const ConfigFileSectiongetSection (ConfigFileSectionVector::size_type index) const
 Returns the reference to the section object by the section index.
ConfigFileSectionVector::size_type getSectionCount () const
 Returns the number of read sections.
bool hasSection (const std::string &name) const
 Checks if the specified section is accessible.
void load (const std::string &fileName)
 Loads configuration file content.
virtual ~ConfigFile ()
 The destructor.

Protected Types

enum  {
  ANY_VALUE = -1, INVALID_VALUE = 0, BOOLEAN_VALUE = 1, STRING_VALUE = 2,
  INT_VALUE = 3, UINT_VALUE = 4, DOUBLE_VALUE = 5
}

Protected Member Functions

virtual int params (const std::string &section, const std::string &param) const =0


Detailed Description

This is the main class to parse configuration file. It reads all data from file, constructs the set of ConfigFileSection objects and fills them with read data. User can analyze prepared information and perform required handling. This class can also check data types by the data types table, defined in child class. None of the data semantics is processed by this class.

Member Function Documentation

void ConfigFile::checkParams (  )  const

This method looks through read values and checks its types. If error is found the ConfigFileValueTypeException will be thrown. Checking is performed by the data provided by params() method. You should override this method in your child classe. There are predefined macroses to define data types table.

const ConfigFileSection & ConfigFile::findSection ( const std::string &  name  )  const

Parameters:
[in] name The name of a section to return

const ConfigFileSection & ConfigFile::getSection ( ConfigFileSectionVector::size_type  index  )  const

Parameters:
[in] index The index of a section to return

bool ConfigFile::hasSection ( const std::string &  name  )  const

Parameters:
[in] name The name of a section to check

void ConfigFile::load ( const std::string &  fileName  ) 

This method saves processed data in the internal structures inside of this class. Any data can be retrieved later. On any error this method throws ConfigFileException. This method does not perform any value type checking. You should explicitly call checkParams() method to do it. This method saves processed data in the internal structures inside of the class. Any required information can be retrieved later through corresponding methods. On any error this method throws ConfigFileException. None of the data types checking is performed by this method. You should explicitly call checkParams() method to do it.

Parameters:
[in] fileName The name of a file to read data from


Generated on Thu May 6 16:10:58 2010 for VoiceMan by  doxygen 1.5.9