#include "ardour/search_paths.h"
#include "ardour/revision.h"
#include "ardour/utils.h"
+#include "ardour/types_convert.h"
#include "gtkmm2ext/rgb_macros.h"
#include "gtkmm2ext/gtk_ui.h"
#include "ardour/tempo.h"
#include "ardour/ticker.h"
#include "ardour/track.h"
+#include "ardour/types_convert.h"
#include "ardour/user_bundle.h"
#include "ardour/utils.h"
#include "ardour/vca_manager.h"
#include "pbd/pathexpand.h"
#include "ardour/types.h"
+#include "ardour/types_convert.h"
#include "ardour/filesystem_paths.h"
#include "ardour/session_configuration.h"
#include "ardour/utils.h"
// placeholder for any debugging desired when a config variable
// 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);
-}
#ifndef __libpbd_configuration_variable_h__
#define __libpbd_configuration_variable_h__
-#include <iostream>
-#include <sstream>
#include <string>
#include "pbd/xml++.h"
-#include "pbd/convert.h"
+#include "pbd/string_convert.h"
#include "pbd/libpbd_visibility.h"
namespace PBD {
}
std::string get_as_string () const {
- std::ostringstream ss;
- ss << value;
- return ss.str ();
+ return to_string<T>(value);
}
virtual bool set (T val) {
}
virtual void set_from_string (std::string const & s) {
- std::stringstream ss;
- ss << s;
- ss >> value;
+ value = string_to<T>(s);
}
protected:
T value;
};
-/** Specialisation of ConfigVariable to deal with float (-inf etc) */
-template<> LIBPBD_API 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
std::string value;
};
-template<>
-class /*LIBPBD_API*/ ConfigVariable<bool> : public ConfigVariableBase
-{
- public:
-
- ConfigVariable (std::string str) : ConfigVariableBase (str), value (false) {}
- ConfigVariable (std::string str, bool val) : ConfigVariableBase (str), value (val) {}
-
- bool get() const {
- return value;
- }
-
- std::string get_as_string () const {
- std::ostringstream ss;
- ss << value;
- return ss.str ();
- }
-
- virtual bool set (bool val) {
- if (val == value) {
- miss ();
- return false;
- }
- value = val;
- notify ();
- return true;
- }
-
- void set_from_string (std::string const & s) {
- value = PBD::string_is_affirmative (s);
- }
-
- protected:
- virtual bool get_for_save() { return value; }
- bool value;
-};
-
template<class T>
class /*LIBPBD_API*/ ConfigVariableWithMutation : public ConfigVariable<T>
{
}
void set_from_string (std::string const & s) {
- T v;
- std::stringstream ss;
- ss << s;
- ss >> v;
- set (v);
+ set (string_to<T>(s));
}
protected: