2 Copyright (C) 1999-2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "pbd/compose.h"
23 #include "pbd/configuration_variable.h"
24 #include "pbd/debug.h"
26 #if defined(_MSC_VER) && (_MSC_VER < 1800)
27 // MSVC only introduced std::strtof in VS2013
28 #define strtof(s, e) strtod(s, e)
35 ConfigVariableBase::add_to_node (XMLNode& node)
37 const std::string v = get_as_string ();
38 DEBUG_TRACE (DEBUG::Configuration, string_compose ("Config variable %1 stored as [%2]\n", _name, v));
39 XMLNode* child = new XMLNode ("Option");
40 child->set_property ("name", _name);
41 child->set_property ("value", v);
42 node.add_child_nocopy (*child);
46 ConfigVariableBase::set_from_node (XMLNode const & node)
48 if (node.name() == "Config" || node.name() == "Canvas" || node.name() == "UI") {
53 XMLNodeConstIterator niter;
54 XMLNode const * child;
57 nlist = node.children();
59 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
63 if (child->name() == "Option") {
64 if (child->get_property ("name", str) && str == _name) {
65 if (child->get_property ("value", str)) {
66 set_from_string (str);
73 } else if (node.name() == "Options") {
78 XMLNodeConstIterator oiter;
82 olist = node.children();
84 for (oiter = olist.begin(); oiter != olist.end(); ++oiter) {
88 if (option->name() == _name) {
89 if (option->get_property ("val", str)) {
90 set_from_string (str);
101 ConfigVariableBase::notify ()
103 // placeholder for any debugging desired when a config variable is modified
107 ConfigVariableBase::miss ()
109 // placeholder for any debugging desired when a config variable
110 // is set but to the same value as it already has