diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-02 15:31:39 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-02 15:31:39 +0000 |
commit | 03f6001f4a47d7095f148aa193042c9d0656bc56 (patch) | |
tree | bdbc9f2a9a954c190f61e22006629ff8e86cd361 | |
parent | 9bddd37ea2dfab5a5eca6fdf03696e1dbae53e1d (diff) |
replace all instances of prop->value() == "yes" with string_is_affirmative (prop->value()) to avoid XML property SNAFUs
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5720 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/ardour/ardour/utils.h | 1 | ||||
-rw-r--r-- | libs/ardour/audioregion.cc | 4 | ||||
-rw-r--r-- | libs/ardour/control_protocol_manager.cc | 2 | ||||
-rw-r--r-- | libs/ardour/crossfade.cc | 6 | ||||
-rw-r--r-- | libs/ardour/io.cc | 2 | ||||
-rw-r--r-- | libs/ardour/location.cc | 2 | ||||
-rw-r--r-- | libs/ardour/panner.cc | 6 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 2 | ||||
-rw-r--r-- | libs/ardour/redirect.cc | 2 | ||||
-rw-r--r-- | libs/ardour/route.cc | 16 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 2 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 4 | ||||
-rw-r--r-- | libs/ardour/utils.cc | 20 |
13 files changed, 45 insertions, 24 deletions
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 9e0067c652..eccfc33d25 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -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; diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 87d79c6c2c..6163897b20 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -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); diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 00c05b2800..483243bb6f 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -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) { diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index d9c98e0e25..ee8e761f8f 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -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; } diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index ef9c6f6215..596d3f9402 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -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) { diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 6bd10ca27a..3953d27716 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -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; } diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index cf56c8fdb7..d626ec4afb 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -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) { diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index eae97e19df..44e28d37ed 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -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()); } } diff --git a/libs/ardour/redirect.cc b/libs/ardour/redirect.cc index 5f99c742ad..6cfd2e97c6 100644 --- a/libs/ardour/redirect.cc +++ b/libs/ardour/redirect.cc @@ -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; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index ac30cb4702..5d3fecf724 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -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) { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 0382899b7a..0fde43b5a8 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -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()); } } diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 4b9ac61e49..8414242b43 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -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& diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index 684c4b49f6..57500586a3 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -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); } } |