summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/pbd/configuration_variable.cc7
-rw-r--r--libs/pbd/pbd/configuration_variable.h4
2 files changed, 11 insertions, 0 deletions
diff --git a/libs/pbd/configuration_variable.cc b/libs/pbd/configuration_variable.cc
index 578114e92a..cde1d15bf1 100644
--- a/libs/pbd/configuration_variable.cc
+++ b/libs/pbd/configuration_variable.cc
@@ -107,3 +107,10 @@ ConfigVariableBase::miss ()
// is set but to the same value as it already has
}
+/* Specialisation of ConfigVariable to deal with float (-inf etc)
+ * http://stackoverflow.com/questions/23374095/should-a-stringstream-parse-infinity-as-an-infinite-value
+ */
+template<> void
+ConfigVariable<float>::set_from_string (std::string const & s) {
+ value = std::strtof (s.c_str(), NULL);
+}
diff --git a/libs/pbd/pbd/configuration_variable.h b/libs/pbd/pbd/configuration_variable.h
index 6bdf0f7868..7af7974229 100644
--- a/libs/pbd/pbd/configuration_variable.h
+++ b/libs/pbd/pbd/configuration_variable.h
@@ -89,6 +89,10 @@ class /*LIBPBD_API*/ ConfigVariable : public ConfigVariableBase
T value;
};
+/** Specialisation of ConfigVariable to deal with float (-inf etc) */
+template<> void
+ConfigVariable<float>::set_from_string (std::string const & s);
+
/** Specialisation of ConfigVariable for std::string to cope with whitespace properly */
template<>
class /*LIBPBD_API*/ ConfigVariable<std::string> : public ConfigVariableBase