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

Add convenience functions for config_value_map

parent cce7fec0
......@@ -549,11 +549,19 @@ void put_impl(dictionary<config_value::dictionary>& dict, string_view key,
/// @param value New value for given `key`.
template <class T>
void put(dictionary<config_value::dictionary>& dict, string_view key,
T&& value) {
T&& value) {
config_value tmp{std::forward<T>(value)};
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