Updated TinyXML

This commit is contained in:
Dmitry-Me 2018-03-13 23:09:57 +03:00
parent 348232a599
commit 6ceb4b057b
2 changed files with 37 additions and 26 deletions

View File

@ -2037,7 +2037,7 @@ void XMLDocument::Clear()
DeleteNode(_unlinked[0]); // Will remove from _unlinked as part of delete.
}
#ifdef DEBUG
#ifdef TINYXML2_DEBUG
const bool hadError = Error();
#endif
ClearError();
@ -2052,7 +2052,7 @@ void XMLDocument::Clear()
_attributePool.Trace( "attribute" );
#endif
#ifdef DEBUG
#ifdef TINYXML2_DEBUG
if ( !hadError ) {
TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() );
TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );
@ -2151,10 +2151,16 @@ void XMLDocument::DeleteNode( XMLNode* node ) {
XMLError XMLDocument::LoadFile( const char* filename )
{
if ( !filename ) {
TIXMLASSERT( false );
SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=<null>" );
return _errorID;
}
Clear();
FILE* fp = callfopen( filename, "rb" );
if ( !fp ) {
SetError( XML_ERROR_FILE_NOT_FOUND, 0, "filename=%s", filename ? filename : "<null>");
SetError( XML_ERROR_FILE_NOT_FOUND, 0, "filename=%s", filename );
return _errorID;
}
LoadFile( fp );
@ -2233,9 +2239,15 @@ XMLError XMLDocument::LoadFile( FILE* fp )
XMLError XMLDocument::SaveFile( const char* filename, bool compact )
{
if ( !filename ) {
TIXMLASSERT( false );
SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=<null>" );
return _errorID;
}
FILE* fp = callfopen( filename, "w" );
if ( !fp ) {
SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=%s", filename ? filename : "<null>");
SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, 0, "filename=%s", filename );
return _errorID;
}
SaveFile(fp, compact);
@ -2791,4 +2803,3 @@ bool XMLPrinter::Visit( const XMLUnknown& unknown )
}
} // namespace tinyxml2

View File

@ -47,15 +47,15 @@ distribution.
*/
/*
gcc:
g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
Formatting, Artistic Style:
AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
*/
#if defined( _DEBUG ) || defined (__DEBUG__)
# ifndef DEBUG
# define DEBUG
# ifndef TINYXML2_DEBUG
# define TINYXML2_DEBUG
# endif
#endif
@ -79,7 +79,7 @@ distribution.
#endif
#if defined(DEBUG)
#if defined(TINYXML2_DEBUG)
# if defined(_MSC_VER)
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
@ -395,7 +395,7 @@ public:
}
--_currentAllocs;
Item* item = static_cast<Item*>( mem );
#ifdef DEBUG
#ifdef TINYXML2_DEBUG
memset( item, 0xfe, sizeof( *item ) );
#endif
item->next = _root;