My Project
|
Helper class to read configuration files. More...
#include <unity/util/IniParser.h>
Public Member Functions | |
IniParser (const char *filename) | |
Accessors | |
These member functions provide access to configuration entries by group and key. Attempts to retrieve a value as the wrong type, such as retrieving a string value "abc" as an integer, throw LogicException. | |
bool | has_group (const std::string &group) const noexcept |
bool | has_key (const std::string &group, const std::string &key) const |
std::string | get_string (const std::string &group, const std::string &key) const |
std::string | get_locale_string (const std::string &group, const std::string &key, const std::string &locale=std::string()) const |
bool | get_boolean (const std::string &group, const std::string &key) const |
int | get_int (const std::string &group, const std::string &key) const |
std::vector< std::string > | get_string_array (const std::string &group, const std::string &key) const |
std::vector< std::string > | get_locale_string_array (const std::string &group, const std::string &key, const std::string &locale=std::string()) const |
std::vector< int > | get_int_array (const std::string &group, const std::string &key) const |
std::vector< bool > | get_boolean_array (const std::string &group, const std::string &key) const |
std::string | get_start_group () const |
std::vector< std::string > | get_groups () const |
std::vector< std::string > | get_keys (const std::string &group) const |
Helper class to read configuration files.
This class reads configuration files in the .ini format and provides for a simple and type safe way of extracting information. A typical ini file looks like this:
To obtain a value, simply specify the group and key names to the get* functions of this class. The array functions use a semicolon as a separator.
The get functions indicate errors by throwing LogicExceptions. Examples why this might happen is because a value can't be coerced into the given type (i.e trying to convert the value "hello" into a boolean).
unity::util::IniParser::IniParser | ( | const char * | filename | ) |
Parse the given file.