From b01190a0b9cd0077a946bc016966e0621551eecf Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Wed, 17 Feb 2016 15:27:22 +0100 Subject: Add ConfigValue for Float (double) --- ConfigBase.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ConfigBase.hpp') diff --git a/ConfigBase.hpp b/ConfigBase.hpp index ade454a..a31e66b 100644 --- a/ConfigBase.hpp +++ b/ConfigBase.hpp @@ -51,6 +51,7 @@ public: using String = QString; using Integer = int; +using Float = double; using Port = ushort; using Boolean = bool; #define List(Type) QList @@ -103,6 +104,22 @@ public: virtual ConfigValueType::Type type() { return ConfigValueType::Type::Integer; } }; +template<> +class ConfigValue : public ConfigValueBase { + Float& config; +public: + ConfigValue(Float& config) : config(config) { } + + virtual void setValue(const QString& value) + { + bool ok = true; + Float temp = value.toDouble(&ok); + if(!ok) throw ConfigException("\"" + value.toStdString() + "\" could not be parsed as a Float"); + config = temp; + } + virtual QString value() { return QString::number(config, 'g', 10); } +}; + template<> class ConfigValue : public ConfigValueBase { Boolean& config; -- cgit v1.2.3-54-g00ecf