The configuration file parser.
More...
|
enum | {
AnyValue = -1,
InvalidValue = 0,
BooleanValue = 1,
StringValue = 2,
IntValue = 3,
UintValue = 4,
DoubleValue = 5
} |
|
|
virtual int | params (const std::string §ion, const std::string ¶m) const =0 |
|
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.
- See also
- ConfigFileSection ConfigFileException ConfigFileValueTypeException
void ConfigFile::checkParams |
( |
| ) |
const |
This method looks through read values and checks its types. If error is found the ConfigFileValueTypeException is 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.
This method looks through stored sections vector and finds U corresponding by section name. You must be strongly sure the required section exists. This method does not have any way to notify about an error.
- Parameters
-
[in] | name | The name of a section to return |
- Returns
- The reference to desired section object
const ConfigFileSection & ConfigFile::getSection |
( |
ConfigFileSectionVector::size_type |
index | ) |
const |
Use this method to get desired section object.
- Parameters
-
[in] | index | The index of a section to return |
- Returns
- The reference to desired section object
ConfigFileSectionVector::size_type ConfigFile::getSectionCount |
( |
| ) |
const |
Use this method to get number of parsed sections.
- Returns
- Number of parsed sections
bool ConfigFile::hasSection |
( |
const std::string & |
name | ) |
const |
Use this method to be sure the desired section exists.
- Parameters
-
[in] | name | The name of a section to check |
- Returns
- Non-zero if specified section exists
void ConfigFile::load |
( |
const std::string & |
fileName | ) |
|
This method reads configuration file and saves processed data in the internal structures inside of this class. Any data can be retrieved later. On any error it throws ConfigFileException. This method does not perform any value type checking. You should explicitly call checkParams() method to do it.
- Parameters
-
[in] | fileName | The name of a file to read data from |