aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/config.hh
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 04:47:18 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 04:47:18 +0100
commit4d9dde15efbc05af471acb3efc5b04c087ceeef0 (patch)
treee01d0cc3902973a2900973d999b3c076a2d78cc6 /src/libutil/config.hh
parentab40b2c5d0f90d6a119bf4b368f933f5331b0c15 (diff)
Merge pull request #9191 from tfc/libutil-implementation
libutil: Small improvements (cherry picked from commit edc07588ecd5053da57c2ab6c2543abf49730ce3) Change-Id: I01a481d872d859b372a4bade9bebd3dab2fb4efb
Diffstat (limited to 'src/libutil/config.hh')
-rw-r--r--src/libutil/config.hh37
1 files changed, 8 insertions, 29 deletions
diff --git a/src/libutil/config.hh b/src/libutil/config.hh
index cc8532587..3e6762e54 100644
--- a/src/libutil/config.hh
+++ b/src/libutil/config.hh
@@ -52,9 +52,7 @@ class AbstractConfig
protected:
StringMap unknownSettings;
- AbstractConfig(const StringMap & initials = {})
- : unknownSettings(initials)
- { }
+ AbstractConfig(StringMap initials = {});
public:
@@ -150,9 +148,6 @@ public:
{
bool isAlias;
AbstractSetting * setting;
- SettingData(bool isAlias, AbstractSetting * setting)
- : isAlias(isAlias), setting(setting)
- { }
};
typedef std::map<std::string, SettingData> Settings;
@@ -163,9 +158,7 @@ private:
public:
- Config(const StringMap & initials = {})
- : AbstractConfig(initials)
- { }
+ Config(StringMap initials = {});
bool set(const std::string & name, const std::string & value) override;
@@ -206,12 +199,7 @@ protected:
const std::set<std::string> & aliases,
std::optional<ExperimentalFeature> experimentalFeature = std::nullopt);
- virtual ~AbstractSetting()
- {
- // Check against a gcc miscompilation causing our constructor
- // not to run (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80431).
- assert(created == 123);
- }
+ virtual ~AbstractSetting();
virtual void set(const std::string & value, bool append = false) = 0;
@@ -229,7 +217,7 @@ protected:
virtual void convertToArg(Args & args, const std::string & category);
- bool isOverridden() const { return overridden; }
+ bool isOverridden() const;
};
/**
@@ -324,8 +312,7 @@ public:
template<typename T>
std::ostream & operator <<(std::ostream & str, const BaseSetting<T> & opt)
{
- str << (const T &) opt;
- return str;
+ return str << static_cast<const T &>(opt);
}
template<typename T>
@@ -365,11 +352,7 @@ public:
const Path & def,
const std::string & name,
const std::string & description,
- const std::set<std::string> & aliases = {})
- : BaseSetting<Path>(def, true, name, description, aliases)
- {
- options->addSetting(this);
- }
+ const std::set<std::string> & aliases = {});
Path parse(const std::string & str) const override;
@@ -391,15 +374,11 @@ public:
const std::optional<Path> & def,
const std::string & name,
const std::string & description,
- const std::set<std::string> & aliases = {})
- : BaseSetting<std::optional<Path>>(def, true, name, description, aliases)
- {
- options->addSetting(this);
- }
+ const std::set<std::string> & aliases = {});
std::optional<Path> parse(const std::string & str) const override;
- void operator =(const std::optional<Path> & v) { this->assign(v); }
+ void operator =(const std::optional<Path> & v);
};
struct GlobalConfig : public AbstractConfig