diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-04-13 15:55:38 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-04-13 16:03:31 +0200 |
commit | 2040240e238a41c2eb799bf4dbf394fec297ac16 (patch) | |
tree | 73661117f25db0f21cf7497ad43c6cb2766a7a05 /src/libutil/types.hh | |
parent | 568a099c889e7ccc5a49b15575078e99acf8bc2f (diff) |
Add a Config class to simplify adding 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 overriden
}
};
Currently, this is used by Store and its subclasses for store
parameters. You now get a warning if you specify a non-existant store
parameter in a store URI.
Diffstat (limited to 'src/libutil/types.hh')
-rw-r--r-- | src/libutil/types.hh | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libutil/types.hh b/src/libutil/types.hh index 97d79af9b..1429c2385 100644 --- a/src/libutil/types.hh +++ b/src/libutil/types.hh @@ -7,6 +7,7 @@ #include <list> #include <set> #include <memory> +#include <map> #include <boost/format.hpp> @@ -141,6 +142,7 @@ private: typedef list<string> Strings; typedef set<string> StringSet; +typedef std::map<std::string, std::string> StringMap; /* Paths are just strings. */ |