1
0
mirror of https://github.com/leethomason/tinyxml2.git synced 2026-07-29 15:13:01 +04:00

Compare commits

..

5 Commits

Author SHA1 Message Date
Lee Thomason 118358092a remove the c code path 2025-11-22 15:59:12 -08:00
Lee Thomason 888bbb912a Merge branch 'MattHuangGarmin-master' into leethomason/fallthrough 2025-11-22 15:47:41 -08:00
Lee Thomason 9c09e46619 move to cpp file 2025-11-22 15:46:45 -08:00
Lee Thomason 6d6285b18a Merge branch 'master' of github.com:MattHuangGarmin/tinyxml2 into MattHuangGarmin-master 2025-11-22 15:44:05 -08:00
MattHuangGarmin be7b5a107f Fix GCC 4.9.3 Build Errors
Since GCC version 4.9.3 does not support the -Wimplicit-fallthrough warning option or the __attribute__((fallthrough)) annotation,
introduce the corresponding fixes to prevent build errors.
2025-11-04 14:40:21 +08:00
3 changed files with 57 additions and 15 deletions
+4 -4
View File
@@ -59,7 +59,7 @@ browsers or have more complete XML needs, TinyXML-2 is not the parser for you.
TinyXML-1 vs. TinyXML-2 TinyXML-1 vs. TinyXML-2
----------------------- -----------------------
TinyXML-2 has long been the focus of all development. It is well tested TinyXML-2 long been the focus of all development. It is well tested
and should be used instead of TinyXML-1. and should be used instead of TinyXML-1.
TinyXML-2 uses a similar API to TinyXML-1 and the same TinyXML-2 uses a similar API to TinyXML-1 and the same
@@ -145,7 +145,7 @@ It essentially causes the XML to be parsed twice.
For applications that need to know about text nodes that are composed entirely of For applications that need to know about text nodes that are composed entirely of
whitespace, PEDANTIC_WHITESPACE is available. PEDANTIC_WHITESPACE maintains all the whitespace, PEDANTIC_WHITESPACE is available. PEDANTIC_WHITESPACE maintains all the
whitespace between elements. whilespace between elements.
PEDANTIC_WHITESPACE is a new mode and not as tested as the other whitespace modes. PEDANTIC_WHITESPACE is a new mode and not as tested as the other whitespace modes.
@@ -178,7 +178,7 @@ will have the Value() of "Far & Away" when queried from the XMLText object,
and will be written back to the XML stream/file as an ampersand. and will be written back to the XML stream/file as an ampersand.
Additionally, any character can be specified by its Unicode code point: Additionally, any character can be specified by its Unicode code point:
The syntax ` ` or ` ` both refer to the non-breaking space character. The syntax ` ` or ` ` are both to the non-breaking space character.
This is called a 'numeric character reference'. Any numeric character reference This is called a 'numeric character reference'. Any numeric character reference
that isn't one of the special entities above, will be read, but written as a that isn't one of the special entities above, will be read, but written as a
regular code point. The output is correct, but the entity syntax isn't preserved. regular code point. The output is correct, but the entity syntax isn't preserved.
@@ -270,7 +270,7 @@ tinyxml2.h files in your project and build with your other source code.
There is also a CMake build included. CMake is the general build for TinyXML-2. There is also a CMake build included. CMake is the general build for TinyXML-2.
(Additional build systems are costly to maintain, and tend to become outdated. They are (Additional build systems are costly to maintain, and tend to bit-rot. They are
being removed over time.) being removed over time.)
Building TinyXML-2 - Using vcpkg Building TinyXML-2 - Using vcpkg
+41 -10
View File
@@ -24,7 +24,7 @@ distribution.
#include "tinyxml2.h" #include "tinyxml2.h"
#include <new> // yes, this one new style header, is in the Android SDK. #include <new> // yes, this one new style header, is in the Android SDK.
#if defined(ANDROID_NDK) #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) || defined(__CC_ARM)
# include <stddef.h> # include <stddef.h>
# include <stdarg.h> # include <stdarg.h>
#else #else
@@ -40,7 +40,9 @@ distribution.
# define __has_cpp_attribute(x) 0 # define __has_cpp_attribute(x) 0
#endif #endif
#if (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough)) #if defined(_MSC_VER)
# define TIXML_FALLTHROUGH (void(0))
#elif (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
# define TIXML_FALLTHROUGH [[fallthrough]] # define TIXML_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough) #elif __has_cpp_attribute(clang::fallthrough)
# define TIXML_FALLTHROUGH [[clang::fallthrough]] # define TIXML_FALLTHROUGH [[clang::fallthrough]]
@@ -51,8 +53,15 @@ distribution.
#endif #endif
#if defined(_MSC_VER) && (_MSC_VER >= 1400) #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
// Microsoft Visual Studio, version 2005 and higher. // Microsoft Visual Studio, version 2005 and higher. Not WinCE.
/*int _snprintf_s(
char *buffer,
size_t sizeOfBuffer,
size_t count,
const char *format [,
argument] ...
);*/
static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
{ {
va_list va; va_list va;
@@ -71,11 +80,33 @@ distribution.
#define TIXML_VSCPRINTF _vscprintf #define TIXML_VSCPRINTF _vscprintf
#define TIXML_SSCANF sscanf_s #define TIXML_SSCANF sscanf_s
#elif defined _MSC_VER #elif defined _MSC_VER
// Microsoft Visual Studio 2003 and earlier. // Microsoft Visual Studio 2003 and earlier or WinCE
#define TIXML_SNPRINTF _snprintf #define TIXML_SNPRINTF _snprintf
#define TIXML_VSNPRINTF _vsnprintf #define TIXML_VSNPRINTF _vsnprintf
#define TIXML_SSCANF sscanf #define TIXML_SSCANF sscanf
#define TIXML_VSCPRINTF _vscprintf #if (_MSC_VER < 1400 ) && (!defined WINCE)
// Microsoft Visual Studio 2003 and not WinCE.
#define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.
#else
// Microsoft Visual Studio 2003 and earlier or WinCE.
static inline int TIXML_VSCPRINTF( const char* format, va_list va )
{
int len = 512;
for (;;) {
len = len*2;
char* str = new char[len]();
const int required = _vsnprintf(str, len, format, va);
delete[] str;
if ( required != -1 ) {
TIXMLASSERT( required >= 0 );
len = required;
break;
}
}
TIXMLASSERT( len >= 0 );
return len;
}
#endif
#else #else
// GCC version 3 and higher // GCC version 3 and higher
//#warning( "Using sn* functions." ) //#warning( "Using sn* functions." )
@@ -90,7 +121,7 @@ distribution.
#define TIXML_SSCANF sscanf #define TIXML_SSCANF sscanf
#endif #endif
#if defined(_MSC_VER) #if defined(_WIN64)
#define TIXML_FSEEK _fseeki64 #define TIXML_FSEEK _fseeki64
#define TIXML_FTELL _ftelli64 #define TIXML_FTELL _ftelli64
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__CYGWIN__) #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__CYGWIN__)
@@ -2226,7 +2257,7 @@ void XMLDocument::Clear()
delete [] _charBuffer; delete [] _charBuffer;
_charBuffer = 0; _charBuffer = 0;
_parsingDepth = 0; _parsingDepth = 0;
#if 0 #if 0
_textPool.Trace( "text" ); _textPool.Trace( "text" );
_elementPool.Trace( "element" ); _elementPool.Trace( "element" );
@@ -2301,7 +2332,7 @@ static FILE* callfopen( const char* filepath, const char* mode )
{ {
TIXMLASSERT( filepath ); TIXMLASSERT( filepath );
TIXMLASSERT( mode ); TIXMLASSERT( mode );
#if defined(_MSC_VER) && (_MSC_VER >= 1400) #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
FILE* fp = 0; FILE* fp = 0;
const errno_t err = fopen_s( &fp, filepath, mode ); const errno_t err = fopen_s( &fp, filepath, mode );
if ( err ) { if ( err ) {
@@ -2625,7 +2656,7 @@ void XMLPrinter::Write( const char* data, size_t size )
fwrite ( data , sizeof(char), size, _fp); fwrite ( data , sizeof(char), size, _fp);
} }
else { else {
char* p = _buffer.PushArr( size ) - 1; // back up over the null terminator. char* p = _buffer.PushArr( static_cast<int>(size) ) - 1; // back up over the null terminator.
memcpy( p, data, size ); memcpy( p, data, size );
p[size] = 0; p[size] = 0;
} }
+12 -1
View File
@@ -24,12 +24,15 @@ distribution.
#ifndef TINYXML2_INCLUDED #ifndef TINYXML2_INCLUDED
#define TINYXML2_INCLUDED #define TINYXML2_INCLUDED
#if defined(ANDROID_NDK) #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
# include <ctype.h> # include <ctype.h>
# include <limits.h> # include <limits.h>
# include <stdio.h> # include <stdio.h>
# include <stdlib.h> # include <stdlib.h>
# include <string.h> # include <string.h>
# if defined(__PS3__)
# include <stddef.h>
# endif
#else #else
# include <cctype> # include <cctype>
# include <climits> # include <climits>
@@ -39,6 +42,14 @@ distribution.
#endif #endif
#include <stdint.h> #include <stdint.h>
/*
gcc:
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__) #if defined( _DEBUG ) || defined (__DEBUG__)
# ifndef TINYXML2_DEBUG # ifndef TINYXML2_DEBUG
# define TINYXML2_DEBUG # define TINYXML2_DEBUG