To bring BoolFirstChild() more in line with the other methods, reimplemented it in terms of a new QueryBoolFirstChild().
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index efcc8c7..c00f0e3 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -1336,13 +1336,25 @@
}
-bool XMLElement::BoolFirstChild()
+XMLError XMLElement::QueryBoolFirstChild( bool *outBool )
{
- if ( FirstChild() && FirstChild()->ToElement() ) {
- return strcmp( FirstChild()->Value(), "true" ) == 0;
+ if ( FirstChild() )
+ {
+ if ( FirstChild()->ToElement() )
+ {
+ bool isTrue = strcmp( FirstChild()->Value(), "true" ) == 0;
+ bool isFalse = strcmp( FirstChild()->Value(), "false" ) == 0;
+ if( !isTrue && !isFalse )
+ return XML_CAN_NOT_CONVERT_TEXT;
+
+ *outBool = isTrue;
+ return XML_SUCCESS;
+ }
+ else
+ return XML_NO_ELEMENT_NODE;
}
-
- return false;
+ else
+ return XML_NO_ELEMENT_NODE;
}