config.hpp
Maintains a set of configuration options.
This file defines a master configuration option Config, whose values can be loaded at runtime or else set as constant values throughout the code.
Assuming you have an Config object called config, you can:
access a setting value: config.SETTING_NAME() adjust a setting value: config.SETTING_NAME(new_value) determine if a setting is locked: config.SETTING_NAME_is_const() lookup a setting dynamically: config(“SETTING_NAME”) adjust a setting dynamically: config(“SETTING_NAME”, “new_value”)
load settings from a stream: config.Read(stream); load settings from a file: config.Read(filename); save settings to a stream: config.Write(stream); save settings to a file: config.Write(filename); generate a query string: config.WriteUrlQueryString(stream);
write settings macros to a stream: config.WriteMacros(stream); write settings macros to a file: config.WriteMacros(filename);
The configuration files generated can use the following keywords in order to configure this object: include OTHER_FILENAME — Load in all data from another file. set SETTING_NAME VALUE — Set a basic configuration setting. new OBJECT_TYPE OBJECT_NAME — Create a new config object of a managed class. use OBJECT_TYPE OBJECT_NAME — Use a previouly created configuration object.
-
class ConfigEntry
- #include <config.hpp>
Base class for all configuration settings.
Subclassed by Config::ConfigLiveEntry, Config::tConfigConstEntry< VAR_TYPE >, Config::tConfigEntry< VAR_TYPE >
Public Functions
-
inline ConfigEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc)
-
inline virtual ~ConfigEntry()
-
inline ConfigEntry &SetName(const std::string &_in)
-
inline ConfigEntry &SetType(const std::string &_in)
-
inline ConfigEntry &SetDefault(const std::string &_in)
-
inline ConfigEntry &SetDescription(const std::string &_in)
-
inline ConfigEntry &AddAlias(const std::string &_in)
Alert this setting that it is aliased to alternate possible names.
-
virtual std::string GetLiteralValue() const = 0
Conver the value of this setting into a literal that C++ would recognize as its current value.
-
virtual ConfigEntry &SetValue(const std::string &in_val, std::stringstream &warnings) = 0
Use a string to set the value of this setting.
-
virtual bool IsConst() const = 0
Identify if this setting is fixed at compile time.
-
inline ConfigEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc)
-
class Config
- #include <config.hpp>
Master configuration class that manages all of the settings.
Public Functions
-
inline ~Config()
-
inline ConfigEntry *operator[](const std::string &name)
-
inline const ConfigEntry *operator[](const std::string &name) const
-
inline Config &Set(std::string setting_name, const std::string &new_value, const std::string &in_desc = "")
-
inline bool Read(std::istream &input, const std::string &cur_namespace = "")
Read in from a text representation (typically a file) to set the state of Config. Return success state.
-
inline void AddCommand(const std::string &command_name, std::function<bool(std::string)> command_fun)
-
template<class MANAGED_TYPE>
inline void AddManagedType(const std::string &type_keyword, const std::string &command_keyword, std::function<bool(MANAGED_TYPE&, std::string)> fun_callback)
-
inline vector<ConfigGroup*> GetGroupSet()
Access group_set using this method since it is protected.
Protected Functions
-
inline ConfigGroup *GetActiveGroup()
-
inline ConfigEntry *GetActiveEntry()
-
inline bool IsVarChar(const char c)
Protected Attributes
-
unordered_map<std::string, ConfigEntry*> var_map
-
vector<ConfigGroup*> group_set
-
int delay_warnings
-
unordered_map<std::string, std::string> alias_map
-
unordered_map<std::string, Config*> namespace_map
-
unordered_map<std::string, ConfigManager_Base*> type_manager_map
-
unordered_map<std::string, std::function<bool(std::string)>> command_map
-
unordered_map<std::string, std::function<bool(std::string)>> new_map
-
unordered_map<std::string, std::function<bool(std::string)>> use_map
-
bool expand_ok
-
class ConfigGroup
- #include <config.hpp>
Information about a sub-group of settings.
Public Functions
-
inline ~ConfigGroup()
-
inline size_t GetSize() const
-
inline ConfigEntry *GetEntry(size_t id)
-
inline ConfigEntry *GetLastEntry()
-
inline void Add(ConfigEntry *new_entry)
-
inline ~ConfigGroup()
-
class ConfigLiveEntry : public ConfigEntry
- #include <config.hpp>
Special settings entry for settings created during the run (only accissibly dynamically)
Public Functions
-
inline ConfigLiveEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc)
-
inline ~ConfigLiveEntry()
-
inline virtual std::string GetLiteralValue() const
Conver the value of this setting into a literal that C++ would recognize as its current value.
-
inline virtual ConfigEntry &SetValue(const std::string &in_val, std::stringstream &warnings)
Use a string to set the value of this setting.
-
inline virtual bool IsConst() const
Identify if this setting is fixed at compile time.
-
inline ConfigLiveEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc)
-
template<class VAR_TYPE>
class tConfigConstEntry : public ConfigEntry - #include <config.hpp>
Type-specific and CONST versions of ConfigEntry class to manage fixed settings.
Public Functions
-
inline tConfigConstEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc, const VAR_TYPE &_literal_val)
-
inline ~tConfigConstEntry()
-
inline virtual std::string GetLiteralValue() const
Conver the value of this setting into a literal that C++ would recognize as its current value.
-
inline virtual ConfigEntry &SetValue(const std::string &in_val, std::stringstream &warnings)
Use a string to set the value of this setting.
-
inline virtual bool IsConst() const
Identify if this setting is fixed at compile time.
-
inline tConfigConstEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc, const VAR_TYPE &_literal_val)
-
template<class VAR_TYPE>
class tConfigEntry : public ConfigEntry - #include <config.hpp>
Type-specific versions of ConfigEntry class to manage settings.
Public Functions
-
inline tConfigEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc, VAR_TYPE &_ref)
-
inline ~tConfigEntry()
-
inline virtual std::string GetLiteralValue() const
Conver the value of this setting into a literal that C++ would recognize as its current value.
-
inline virtual ConfigEntry &SetValue(const std::string &in_val, std::stringstream&)
Use a string to set the value of this setting.
-
inline virtual bool IsConst() const
Identify if this setting is fixed at compile time.
-
inline tConfigEntry(const std::string _name, const std::string _type, const std::string _d_val, const std::string _desc, VAR_TYPE &_ref)
-
inline ~Config()
-
namespace placeholders