Add "add" method to Parameter

This commit is contained in:
badaix 2021-06-10 08:51:18 +02:00
parent de9e3496df
commit 7ad308cd01

View file

@ -190,6 +190,8 @@ public:
bool has(const std::string& key) const; bool has(const std::string& key) const;
bool has(size_t idx) const; bool has(size_t idx) const;
void add(const std::string& key, const Json& value);
template <typename T> template <typename T>
T get(const std::string& key) const T get(const std::string& key) const
{ {
@ -691,11 +693,16 @@ inline Parameter::Parameter(const std::string& key1, const Json& value1, const s
{ {
param_map[key1] = value1; param_map[key1] = value1;
if (!key2.empty()) if (!key2.empty())
param_map[key2] = value2; add(key2, value2);
if (!key3.empty()) if (!key3.empty())
param_map[key3] = value3; add(key3, value3);
if (!key4.empty()) if (!key4.empty())
param_map[key4] = value4; add(key4, value4);
}
inline void Parameter::add(const std::string& key, const Json& value)
{
param_map[key] = value;
} }
inline void Parameter::parse_json(const Json& json) inline void Parameter::parse_json(const Json& json)