To bring BoolFirstChild() more in line with the other methods, reimplemented it in terms of a new QueryBoolFirstChild().

This commit is contained in:
Uli Kusterer
2014-01-21 02:53:47 +01:00
parent 4af5573f42
commit ff8e2041dd
2 changed files with 29 additions and 8 deletions

View File

@@ -1336,13 +1336,25 @@ void XMLElement::SetBoolFirstChild( bool inBool )
}
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;
}