Commit 5b4d38ad authored by Dominik Charousset's avatar Dominik Charousset

Add convenience functions for config_value_map

parent cce7fec0
......@@ -554,6 +554,14 @@ void put(dictionary<config_value::dictionary>& dict, string_view key,
put_impl(dict, key, tmp);
}
/// Inserts a new list named `name` into the dictionary `xs` and returns
/// a reference to it. Overrides existing entries with the same name.
config_value::list& put_list(config_value::dictionary& xs, std::string name);
/// Inserts a new list named `name` into the dictionary `xs` and returns
/// a reference to it. Overrides existing entries with the same name.
config_value::dictionary& put_dictionary(config_value::dictionary& xs,
std::string name);
/// @relates config_value
bool operator<(const config_value& x, const config_value& y);
......
......@@ -190,5 +190,16 @@ void put_impl(dictionary<config_value::dictionary>& dict, string_view key,
put_impl(dict[category], path, value);
}
config_value::list& put_list(config_value::dictionary& xs, std::string name) {
auto i = xs.insert_or_assign(std::move(name), config_value::list{});
return get<config_value::list>(i.first->second);
}
config_value::dictionary& put_dictionary(config_value::dictionary& xs,
std::string name) {
auto i = xs.insert_or_assign(std::move(name), config_value::dictionary{});
return get<config_value::dictionary>(i.first->second);
}
} // namespace caf
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment