diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-12 11:45:40 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-12 11:45:40 +0000 |
commit | d6051c9953ea8778399ad72fc91c334c242d25e0 (patch) | |
tree | 34c9725486c0c7b9242c8b645aa2e4290218273a | |
parent | 81a76cc0fdf569e96697c4cea58debb74d6e5545 (diff) |
move string_is_affirmative() into libpbd
git-svn-id: svn://localhost/ardour2/branches/3.0@11936 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/axis_view.cc | 5 | ||||
-rwxr-xr-x | gtk2_ardour/window_proxy.cc | 5 | ||||
-rw-r--r-- | libs/ardour/ardour/configuration_variable.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/utils.h | 2 | ||||
-rw-r--r-- | libs/ardour/midi_clock_slave.cc | 1 | ||||
-rw-r--r-- | libs/ardour/mute_master.cc | 3 | ||||
-rw-r--r-- | libs/ardour/utils.cc | 20 | ||||
-rw-r--r-- | libs/pbd/convert.cc | 20 | ||||
-rw-r--r-- | libs/pbd/pbd/convert.h | 2 | ||||
-rw-r--r-- | libs/surfaces/mackie/pot.h | 19 | ||||
-rw-r--r-- | libs/surfaces/mackie/wscript | 1 |
11 files changed, 54 insertions, 27 deletions
diff --git a/gtk2_ardour/axis_view.cc b/gtk2_ardour/axis_view.cc index 5e0a50fdf7..43763abcc3 100644 --- a/gtk2_ardour/axis_view.cc +++ b/gtk2_ardour/axis_view.cc @@ -26,6 +26,7 @@ #include <list> #include "pbd/error.h" +#include "pbd/convert.h" #include <gtkmm2ext/utils.h> #include <gtkmm2ext/selector.h> @@ -74,14 +75,14 @@ bool AxisView::marked_for_display () const { string const v = gui_property ("visible"); - return (v == "" || string_is_affirmative (v)); + return (v == "" || PBD::string_is_affirmative (v)); } bool AxisView::set_marked_for_display (bool yn) { string const v = gui_property ("visible"); - if (v == "" || yn != string_is_affirmative (v)) { + if (v == "" || yn != PBD::string_is_affirmative (v)) { set_gui_property ("visible", yn); return true; // things changed } diff --git a/gtk2_ardour/window_proxy.cc b/gtk2_ardour/window_proxy.cc index ff525eb392..99da166af0 100755 --- a/gtk2_ardour/window_proxy.cc +++ b/gtk2_ardour/window_proxy.cc @@ -19,6 +19,9 @@ #include <gtkmm/window.h> #include "window_proxy.h" + +#include "pbd/convert.h" + #include "i18n.h" using namespace std; @@ -57,7 +60,7 @@ WindowProxyBase::WindowProxyBase (string const & name, XMLNode const * node) XMLProperty* prop; if ((prop = (*i)->property (X_("visible"))) != 0) { - _visible = string_is_affirmative (prop->value ()); + _visible = PBD::string_is_affirmative (prop->value ()); } if ((prop = (*i)->property (X_("x-off"))) != 0) { diff --git a/libs/ardour/ardour/configuration_variable.h b/libs/ardour/ardour/configuration_variable.h index da8fc1b9a1..a7fe8def48 100644 --- a/libs/ardour/ardour/configuration_variable.h +++ b/libs/ardour/ardour/configuration_variable.h @@ -24,6 +24,7 @@ #include <sstream> #include "pbd/xml++.h" +#include "pbd/convert.h" #include "ardour/types.h" #include "ardour/utils.h" @@ -153,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: diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 52b7c3053e..7eba3fa18c 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -32,8 +32,6 @@ #include <CoreFoundation/CoreFoundation.h> #endif /* __APPLE__ */ -bool string_is_affirmative (const std::string&); - #include "ardour/ardour.h" #include "ardour/data_type.h" #include "ardour/dB.h" diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc index 892bc800ff..87ea05738d 100644 --- a/libs/ardour/midi_clock_slave.cc +++ b/libs/ardour/midi_clock_slave.cc @@ -26,6 +26,7 @@ #include "pbd/error.h" #include "pbd/failed_constructor.h" #include "pbd/pthread_utils.h" +#include "pbd/convert.h" #include "midi++/port.h" diff --git a/libs/ardour/mute_master.cc b/libs/ardour/mute_master.cc index a58bb8a421..9f2ed08dab 100644 --- a/libs/ardour/mute_master.cc +++ b/libs/ardour/mute_master.cc @@ -20,6 +20,7 @@ #include "pbd/enumwriter.h" #include "pbd/xml++.h" +#include "pbd/convert.h" #include "ardour/types.h" #include "ardour/mute_master.h" @@ -144,7 +145,7 @@ MuteMaster::set_state (const XMLNode& node, int /*version*/) } if ((prop = node.property ("muted")) != 0) { - _muted_by_self = string_is_affirmative (prop->value()); + _muted_by_self = PBD::string_is_affirmative (prop->value()); } else { _muted_by_self = (_mute_point != MutePoint (0)); } diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 4933cd7e5c..beb003e713 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -627,26 +627,6 @@ bool_as_string (bool yn) return (yn ? "yes" : "no"); } -bool -string_is_affirmative (const std::string& str) -{ - /* to be used only with XML data - not intended to handle user input */ - - if (str.empty ()) { - return false; - } - - /* the use of g_strncasecmp() is solely to get around issues with - * charsets posed by trying to use C++ for the same - * comparison. switching a std::string to its lower- or upper-case - * version has several issues, but handled by default - * in the way we desire when doing it in C. - */ - - return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length())) || - (!g_strncasecmp(str.c_str(), "true", str.length())); -} - const char* native_header_format_extension (HeaderFormat hf, const DataType& type) { diff --git a/libs/pbd/convert.cc b/libs/pbd/convert.cc index 3d968d0627..07407e2fad 100644 --- a/libs/pbd/convert.cc +++ b/libs/pbd/convert.cc @@ -255,6 +255,26 @@ strings_equal_ignore_case (const string& a, const string& b) return false; } +bool +string_is_affirmative (const std::string& str) +{ + /* to be used only with XML data - not intended to handle user input */ + + if (str.empty ()) { + return false; + } + + /* the use of g_strncasecmp() is solely to get around issues with + * charsets posed by trying to use C++ for the same + * comparison. switching a std::string to its lower- or upper-case + * version has several issues, but handled by default + * in the way we desire when doing it in C. + */ + + return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length())) || + (!g_strncasecmp(str.c_str(), "true", str.length())); +} + /** A wrapper for dgettext that takes a msgid of the form Context|Text. * If Context|Text is translated, the translation is returned, otherwise * just Text is returned. Useful for getting translations of words or phrases diff --git a/libs/pbd/pbd/convert.h b/libs/pbd/pbd/convert.h index 937b5a7a9d..fec0248157 100644 --- a/libs/pbd/pbd/convert.h +++ b/libs/pbd/pbd/convert.h @@ -53,6 +53,8 @@ to_string (T t, std::ios_base & (*f)(std::ios_base&)) return oss.str(); } +bool string_is_affirmative (const std::string&); + const char * sgettext (const char *, const char *); diff --git a/libs/surfaces/mackie/pot.h b/libs/surfaces/mackie/pot.h index 5e9ca6e682..ad700be906 100644 --- a/libs/surfaces/mackie/pot.h +++ b/libs/surfaces/mackie/pot.h @@ -1,3 +1,22 @@ +/* + Copyright (C) 2006,2007 John Anderson + Copyright (C) 2012 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + #ifndef __ardour_mackie_control_protocol_pot_h__ #define __ardour_mackie_control_protocol_pot_h__ diff --git a/libs/surfaces/mackie/wscript b/libs/surfaces/mackie/wscript index b7712865d5..6cf60e842c 100644 --- a/libs/surfaces/mackie/wscript +++ b/libs/surfaces/mackie/wscript @@ -23,6 +23,7 @@ def build(bld): obj.source = ''' button.cc controls.cc + device_info.cc fader.cc gui.cc interface.cc |