Support option_add for HashMap options

Fixes #1407
This commit is contained in:
Maxime Coste 2017-06-03 18:01:38 +01:00
parent 6906e6924b
commit 8dc9f8cc22

View File

@ -118,9 +118,9 @@ String option_to_string(const HashMap<Key, Value, domain>& opt)
}
template<typename Key, typename Value, MemoryDomain domain>
void option_from_string(StringView str, HashMap<Key, Value, domain>& opt)
bool option_add(HashMap<Key, Value, domain>& opt, StringView str)
{
opt.clear();
bool changed = false;
for (auto& elem : split(str, list_separator, '\\'))
{
Vector<String> pair_str = split(elem, '=', '\\');
@ -131,7 +131,16 @@ void option_from_string(StringView str, HashMap<Key, Value, domain>& opt)
option_from_string(pair_str[0], key);
option_from_string(pair_str[1], value);
opt.insert({ std::move(key), std::move(value) });
changed = true;
}
return changed;
}
template<typename Key, typename Value, MemoryDomain domain>
void option_from_string(StringView str, HashMap<Key, Value, domain>& opt)
{
opt.clear();
option_add(opt, str);
}
template<typename K, typename V, MemoryDomain D>