#include <yatengine.h>
Inheritance diagram for Configuration:
Public Member Functions | |
Configuration () | |
Configuration (const char *filename) | |
Configuration & | operator= (const String &value) |
unsigned int | sections () const |
NamedList * | getSection (unsigned int index) const |
NamedList * | getSection (const String §) const |
NamedString * | getKey (const String §, const String &key) const |
const char * | getValue (const String §, const String &key, const char *defvalue=0) const |
int | getIntValue (const String §, const String &key, int defvalue=0) const |
int | getIntValue (const String §, const String &key, const TokenDict *tokens, int defvalue=0) const |
double | getDoubleValue (const String §, const String &key, double defvalue=0.0) const |
bool | getBoolValue (const String §, const String &key, bool defvalue=false) const |
void | clearSection (const char *sect=0) |
void | createSection (const String §) |
void | clearKey (const String §, const String &key) |
void | addValue (const String §, const char *key, const char *value=0) |
void | setValue (const String §, const char *key, const char *value=0) |
void | setValue (const String §, const char *key, int value) |
void | setValue (const String §, const char *key, bool value) |
bool | load () |
bool | save () const |
A class for parsing and quickly accessing INI style configuration files
Configuration | ( | ) |
Create an empty configuration
Configuration | ( | const char * | filename | ) |
Create a configuration from a file
filename | Name of file to initialize from |
Configuration& operator= | ( | const String & | value | ) | [inline] |
Assignment from string operator
Reimplemented from String.
unsigned int sections | ( | ) | const [inline] |
Get the number of sections
NamedList* getSection | ( | unsigned int | index | ) | const |
Retrive an entire section
index | Index of the section |
Retrive an entire section
sect | Name of the section |
NamedString* getKey | ( | const String & | sect, | |
const String & | key | |||
) | const |
Locate a key/value pair in the section.
sect | Name of the section | |
key | Name of the key in section |
Retrive the value of a key in a section.
sect | Name of the section | |
key | Name of the key in section | |
defvalue | Default value to return if not found |
Retrive the numeric value of a key in a section.
sect | Name of the section | |
key | Name of the key in section | |
defvalue | Default value to return if not found |
int getIntValue | ( | const String & | sect, | |
const String & | key, | |||
const TokenDict * | tokens, | |||
int | defvalue = 0 | |||
) | const |
Retrive the numeric value of a key in a section trying first a table lookup.
sect | Name of the section | |
key | Name of the key in section | |
tokens | A pointer to an array of tokens to try to lookup | |
defvalue | Default value to return if not found |
Retrive the floating point value of a key in a section.
sect | Name of the section | |
key | Name of the key in section | |
defvalue | Default value to return if not found |
Retrive the boolean value of a key in a section.
sect | Name of the section | |
key | Name of the key in section | |
defvalue | Default value to return if not found |
void clearSection | ( | const char * | sect = 0 |
) |
Deletes an entire section
sect | Name of section to delete, NULL to delete all |
void createSection | ( | const String & | sect | ) | [inline] |
Makes sure a section with a given name exists, creates if required
sect | Name of section to check or create |
Deletes a key/value pair
sect | Name of section | |
key | Name of the key to delete |
void addValue | ( | const String & | sect, | |
const char * | key, | |||
const char * | value = 0 | |||
) |
Add the value of a key in a section.
sect | Name of the section, will be created if missing | |
key | Name of the key to add in the section | |
value | Value to set in the key |
void setValue | ( | const String & | sect, | |
const char * | key, | |||
const char * | value = 0 | |||
) |
Set the value of a key in a section.
sect | Name of the section, will be created if missing | |
key | Name of the key in section, will be created if missing | |
value | Value to set in the key |
void setValue | ( | const String & | sect, | |
const char * | key, | |||
int | value | |||
) |
Set the numeric value of a key in a section.
sect | Name of the section, will be created if missing | |
key | Name of the key in section, will be created if missing | |
value | Value to set in the key |
void setValue | ( | const String & | sect, | |
const char * | key, | |||
bool | value | |||
) |
Set the boolean value of a key in a section.
sect | Name of the section, will be created if missing | |
key | Name of the key in section, will be created if missing | |
value | Value to set in the key |
bool load | ( | ) |
Load the configuration from file
bool save | ( | ) | const |
Save the configuration to file