diff options
Diffstat (limited to 'src/libutil/config.hh')
-rw-r--r-- | src/libutil/config.hh | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libutil/config.hh b/src/libutil/config.hh index df5c2226f..79ec0f9cf 100644 --- a/src/libutil/config.hh +++ b/src/libutil/config.hh @@ -194,8 +194,6 @@ public: bool overridden = false; - void setDefault(const std::string & str); - protected: AbstractSetting( @@ -234,16 +232,19 @@ protected: T value; const T defaultValue; + const bool documentDefault; public: BaseSetting(const T & def, + const bool documentDefault, const std::string & name, const std::string & description, const std::set<std::string> & aliases = {}) : AbstractSetting(name, description, aliases) , value(def) , defaultValue(def) + , documentDefault(documentDefault) { } operator const T &() const { return value; } @@ -253,6 +254,7 @@ public: bool operator !=(const T & v2) const { return value != v2; } void operator =(const T & v) { assign(v); } virtual void assign(const T & v) { value = v; } + void setDefault(const T & v) { if (!overridden) value = v; } void set(const std::string & str, bool append = false) override; @@ -289,8 +291,9 @@ public: const T & def, const std::string & name, const std::string & description, - const std::set<std::string> & aliases = {}) - : BaseSetting<T>(def, name, description, aliases) + const std::set<std::string> & aliases = {}, + const bool documentDefault = true) + : BaseSetting<T>(def, documentDefault, name, description, aliases) { options->addSetting(this); } @@ -312,7 +315,7 @@ public: const std::string & name, const std::string & description, const std::set<std::string> & aliases = {}) - : BaseSetting<Path>(def, name, description, aliases) + : BaseSetting<Path>(def, true, name, description, aliases) , allowEmpty(allowEmpty) { options->addSetting(this); |