Item in config file is represented by a name, a value and (optionally) a section it belongs. Names and sections are case sensitive. Section name is written in a separate line between '[' and ']' brackets; all items till next section belong to this section. All items before the very first section belong to all sections. Comments are written after '#' or ';' till end of line.
Program can optionally modify config file values (or append new ones), and they can be written back to the file (if writing is not disabled in the constructor).
Global game config file can be accesed via CEngine.
Public Types | |
| typedef std::vector< int > | TIntVector |
| Vector of int's. | |
| typedef std::vector< float > | TFloatVector |
| Vector of float's. | |
| typedef std::vector< std::string > | TStringVector |
| Vector of std::string's. | |
Public Methods | |
| CConfig (const std::string &readName="default.cfg", bool write=false) | |
| Constructor. | |
| CConfig (const std::string &readName, const std::string &writeName) | |
| Constructor. | |
| ~CConfig () | |
| Destructor. | |
| std::string | readS (const std::string §ion, const std::string &name, const std::string &def) |
| Read string from config. | |
| int | readI (const std::string §ion, const std::string &name, int def) |
| Read integer from config. | |
| float | readF (const std::string §ion, const std::string &name, float def) |
| Read float from config. | |
| TStringVector | readSn (const std::string §ion, const std::string &name) |
| Read strings from config (eg. | |
| TIntVector | readIn (const std::string §ion, const std::string &name) |
| Read ints from config (eg. | |
| TFloatVector | readFn (const std::string §ion, const std::string &name) |
| Read floats from config (eg. | |
| void | modifyS (const std::string §ion, const std::string &name, const std::string &val) |
| Sets item value as a string. | |
| void | modifyI (const std::string §ion, const std::string &name, int val) |
| Sets item value as an integer. | |
| void | modifyF (const std::string §ion, const std::string &name, float val) |
| Sets item value as a float. | |
|
||||||||||||
|
Constructor.
|
|
||||||||||||
|
Constructor.
|
|
|
Destructor. Writing of modified/added values happens upon destruction only! |
|
||||||||||||||||
|
Sets item value as a float. Modifies existing one or appends.
|
|
||||||||||||||||
|
Sets item value as an integer. Modifies existing one or appends.
|
|
||||||||||||||||
|
Sets item value as a string. Modifies existing one or appends.
|
|
||||||||||||||||
|
Read float from config.
|
|
||||||||||||
|
Read floats from config (eg. name = 14.5 -3.0 3.1415927).
|
|
||||||||||||||||
|
Read integer from config.
|
|
||||||||||||
|
Read ints from config (eg. name = 1 -7 124).
|
|
||||||||||||||||
|
Read string from config.
|
|
||||||||||||
|
Read strings from config (eg. name = abc ghty llkfj).
|
1.2.17