summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-09-24 18:52:22 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2015-09-24 18:52:22 +0200
commitc033dd56d7765cd72c7287dc719941a864cb2c69 (patch)
treec15b6ff40295caa2b6ef4984be0e93d3e45d8552 /src
parent556692d4ed56767c25c0474984fb0ac1e7766d2c (diff)
downloadmanager-c033dd56d7765cd72c7287dc719941a864cb2c69.tar.gz
manager-c033dd56d7765cd72c7287dc719941a864cb2c69.zip
Add CRSMConfigValueBase::getValue and
CRSMConfigValueBase::getStringValue and use them where appropriate
Diffstat (limited to 'src')
-rw-r--r--src/CRSMConfig.hpp43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/CRSMConfig.hpp b/src/CRSMConfig.hpp
index c6c072d..e38199b 100644
--- a/src/CRSMConfig.hpp
+++ b/src/CRSMConfig.hpp
@@ -26,6 +26,14 @@ public:
virtual void setValue(const QString&) { }
virtual QString value() { return ""; }
virtual CRSMConfigValueType::Type type() { return CRSMConfigValueType::Type::None; }
+
+
+
+ template<typename Type>
+ static Type getValue(const QString& value);
+
+ template<typename Type>
+ static QString getStringValue(Type val);
};
template<typename Type>
@@ -125,9 +133,7 @@ public:
virtual void append(const QString &entry)
{
- Type val;
- CRSMConfigValue<Type> configValue(val);
- configValue.setValue(entry);
+ Type val = CRSMConfigValueBase::getValue<Type>(entry);
if(!config.contains(val))
{
config.append(val);
@@ -140,8 +146,7 @@ public:
foreach(Type val, config)
{
- CRSMConfigValue<Type> value(val);
- ret.append(value.value());
+ ret.append(CRSMConfigValueBase::getStringValue(val));
}
return ret;
@@ -162,13 +167,7 @@ public:
virtual void setKeyValue(const QString& key, const QString& value)
{
- KeyType keyVal;
- CRSMConfigValue<KeyType> keyConfigValue(keyVal);
- keyConfigValue.setValue(key);
- ValueType valueVal;
- CRSMConfigValue<ValueType> valueConfigValue(valueVal);
- valueConfigValue.setValue(value);
- config[keyVal] = valueVal;
+ config[CRSMConfigValueBase::getValue<KeyType>(key)] = CRSMConfigValueBase::getValue<ValueType>(value);
}
virtual QMap<QString, QString> getValues()
@@ -177,9 +176,7 @@ public:
foreach(KeyType key, config.keys())
{
- CRSMConfigValue<KeyType> keyValue(key);
- CRSMConfigValue<ValueType> valValue(config[key]);
- ret[keyValue.value()] = valValue.value();
+ ret[CRSMConfigValueBase::getStringValue(key)] = CRSMConfigValueBase::getStringValue(config[key]);
}
return ret;
@@ -192,6 +189,22 @@ CRSMConfigValue<Type>* mkConfigValue(Type& Value)
return new CRSMConfigValue<Type>(Value);
}
+template<typename Type>
+Type CRSMConfigValueBase::getValue(const QString& value)
+{
+ Type ret;
+ CRSMConfigValue<Type> val(ret);
+ val.setValue(value);
+ return ret;
+}
+
+template<typename Type>
+QString CRSMConfigValueBase::getStringValue(Type value)
+{
+ CRSMConfigValue<Type> val(value);
+ return val.value();
+}
+
class CRSMConfig
{
public: