Config Keys and Properties
Checks if Key exists in Category
Non-strict method to get the value of a config key into the specified output value. If the config key does not exist, the given default value is returned.
Alternative form non-strict config value getter, returning the retrieved value via a reference. (For interface consistency with the reference version of getStrict(), above.)
Non-strict method to get a multi-line value. The existence or non-existence of the key is returned. If the configuration key cannot be found, the output list remains unchanged.
Strict method to get a multi-line value. If the requested key cannot be found, an exception is thrown.
Strict method to get the value of a config key. If the requested key cannot be found, an exception is thrown.
Alternative form strict config value getter, returning the retrieved value via a reference. (The advantage being that the template type can then be inferred by the compiler.)
Tells whether the config object has no values loaded.
Returns an iterator over keys or key/value pairs in a category. The values are converted to T, unless T is istring.
Iterator. Iterates over categories of the config file
Read Config File
Parse a string
Prints the current configuration to the given formatted text stream.
Remove Config-Key Property
Set Config-Key Property
Variable Iterator. Iterates over keys or key/value pairs of a category. The values are converted to T, unless T is istring.
Usage example
void main () { // Read config file from disk scope config = new ConfigParser("etc/config.ini"); // Read a single value istring value = config.getStrict!(istring)("category", "key"); // Set a single value config.set("category", "key", "new value"); // Read a multi-line value istring[] values = config.getListStrict("category", "key"); }
Config reads all properties of the application from an INI style of the following format:
The properties defined in the file are read and stored in an internal array, which can then be accessed through get and set methods as follows:
The parseFile() method only needs to be called once, though may be called multiple times if the config file needs to be re-read from the file on disk.
TODO: At the moment it's possible to set a key (se set), but it's not possible to write back to the file.