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;
}
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);
}
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);
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) {
}
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);
}
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;
}
}
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) {
_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;
}
XMLNodeConstIterator iter;
if ((prop = node.property (X_("muted")))) {
- set_muted (prop->value() == "yes");
+ set_muted (string_is_affirmative (prop->value()));
}
return 0;
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) {
} 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());
}
}
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;
}
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 */
}
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 */
}
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) {
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());
}
}
throw failed_constructor();
}
- set_movable (prop->value() == "yes");
+ set_movable (string_is_affirmative (prop->value()));
}
XMLNode&
throw failed_constructor();
}
- set_movable (prop->value() == "yes");
+ set_movable (string_is_affirmative (prop->value()));
}
XMLNode&
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); }
}