summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-06-03 18:01:38 +0100
committerMaxime Coste <mawww@kakoune.org>2017-06-03 18:01:38 +0100
commit8dc9f8cc22a6667b9d43c46086f7fc2c447037b7 (patch)
tree7df716f28242d3ff71dc9da4845afff2d76e0eaa
parent6906e6924bf97b5974a14db3b49cfa21dbc64c1a (diff)
Support option_add for HashMap options
Fixes #1407
-rw-r--r--src/option_types.hh13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/option_types.hh b/src/option_types.hh
index 56b32e99..1a2fda97 100644
--- a/src/option_types.hh
+++ b/src/option_types.hh
@@ -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>