aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/config.hh
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-09-09 11:35:33 +0200
committerregnat <rg@regnat.ovh>2020-09-16 13:53:08 +0200
commit3c525d15903ea98e5401ff57061295b8c625cc45 (patch)
tree08b4a56d9b02b1d18b296e1b86a4108130e5d3da /src/libutil/config.hh
parent3b57181f8ed94cfa149ad4319ba96d41c5fbc30e (diff)
Complete the `toJSON` instance for `Setting<T>`
Don't let it just contain the value, but also the other fields of the setting (description, aliases, etc..)
Diffstat (limited to 'src/libutil/config.hh')
-rw-r--r--src/libutil/config.hh11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libutil/config.hh b/src/libutil/config.hh
index 2b4265806..be23076b0 100644
--- a/src/libutil/config.hh
+++ b/src/libutil/config.hh
@@ -206,7 +206,9 @@ protected:
virtual std::string to_string() const = 0;
- virtual nlohmann::json toJSON();
+ nlohmann::json toJSON();
+
+ virtual std::map<std::string, nlohmann::json> toJSONObject();
virtual void convertToArg(Args & args, const std::string & category);
@@ -251,7 +253,12 @@ public:
void convertToArg(Args & args, const std::string & category) override;
- nlohmann::json toJSON() override;
+ std::map<std::string, nlohmann::json> toJSONObject() override
+ {
+ auto obj = AbstractSetting::toJSONObject();
+ obj.emplace("value", value);
+ return obj;
+ }
};
template<typename T>