#include <IniFile.h>
Public Member Functions | |
IniFile () | |
IniFile (const char *filename) | |
bool | load (const char *filename) |
bool | save (const char *filename) const |
void | removeKey (const char *section, const char *key) |
const char * | getString (const char *section, const char *key, const char *def="") const |
int | getInt (const char *section, const char *key, int def=0) const |
double | getDouble (const char *section, const char *key, double def=0) const |
bool | getBool (const char *section, const char *key, bool def=false) const |
void | setString (const char *section, const char *key, const char *val) |
void | setInt (const char *section, const char *key, int val) |
void | setDouble (const char *section, const char *key, double val) |
void | setBool (const char *section, const char *key, bool val) |
Private Types | |
typedef map< string, string, lt_nocase > | Keys |
typedef map< string, Keys, lt_nocase > | Sections |
Private Attributes | |
Sections | sections |
Classes | |
struct | lt_nocase |
The values are stored in a double layered map. The first layer contains the section names, the second layer contains the actual key/value pairs. All names are case-insensitive, and are kept in sorted order. Insertion, lookup and removal of keys should take logarithmic time.
Definition at line 18 of file IniFile.h.
typedef map<string, string, lt_nocase> IniFile::Keys [private] |
typedef map<string, Keys, lt_nocase> IniFile::Sections [private] |
IniFile::IniFile | ( | ) |
Construct an empty IniFile.
Definition at line 29 of file IniFile.cpp.
IniFile::IniFile | ( | const char * | filename | ) |
Construct an IniFile and load settings.
filename | name of .ini file to load |
Definition at line 39 of file IniFile.cpp.
References load().
bool IniFile::getBool | ( | const char * | section, | |
const char * | key, | |||
bool | def = false | |||
) | const |
double IniFile::getDouble | ( | const char * | section, | |
const char * | key, | |||
double | def = 0 | |||
) | const |
int IniFile::getInt | ( | const char * | section, | |
const char * | key, | |||
int | def = 0 | |||
) | const |
const char * IniFile::getString | ( | const char * | section, | |
const char * | key, | |||
const char * | def = "" | |||
) | const |
Get value of key.
section | section of key | |
key | name of key to retrieve | |
def | default value |
Definition at line 270 of file IniFile.cpp.
References sections.
Referenced by getBool(), getDouble(), and getInt().
bool IniFile::load | ( | const char * | filename | ) |
Load settings from an .ini file.
Lines can be arbitrarily long and may use \-escaping and quoted whitespace. Comments must start with an ';'.
filename | name of .ini file to load |
Definition at line 74 of file IniFile.cpp.
References InFile::exists(), InFile::getEof(), InStream< S, R >::read(), and sections.
Referenced by IniFile().
void IniFile::removeKey | ( | const char * | section, | |
const char * | key | |||
) |
Remove a key from a section.
section | section of key | |
key | name of key to remove |
Definition at line 52 of file IniFile.cpp.
References sections.
bool IniFile::save | ( | const char * | filename | ) | const |
Save setting to an .ini-File.
filename | name of .ini file to save into |
Definition at line 225 of file IniFile.cpp.
References esc(), OutFile::exists(), and sections.
void IniFile::setBool | ( | const char * | section, | |
const char * | key, | |||
bool | val | |||
) |
void IniFile::setDouble | ( | const char * | section, | |
const char * | key, | |||
double | val | |||
) |
void IniFile::setInt | ( | const char * | section, | |
const char * | key, | |||
int | val | |||
) |
void IniFile::setString | ( | const char * | section, | |
const char * | key, | |||
const char * | val | |||
) |
Set value of key.
section | section of key | |
key | name of key to set | |
val | value to set |
Definition at line 254 of file IniFile.cpp.
References sections.
Referenced by setBool(), setDouble(), and setInt().
Sections IniFile::sections [private] |
Definition at line 30 of file IniFile.h.
Referenced by getString(), load(), removeKey(), save(), and setString().