SPH
|
Holds a map of virtual entries, associated with a unique name. More...
#include <VirtualSettings.h>
Classes | |
class | Category |
class | IEntryProc |
Interface allowing to enumerate all entries in the settings. More... | |
Public Member Functions | |
void | set (const std::string &key, const IVirtualEntry::Value &value) |
Modifies an existing entry in the settings. More... | |
template<typename TEnum , typename = std::enable_if_t<std::is_enum<TEnum>::value>> | |
void | set (const TEnum id, const IVirtualEntry::Value &value) |
Overload allowing to use an ID associated with a Settings entry. More... | |
IVirtualEntry::Value | get (const std::string &key) const |
Returns a value of an entry. More... | |
Category & | addCategory (const std::string &name) |
Creates a new category of entries. More... | |
void | enumerate (const IEntryProc &proc) |
Enumerates all entries stored in the settings. More... | |
Holds a map of virtual entries, associated with a unique name.
The key-value pairs are not stored in the settings directly, they are stored in settings categories; the VirtualSettings object then holds a map of categories. This provides clustering of related entries, which helps to separate the entries in UI.
Definition at line 229 of file VirtualSettings.h.
VirtualSettings::Category & VirtualSettings::addCategory | ( | const std::string & | name | ) |
Creates a new category of entries.
Returned object can be used to add entries into settings.
name | Name of the created category. |
Definition at line 100 of file VirtualSettings.cpp.
void VirtualSettings::enumerate | ( | const IEntryProc & | proc | ) |
Enumerates all entries stored in the settings.
Definition at line 104 of file VirtualSettings.cpp.
IVirtualEntry::Value VirtualSettings::get | ( | const std::string & | key | ) | const |
Returns a value of an entry.
key | Identifier of the entry |
InvalidSetup | if no entry with given key exists. |
Definition at line 90 of file VirtualSettings.cpp.
void VirtualSettings::set | ( | const std::string & | key, |
const IVirtualEntry::Value & | value | ||
) |
Modifies an existing entry in the settings.
This function cannot be used to add a new entry. Use Category to create entries.
key | Identifier of the entry |
value | New value of the entry |
InvalidSetup | if no entry with given key exists. |
Definition at line 79 of file VirtualSettings.cpp.
void VirtualSettings::set | ( | const TEnum | id, |
const IVirtualEntry::Value & | value | ||
) |
Overload allowing to use an ID associated with a Settings entry.
This is useful if the virtual entry is connected to an entry in a Settings object. This way, an enum value can be used instead of string, ensuring the value is valid (string may contain typos) and can be easily renamed if necessary.
Note that there is no check that the virtual entry is really connected to a "real" entry with given ID, virtual entry is (intentionally) a black box here.
id | ID of the connected entry |
value | New value of the entry |
InvalidSetup | if the ID is invalid or no entry with given ID exists. |
Definition at line 267 of file VirtualSettings.inl.h.