diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/utils.h | 2 | ||||
-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_processor.cc | 4 | ||||
-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/processor.cc | 2 | ||||
-rw-r--r-- | libs/ardour/route.cc | 10 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 4 | ||||
-rw-r--r-- | libs/ardour/utils.cc | 23 |
12 files changed, 46 insertions, 21 deletions
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index 2ccc61bb9c..dc6c1b8479 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -39,6 +39,8 @@ class XMLNode; Glib::ustring legalize_for_path (Glib::ustring str); std::ostream& operator<< (std::ostream& o, const ARDOUR::BBT_Time& bbt); XMLNode* find_named_node (const XMLNode& node, std::string name); +std::string bool_as_string (bool); +bool string_is_affirmative (const std::string&); static inline float f_max(float x, float a) { x -= a; diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 2c6c9fc0aa..89debf82c7 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -714,7 +714,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); @@ -735,7 +735,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 90d8198ec4..be173e7102 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -304,7 +304,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 86d509ec66..2d46c0c01a 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -743,7 +743,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); @@ -753,13 +753,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_processor.cc b/libs/ardour/io_processor.cc index 505d33a1b0..1408cdcafb 100644 --- a/libs/ardour/io_processor.cc +++ b/libs/ardour/io_processor.cc @@ -155,11 +155,11 @@ IOProcessor::set_state (const XMLNode& node) Processor::set_state(node); if ((prop = node.property ("own-input")) != 0) { - _own_input = (prop->value() == "yes"); + _own_input = string_is_affirmative (prop->value()); } if ((prop = node.property ("own-output")) != 0) { - _own_output = (prop->value() == "yes"); + _own_output = string_is_affirmative (prop->value()); } /* don't attempt to set state for a proxied IO that we don't own */ diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index b66d0f3942..c232b9738e 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -402,7 +402,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 f43741300a..d23929232a 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -168,7 +168,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; @@ -1104,12 +1104,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 cd53f35d95..53d749db82 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -1820,7 +1820,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/processor.cc b/libs/ardour/processor.cc index 04706c0c2d..6f32afc925 100644 --- a/libs/ardour/processor.cc +++ b/libs/ardour/processor.cc @@ -212,7 +212,7 @@ Processor::set_state (const XMLNode& node) } } - if (_active != (prop->value() == "yes")) { + if (_active != string_is_affirmative (prop->value())) { _active = !_active; ActiveChanged (); /* EMIT_SIGNAL */ } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 1cb7b84bc9..5595ac3972 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1667,25 +1667,25 @@ Route::_set_state (const XMLNode& node, bool /*call_base*/) } if ((prop = node.property ("solo-isolated")) != 0) { - set_solo_isolated (prop->value() == "yes", this); + set_solo_isolated (string_is_affirmative (prop->value()), this); } if ((prop = node.property (X_("phase-invert"))) != 0) { - set_phase_invert (prop->value()=="yes"?true:false); + set_phase_invert (string_is_affirmative (prop->value())); } if ((prop = node.property (X_("denormal-protection"))) != 0) { - set_denormal_protection (prop->value()=="yes"?true:false); + set_denormal_protection (string_is_affirmative (prop->value())); } if ((prop = node.property (X_("active"))) != 0) { - bool yn = (prop->value() == "yes"); + bool yn = string_is_affirmative (prop->value()); _active = !yn; // force switch set_active (yn); } if ((prop = node.property (X_("soloed"))) != 0) { - bool yn = (prop->value()=="yes"); + bool yn = string_is_affirmative (prop->value()); /* XXX force reset of solo status */ diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index a2307901bc..2ee0e456fc 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 e12ae2cd89..c8e6b1145f 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -506,6 +506,29 @@ ARDOUR::auto_style_to_string (AutoStyle as) return ""; } +std::string +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 == "1" || str == "y" || str == "Y") { + return true; + } else { + std::string str_uc; + std::transform(str.begin(), str.end(), str_uc.begin(), ::toupper); + if (str_uc == "YES") { + return true; + } + } + return false; +} + extern "C" { void c_stacktrace() { stacktrace (cerr); } } |