replace all instances of prop->value() == "yes" with string_is_affirmative (prop...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 2 Oct 2009 15:31:39 +0000 (15:31 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 2 Oct 2009 15:31:39 +0000 (15:31 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5720 d708f5d6-7413-0410-9779-e7cbd77b26cf

13 files changed:
libs/ardour/ardour/utils.h
libs/ardour/audioregion.cc
libs/ardour/control_protocol_manager.cc
libs/ardour/crossfade.cc
libs/ardour/io.cc
libs/ardour/location.cc
libs/ardour/panner.cc
libs/ardour/playlist.cc
libs/ardour/redirect.cc
libs/ardour/route.cc
libs/ardour/session_state.cc
libs/ardour/tempo.cc
libs/ardour/utils.cc

index 9e0067c65243619a283814e5a10d1bcc8e320fd3..eccfc33d250a2701543c17ae3e510284ccf5e437 100644 (file)
@@ -37,6 +37,7 @@ Glib::ustring legalize_for_path (Glib::ustring);
 void elapsed_time_to_str (char *buf, uint32_t seconds);
 std::ostream& operator<< (std::ostream& o, const ARDOUR::BBT_Time& bbt);
 XMLNode* find_named_node (const XMLNode& node, std::string name);
+bool string_is_affirmative (const std::string& str);
 
 static inline float f_max(float x, float a) {
        x -= a;
index 87d79c6c2c2e7811e3b2a43c21da07c7e4052c66..6163897b2015c24ce9434fd23706efc5ff676649 100644 (file)
@@ -847,7 +847,7 @@ AudioRegion::set_live_state (const XMLNode& node, Change& what_changed, bool sen
                        }
 
                        if ((prop = child->property ("active")) != 0) {
-                               if (prop->value() == "yes") {
+                               if (string_is_affirmative (prop->value())) {
                                        set_fade_in_active (true);
                                } else {
                                        set_fade_in_active (true);
@@ -868,7 +868,7 @@ AudioRegion::set_live_state (const XMLNode& node, Change& what_changed, bool sen
                        }
 
                        if ((prop = child->property ("active")) != 0) {
-                               if (prop->value() == "yes") {
+                               if (string_is_affirmative (prop->value())) {
                                        set_fade_out_active (true);
                                } else {
                                        set_fade_out_active (false);
index 00c05b280039fef867b74767bd9f1700f65ebee1..483243bb6f8131b311ceb5e14edba002e25c5e17 100644 (file)
@@ -309,7 +309,7 @@ ControlProtocolManager::set_state (const XMLNode& node)
 
                        prop = (*citer)->property (X_("active"));
 
-                       if (prop && prop->value() == X_("yes")) {
+                       if (prop && string_is_affirmative (prop->value())) {
                                if ((prop = (*citer)->property (X_("name"))) != 0) {
                                        ControlProtocolInfo* cpi = cpi_by_name (prop->value());
                                        if (cpi) {
index d9c98e0e2588ebe311db25de6a19f826e42d8a2a..ee8e761f8f637ddc07cd1b5b01e2026d192dc3f3 100644 (file)
@@ -728,7 +728,7 @@ Crossfade::set_state (const XMLNode& node)
        }
 
        if ((prop = node.property ("active")) != 0) {
-               bool x = (prop->value() == "yes");
+               bool x = string_is_affirmative (prop->value());
                if (x != _active) {
                        _active = x;
                        what_changed = Change (what_changed | ActiveChanged);
@@ -738,13 +738,13 @@ Crossfade::set_state (const XMLNode& node)
        }
 
        if ((prop = node.property ("follow-overlap")) != 0) {
-               _follow_overlap = (prop->value() == "yes");
+               _follow_overlap = string_is_affirmative (prop->value());
        } else {
                _follow_overlap = false;
        }
 
        if ((prop = node.property ("fixed")) != 0) {
-               _fixed = (prop->value() == "yes");
+               _fixed = string_is_affirmative (prop->value());
        } else {
                _fixed = false;
        }
index ef9c6f62152271c9fada1c979fa780a77b5a18cc..596d3f9402f5e6ee4d3e1f8ed54b15350d5ba08a 100644 (file)
@@ -1611,7 +1611,7 @@ IO::set_state (const XMLNode& node)
        }
 
        if ((prop = node.property (X_("active"))) != 0) {
-               set_active (prop->value() == "yes");
+               set_active (string_is_affirmative (prop->value()));
        }
 
        for (iter = node.children().begin(); iter != node.children().end(); ++iter) {
index 6bd10ca27a3e59333f9d76efecc2af36d821bbd0..3953d2771634557c0a725178a89b745ce002e0ec 100644 (file)
@@ -393,7 +393,7 @@ Location::set_state (const XMLNode& node)
        _flags = Flags (string_2_enum (prop->value(), _flags));
 
        if ((prop = node.property ("locked")) != 0) {
-               _locked = (prop->value() == "yes");
+               _locked = string_is_affirmative (prop->value());
        } else {
                _locked = false;
        }
index cf56c8fdb7e6ba11cc3a65496c1dd0367531ff8a..d626ec4afbc03d113f475176598b65867f8d3f0d 100644 (file)
@@ -171,7 +171,7 @@ StreamPanner::set_state (const XMLNode& node)
        XMLNodeConstIterator iter;
 
        if ((prop = node.property (X_("muted")))) {
-               set_muted (prop->value() == "yes");
+               set_muted (string_is_affirmative (prop->value()));
        }
 
        return 0;
@@ -1162,12 +1162,12 @@ Panner::set_state (const XMLNode& node)
        outputs.clear ();
 
        if ((prop = node.property (X_("linked"))) != 0) {
-               set_linked (prop->value() == "yes");
+               set_linked (string_is_affirmative (prop->value()));
        }
 
 
        if ((prop = node.property (X_("bypassed"))) != 0) {
-               set_bypassed (prop->value() == "yes");
+               set_bypassed (string_is_affirmative (prop->value()));
        }
 
        if ((prop = node.property (X_("link_direction"))) != 0) {
index eae97e19df0431198da30a6052b2973d53c77ef7..44e28d37ede57f2b339eb6fbcce9b37d7c042ba2 100644 (file)
@@ -1768,7 +1768,7 @@ Playlist::set_state (const XMLNode& node)
                } else if (prop->name() == X_("orig_diskstream_id")) {
                        _orig_diskstream_id = prop->value ();
                } else if (prop->name() == X_("frozen")) {
-                       _frozen = (prop->value() == X_("yes"));
+                       _frozen = string_is_affirmative (prop->value());
                }
        }
 
index 5f99c742ad4fd0b334ad66a62eb8c6a1d09f7477..6cfd2e97c6153d889bd79103f23024dd0d04ad14 100644 (file)
@@ -278,7 +278,7 @@ Redirect::set_state (const XMLNode& node)
                return -1;
        }
 
-       if (_active != (prop->value() == "yes")) {
+       if (_active != string_is_affirmative (prop->value())) {
                if (!(_session.state_of_the_state() & Session::Loading) || 
                    !Session::get_disable_all_loaded_plugins()) {
                        _active = !_active;
index ac30cb47026932a32b036bdac5ea87d1c173328c..5d3fecf724b183b65d47f9f084a3265f6ebf50d4 100644 (file)
@@ -1696,15 +1696,15 @@ Route::_set_state (const XMLNode& node, bool call_base)
        }
 
        if ((prop = node.property (X_("phase-invert"))) != 0) {
-               set_phase_invert (prop->value()=="yes"?true:false, this);
+               set_phase_invert (string_is_affirmative (prop->value()), this);
        }
 
        if ((prop = node.property (X_("denormal-protection"))) != 0) {
-               set_denormal_protection (prop->value()=="yes"?true:false, this);
+               set_denormal_protection (string_is_affirmative (prop->value()), this);
        }
 
        if ((prop = node.property (X_("muted"))) != 0) {
-               bool yn = prop->value()=="yes"?true:false; 
+               bool yn = string_is_affirmative (prop->value());
 
                /* force reset of mute status */
 
@@ -1714,7 +1714,7 @@ Route::_set_state (const XMLNode& node, bool call_base)
        }
 
        if ((prop = node.property (X_("soloed"))) != 0) {
-               bool yn = prop->value()=="yes"?true:false; 
+               bool yn = string_is_affirmative (prop->value());
 
                /* force reset of solo status */
 
@@ -1724,19 +1724,19 @@ Route::_set_state (const XMLNode& node, bool call_base)
        }
 
        if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
-               _mute_affects_pre_fader = (prop->value()=="yes")?true:false;
+               _mute_affects_pre_fader = string_is_affirmative (prop->value());
        }
 
        if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
-               _mute_affects_post_fader = (prop->value()=="yes")?true:false;
+               _mute_affects_post_fader = string_is_affirmative (prop->value());
        }
 
        if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
-               _mute_affects_control_outs = (prop->value()=="yes")?true:false;
+               _mute_affects_control_outs = string_is_affirmative (prop->value());
        }
 
        if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
-               _mute_affects_main_outs = (prop->value()=="yes")?true:false;
+               _mute_affects_main_outs = string_is_affirmative (prop->value());
        }
 
        if ((prop = node.property (X_("meter-point"))) != 0) {
index 0382899b7af84be454e085eca5cf6f5100375060..0fde43b5a8f4ab370b7155c6dfb30ea3d2eab364 100644 (file)
@@ -878,7 +878,7 @@ Session::load_options (const XMLNode& node)
 
        if ((child = find_named_node (node, "end-marker-is-free")) != 0) {
                if ((prop = child->property ("val")) != 0) {
-                       _end_location_is_free = (prop->value() == "yes");
+                       _end_location_is_free = string_is_affirmative (prop->value());
                }
        }
 
index 4b9ac61e4913380a6b67e87834a5145be2651b21..8414242b4331113470a334a75daef8e882897518 100644 (file)
@@ -107,7 +107,7 @@ TempoSection::TempoSection (const XMLNode& node)
                throw failed_constructor();
        }
 
-       set_movable (prop->value() == "yes");
+       set_movable (string_is_affirmative (prop->value()));
 }
 
 XMLNode&
@@ -183,7 +183,7 @@ MeterSection::MeterSection (const XMLNode& node)
                throw failed_constructor();
        }
 
-       set_movable (prop->value() == "yes");
+       set_movable (string_is_affirmative (prop->value()));
 }
 
 XMLNode&
index 684c4b49f6956a688b2658c189ec571d776a0fc6..57500586a308e94a67378b98b133fe70667e6e90 100644 (file)
@@ -582,6 +582,26 @@ ARDOUR::auto_style_to_string (AutoStyle as)
        return "";
 }
 
+bool
+string_is_affirmative (const std::string& str)
+{
+       /* to be used only with XML data - not intended to handle user input */
+
+       if (str.length() == 1) {
+               if (str[0] == '1' || str[0] == 'y' || str[0] == 'Y') {
+                       return true;
+               } else {
+                       return false;
+               }
+       } else {
+               if (str == "yes" || str == "Yes" || str == "YES") {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+}
+
 extern "C" {
        void c_stacktrace() { stacktrace (cerr); }
 }