Make boolean string values 0 and 1 to maintain backwards compatibility
authorTim Mayberry <mojofunk@gmail.com>
Tue, 18 Apr 2017 03:10:58 +0000 (13:10 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Tue, 18 Apr 2017 21:49:57 +0000 (07:49 +1000)
I would prefer "yes" and "no" as it distinguishes boolean values from numeric
but using "yes and "no" results in PBD::Property<T>::from_string failing to
parse the correct values when opening in an older Ardour version as there is no
specialization for bool.

Using 0 and 1 also results in less change to the Session file.

libs/pbd/string_convert.cc
libs/pbd/test/string_convert_test.cc

index 3a46b8a682e20a33a59d8a0de760b252878ee4e5..a543c96ff1d464f4b9a1333a8e8378e034067bd4 100644 (file)
@@ -210,9 +210,9 @@ bool string_to_double (const std::string& str, double& val)
 bool bool_to_string (bool val, std::string& str)
 {
        if (val) {
-               str = X_("yes");
+               str = X_("1");
        } else {
-               str = X_("no");
+               str = X_("0");
        }
        return true;
 }
index 2f06ad9c52868894a730ddf50f2a1d3a31112d17..27a24c54efe3c39b3f376eee0014d81353e39a93 100644 (file)
@@ -564,8 +564,8 @@ StringConvertTest::test_double_conversion ()
 }
 
 // we have to use these as CPPUNIT_ASSERT_EQUAL won't accept char arrays
-static const std::string BOOL_TRUE_STR ("yes");
-static const std::string BOOL_FALSE_STR ("no");
+static const std::string BOOL_TRUE_STR ("1");
+static const std::string BOOL_FALSE_STR ("0");
 
 void
 StringConvertTest::test_bool_conversion ()