CGRA-ME
|
#include <ConfigStore.h>
Public Types | |
using | BackingStore = std::map< std::string, std::string > |
Public Member Functions | |
ConfigStore ()=default | |
ConfigStore (BackingStore src) | |
ConfigStore (std::initializer_list< std::pair< std::string, ImplicitlyToString >> ilist) | |
Flexible constructor that converts everything value it is given to a string. More... | |
ConfigStore (const ConfigStore &)=default | |
ConfigStore & | operator= (const ConfigStore &)=default |
ConfigStore (ConfigStore &&)=default | |
ConfigStore & | operator= (ConfigStore &&)=default |
bool | addString (std::string key, std::string value) |
bool | addInt (std::string key, long long value) |
bool | addReal (std::string key, double value) |
bool | addBool (std::string key, bool value) |
void | setString (std::string key, std::string value) |
void | setInt (std::string key, long long value) |
void | setReal (std::string key, double value) |
void | setBool (std::string key, bool value) |
const std::string & | getString (const std::string &key) const |
long long | getInt (const std::string &key) const |
double | getReal (const std::string &key) const |
bool | getBool (const std::string &key) const |
const std::string & | getStringOr (const std::string &key, const std::string &otherwise) const |
std::string | getStringOr (const std::string &key, std::string &&otherwise) const |
long long | getIntOr (const std::string &key, long long otherwise) const |
double | getRealOr (const std::string &key, double otherwise) const |
bool | getBoolOr (const std::string &key, bool otherwise) const |
bool | hasKey (const std::string &key) const |
auto | begin () const |
auto | end () const |
bool | empty () const |
bool | operator== (const ConfigStore &rhs) const |
bool | operator!= (const ConfigStore &rhs) const |
Private Member Functions | |
std::invalid_argument | makeIncompleteConversionException (const std::string &key, const std::string &value) const |
Private Attributes | |
BackingStore | backing_store = {} |
Friends | |
std::ostream & | operator<< (std::ostream &os, const ConfigStore &cs) |
A class that helps with storing things like INI settings or other simple key-value data. Provides convenience conversions from the stored string data and supports in-code defaults.
Definition at line 76 of file ConfigStore.h.
using ConfigStore::BackingStore = std::map<std::string, std::string> |
Definition at line 78 of file ConfigStore.h.
|
default |
|
inline |
Definition at line 82 of file ConfigStore.h.
|
inline |
Flexible constructor that converts everything value it is given to a string.
Keys must be string due to ambiguity (eg. what is a canonical conversion for bools?), and not having a clear use-case.
Ex.:
Definition at line 104 of file ConfigStore.h.
|
default |
|
default |
|
inline |
Definition at line 123 of file ConfigStore.h.
|
inline |
Definition at line 121 of file ConfigStore.h.
|
inline |
Definition at line 122 of file ConfigStore.h.
|
inline |
Inserts value
under the key key
. Does not overwrite.
Definition at line 120 of file ConfigStore.h.
|
inline |
Definition at line 213 of file ConfigStore.h.
|
inline |
Definition at line 215 of file ConfigStore.h.
|
inline |
Definition at line 214 of file ConfigStore.h.
|
inline |
Definition at line 166 of file ConfigStore.h.
|
inline |
Definition at line 201 of file ConfigStore.h.
|
inline |
Definition at line 146 of file ConfigStore.h.
|
inline |
Definition at line 191 of file ConfigStore.h.
|
inline |
Definition at line 156 of file ConfigStore.h.
|
inline |
Definition at line 196 of file ConfigStore.h.
|
inline |
The simple getters. Throw exceptions if the key is not found.
Definition at line 136 of file ConfigStore.h.
|
inline |
The defaulted getters. Return the second argument if the key has no value.
Definition at line 181 of file ConfigStore.h.
|
inline |
Definition at line 186 of file ConfigStore.h.
|
inline |
Returns true iff key has a value
Definition at line 209 of file ConfigStore.h.
|
inlineprivate |
Definition at line 240 of file ConfigStore.h.
|
inline |
Definition at line 220 of file ConfigStore.h.
|
default |
|
default |
|
inline |
Definition at line 217 of file ConfigStore.h.
|
inline |
Definition at line 131 of file ConfigStore.h.
|
inline |
Definition at line 129 of file ConfigStore.h.
|
inline |
Definition at line 130 of file ConfigStore.h.
|
inline |
Sets key
to have the value value
. Will overwrite.
Definition at line 128 of file ConfigStore.h.
|
friend |
Print out the contents in a neat way.
Definition at line 225 of file ConfigStore.h.
|
private |
Definition at line 244 of file ConfigStore.h.