Updated TinyXML, make use of second argument of XMLElement::Attribute()
This commit is contained in:
parent
c1594bedbb
commit
b5d3ecb942
|
@ -631,7 +631,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
// Rule file
|
||||
else if (std::strncmp(argv[i], "--rule-file=", 12) == 0) {
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (doc.LoadFile(12+argv[i]) == tinyxml2::XML_NO_ERROR) {
|
||||
if (doc.LoadFile(12+argv[i]) == tinyxml2::XML_SUCCESS) {
|
||||
tinyxml2::XMLElement *node = doc.FirstChildElement();
|
||||
for (; node && strcmp(node->Value(), "rule") == 0; node = node->NextSiblingElement()) {
|
||||
Settings::Rule rule;
|
||||
|
|
|
@ -24,7 +24,7 @@ distribution.
|
|||
#include "tinyxml2.h"
|
||||
|
||||
#include <new> // yes, this one new style header, is in the Android SDK.
|
||||
#if defined(ANDROID_NDK) || defined(__QNXNTO__)
|
||||
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
|
||||
# include <stddef.h>
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
|
@ -471,7 +471,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
|
|||
else {
|
||||
return 0;
|
||||
}
|
||||
TIXMLASSERT( digit >= 0 && digit < 16);
|
||||
TIXMLASSERT( digit < 16 );
|
||||
TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
|
||||
const unsigned int digitScaled = mult * digit;
|
||||
TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );
|
||||
|
@ -501,7 +501,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
|
|||
while ( *q != '#' ) {
|
||||
if ( *q >= '0' && *q <= '9' ) {
|
||||
const unsigned int digit = *q - '0';
|
||||
TIXMLASSERT( digit >= 0 && digit < 10);
|
||||
TIXMLASSERT( digit < 10 );
|
||||
TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit );
|
||||
const unsigned int digitScaled = mult * digit;
|
||||
TIXMLASSERT( ucs <= ULONG_MAX - digitScaled );
|
||||
|
@ -776,6 +776,7 @@ void XMLNode::DeleteChild( XMLNode* node )
|
|||
TIXMLASSERT( node );
|
||||
TIXMLASSERT( node->_document == _document );
|
||||
TIXMLASSERT( node->_parent == this );
|
||||
Unlink( node );
|
||||
DeleteNode( node );
|
||||
}
|
||||
|
||||
|
@ -1285,7 +1286,7 @@ void XMLAttribute::SetName( const char* n )
|
|||
XMLError XMLAttribute::QueryIntValue( int* value ) const
|
||||
{
|
||||
if ( XMLUtil::ToInt( Value(), value )) {
|
||||
return XML_NO_ERROR;
|
||||
return XML_SUCCESS;
|
||||
}
|
||||
return XML_WRONG_ATTRIBUTE_TYPE;
|
||||
}
|
||||
|
@ -1294,7 +1295,7 @@ XMLError XMLAttribute::QueryIntValue( int* value ) const
|
|||
XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const
|
||||
{
|
||||
if ( XMLUtil::ToUnsigned( Value(), value )) {
|
||||
return XML_NO_ERROR;
|
||||
return XML_SUCCESS;
|
||||
}
|
||||
return XML_WRONG_ATTRIBUTE_TYPE;
|
||||
}
|
||||
|
@ -1303,7 +1304,7 @@ XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const
|
|||
XMLError XMLAttribute::QueryBoolValue( bool* value ) const
|
||||
{
|
||||
if ( XMLUtil::ToBool( Value(), value )) {
|
||||
return XML_NO_ERROR;
|
||||
return XML_SUCCESS;
|
||||
}
|
||||
return XML_WRONG_ATTRIBUTE_TYPE;
|
||||
}
|
||||
|
@ -1312,7 +1313,7 @@ XMLError XMLAttribute::QueryBoolValue( bool* value ) const
|
|||
XMLError XMLAttribute::QueryFloatValue( float* value ) const
|
||||
{
|
||||
if ( XMLUtil::ToFloat( Value(), value )) {
|
||||
return XML_NO_ERROR;
|
||||
return XML_SUCCESS;
|
||||
}
|
||||
return XML_WRONG_ATTRIBUTE_TYPE;
|
||||
}
|
||||
|
@ -1321,7 +1322,7 @@ XMLError XMLAttribute::QueryFloatValue( float* value ) const
|
|||
XMLError XMLAttribute::QueryDoubleValue( double* value ) const
|
||||
{
|
||||
if ( XMLUtil::ToDouble( Value(), value )) {
|
||||
return XML_NO_ERROR;
|
||||
return XML_SUCCESS;
|
||||
}
|
||||
return XML_WRONG_ATTRIBUTE_TYPE;
|
||||
}
|
||||
|
@ -1770,7 +1771,7 @@ XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) :
|
|||
XMLNode( 0 ),
|
||||
_writeBOM( false ),
|
||||
_processEntities( processEntities ),
|
||||
_errorID( XML_NO_ERROR ),
|
||||
_errorID(XML_SUCCESS),
|
||||
_whitespace( whitespace ),
|
||||
_errorStr1( 0 ),
|
||||
_errorStr2( 0 ),
|
||||
|
@ -1794,7 +1795,7 @@ void XMLDocument::Clear()
|
|||
#ifdef DEBUG
|
||||
const bool hadError = Error();
|
||||
#endif
|
||||
_errorID = XML_NO_ERROR;
|
||||
_errorID = XML_SUCCESS;
|
||||
_errorStr1 = 0;
|
||||
_errorStr2 = 0;
|
||||
|
||||
|
@ -1953,6 +1954,7 @@ XMLError XMLDocument::LoadFile( FILE* fp )
|
|||
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
|
||||
return _errorID;
|
||||
}
|
||||
TIXMLASSERT( filelength >= 0 );
|
||||
|
||||
if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) {
|
||||
// Cannot handle files which won't fit in buffer together with null terminator
|
||||
|
@ -1998,7 +2000,7 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
|
|||
{
|
||||
// Clear any error from the last save, otherwise it will get reported
|
||||
// for *this* call.
|
||||
SetError( XML_NO_ERROR, 0, 0 );
|
||||
SetError(XML_SUCCESS, 0, 0);
|
||||
XMLPrinter stream( fp, compact );
|
||||
Print( &stream );
|
||||
return _errorID;
|
||||
|
|
|
@ -30,6 +30,9 @@ distribution.
|
|||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# if defined(__PS3__)
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
#else
|
||||
# include <cctype>
|
||||
# include <climits>
|
||||
|
@ -485,7 +488,6 @@ public:
|
|||
// WARNING: must match XMLDocument::_errorNames[]
|
||||
enum XMLError {
|
||||
XML_SUCCESS = 0,
|
||||
XML_NO_ERROR = 0,
|
||||
XML_NO_ATTRIBUTE,
|
||||
XML_WRONG_ATTRIBUTE_TYPE,
|
||||
XML_ERROR_FILE_NOT_FOUND,
|
||||
|
@ -893,7 +895,6 @@ private:
|
|||
*/
|
||||
class TINYXML2_LIB XMLText : public XMLNode
|
||||
{
|
||||
friend class XMLBase;
|
||||
friend class XMLDocument;
|
||||
public:
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
@ -1142,7 +1143,6 @@ private:
|
|||
*/
|
||||
class TINYXML2_LIB XMLElement : public XMLNode
|
||||
{
|
||||
friend class XMLBase;
|
||||
friend class XMLDocument;
|
||||
public:
|
||||
/// Get the name of an element (which is the Value() of the node.)
|
||||
|
@ -1675,7 +1675,7 @@ public:
|
|||
|
||||
/// Return true if there was an error parsing the document.
|
||||
bool Error() const {
|
||||
return _errorID != XML_NO_ERROR;
|
||||
return _errorID != XML_SUCCESS;
|
||||
}
|
||||
/// Return the errorID.
|
||||
XMLError ErrorID() const {
|
||||
|
|
|
@ -92,7 +92,7 @@ Library::Error Library::load(const char exename[], const char path[])
|
|||
} else
|
||||
absolute_path = Path::getAbsoluteFilePath(path);
|
||||
|
||||
if (error == tinyxml2::XML_NO_ERROR) {
|
||||
if (error == tinyxml2::XML_SUCCESS) {
|
||||
if (_files.find(absolute_path) == _files.end()) {
|
||||
Error err = load(doc);
|
||||
if (err.errorcode == OK)
|
||||
|
@ -109,7 +109,7 @@ Library::Error Library::load(const char exename[], const char path[])
|
|||
bool Library::loadxmldata(const char xmldata[], std::size_t len)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
return (tinyxml2::XML_NO_ERROR == doc.Parse(xmldata, len)) && (load(doc).errorcode == OK);
|
||||
return (tinyxml2::XML_SUCCESS == doc.Parse(xmldata, len)) && (load(doc).errorcode == OK);
|
||||
}
|
||||
|
||||
Library::Error Library::load(const tinyxml2::XMLDocument &doc)
|
||||
|
@ -161,10 +161,9 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
|
|||
AllocFunc temp;
|
||||
temp.groupId = allocationId;
|
||||
|
||||
const char *init = memorynode->Attribute("init");
|
||||
if (init && strcmp(init,"false")==0) {
|
||||
if (memorynode->Attribute("init", "false"))
|
||||
returnuninitdata.insert(memorynode->GetText());
|
||||
}
|
||||
|
||||
const char *arg = memorynode->Attribute("arg");
|
||||
if (arg)
|
||||
temp.arg = atoi(arg);
|
||||
|
@ -234,10 +233,8 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
|
|||
return Error(MISSING_ATTRIBUTE, "ext");
|
||||
_markupExtensions.insert(extension);
|
||||
|
||||
const char * const reporterrors = node->Attribute("reporterrors");
|
||||
_reporterrors[extension] = (reporterrors && strcmp(reporterrors, "true") == 0);
|
||||
const char * const aftercode = node->Attribute("aftercode");
|
||||
_processAfterCode[extension] = (aftercode && strcmp(aftercode, "true") == 0);
|
||||
_reporterrors[extension] = (node->Attribute("reporterrors", "true") != nullptr);
|
||||
_processAfterCode[extension] = (node->Attribute("aftercode", "true") != nullptr);
|
||||
|
||||
for (const tinyxml2::XMLElement *markupnode = node->FirstChildElement(); markupnode; markupnode = markupnode->NextSiblingElement()) {
|
||||
const std::string markupnodename = markupnode->Name();
|
||||
|
@ -339,9 +336,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
|
|||
const char* const itEndPattern = node->Attribute("itEndPattern");
|
||||
if (itEndPattern)
|
||||
container.itEndPattern = itEndPattern;
|
||||
const char* const opLessAllowed = node->Attribute("opLessAllowed");
|
||||
if (opLessAllowed)
|
||||
container.opLessAllowed = std::string(opLessAllowed) == "true";
|
||||
container.opLessAllowed = (node->Attribute("opLessAllowed", "true") != nullptr);
|
||||
|
||||
for (const tinyxml2::XMLElement *containerNode = node->FirstChildElement(); containerNode; containerNode = containerNode->NextSiblingElement()) {
|
||||
const std::string containerNodeName = containerNode->Name();
|
||||
|
@ -419,18 +414,14 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
|
|||
if (templateArg)
|
||||
container.size_templateArgNo = atoi(templateArg);
|
||||
} else if (containerNodeName == "access") {
|
||||
const char* const indexArg = containerNode->Attribute("indexOperator");
|
||||
if (indexArg)
|
||||
container.arrayLike_indexOp = std::string(indexArg) == "array-like";
|
||||
container.arrayLike_indexOp = (containerNode->Attribute("indexOperator", "array-like") != nullptr);
|
||||
}
|
||||
} else if (containerNodeName == "type") {
|
||||
const char* const templateArg = containerNode->Attribute("templateParameter");
|
||||
if (templateArg)
|
||||
container.type_templateArgNo = atoi(templateArg);
|
||||
|
||||
const char* const string = containerNode->Attribute("string");
|
||||
if (string)
|
||||
container.stdStringLike = std::string(string) == "std-like";
|
||||
container.stdStringLike = (containerNode->Attribute("string", "std-like") != nullptr);
|
||||
} else
|
||||
unknown_elements.insert(containerNodeName);
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ bool Settings::platformFile(const std::string &filename)
|
|||
{
|
||||
// open file..
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_NO_ERROR)
|
||||
if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS)
|
||||
return false;
|
||||
|
||||
const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement();
|
||||
|
|
Loading…
Reference in New Issue