summaryrefslogtreecommitdiffstats
path: root/src/CRSMConfig.hpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-10-08 20:46:51 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2015-10-08 20:46:51 +0200
commitc379d65481b7bf20f330d9ff16e7f7bf47dd77f9 (patch)
tree9f479ecdee6f263afc298722ffda6af3ff171ce6 /src/CRSMConfig.hpp
parente21a8296521b888a5a6aa8633dba47359af218cf (diff)
downloadmanager-c379d65481b7bf20f330d9ff16e7f7bf47dd77f9.tar.gz
manager-c379d65481b7bf20f330d9ff16e7f7bf47dd77f9.zip
Add an optional bool parameter to CRSMConfigValue-list-specialization-
constructor to allow duplicate entries
Diffstat (limited to 'src/CRSMConfig.hpp')
-rw-r--r--src/CRSMConfig.hpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/CRSMConfig.hpp b/src/CRSMConfig.hpp
index 5c9adb9..7cdd501 100644
--- a/src/CRSMConfig.hpp
+++ b/src/CRSMConfig.hpp
@@ -56,6 +56,7 @@ using Boolean = bool;
#define ConfigValue(Value) {#Value, mkConfigValue(Value)}
+#define ConfigValueEx(Value, ...) {#Value, mkConfigValue(Value, __VA_ARGS__)}
template<>
class CRSMConfigValue<String> : public CRSMConfigValueBase {
@@ -158,9 +159,10 @@ class CRSMConfigValue<QList<Type>> : public CRSMConfigValueList {
using ListType = QList<Type>;
ListType& config;
+ const bool deduplicate;
public:
- CRSMConfigValue(ListType& config) : config(config) {}
+ CRSMConfigValue(ListType& config, bool deduplicate = true) : config(config), deduplicate(deduplicate) {}
virtual ListType& list() { return config; }
virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::List; }
@@ -168,7 +170,7 @@ public:
virtual void append(const QString &entry)
{
Type val = CRSMConfigValueBase::getValue<Type>(entry);
- if(!config.contains(val))
+ if(!deduplicate || !config.contains(val))
{
config.append(val);
}
@@ -231,10 +233,10 @@ public:
CRSMConfigValue(Type& config) : CRSMConfigValue<UndType>::CRSMConfigValue((UndType&)config) {}
};
-template<typename Type>
-CRSMConfigValue<Type>* mkConfigValue(Type& Value)
+template<typename Type, typename... Types>
+CRSMConfigValue<Type>* mkConfigValue(Type& Value, Types... values)
{
- return new CRSMConfigValue<Type>(Value);
+ return new CRSMConfigValue<Type>(Value, values...);
}
template<typename Type>