tweaks to bool serialization
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 40f6d82..1f7a918 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -371,19 +371,13 @@
const char* XMLUtil::writeBoolTrue = "true";
const char* XMLUtil::writeBoolFalse = "false";
-void XMLUtil::SetBool(const char* writeTrue, const char* writeFalse)
+void XMLUtil::SetBoolSerialization(const char* writeTrue, const char* writeFalse)
{
- static const char* defTrue = "true";
+ static const char* defTrue = "true";
static const char* defFalse = "false";
- if (writeTrue)
- writeBoolTrue = writeTrue;
- else
- writeBoolTrue = defTrue;
- if (writeFalse)
- writeBoolFalse = writeFalse;
- else
- writeBoolFalse = defFalse;
+ writeBoolTrue = (writeTrue) ? writeTrue : defTrue;
+ writeBoolFalse = (writeFalse) ? writeFalse : defFalse;
}
diff --git a/tinyxml2.h b/tinyxml2.h
index 8030e7d..00f6883 100755
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -606,14 +606,12 @@
static bool ToDouble( const char* str, double* value );
static bool ToInt64(const char* str, int64_t* value);
- // Default to "true" and "false". If you
- // need different values, can assign them. (For instance
- // if you need "true" to be "1".)
+ // Changes what is serialized for a boolean value.
+ // Default to "true" and "false". Shouldn't be changed
+ // unless you have a special testing or compatibility need.
// Be careful: static, global, & not thread safe.
// Be sure to set static const memory as parameters.
- // Shouldn't be set unless you have a special reason
- // such as back-compatibility or testing.
- static void SetBool(const char* writeTrue, const char* writeFalse);
+ static void SetBoolSerialization(const char* writeTrue, const char* writeFalse);
private:
static const char* writeBoolTrue;
diff --git a/xmltest.cpp b/xmltest.cpp
index 27c9665..7c11389 100644
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -757,12 +757,12 @@
const char* result = element->Attribute("attrib");
XMLTest("Bool true is 'true'", "true", result);
- XMLUtil::SetBool("1", "0");
+ XMLUtil::SetBoolSerialization("1", "0");
element->SetAttribute("attrib", true);
result = element->Attribute("attrib");
XMLTest("Bool true is '1'", "1", result);
- XMLUtil::SetBool(0, 0);
+ XMLUtil::SetBoolSerialization(0, 0);
}
{
element->SetAttribute("attrib", 100.0);