![]() |
Jazz 1.25.+
|
A configuration file as a key/value store. More...
#include <utils.h>
Public Member Functions | |
| ConfigFile (const char *input_file_name) | |
| bool | load_config (const char *input_file_name) |
| int | num_keys () |
| bool | get_key (const char *key, int &value) |
| bool | get_key (const char *key, double &value) |
| bool | get_key (const char *key, String &value) |
| void | debug_put (const String key, const String val) |
Private Attributes | |
| std::map< String, String > | config |
| The configuration key/value store. | |
A configuration file as a key/value store.
The configuration is loaded when constructing the object and available for reading as int, double or string via get_key().
The input file format removes anything to the right of a // as a remark. It uses a single equal (=) character to separate the key from the value. It also performs a very simple form of quote replacement using CleanConfigArgument().
| jazz_elements::ConfigFile::ConfigFile | ( | const char * | input_file_name | ) |
Build a ConfigFile by calling load_config()
| input_file_name | The input file name containing a configuration |
It returns nothing. Check num_keys() for errors.
| bool jazz_elements::ConfigFile::load_config | ( | const char * | input_file_name | ) |
Load a configuration from a file.
Configuration is stored in: map<string, string> config which is private and read using the function get_key().
| input_file_name | The input file name containing a configuration |
| int jazz_elements::ConfigFile::num_keys | ( | ) |
Get the number of known configuration keys.
| bool jazz_elements::ConfigFile::get_key | ( | const char * | key, |
| int & | value | ||
| ) |
Get the value for an existing configuration key.
| key | The configuration key to be searched. |
| value | Value to be returned only when the function returns true. |
| bool jazz_elements::ConfigFile::get_key | ( | const char * | key, |
| double & | value | ||
| ) |
Get the value for an existing configuration key.
| key | The configuration key to be searched. |
| value | Value to be returned only when the function returns true. |
| bool jazz_elements::ConfigFile::get_key | ( | const char * | key, |
| String & | value | ||
| ) |
Get the value for an existing configuration key.
| key | The configuration key to be searched. |
| value | Value to be returned only when the function returns true. |
DEBUG ONLY function: Set a config key manually.
| key | The configuration key to be set. |
| val | New value of the key as a string (also valid for int and double if the string can be converted). |