#include <config.hh>
Classes | |
struct | SettingData |
Public Types | |
using | Settings = std::map<std::string, SettingData> |
Public Member Functions | |
Config (StringMap initials={}) | |
bool | set (const std::string &name, const std::string &value) override |
void | addSetting (AbstractSetting *setting) |
void | getSettings (std::map< std::string, SettingInfo > &res, bool overriddenOnly=false) override |
void | resetOverridden () override |
nlohmann::json | toJSON () override |
std::string | toKeyValue () override |
void | convertToArgs (Args &args, const std::string &category) override |
![]() | |
void | applyConfig (const std::string &contents, const std::string &path="<unknown>") |
void | warnUnknownSettings () |
void | reapplyUnknownSettings () |
Friends | |
class | AbstractSetting |
Additional Inherited Members | |
![]() | |
AbstractConfig (StringMap initials={}) | |
![]() | |
StringMap | unknownSettings |
A class to simplify providing configuration settings. The typical use is to inherit Config and add Setting<T> members:
class MyClass : private Config { Setting<int> foo{this, 123, "foo", "the number of foos to use"}; Setting<std::string> bar{this, "blabla", "bar", "the name of the bar"};
MyClass() : Config(readConfigFile("/etc/my-app.conf")) { std::cout << foo << "\n"; // will print 123 unless overridden } };
|
overridevirtual |
Converts settings to Args
to be used on the command line interface
Implements nix::AbstractConfig.
|
overridevirtual |
Adds the currently known settings to the given result map res
.
res
Implements nix::AbstractConfig.
|
overridevirtual |
Resets the overridden
flag of all Settings
Implements nix::AbstractConfig.
|
overridevirtual |
Sets the value referenced by name
to value
. Returns true if the setting is known, false otherwise.
Implements nix::AbstractConfig.
|
overridevirtual |
Outputs all settings to JSON
Implements nix::AbstractConfig.
|
overridevirtual |
Outputs all settings in a key-value pair format suitable to be used as nix.conf
Implements nix::AbstractConfig.
|
friend |
A class to simplify providing configuration settings. The typical use is to inherit Config and add Setting<T> members:
class MyClass : private Config { Setting<int> foo{this, 123, "foo", "the number of foos to use"}; Setting<std::string> bar{this, "blabla", "bar", "the name of the bar"};
MyClass() : Config(readConfigFile("/etc/my-app.conf")) { std::cout << foo << "\n"; // will print 123 unless overridden } };