From 139de5aa8b0a278f23056d8bcd9ad0fffd34db68 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 15 Oct 2015 15:48:45 +0200 Subject: Add setValue() and value() to list-specialization of ConfigValue for inline saving --- src/ConfigBase.hpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/ConfigBase.hpp') diff --git a/src/ConfigBase.hpp b/src/ConfigBase.hpp index 72625e5..ae3c3de 100644 --- a/src/ConfigBase.hpp +++ b/src/ConfigBase.hpp @@ -149,9 +149,10 @@ class ConfigValue> : public ConfigValueList { ListType& config; const bool deduplicate; + const QChar splitChar; public: - ConfigValue(ListType& config, bool deduplicate = true) : config(config), deduplicate(deduplicate) {} + ConfigValue(ListType& config, bool deduplicate = true, const QChar splitChar = ';') : config(config), deduplicate(deduplicate), splitChar(splitChar) {} virtual ListType& list() { return config; } virtual ConfigValueType::Type type() { return ConfigValueType::Type::List; } @@ -178,6 +179,26 @@ public: return ret; } + + void setValue(const QString& value) + { + config.clear(); + QStringList parts = Util::splitEscaped(value, splitChar); + foreach(const QString& part, parts) + { + config.append(ConfigValueBase::getValue(part)); + } + } + + QString value() + { + QStringList parts; + foreach(const Type& part, config) + { + parts.append(ConfigValueBase::getStringValue(part)); + } + return Util::joinEscape(parts, splitChar); + } }; template -- cgit v1.2.3-54-g00ecf