Fix a few framecnt / framepos type confusions.
[ardour.git] / libs / ardour / ardour / configuration_variable.h
index fa53b6a1c4f16ed609df8bfdb75851232a0d69bf..a7fe8def48169c17c508ca714ffc135a1ea9bfb9 100644 (file)
@@ -24,6 +24,7 @@
 #include <sstream>
 
 #include "pbd/xml++.h"
+#include "pbd/convert.h"
 #include "ardour/types.h"
 #include "ardour/utils.h"
 
@@ -88,6 +89,42 @@ class ConfigVariable : public ConfigVariableBase
        T value;
 };
 
+/** Specialisation of ConfigVariable for std::string to cope with whitespace properly */
+template<>
+class ConfigVariable<std::string> : public ConfigVariableBase
+{
+  public:
+
+       ConfigVariable (std::string str) : ConfigVariableBase (str) {}
+       ConfigVariable (std::string str, std::string val) : ConfigVariableBase (str), value (val) {}
+
+       std::string get() const {
+               return value;
+       }
+
+       std::string get_as_string () const {
+               return value;
+       }
+
+       virtual bool set (std::string val) {
+               if (val == value) {
+                       miss ();
+                       return false;
+               }
+               value = val;
+               notify ();
+               return true;
+       }
+
+       virtual void set_from_string (std::string const & s) {
+               value = s;
+       }
+
+  protected:
+       virtual std::string get_for_save() { return value; }
+       std::string value;
+};
+
 template<>
 class ConfigVariable<bool> : public ConfigVariableBase
 {
@@ -117,7 +154,7 @@ class ConfigVariable<bool> : public ConfigVariableBase
        }
 
        void set_from_string (std::string const & s) {
-                value = string_is_affirmative (s);
+               value = PBD::string_is_affirmative (s);
        }
 
   protected:
@@ -141,11 +178,11 @@ class ConfigVariableWithMutation : public ConfigVariable<T>
        }
 
        void set_from_string (std::string const & s) {
-                T v;
-                std::stringstream ss;
-                ss << s;
+               T v;
+               std::stringstream ss;
+               ss << s;
                ss >> v;
-                set (v);
+               set (v);
        }
 
   protected: