From 8dc9f8cc22a6667b9d43c46086f7fc2c447037b7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 3 Jun 2017 18:01:38 +0100 Subject: [PATCH] Support option_add for HashMap options Fixes #1407 --- src/option_types.hh | 13 +++++++++++-- 1 file 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& opt) } template -void option_from_string(StringView str, HashMap& opt) +bool option_add(HashMap& opt, StringView str) { - opt.clear(); + bool changed = false; for (auto& elem : split(str, list_separator, '\\')) { Vector pair_str = split(elem, '=', '\\'); @@ -131,7 +131,16 @@ void option_from_string(StringView str, HashMap& 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 +void option_from_string(StringView str, HashMap& opt) +{ + opt.clear(); + option_add(opt, str); } template