From 7f9cab8c2883611979e52f2e7b5a4fca09f6b93b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 17 Nov 2010 12:25:44 +0000 Subject: [PATCH] Add std::string specialization for ConfigVariableWithMutation which handles spaces correctly. Fixes #3541. git-svn-id: svn://localhost/ardour2/branches/3.0@8052 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/configuration_variable.h | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libs/ardour/ardour/configuration_variable.h b/libs/ardour/ardour/configuration_variable.h index ec954e8d9c..fa53b6a1c4 100644 --- a/libs/ardour/ardour/configuration_variable.h +++ b/libs/ardour/ardour/configuration_variable.h @@ -154,6 +154,31 @@ class ConfigVariableWithMutation : public ConfigVariable T (*mutator)(T); }; +template<> +class ConfigVariableWithMutation : public ConfigVariable +{ + public: + ConfigVariableWithMutation (std::string name, std::string val, std::string (*m)(std::string)) + : ConfigVariable (name, val), mutator (m) {} + + bool set (std::string val) { + if (unmutated_value != val) { + unmutated_value = val; + return ConfigVariable::set (mutator (val)); + } + return false; + } + + void set_from_string (std::string const & s) { + set (s); + } + + protected: + virtual std::string get_for_save() { return unmutated_value; } + std::string unmutated_value; + std::string (*mutator)(std::string); +}; + } #endif /* __ardour_configuration_variable_h__ */