mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
A wrapper for the ini functions.
Places results of the ini parser in an unordered map, with keys of "section=name", and value strings containing the value of the config item.
Definition at line 46 of file iniFile.hpp.
#include <app/iniFile.hpp>
Public Types | |
typedef std::unordered_map< std::string, std::string > | nameMapT |
the unordered map type used for storing values. More... | |
Public Member Functions | |
int | parse (const std::string &fname) |
Calls the inih parse function with this->handler. More... | |
int | insert (const char *section, const char *name, const char *value) |
Insert a config value. Appends if the key already exists in the map. More... | |
size_t | count (const std::string §ion, const std::string &name) |
Get the number of entries for the given section and name. More... | |
int | erase (const std::string §ion, const std::string &name) |
Erase the entry for the given section and name. More... | |
std::string | operator() (const std::string §ion, const std::string &name) |
Get the value associated with this section=name pair. More... | |
std::string | operator() (const std::string &name) |
Get the value associated with this name with an empty section. More... | |
Static Public Member Functions | |
static std::string | makeKey (const std::string §ion, const std::string &name) |
Return a key generated from the section and name. More... | |
static int | parseKey (std::string §ion, std::string &name, const std::string &key) |
Parse a key into its section and name consituents. More... | |
static int | handler (void *user, const char *section, const char *name, const char *value) |
Config entry handler for the parser. More... | |
Public Attributes | |
nameMapT | names |
The map of section=name keys to values. More... | |
typedef std::unordered_map<std::string, std::string> mx::app::iniFile::nameMapT |
the unordered map type used for storing values.
Definition at line 48 of file iniFile.hpp.
|
inline |
Get the number of entries for the given section and name.
Is either 1 or 0, depending on if this cconfig key exists.
[in] | section | The section for the key |
[in] | name | the name for the key |
Definition at line 141 of file iniFile.hpp.
References makeKey(), and names.
Referenced by mx::app::appConfigurator::readConfig().
|
inline |
Erase the entry for the given section and name.
[in] | section | The section for the key |
[in] | name | the name for the key |
Definition at line 153 of file iniFile.hpp.
References makeKey(), and names.
Referenced by mx::app::appConfigurator::readConfig().
|
inlinestatic |
Config entry handler for the parser.
Calls insert, and returns its result. Any non-zero return will cause ini_parse to report the current line number as an error.
[in] | user | a pointer to this. |
[in] | section | the section of the config entry |
[in] | name | the name of the config entry |
[in] | value | the value of the config entry |
Definition at line 126 of file iniFile.hpp.
References insert().
Referenced by parse().
|
inline |
Insert a config value. Appends if the key already exists in the map.
[in] | section | The section for the key |
[in] | name | the name for the key |
[in] | value | the value to insert |
Definition at line 105 of file iniFile.hpp.
References makeKey(), and names.
Referenced by handler().
|
inlinestatic |
Return a key generated from the section and name.
Constructs the key as "section=name".
[in] | section | The section for the key |
[in] | name | the name for the key |
Definition at line 57 of file iniFile.hpp.
Referenced by mx::app::appConfigurator::configUnused(), count(), erase(), insert(), and operator()().
|
inline |
Get the value associated with this name with an empty section.
[in] | name | the name for the key |
Definition at line 186 of file iniFile.hpp.
References operator()().
|
inline |
Get the value associated with this section=name pair.
[in] | section | The section for the key |
[in] | name | the name for the key |
Definition at line 166 of file iniFile.hpp.
References makeKey(), and names.
Referenced by operator()().
|
inline |
Calls the inih parse function with this->handler.
This returns the result of the ini_parse function.
[in] | fname | the full path of the file |
Definition at line 94 of file iniFile.hpp.
References handler(), and ini_parse().
Referenced by mx::app::appConfigurator::readConfig().
|
inlinestatic |
Parse a key into its section and name consituents.
Requires that =
be present.
=
found. [out] | section | the section extracted from the key |
[out] | name | the name extracted from the key |
[in] | key | th key to parse. |
Definition at line 70 of file iniFile.hpp.
Referenced by mx::app::appConfigurator::readConfig().
nameMapT mx::app::iniFile::names |
The map of section=name keys to values.
Definition at line 50 of file iniFile.hpp.
Referenced by count(), erase(), insert(), operator()(), and mx::app::appConfigurator::readConfig().