X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fconfiguration_variable.cc;h=4774f4eebd2ee1f9294489daaf84b6699d083f67;hb=3c7dea43af9d9e5b2563aee81ac5253fb2ee7858;hp=cde1d15bf186bd348ef9fbb965197bc916ceea33;hpb=7b1f97bffa8c3a43618e35d5a50e6c7cf1558ff9;p=ardour.git diff --git a/libs/pbd/configuration_variable.cc b/libs/pbd/configuration_variable.cc index cde1d15bf1..4774f4eebd 100644 --- a/libs/pbd/configuration_variable.cc +++ b/libs/pbd/configuration_variable.cc @@ -23,6 +23,11 @@ #include "pbd/configuration_variable.h" #include "pbd/debug.h" +#if defined(_MSC_VER) && (_MSC_VER < 1800) +// MSVC only introduced std::strtof in VS2013 +#define strtof(s, e) strtod(s, e) +#endif + using namespace std; using namespace PBD; @@ -32,8 +37,8 @@ ConfigVariableBase::add_to_node (XMLNode& node) const std::string v = get_as_string (); DEBUG_TRACE (DEBUG::Configuration, string_compose ("Config variable %1 stored as [%2]\n", _name, v)); XMLNode* child = new XMLNode ("Option"); - child->add_property ("name", _name); - child->add_property ("value", v); + child->set_property ("name", _name); + child->set_property ("value", v); node.add_child_nocopy (*child); } @@ -44,10 +49,10 @@ ConfigVariableBase::set_from_node (XMLNode const & node) /* ardour.rc */ - const XMLProperty* prop; XMLNodeList nlist; XMLNodeConstIterator niter; XMLNode const * child; + std::string str; nlist = node.children(); @@ -56,13 +61,11 @@ ConfigVariableBase::set_from_node (XMLNode const & node) child = *niter; if (child->name() == "Option") { - if ((prop = child->property ("name")) != 0) { - if (prop->value() == _name) { - if ((prop = child->property ("value")) != 0) { - set_from_string (prop->value()); - return true; - } + if (child->get_property ("name", str) && str == _name) { + if (child->get_property ("value", str)) { + set_from_string (str); } + return true; } } } @@ -74,7 +77,7 @@ ConfigVariableBase::set_from_node (XMLNode const & node) XMLNodeList olist; XMLNodeConstIterator oiter; XMLNode* option; - const XMLProperty* opt_prop; + std::string str; olist = node.children(); @@ -83,8 +86,8 @@ ConfigVariableBase::set_from_node (XMLNode const & node) option = *oiter; if (option->name() == _name) { - if ((opt_prop = option->property ("val")) != 0) { - set_from_string (opt_prop->value()); + if (option->get_property ("val", str)) { + set_from_string (str); return true; } } @@ -106,11 +109,3 @@ ConfigVariableBase::miss () // 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::set_from_string (std::string const & s) { - value = std::strtof (s.c_str(), NULL); -}