string_is_affirmative() fix for 3.0
git-svn-id: svn://localhost/ardour2/branches/3.0@5723 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
342cdda32e
commit
e488378d42
@ -1061,25 +1061,25 @@ AudioRegionView::set_flags (XMLNode* node)
|
||||
XMLProperty *prop;
|
||||
|
||||
if ((prop = node->property ("waveform-visible")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
_flags |= WaveformVisible;
|
||||
}
|
||||
}
|
||||
|
||||
if ((prop = node->property ("envelope-visible")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
_flags |= EnvelopeVisible;
|
||||
}
|
||||
}
|
||||
|
||||
if ((prop = node->property ("waveform-rectified")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
_flags |= WaveformRectified;
|
||||
}
|
||||
}
|
||||
|
||||
if ((prop = node->property ("waveform-logscaled")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
_flags |= WaveformLogScaled;
|
||||
}
|
||||
}
|
||||
|
@ -2337,7 +2337,7 @@ Editor::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
if ((prop = node.property ("internal-edit"))) {
|
||||
bool yn = (prop->value() == "yes");
|
||||
bool yn = string_is_affirmative (prop->value());
|
||||
RefPtr<Action> act = ActionManager::get_action (X_("MouseMode"), X_("toggle-internal-edit"));
|
||||
if (act) {
|
||||
RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
|
||||
@ -2351,7 +2351,7 @@ Editor::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
if ((prop = node.property ("show-waveforms-recording"))) {
|
||||
bool yn = (prop->value() == "yes");
|
||||
bool yn = string_is_affirmative (prop->value());
|
||||
_show_waveforms_recording = !yn;
|
||||
RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
|
||||
if (act) {
|
||||
@ -2363,7 +2363,7 @@ Editor::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
if ((prop = node.property ("show-measures"))) {
|
||||
bool yn = (prop->value() == "yes");
|
||||
bool yn = string_is_affirmative (prop->value());
|
||||
_show_measures = !yn;
|
||||
RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
|
||||
if (act) {
|
||||
@ -2375,7 +2375,7 @@ Editor::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
if ((prop = node.property ("follow-playhead"))) {
|
||||
bool yn = (prop->value() == "yes");
|
||||
bool yn = string_is_affirmative (prop->value());
|
||||
set_follow_playhead (yn);
|
||||
RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead"));
|
||||
if (act) {
|
||||
@ -2391,7 +2391,7 @@ Editor::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
if ((prop = node.property ("xfades-visible"))) {
|
||||
bool yn = (prop->value() == "yes");
|
||||
bool yn = string_is_affirmative (prop->value());
|
||||
_xfade_visibility = !yn;
|
||||
// set_xfade_visibility (yn);
|
||||
}
|
||||
@ -2402,7 +2402,7 @@ Editor::set_state (const XMLNode& node)
|
||||
if (act) {
|
||||
|
||||
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
|
||||
bool yn = (prop->value() == X_("yes"));
|
||||
bool yn = string_is_affirmative (prop->value());
|
||||
|
||||
/* do it twice to force the change */
|
||||
|
||||
@ -2418,7 +2418,7 @@ Editor::set_state (const XMLNode& node)
|
||||
if (act) {
|
||||
|
||||
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
|
||||
bool yn = (prop->value() == X_("yes"));
|
||||
bool yn = string_is_affirmative (prop->value());
|
||||
|
||||
/* do it twice to force the change */
|
||||
|
||||
|
@ -455,56 +455,56 @@ Editor::restore_ruler_visibility ()
|
||||
|
||||
if (node) {
|
||||
if ((prop = node->property ("smpte")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_timecode_action->set_active (true);
|
||||
} else {
|
||||
ruler_timecode_action->set_active (false);
|
||||
}
|
||||
}
|
||||
if ((prop = node->property ("bbt")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_bbt_action->set_active (true);
|
||||
} else {
|
||||
ruler_bbt_action->set_active (false);
|
||||
}
|
||||
}
|
||||
if ((prop = node->property ("frames")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_samples_action->set_active (true);
|
||||
} else {
|
||||
ruler_samples_action->set_active (false);
|
||||
}
|
||||
}
|
||||
if ((prop = node->property ("minsec")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_minsec_action->set_active (true);
|
||||
} else {
|
||||
ruler_minsec_action->set_active (false);
|
||||
}
|
||||
}
|
||||
if ((prop = node->property ("tempo")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_tempo_action->set_active (true);
|
||||
} else {
|
||||
ruler_tempo_action->set_active (false);
|
||||
}
|
||||
}
|
||||
if ((prop = node->property ("meter")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_meter_action->set_active (true);
|
||||
} else {
|
||||
ruler_meter_action->set_active (false);
|
||||
}
|
||||
}
|
||||
if ((prop = node->property ("marker")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_marker_action->set_active (true);
|
||||
} else {
|
||||
ruler_marker_action->set_active (false);
|
||||
}
|
||||
}
|
||||
if ((prop = node->property ("rangemarker")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_range_action->set_active (true);
|
||||
} else {
|
||||
ruler_range_action->set_active (false);
|
||||
@ -512,7 +512,7 @@ Editor::restore_ruler_visibility ()
|
||||
}
|
||||
|
||||
if ((prop = node->property ("transportmarker")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_loop_punch_action->set_active (true);
|
||||
} else {
|
||||
ruler_loop_punch_action->set_active (false);
|
||||
@ -520,7 +520,7 @@ Editor::restore_ruler_visibility ()
|
||||
}
|
||||
|
||||
if ((prop = node->property ("cdmarker")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
ruler_cd_marker_action->set_active (true);
|
||||
} else {
|
||||
ruler_cd_marker_action->set_active (false);
|
||||
|
@ -1329,7 +1329,7 @@ Mixer_UI::set_state (const XMLNode& node)
|
||||
set_window_pos_and_size ();
|
||||
|
||||
if ((prop = node.property ("narrow-strips"))) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
set_strip_width (Narrow);
|
||||
} else {
|
||||
set_strip_width (Wide);
|
||||
@ -1337,7 +1337,7 @@ Mixer_UI::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
if ((prop = node.property ("show-mixer"))) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
_visible = true;
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ RouteTimeAxisView::set_state (const XMLNode& node)
|
||||
if ((prop = (*iter)->property ("automation-id")) != 0) {
|
||||
|
||||
Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
|
||||
bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
|
||||
bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
|
||||
create_automation_child(param, show);
|
||||
} else {
|
||||
warning << "Automation child has no ID" << endmsg;
|
||||
@ -1965,7 +1965,7 @@ RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_p
|
||||
|
||||
if ((node = track->get_state_node()) != 0) {
|
||||
if ((prop = node->property ("shown")) != 0) {
|
||||
if (prop->value() == "yes") {
|
||||
if (string_is_affirmative (prop->value())) {
|
||||
hideit = false;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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&
|
||||
|
@ -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); }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user