forked from lix-project/lix
Don't include nlohmann/json.hpp in config.hh
Instead make a separate header with the template implementation of `BaseSetting<T>::toJSONObj` that can be included where needed
This commit is contained in:
parent
93c0e14a30
commit
e0817cbcdc
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
|
#include "abstractsettingtojson.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
15
src/libutil/abstractsettingtojson.hh
Normal file
15
src/libutil/abstractsettingtojson.hh
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include "config.hh"
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
template<typename T>
|
||||||
|
std::map<std::string, nlohmann::json> BaseSetting<T>::toJSONObject()
|
||||||
|
{
|
||||||
|
auto obj = AbstractSetting::toJSONObject();
|
||||||
|
obj.emplace("value", value);
|
||||||
|
obj.emplace("defaultValue", defaultValue);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "args.hh"
|
#include "args.hh"
|
||||||
|
#include "abstractsettingtojson.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -255,13 +255,7 @@ public:
|
||||||
|
|
||||||
void convertToArg(Args & args, const std::string & category) override;
|
void convertToArg(Args & args, const std::string & category) override;
|
||||||
|
|
||||||
std::map<std::string, nlohmann::json> toJSONObject() override
|
std::map<std::string, nlohmann::json> toJSONObject() override;
|
||||||
{
|
|
||||||
auto obj = AbstractSetting::toJSONObject();
|
|
||||||
obj.emplace("value", value);
|
|
||||||
obj.emplace("defaultValue", defaultValue);
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in a new issue