diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2016-02-17 15:27:22 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2016-02-17 15:27:22 +0100 |
| commit | b01190a0b9cd0077a946bc016966e0621551eecf (patch) | |
| tree | ce5c1dfbda8da3e234de256b9a73e91b7fe18b9e /ConfigBase.hpp | |
| parent | ccaf4c0110067442ff8b141a73604ab2c5d5e715 (diff) | |
| download | qt-config-b01190a0b9cd0077a946bc016966e0621551eecf.tar.gz qt-config-b01190a0b9cd0077a946bc016966e0621551eecf.zip | |
Add ConfigValue for Float (double)
Diffstat (limited to 'ConfigBase.hpp')
| -rw-r--r-- | ConfigBase.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
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<Type> @@ -104,6 +105,22 @@ public: }; template<> +class ConfigValue<Float> : 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<Boolean> : public ConfigValueBase { Boolean& config; |
