mirror of https://github.com/AxioDL/tinyxml2.git
tweaks to bool serialization
This commit is contained in:
parent
f458d265c1
commit
c5c99c2ba0
14
tinyxml2.cpp
14
tinyxml2.cpp
|
@ -371,19 +371,13 @@ const char* StrPair::GetStr()
|
||||||
const char* XMLUtil::writeBoolTrue = "true";
|
const char* XMLUtil::writeBoolTrue = "true";
|
||||||
const char* XMLUtil::writeBoolFalse = "false";
|
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";
|
static const char* defFalse = "false";
|
||||||
if (writeTrue)
|
|
||||||
writeBoolTrue = writeTrue;
|
|
||||||
else
|
|
||||||
writeBoolTrue = defTrue;
|
|
||||||
|
|
||||||
if (writeFalse)
|
writeBoolTrue = (writeTrue) ? writeTrue : defTrue;
|
||||||
writeBoolFalse = writeFalse;
|
writeBoolFalse = (writeFalse) ? writeFalse : defFalse;
|
||||||
else
|
|
||||||
writeBoolFalse = defFalse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
10
tinyxml2.h
10
tinyxml2.h
|
@ -606,14 +606,12 @@ public:
|
||||||
static bool ToDouble( const char* str, double* value );
|
static bool ToDouble( const char* str, double* value );
|
||||||
static bool ToInt64(const char* str, int64_t* value);
|
static bool ToInt64(const char* str, int64_t* value);
|
||||||
|
|
||||||
// Default to "true" and "false". If you
|
// Changes what is serialized for a boolean value.
|
||||||
// need different values, can assign them. (For instance
|
// Default to "true" and "false". Shouldn't be changed
|
||||||
// if you need "true" to be "1".)
|
// unless you have a special testing or compatibility need.
|
||||||
// Be careful: static, global, & not thread safe.
|
// Be careful: static, global, & not thread safe.
|
||||||
// Be sure to set static const memory as parameters.
|
// Be sure to set static const memory as parameters.
|
||||||
// Shouldn't be set unless you have a special reason
|
static void SetBoolSerialization(const char* writeTrue, const char* writeFalse);
|
||||||
// such as back-compatibility or testing.
|
|
||||||
static void SetBool(const char* writeTrue, const char* writeFalse);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char* writeBoolTrue;
|
static const char* writeBoolTrue;
|
||||||
|
|
|
@ -757,12 +757,12 @@ int main( int argc, const char ** argv )
|
||||||
const char* result = element->Attribute("attrib");
|
const char* result = element->Attribute("attrib");
|
||||||
XMLTest("Bool true is 'true'", "true", result);
|
XMLTest("Bool true is 'true'", "true", result);
|
||||||
|
|
||||||
XMLUtil::SetBool("1", "0");
|
XMLUtil::SetBoolSerialization("1", "0");
|
||||||
element->SetAttribute("attrib", true);
|
element->SetAttribute("attrib", true);
|
||||||
result = element->Attribute("attrib");
|
result = element->Attribute("attrib");
|
||||||
XMLTest("Bool true is '1'", "1", result);
|
XMLTest("Bool true is '1'", "1", result);
|
||||||
|
|
||||||
XMLUtil::SetBool(0, 0);
|
XMLUtil::SetBoolSerialization(0, 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
element->SetAttribute("attrib", 100.0);
|
element->SetAttribute("attrib", 100.0);
|
||||||
|
|
Loading…
Reference in New Issue