mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Update TinyXML2 to 9.0.0
This updates TinyXML2 to the major release tagged on June 6, 2021.
This commit is contained in:
parent
84f9bb6dd6
commit
ed4d3d0fa8
2 changed files with 98 additions and 52 deletions
111
third_party/tinyxml2/tinyxml2.cpp
vendored
111
third_party/tinyxml2/tinyxml2.cpp
vendored
|
@ -103,7 +103,7 @@ distribution.
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
#define TIXML_FSEEK _fseeki64
|
#define TIXML_FSEEK _fseeki64
|
||||||
#define TIXML_FTELL _ftelli64
|
#define TIXML_FTELL _ftelli64
|
||||||
#elif defined(__APPLE__) || (__FreeBSD__) || (__OpenBSD__)
|
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__ANDROID__)
|
||||||
#define TIXML_FSEEK fseeko
|
#define TIXML_FSEEK fseeko
|
||||||
#define TIXML_FTELL ftello
|
#define TIXML_FTELL ftello
|
||||||
#elif defined(__unix__) && defined(__x86_64__)
|
#elif defined(__unix__) && defined(__x86_64__)
|
||||||
|
@ -234,13 +234,13 @@ char* StrPair::ParseName( char* p )
|
||||||
if ( !p || !(*p) ) {
|
if ( !p || !(*p) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( !XMLUtil::IsNameStartChar( *p ) ) {
|
if ( !XMLUtil::IsNameStartChar( (unsigned char) *p ) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* const start = p;
|
char* const start = p;
|
||||||
++p;
|
++p;
|
||||||
while ( *p && XMLUtil::IsNameChar( *p ) ) {
|
while ( *p && XMLUtil::IsNameChar( (unsigned char) *p ) ) {
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,17 +608,26 @@ void XMLUtil::ToStr( uint64_t v, char* buffer, int bufferSize )
|
||||||
TIXML_SNPRINTF(buffer, bufferSize, "%llu", (long long)v);
|
TIXML_SNPRINTF(buffer, bufferSize, "%llu", (long long)v);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XMLUtil::ToInt( const char* str, int* value )
|
bool XMLUtil::ToInt(const char* str, int* value)
|
||||||
{
|
{
|
||||||
if ( TIXML_SSCANF( str, "%d", value ) == 1 ) {
|
if (IsPrefixHex(str)) {
|
||||||
return true;
|
unsigned v;
|
||||||
|
if (TIXML_SSCANF(str, "%x", &v) == 1) {
|
||||||
|
*value = static_cast<int>(v);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (TIXML_SSCANF(str, "%d", value) == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XMLUtil::ToUnsigned( const char* str, unsigned *value )
|
bool XMLUtil::ToUnsigned(const char* str, unsigned* value)
|
||||||
{
|
{
|
||||||
if ( TIXML_SSCANF( str, "%u", value ) == 1 ) {
|
if (TIXML_SSCANF(str, IsPrefixHex(str) ? "%x" : "%u", value) == 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -670,18 +679,27 @@ bool XMLUtil::ToDouble( const char* str, double* value )
|
||||||
|
|
||||||
bool XMLUtil::ToInt64(const char* str, int64_t* value)
|
bool XMLUtil::ToInt64(const char* str, int64_t* value)
|
||||||
{
|
{
|
||||||
long long v = 0; // horrible syntax trick to make the compiler happy about %lld
|
if (IsPrefixHex(str)) {
|
||||||
if (TIXML_SSCANF(str, "%lld", &v) == 1) {
|
unsigned long long v = 0; // horrible syntax trick to make the compiler happy about %llx
|
||||||
*value = static_cast<int64_t>(v);
|
if (TIXML_SSCANF(str, "%llx", &v) == 1) {
|
||||||
return true;
|
*value = static_cast<int64_t>(v);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
long long v = 0; // horrible syntax trick to make the compiler happy about %lld
|
||||||
|
if (TIXML_SSCANF(str, "%lld", &v) == 1) {
|
||||||
|
*value = static_cast<int64_t>(v);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool XMLUtil::ToUnsigned64(const char* str, uint64_t* value) {
|
bool XMLUtil::ToUnsigned64(const char* str, uint64_t* value) {
|
||||||
unsigned long long v = 0; // horrible syntax trick to make the compiler happy about %llu
|
unsigned long long v = 0; // horrible syntax trick to make the compiler happy about %llu
|
||||||
if(TIXML_SSCANF(str, "%llu", &v) == 1) {
|
if(TIXML_SSCANF(str, IsPrefixHex(str) ? "%llx" : "%llu", &v) == 1) {
|
||||||
*value = (uint64_t)v;
|
*value = (uint64_t)v;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1637,8 +1655,18 @@ float XMLElement::FloatAttribute(const char* name, float defaultValue) const
|
||||||
|
|
||||||
const char* XMLElement::GetText() const
|
const char* XMLElement::GetText() const
|
||||||
{
|
{
|
||||||
if ( FirstChild() && FirstChild()->ToText() ) {
|
/* skip comment node */
|
||||||
return FirstChild()->Value();
|
const XMLNode* node = FirstChild();
|
||||||
|
while (node) {
|
||||||
|
if (node->ToComment()) {
|
||||||
|
node = node->NextSibling();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( node && node->ToText() ) {
|
||||||
|
return node->Value();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1909,7 +1937,7 @@ char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr )
|
||||||
}
|
}
|
||||||
|
|
||||||
// attribute.
|
// attribute.
|
||||||
if (XMLUtil::IsNameStartChar( *p ) ) {
|
if (XMLUtil::IsNameStartChar( (unsigned char) *p ) ) {
|
||||||
XMLAttribute* attrib = CreateAttribute();
|
XMLAttribute* attrib = CreateAttribute();
|
||||||
TIXMLASSERT( attrib );
|
TIXMLASSERT( attrib );
|
||||||
attrib->_parseLineNum = _document->_parseCurLineNum;
|
attrib->_parseLineNum = _document->_parseCurLineNum;
|
||||||
|
@ -2427,6 +2455,13 @@ void XMLDocument::Print( XMLPrinter* streamer ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void XMLDocument::ClearError() {
|
||||||
|
_errorID = XML_SUCCESS;
|
||||||
|
_errorLineNum = 0;
|
||||||
|
_errorStr.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ... )
|
void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ... )
|
||||||
{
|
{
|
||||||
TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT );
|
TIXMLASSERT( error >= 0 && error < XML_ERROR_COUNT );
|
||||||
|
@ -2659,22 +2694,33 @@ void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XMLPrinter::PrepareForNewNode( bool compactMode )
|
||||||
void XMLPrinter::OpenElement( const char* name, bool compactMode )
|
|
||||||
{
|
{
|
||||||
SealElementIfJustOpened();
|
SealElementIfJustOpened();
|
||||||
_stack.Push( name );
|
|
||||||
|
|
||||||
if ( _textDepth < 0 && !_firstElement && !compactMode ) {
|
if ( compactMode ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( _firstElement ) {
|
||||||
|
PrintSpace (_depth);
|
||||||
|
} else if ( _textDepth < 0) {
|
||||||
Putc( '\n' );
|
Putc( '\n' );
|
||||||
PrintSpace( _depth );
|
PrintSpace( _depth );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_firstElement = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XMLPrinter::OpenElement( const char* name, bool compactMode )
|
||||||
|
{
|
||||||
|
PrepareForNewNode( compactMode );
|
||||||
|
_stack.Push( name );
|
||||||
|
|
||||||
Write ( "<" );
|
Write ( "<" );
|
||||||
Write ( name );
|
Write ( name );
|
||||||
|
|
||||||
_elementJustOpened = true;
|
_elementJustOpened = true;
|
||||||
_firstElement = false;
|
|
||||||
++_depth;
|
++_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2850,12 +2896,7 @@ void XMLPrinter::PushText( double value )
|
||||||
|
|
||||||
void XMLPrinter::PushComment( const char* comment )
|
void XMLPrinter::PushComment( const char* comment )
|
||||||
{
|
{
|
||||||
SealElementIfJustOpened();
|
PrepareForNewNode( _compactMode );
|
||||||
if ( _textDepth < 0 && !_firstElement && !_compactMode) {
|
|
||||||
Putc( '\n' );
|
|
||||||
PrintSpace( _depth );
|
|
||||||
}
|
|
||||||
_firstElement = false;
|
|
||||||
|
|
||||||
Write( "<!--" );
|
Write( "<!--" );
|
||||||
Write( comment );
|
Write( comment );
|
||||||
|
@ -2865,12 +2906,7 @@ void XMLPrinter::PushComment( const char* comment )
|
||||||
|
|
||||||
void XMLPrinter::PushDeclaration( const char* value )
|
void XMLPrinter::PushDeclaration( const char* value )
|
||||||
{
|
{
|
||||||
SealElementIfJustOpened();
|
PrepareForNewNode( _compactMode );
|
||||||
if ( _textDepth < 0 && !_firstElement && !_compactMode) {
|
|
||||||
Putc( '\n' );
|
|
||||||
PrintSpace( _depth );
|
|
||||||
}
|
|
||||||
_firstElement = false;
|
|
||||||
|
|
||||||
Write( "<?" );
|
Write( "<?" );
|
||||||
Write( value );
|
Write( value );
|
||||||
|
@ -2880,12 +2916,7 @@ void XMLPrinter::PushDeclaration( const char* value )
|
||||||
|
|
||||||
void XMLPrinter::PushUnknown( const char* value )
|
void XMLPrinter::PushUnknown( const char* value )
|
||||||
{
|
{
|
||||||
SealElementIfJustOpened();
|
PrepareForNewNode( _compactMode );
|
||||||
if ( _textDepth < 0 && !_firstElement && !_compactMode) {
|
|
||||||
Putc( '\n' );
|
|
||||||
PrintSpace( _depth );
|
|
||||||
}
|
|
||||||
_firstElement = false;
|
|
||||||
|
|
||||||
Write( "<!" );
|
Write( "<!" );
|
||||||
Write( value );
|
Write( value );
|
||||||
|
|
39
third_party/tinyxml2/tinyxml2.h
vendored
39
third_party/tinyxml2/tinyxml2.h
vendored
|
@ -79,6 +79,7 @@ distribution.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(TIXMLASSERT)
|
||||||
#if defined(TINYXML2_DEBUG)
|
#if defined(TINYXML2_DEBUG)
|
||||||
# if defined(_MSC_VER)
|
# if defined(_MSC_VER)
|
||||||
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
|
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
|
||||||
|
@ -93,16 +94,16 @@ distribution.
|
||||||
#else
|
#else
|
||||||
# define TIXMLASSERT( x ) {}
|
# define TIXMLASSERT( x ) {}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Versioning, past 1.0.14:
|
/* Versioning, past 1.0.14:
|
||||||
http://semver.org/
|
http://semver.org/
|
||||||
*/
|
*/
|
||||||
static const int TIXML2_MAJOR_VERSION = 8;
|
static const int TIXML2_MAJOR_VERSION = 9;
|
||||||
static const int TIXML2_MINOR_VERSION = 0;
|
static const int TIXML2_MINOR_VERSION = 0;
|
||||||
static const int TIXML2_PATCH_VERSION = 0;
|
static const int TIXML2_PATCH_VERSION = 0;
|
||||||
|
|
||||||
#define TINYXML2_MAJOR_VERSION 8
|
#define TINYXML2_MAJOR_VERSION 9
|
||||||
#define TINYXML2_MINOR_VERSION 0
|
#define TINYXML2_MINOR_VERSION 0
|
||||||
#define TINYXML2_PATCH_VERSION 0
|
#define TINYXML2_PATCH_VERSION 0
|
||||||
|
|
||||||
|
@ -135,7 +136,7 @@ class XMLPrinter;
|
||||||
class TINYXML2_LIB StrPair
|
class TINYXML2_LIB StrPair
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum Mode {
|
||||||
NEEDS_ENTITY_PROCESSING = 0x01,
|
NEEDS_ENTITY_PROCESSING = 0x01,
|
||||||
NEEDS_NEWLINE_NORMALIZATION = 0x02,
|
NEEDS_NEWLINE_NORMALIZATION = 0x02,
|
||||||
NEEDS_WHITESPACE_COLLAPSING = 0x04,
|
NEEDS_WHITESPACE_COLLAPSING = 0x04,
|
||||||
|
@ -590,6 +591,11 @@ public:
|
||||||
|| ch == '-';
|
|| ch == '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static bool IsPrefixHex( const char* p) {
|
||||||
|
p = SkipWhiteSpace(p, 0);
|
||||||
|
return p && *p == '0' && ( *(p + 1) == 'x' || *(p + 1) == 'X');
|
||||||
|
}
|
||||||
|
|
||||||
inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
|
inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
|
||||||
if ( p == q ) {
|
if ( p == q ) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1451,6 +1457,10 @@ public:
|
||||||
return QueryFloatAttribute( name, value );
|
return QueryFloatAttribute( name, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XMLError QueryAttribute(const char* name, const char** value) const {
|
||||||
|
return QueryStringAttribute(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the named attribute to value.
|
/// Sets the named attribute to value.
|
||||||
void SetAttribute( const char* name, const char* value ) {
|
void SetAttribute( const char* name, const char* value ) {
|
||||||
XMLAttribute* a = FindOrCreateAttribute( name );
|
XMLAttribute* a = FindOrCreateAttribute( name );
|
||||||
|
@ -1478,7 +1488,7 @@ public:
|
||||||
XMLAttribute* a = FindOrCreateAttribute(name);
|
XMLAttribute* a = FindOrCreateAttribute(name);
|
||||||
a->SetAttribute(value);
|
a->SetAttribute(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the named attribute to value.
|
/// Sets the named attribute to value.
|
||||||
void SetAttribute( const char* name, bool value ) {
|
void SetAttribute( const char* name, bool value ) {
|
||||||
XMLAttribute* a = FindOrCreateAttribute( name );
|
XMLAttribute* a = FindOrCreateAttribute( name );
|
||||||
|
@ -1864,9 +1874,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void DeleteNode( XMLNode* node );
|
void DeleteNode( XMLNode* node );
|
||||||
|
|
||||||
void ClearError() {
|
/// Clears the error flags.
|
||||||
SetError(XML_SUCCESS, 0, 0);
|
void ClearError();
|
||||||
}
|
|
||||||
|
|
||||||
/// Return true if there was an error parsing the document.
|
/// Return true if there was an error parsing the document.
|
||||||
bool Error() const {
|
bool Error() const {
|
||||||
|
@ -2322,16 +2331,22 @@ protected:
|
||||||
the space and tabs used. A PrintSpace() override should call Print().
|
the space and tabs used. A PrintSpace() override should call Print().
|
||||||
*/
|
*/
|
||||||
virtual void PrintSpace( int depth );
|
virtual void PrintSpace( int depth );
|
||||||
void Print( const char* format, ... );
|
virtual void Print( const char* format, ... );
|
||||||
void Write( const char* data, size_t size );
|
virtual void Write( const char* data, size_t size );
|
||||||
inline void Write( const char* data ) { Write( data, strlen( data ) ); }
|
virtual void Putc( char ch );
|
||||||
void Putc( char ch );
|
|
||||||
|
inline void Write(const char* data) { Write(data, strlen(data)); }
|
||||||
|
|
||||||
void SealElementIfJustOpened();
|
void SealElementIfJustOpened();
|
||||||
bool _elementJustOpened;
|
bool _elementJustOpened;
|
||||||
DynArray< const char*, 10 > _stack;
|
DynArray< const char*, 10 > _stack;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
Prepares to write a new node. This includes sealing an element that was
|
||||||
|
just opened, and writing any whitespace necessary if not in compact mode.
|
||||||
|
*/
|
||||||
|
void PrepareForNewNode( bool compactMode );
|
||||||
void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
|
void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
|
||||||
|
|
||||||
bool _firstElement;
|
bool _firstElement;
|
||||||
|
|
Loading…
Reference in a new issue