aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-09-09 11:36:48 +0200
committerregnat <rg@regnat.ovh>2020-09-16 13:53:08 +0200
commit35042c96230e922b88c8a5cad6a7f5f06792860f (patch)
tree91ab2fcb789f7d7f376b014479b88b44a82a5dab
parent3c525d15903ea98e5401ff57061295b8c625cc45 (diff)
Add a default value for the settings
The default value is initialized when creating the setting and unchanged after that
-rw-r--r--src/libutil/config.hh3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libutil/config.hh b/src/libutil/config.hh
index be23076b0..42fc856e0 100644
--- a/src/libutil/config.hh
+++ b/src/libutil/config.hh
@@ -222,6 +222,7 @@ class BaseSetting : public AbstractSetting
protected:
T value;
+ const T defaultValue;
public:
@@ -231,6 +232,7 @@ public:
const std::set<std::string> & aliases = {})
: AbstractSetting(name, description, aliases)
, value(def)
+ , defaultValue(def)
{ }
operator const T &() const { return value; }
@@ -257,6 +259,7 @@ public:
{
auto obj = AbstractSetting::toJSONObject();
obj.emplace("value", value);
+ obj.emplace("defaultValue", defaultValue);
return obj;
}
};