Compare commits
174 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1977a7258c | ||
|
|
b53aaa885d | ||
|
|
245bee08d6 | ||
|
|
80647bde2e | ||
|
|
7265b763fc | ||
|
|
ed9aa5a48e | ||
|
|
33bb764d12 | ||
|
|
bab9b6d59c | ||
|
|
6f51c803a1 | ||
|
|
0f922e7c9a | ||
|
|
9fcb876d3b | ||
|
|
f12ece06fa | ||
|
|
023846628d | ||
|
|
1354ffabb6 | ||
|
|
aaa4ceab5e | ||
|
|
03824c305d | ||
|
|
6acc9a5469 | ||
|
|
b733c26bfe | ||
|
|
2875d842de | ||
|
|
e94bde04d2 | ||
|
|
ed7a7dc985 | ||
|
|
30bdc9735b | ||
|
|
9a5a48dbd2 | ||
|
|
38b49ae042 | ||
|
|
d95716bd79 | ||
|
|
22f34982dc | ||
|
|
74fb870c36 | ||
|
|
7e67bc89de | ||
|
|
ba7d9df976 | ||
|
|
bbaf1e1498 | ||
|
|
9f56e12c16 | ||
|
|
778b391286 | ||
|
|
d15686653a | ||
|
|
f802660f7d | ||
|
|
e4fe285427 | ||
|
|
b389252931 | ||
|
|
e53740ec6a | ||
|
|
257e11b25b | ||
|
|
3ae4f3eb3c | ||
|
|
3e0af3793e | ||
|
|
f547a99619 | ||
|
|
e28be7530c | ||
|
|
3cebdc4fac | ||
|
|
75b4e23957 | ||
|
|
6e504e9baf | ||
|
|
59946f6f1a | ||
|
|
625402a01f | ||
|
|
56223ddaea | ||
|
|
deccff765f | ||
|
|
7a7e5dc525 | ||
|
|
5ffa73e979 | ||
|
|
ea617f9380 | ||
|
|
74e394023a | ||
|
|
97476b7b9e | ||
|
|
b4e81b014e | ||
|
|
6d12b7bc3d | ||
|
|
5f06297230 | ||
|
|
9af6ccb3da | ||
|
|
78120c2a1e | ||
|
|
ac503ea88a | ||
|
|
20806ce4e4 | ||
|
|
e4bf6e360d | ||
|
|
4bcbf142a8 | ||
|
|
588bb8de49 | ||
|
|
ee525dba4d | ||
|
|
bb836dce57 | ||
|
|
69242c4b9b | ||
|
|
ffee345723 | ||
|
|
a092bc1f5a | ||
|
|
5b4a5169e3 | ||
|
|
eaddfd8768 | ||
|
|
4e5900c5e8 | ||
|
|
0b4bdd2a47 | ||
|
|
9fae869124 | ||
|
|
8b67d741d4 | ||
|
|
ebb0c8f904 | ||
|
|
7334f9efab | ||
|
|
cd011bc1b7 | ||
|
|
dbfdd8fdd5 | ||
|
|
ee2c46928e | ||
|
|
ed2a407a88 | ||
|
|
b38d29a8c5 | ||
|
|
e6a95ce50e | ||
|
|
f0e8fac4ee | ||
|
|
489e5f30a2 | ||
|
|
abb2d046d0 | ||
|
|
9bcd9c7674 | ||
|
|
e6328b81f7 | ||
|
|
a317bd66a6 | ||
|
|
5c5307013a | ||
|
|
1227d51ed0 | ||
|
|
7254cf7e57 | ||
|
|
ab37df8d67 | ||
|
|
2114e47453 | ||
|
|
18f5d7f133 | ||
|
|
2965880447 | ||
|
|
8a0006ceda | ||
|
|
f59e2d6a89 | ||
|
|
f5d1d9ead2 | ||
|
|
b2ec17dd5f | ||
|
|
a94fc98396 | ||
|
|
c82446c81e | ||
|
|
03494b189c | ||
|
|
575f190412 | ||
|
|
327d5c142e | ||
|
|
92e521b431 | ||
|
|
0b2c22bd46 | ||
|
|
c8ec6fcab4 | ||
|
|
08b40dd8a5 | ||
|
|
1cd7e7422c | ||
|
|
66d2a84715 | ||
|
|
97cfa03865 | ||
|
|
fa20b227a3 | ||
|
|
0826e9632f | ||
|
|
78eee7299f | ||
|
|
4de01a9489 | ||
|
|
f07b952296 | ||
|
|
99916599da | ||
|
|
d211bb1351 | ||
|
|
d048f1e8e3 | ||
|
|
0895e78549 | ||
|
|
097339a099 | ||
|
|
f2496f5824 | ||
|
|
853de8169b | ||
|
|
869f1487e2 | ||
|
|
6d202ff20e | ||
|
|
72bb0ecc39 | ||
|
|
9de541f465 | ||
|
|
b0776aeead | ||
|
|
9fb2b0f42c | ||
|
|
5321a0e21f | ||
|
|
c755667aa0 | ||
|
|
331596e83c | ||
|
|
cd8550c29c | ||
|
|
9f52ad5289 | ||
|
|
003368429f | ||
|
|
8f5d3f8e80 | ||
|
|
bb5ffac22d | ||
|
|
fb732f97d4 | ||
|
|
3659fe1d33 | ||
|
|
cf6d886903 | ||
|
|
e3225b1c64 | ||
|
|
30152836da | ||
|
|
83a6d8c373 | ||
|
|
d526944e3c | ||
|
|
b6b4e82626 | ||
|
|
59b9aaea43 | ||
|
|
ec19a0e513 | ||
|
|
b6ea923f0f | ||
|
|
63f3de1a3c | ||
|
|
dc50a31758 | ||
|
|
67a5bb0ac1 | ||
|
|
0b26702ac9 | ||
|
|
01578db56b | ||
|
|
2af5679b26 | ||
|
|
5657176b61 | ||
|
|
73c822c201 | ||
|
|
acb9c9c260 | ||
|
|
fca00d0ebc | ||
|
|
08e7f7be59 | ||
|
|
84bd9624c6 | ||
|
|
91d34a0989 | ||
|
|
cf33e37d25 | ||
|
|
d740b64044 | ||
|
|
500fb6aa21 | ||
|
|
ca5d684a2b | ||
|
|
6ee53e7d49 | ||
|
|
256adb6371 | ||
|
|
98112fcdba | ||
|
|
433f1272d4 | ||
|
|
b59ac45131 | ||
|
|
a0744c8dca | ||
|
|
8f7b87b323 | ||
|
|
268c683fbd |
@@ -10,8 +10,8 @@ include(GNUInstallDirs)
|
|||||||
################################
|
################################
|
||||||
# set lib version here
|
# set lib version here
|
||||||
|
|
||||||
set(GENERIC_LIB_VERSION "2.0.1")
|
set(GENERIC_LIB_VERSION "3.0.0")
|
||||||
set(GENERIC_LIB_SOVERSION "2")
|
set(GENERIC_LIB_SOVERSION "3")
|
||||||
|
|
||||||
|
|
||||||
################################
|
################################
|
||||||
@@ -46,33 +46,24 @@ endif(MSVC)
|
|||||||
|
|
||||||
################################
|
################################
|
||||||
# Add targets
|
# Add targets
|
||||||
set(BUILD_STATIC_LIBS ON CACHE BOOL "Set to ON to build static libraries")
|
option(BUILD_SHARED_LIBS "build shared or static libraries" ON)
|
||||||
if(BUILD_STATIC_LIBS)
|
add_library(tinyxml2 tinyxml2.cpp tinyxml2.h)
|
||||||
add_library(tinyxml2static STATIC tinyxml2.cpp tinyxml2.h)
|
|
||||||
set_target_properties(tinyxml2static PROPERTIES OUTPUT_NAME tinyxml2)
|
|
||||||
endif(BUILD_STATIC_LIBS)
|
|
||||||
add_library(tinyxml2 SHARED tinyxml2.cpp tinyxml2.h)
|
|
||||||
set_target_properties(tinyxml2 PROPERTIES
|
set_target_properties(tinyxml2 PROPERTIES
|
||||||
COMPILE_DEFINITIONS "TINYXML2_EXPORT"
|
COMPILE_DEFINITIONS "TINYXML2_EXPORT"
|
||||||
VERSION "${GENERIC_LIB_VERSION}"
|
VERSION "${GENERIC_LIB_VERSION}"
|
||||||
SOVERSION "${GENERIC_LIB_SOVERSION}")
|
SOVERSION "${GENERIC_LIB_SOVERSION}")
|
||||||
|
|
||||||
add_executable(test xmltest.cpp)
|
add_executable(xmltest xmltest.cpp)
|
||||||
add_dependencies(test tinyxml2)
|
add_dependencies(xmltest tinyxml2)
|
||||||
add_dependencies(test ${TARGET_DATA_COPY})
|
add_dependencies(xmltest ${TARGET_DATA_COPY})
|
||||||
target_link_libraries(test tinyxml2)
|
target_link_libraries(xmltest tinyxml2)
|
||||||
|
|
||||||
|
|
||||||
if(BUILD_STATIC_LIBS)
|
install(TARGETS tinyxml2
|
||||||
install(TARGETS tinyxml2 tinyxml2static
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
else(BUILD_STATIC_LIBS)
|
|
||||||
install(TARGETS tinyxml2
|
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
||||||
endif(BUILD_STATIC_LIBS)
|
|
||||||
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
|
|
||||||
foreach(p LIB INCLUDE)
|
foreach(p LIB INCLUDE)
|
||||||
@@ -85,4 +76,4 @@ endforeach()
|
|||||||
configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
|
configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
|
|
||||||
#add_test(test ${SAMPLE_NAME} COMMAND $<TARGET_FILE:${SAMPLE_NAME}>)
|
#add_test(xmltest ${SAMPLE_NAME} COMMAND $<TARGET_FILE:${SAMPLE_NAME}>)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 326 KiB After Width: | Height: | Size: 210 KiB |
@@ -269,6 +269,14 @@ an XCode project, a Code::Blocks project, and a cmake CMakeLists.txt included to
|
|||||||
The top of tinyxml.h even has a simple g++ command line if you are are *nix and don't want
|
The top of tinyxml.h even has a simple g++ command line if you are are *nix and don't want
|
||||||
to use a build system.
|
to use a build system.
|
||||||
|
|
||||||
|
Versioning
|
||||||
|
----------
|
||||||
|
|
||||||
|
TinyXML-2 uses semantic versioning. http://semver.org/ Releases are now tagged in github.
|
||||||
|
|
||||||
|
Note that the major version will (probably) change fairly rapidly. API changes are fairly
|
||||||
|
common.
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|||||||
@@ -116,3 +116,8 @@ print( "Release note:" )
|
|||||||
print( '1. Build. g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
|
print( '1. Build. g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
|
||||||
print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' )
|
print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' )
|
||||||
print( '3. Tag. git tag ' + versionStr )
|
print( '3. Tag. git tag ' + versionStr )
|
||||||
|
print( ' OR git tag -a ' + versionStr + ' -m [tag message]' )
|
||||||
|
print( 'Remember to "git push" both code and tag. For the tag:' )
|
||||||
|
print( 'git push origin [tagname]')
|
||||||
|
|
||||||
|
|
||||||
688
tinyxml2.cpp
688
tinyxml2.cpp
File diff suppressed because it is too large
Load Diff
208
tinyxml2.h
208
tinyxml2.h
@@ -14,7 +14,6 @@ not claim that you wrote the original software. If you use this
|
|||||||
software in a product, an acknowledgment in the product documentation
|
software in a product, an acknowledgment in the product documentation
|
||||||
would be appreciated but is not required.
|
would be appreciated but is not required.
|
||||||
|
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such, and
|
2. Altered source versions must be plainly marked as such, and
|
||||||
must not be misrepresented as being the original software.
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ distribution.
|
|||||||
#ifndef TINYXML2_INCLUDED
|
#ifndef TINYXML2_INCLUDED
|
||||||
#define TINYXML2_INCLUDED
|
#define TINYXML2_INCLUDED
|
||||||
|
|
||||||
#if defined(ANDROID_NDK) || defined(__BORLANDC__)
|
#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>
|
||||||
@@ -78,7 +77,8 @@ distribution.
|
|||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
# if defined(_MSC_VER)
|
# if defined(_MSC_VER)
|
||||||
# define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
|
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
|
||||||
|
# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
|
||||||
# elif defined (ANDROID_NDK)
|
# elif defined (ANDROID_NDK)
|
||||||
# include <android/log.h>
|
# include <android/log.h>
|
||||||
# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
|
# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
|
||||||
@@ -91,7 +91,7 @@ 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.
|
||||||
/*int _snprintf_s(
|
/*int _snprintf_s(
|
||||||
char *buffer,
|
char *buffer,
|
||||||
@@ -109,6 +109,9 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#define TIXML_SSCANF sscanf_s
|
#define TIXML_SSCANF sscanf_s
|
||||||
|
#elif defined WINCE
|
||||||
|
#define TIXML_SNPRINTF _snprintf
|
||||||
|
#define TIXML_SSCANF sscanf
|
||||||
#else
|
#else
|
||||||
// GCC version 3 and higher
|
// GCC version 3 and higher
|
||||||
//#warning( "Using sn* functions." )
|
//#warning( "Using sn* functions." )
|
||||||
@@ -119,9 +122,9 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
|||||||
/* Versioning, past 1.0.14:
|
/* Versioning, past 1.0.14:
|
||||||
http://semver.org/
|
http://semver.org/
|
||||||
*/
|
*/
|
||||||
static const int TIXML2_MAJOR_VERSION = 2;
|
static const int TIXML2_MAJOR_VERSION = 3;
|
||||||
static const int TIXML2_MINOR_VERSION = 0;
|
static const int TIXML2_MINOR_VERSION = 0;
|
||||||
static const int TIXML2_PATCH_VERSION = 1;
|
static const int TIXML2_PATCH_VERSION = 0;
|
||||||
|
|
||||||
namespace tinyxml2
|
namespace tinyxml2
|
||||||
{
|
{
|
||||||
@@ -182,6 +185,8 @@ public:
|
|||||||
char* ParseText( char* in, const char* endTag, int strFlags );
|
char* ParseText( char* in, const char* endTag, int strFlags );
|
||||||
char* ParseName( char* in );
|
char* ParseName( char* in );
|
||||||
|
|
||||||
|
void TransferTo( StrPair* other );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Reset();
|
void Reset();
|
||||||
void CollapseWhitespace();
|
void CollapseWhitespace();
|
||||||
@@ -195,6 +200,9 @@ private:
|
|||||||
int _flags;
|
int _flags;
|
||||||
char* _start;
|
char* _start;
|
||||||
char* _end;
|
char* _end;
|
||||||
|
|
||||||
|
StrPair( const StrPair& other ); // not supported
|
||||||
|
void operator=( StrPair& other ); // not supported, use TransferTo()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -207,7 +215,7 @@ template <class T, int INIT>
|
|||||||
class DynArray
|
class DynArray
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DynArray< T, INIT >() {
|
DynArray() {
|
||||||
_mem = _pool;
|
_mem = _pool;
|
||||||
_allocated = INIT;
|
_allocated = INIT;
|
||||||
_size = 0;
|
_size = 0;
|
||||||
@@ -224,11 +232,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Push( T t ) {
|
void Push( T t ) {
|
||||||
|
TIXMLASSERT( _size < INT_MAX );
|
||||||
EnsureCapacity( _size+1 );
|
EnsureCapacity( _size+1 );
|
||||||
_mem[_size++] = t;
|
_mem[_size++] = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* PushArr( int count ) {
|
T* PushArr( int count ) {
|
||||||
|
TIXMLASSERT( count >= 0 );
|
||||||
|
TIXMLASSERT( _size <= INT_MAX - count );
|
||||||
EnsureCapacity( _size+count );
|
EnsureCapacity( _size+count );
|
||||||
T* ret = &_mem[_size];
|
T* ret = &_mem[_size];
|
||||||
_size += count;
|
_size += count;
|
||||||
@@ -236,6 +247,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
T Pop() {
|
T Pop() {
|
||||||
|
TIXMLASSERT( _size > 0 );
|
||||||
return _mem[--_size];
|
return _mem[--_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,12 +270,13 @@ public:
|
|||||||
return _mem[i];
|
return _mem[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const T& PeekTop() const {
|
const T& PeekTop() const {
|
||||||
TIXMLASSERT( _size > 0 );
|
TIXMLASSERT( _size > 0 );
|
||||||
return _mem[ _size - 1];
|
return _mem[ _size - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Size() const {
|
int Size() const {
|
||||||
|
TIXMLASSERT( _size >= 0 );
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,8 +293,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
DynArray( const DynArray& ); // not supported
|
||||||
|
void operator=( const DynArray& ); // not supported
|
||||||
|
|
||||||
void EnsureCapacity( int cap ) {
|
void EnsureCapacity( int cap ) {
|
||||||
|
TIXMLASSERT( cap > 0 );
|
||||||
if ( cap > _allocated ) {
|
if ( cap > _allocated ) {
|
||||||
|
TIXMLASSERT( cap <= INT_MAX / 2 );
|
||||||
int newAllocated = cap * 2;
|
int newAllocated = cap * 2;
|
||||||
T* newMem = new T[newAllocated];
|
T* newMem = new T[newAllocated];
|
||||||
memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
|
memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
|
||||||
@@ -314,6 +332,7 @@ public:
|
|||||||
virtual void* Alloc() = 0;
|
virtual void* Alloc() = 0;
|
||||||
virtual void Free( void* ) = 0;
|
virtual void Free( void* ) = 0;
|
||||||
virtual void SetTracked() = 0;
|
virtual void SetTracked() = 0;
|
||||||
|
virtual void Clear() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -326,10 +345,20 @@ class MemPoolT : public MemPool
|
|||||||
public:
|
public:
|
||||||
MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
|
MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
|
||||||
~MemPoolT() {
|
~MemPoolT() {
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear() {
|
||||||
// Delete the blocks.
|
// Delete the blocks.
|
||||||
for( int i=0; i<_blockPtrs.Size(); ++i ) {
|
while( !_blockPtrs.Empty()) {
|
||||||
delete _blockPtrs[i];
|
Block* b = _blockPtrs.Pop();
|
||||||
|
delete b;
|
||||||
}
|
}
|
||||||
|
_root = 0;
|
||||||
|
_currentAllocs = 0;
|
||||||
|
_nAllocs = 0;
|
||||||
|
_maxAllocs = 0;
|
||||||
|
_nUntracked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int ItemSize() const {
|
virtual int ItemSize() const {
|
||||||
@@ -362,12 +391,13 @@ public:
|
|||||||
_nUntracked++;
|
_nUntracked++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Free( void* mem ) {
|
virtual void Free( void* mem ) {
|
||||||
if ( !mem ) {
|
if ( !mem ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
--_currentAllocs;
|
--_currentAllocs;
|
||||||
Chunk* chunk = (Chunk*)mem;
|
Chunk* chunk = static_cast<Chunk*>( mem );
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
memset( chunk, 0xfe, sizeof(Chunk) );
|
memset( chunk, 0xfe, sizeof(Chunk) );
|
||||||
#endif
|
#endif
|
||||||
@@ -399,6 +429,9 @@ public:
|
|||||||
enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
|
enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MemPoolT( const MemPoolT& ); // not supported
|
||||||
|
void operator=( const MemPoolT& ); // not supported
|
||||||
|
|
||||||
union Chunk {
|
union Chunk {
|
||||||
Chunk* next;
|
Chunk* next;
|
||||||
char mem[SIZE];
|
char mem[SIZE];
|
||||||
@@ -477,6 +510,33 @@ 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,
|
||||||
|
XML_ERROR_FILE_COULD_NOT_BE_OPENED,
|
||||||
|
XML_ERROR_FILE_READ_ERROR,
|
||||||
|
XML_ERROR_ELEMENT_MISMATCH,
|
||||||
|
XML_ERROR_PARSING_ELEMENT,
|
||||||
|
XML_ERROR_PARSING_ATTRIBUTE,
|
||||||
|
XML_ERROR_IDENTIFYING_TAG,
|
||||||
|
XML_ERROR_PARSING_TEXT,
|
||||||
|
XML_ERROR_PARSING_CDATA,
|
||||||
|
XML_ERROR_PARSING_COMMENT,
|
||||||
|
XML_ERROR_PARSING_DECLARATION,
|
||||||
|
XML_ERROR_PARSING_UNKNOWN,
|
||||||
|
XML_ERROR_EMPTY_DOCUMENT,
|
||||||
|
XML_ERROR_MISMATCHED_ELEMENT,
|
||||||
|
XML_ERROR_PARSING,
|
||||||
|
XML_CAN_NOT_CONVERT_TEXT,
|
||||||
|
XML_NO_TEXT_NODE,
|
||||||
|
|
||||||
|
XML_ERROR_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Utility functionality.
|
Utility functionality.
|
||||||
@@ -484,28 +544,33 @@ public:
|
|||||||
class XMLUtil
|
class XMLUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
|
|
||||||
// correct, but simple, and usually works.
|
|
||||||
static const char* SkipWhiteSpace( const char* p ) {
|
static const char* SkipWhiteSpace( const char* p ) {
|
||||||
while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
|
TIXMLASSERT( p );
|
||||||
|
while( IsWhiteSpace(*p) ) {
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
TIXMLASSERT( p );
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
static char* SkipWhiteSpace( char* p ) {
|
static char* SkipWhiteSpace( char* p ) {
|
||||||
while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) {
|
return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );
|
||||||
++p;
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
|
||||||
|
// correct, but simple, and usually works.
|
||||||
static bool IsWhiteSpace( char p ) {
|
static bool IsWhiteSpace( char p ) {
|
||||||
return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
|
return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static bool IsNameStartChar( unsigned char ch ) {
|
inline static bool IsNameStartChar( unsigned char ch ) {
|
||||||
return ( ( ch < 128 ) ? isalpha( ch ) : 1 )
|
if ( ch >= 128 ) {
|
||||||
|| ch == ':'
|
// This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
|
||||||
|| ch == '_';
|
return true;
|
||||||
|
}
|
||||||
|
if ( isalpha( ch ) ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return ch == ':' || ch == '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static bool IsNameChar( unsigned char ch ) {
|
inline static bool IsNameChar( unsigned char ch ) {
|
||||||
@@ -516,10 +581,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 ) {
|
||||||
int n = 0;
|
|
||||||
if ( p == q ) {
|
if ( p == q ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
int n = 0;
|
||||||
while( *p && *q && *p == *q && n<nChar ) {
|
while( *p && *q && *p == *q && n<nChar ) {
|
||||||
++p;
|
++p;
|
||||||
++q;
|
++q;
|
||||||
@@ -531,8 +596,8 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static int IsUTF8Continuation( const char p ) {
|
inline static bool IsUTF8Continuation( const char p ) {
|
||||||
return p & 0x80;
|
return ( p & 0x80 ) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ReadBOM( const char* p, bool* hasBOM );
|
static const char* ReadBOM( const char* p, bool* hasBOM );
|
||||||
@@ -828,8 +893,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
XMLNode( XMLDocument* );
|
XMLNode( XMLDocument* );
|
||||||
virtual ~XMLNode();
|
virtual ~XMLNode();
|
||||||
XMLNode( const XMLNode& ); // not supported
|
|
||||||
XMLNode& operator=( const XMLNode& ); // not supported
|
|
||||||
|
|
||||||
XMLDocument* _document;
|
XMLDocument* _document;
|
||||||
XMLNode* _parent;
|
XMLNode* _parent;
|
||||||
@@ -844,6 +907,11 @@ protected:
|
|||||||
private:
|
private:
|
||||||
MemPool* _memPool;
|
MemPool* _memPool;
|
||||||
void Unlink( XMLNode* child );
|
void Unlink( XMLNode* child );
|
||||||
|
static void DeleteNode( XMLNode* node );
|
||||||
|
void InsertChildPreamble( XMLNode* insertThis ) const;
|
||||||
|
|
||||||
|
XMLNode( const XMLNode& ); // not supported
|
||||||
|
XMLNode& operator=( const XMLNode& ); // not supported
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -889,11 +957,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
|
XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
|
||||||
virtual ~XMLText() {}
|
virtual ~XMLText() {}
|
||||||
XMLText( const XMLText& ); // not supported
|
|
||||||
XMLText& operator=( const XMLText& ); // not supported
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _isCData;
|
bool _isCData;
|
||||||
|
|
||||||
|
XMLText( const XMLText& ); // not supported
|
||||||
|
XMLText& operator=( const XMLText& ); // not supported
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -918,10 +987,10 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
XMLComment( XMLDocument* doc );
|
XMLComment( XMLDocument* doc );
|
||||||
virtual ~XMLComment();
|
virtual ~XMLComment();
|
||||||
XMLComment( const XMLComment& ); // not supported
|
|
||||||
XMLComment& operator=( const XMLComment& ); // not supported
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
XMLComment( const XMLComment& ); // not supported
|
||||||
|
XMLComment& operator=( const XMLComment& ); // not supported
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -956,6 +1025,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
XMLDeclaration( XMLDocument* doc );
|
XMLDeclaration( XMLDocument* doc );
|
||||||
virtual ~XMLDeclaration();
|
virtual ~XMLDeclaration();
|
||||||
|
|
||||||
|
private:
|
||||||
XMLDeclaration( const XMLDeclaration& ); // not supported
|
XMLDeclaration( const XMLDeclaration& ); // not supported
|
||||||
XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
|
XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
|
||||||
};
|
};
|
||||||
@@ -988,38 +1059,13 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
XMLUnknown( XMLDocument* doc );
|
XMLUnknown( XMLDocument* doc );
|
||||||
virtual ~XMLUnknown();
|
virtual ~XMLUnknown();
|
||||||
|
|
||||||
|
private:
|
||||||
XMLUnknown( const XMLUnknown& ); // not supported
|
XMLUnknown( const XMLUnknown& ); // not supported
|
||||||
XMLUnknown& operator=( const XMLUnknown& ); // not supported
|
XMLUnknown& operator=( const XMLUnknown& ); // not supported
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum XMLError {
|
|
||||||
XML_NO_ERROR = 0,
|
|
||||||
XML_SUCCESS = 0,
|
|
||||||
|
|
||||||
XML_NO_ATTRIBUTE,
|
|
||||||
XML_WRONG_ATTRIBUTE_TYPE,
|
|
||||||
|
|
||||||
XML_ERROR_FILE_NOT_FOUND,
|
|
||||||
XML_ERROR_FILE_COULD_NOT_BE_OPENED,
|
|
||||||
XML_ERROR_FILE_READ_ERROR,
|
|
||||||
XML_ERROR_ELEMENT_MISMATCH,
|
|
||||||
XML_ERROR_PARSING_ELEMENT,
|
|
||||||
XML_ERROR_PARSING_ATTRIBUTE,
|
|
||||||
XML_ERROR_IDENTIFYING_TAG,
|
|
||||||
XML_ERROR_PARSING_TEXT,
|
|
||||||
XML_ERROR_PARSING_CDATA,
|
|
||||||
XML_ERROR_PARSING_COMMENT,
|
|
||||||
XML_ERROR_PARSING_DECLARATION,
|
|
||||||
XML_ERROR_PARSING_UNKNOWN,
|
|
||||||
XML_ERROR_EMPTY_DOCUMENT,
|
|
||||||
XML_ERROR_MISMATCHED_ELEMENT,
|
|
||||||
XML_ERROR_PARSING,
|
|
||||||
|
|
||||||
XML_CAN_NOT_CONVERT_TEXT,
|
|
||||||
XML_NO_TEXT_NODE
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** An attribute is a name-value pair. Elements have an arbitrary
|
/** An attribute is a name-value pair. Elements have an arbitrary
|
||||||
number of attributes, each with a unique name.
|
number of attributes, each with a unique name.
|
||||||
@@ -1473,10 +1519,13 @@ private:
|
|||||||
XMLElement( const XMLElement& ); // not supported
|
XMLElement( const XMLElement& ); // not supported
|
||||||
void operator=( const XMLElement& ); // not supported
|
void operator=( const XMLElement& ); // not supported
|
||||||
|
|
||||||
XMLAttribute* FindAttribute( const char* name );
|
XMLAttribute* FindAttribute( const char* name ) {
|
||||||
|
return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));
|
||||||
|
}
|
||||||
XMLAttribute* FindOrCreateAttribute( const char* name );
|
XMLAttribute* FindOrCreateAttribute( const char* name );
|
||||||
//void LinkAttribute( XMLAttribute* attrib );
|
//void LinkAttribute( XMLAttribute* attrib );
|
||||||
char* ParseAttributes( char* p );
|
char* ParseAttributes( char* p );
|
||||||
|
static void DeleteAttribute( XMLAttribute* attribute );
|
||||||
|
|
||||||
enum { BUF_SIZE = 200 };
|
enum { BUF_SIZE = 200 };
|
||||||
int _closingType;
|
int _closingType;
|
||||||
@@ -1536,6 +1585,10 @@ public:
|
|||||||
Load an XML file from disk. You are responsible
|
Load an XML file from disk. You are responsible
|
||||||
for providing and closing the FILE*.
|
for providing and closing the FILE*.
|
||||||
|
|
||||||
|
NOTE: The file should be opened as binary ("rb")
|
||||||
|
not text in order for TinyXML-2 to correctly
|
||||||
|
do newline normalization.
|
||||||
|
|
||||||
Returns XML_NO_ERROR (0) on success, or
|
Returns XML_NO_ERROR (0) on success, or
|
||||||
an errorID.
|
an errorID.
|
||||||
*/
|
*/
|
||||||
@@ -1644,9 +1697,7 @@ public:
|
|||||||
Delete a node associated with this document.
|
Delete a node associated with this document.
|
||||||
It will be unlinked from the DOM.
|
It will be unlinked from the DOM.
|
||||||
*/
|
*/
|
||||||
void DeleteNode( XMLNode* node ) {
|
void DeleteNode( XMLNode* node );
|
||||||
node->_parent->DeleteChild( node );
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetError( XMLError error, const char* str1, const char* str2 );
|
void SetError( XMLError error, const char* str1, const char* str2 );
|
||||||
|
|
||||||
@@ -1658,6 +1709,8 @@ public:
|
|||||||
XMLError ErrorID() const {
|
XMLError ErrorID() const {
|
||||||
return _errorID;
|
return _errorID;
|
||||||
}
|
}
|
||||||
|
const char* ErrorName() const;
|
||||||
|
|
||||||
/// Return a possibly helpful diagnostic location or string.
|
/// Return a possibly helpful diagnostic location or string.
|
||||||
const char* GetErrorStr1() const {
|
const char* GetErrorStr1() const {
|
||||||
return _errorStr1;
|
return _errorStr1;
|
||||||
@@ -1698,6 +1751,10 @@ private:
|
|||||||
MemPoolT< sizeof(XMLAttribute) > _attributePool;
|
MemPoolT< sizeof(XMLAttribute) > _attributePool;
|
||||||
MemPoolT< sizeof(XMLText) > _textPool;
|
MemPoolT< sizeof(XMLText) > _textPool;
|
||||||
MemPoolT< sizeof(XMLComment) > _commentPool;
|
MemPoolT< sizeof(XMLComment) > _commentPool;
|
||||||
|
|
||||||
|
static const char* _errorNames[XML_ERROR_COUNT];
|
||||||
|
|
||||||
|
void Parse();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1741,7 +1798,7 @@ private:
|
|||||||
|
|
||||||
@verbatim
|
@verbatim
|
||||||
XMLHandle docHandle( &document );
|
XMLHandle docHandle( &document );
|
||||||
XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
|
XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement();
|
||||||
if ( child2 )
|
if ( child2 )
|
||||||
{
|
{
|
||||||
// do something useful
|
// do something useful
|
||||||
@@ -1816,19 +1873,19 @@ public:
|
|||||||
}
|
}
|
||||||
/// Safe cast to XMLElement. This can return null.
|
/// Safe cast to XMLElement. This can return null.
|
||||||
XMLElement* ToElement() {
|
XMLElement* ToElement() {
|
||||||
return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToElement() );
|
||||||
}
|
}
|
||||||
/// Safe cast to XMLText. This can return null.
|
/// Safe cast to XMLText. This can return null.
|
||||||
XMLText* ToText() {
|
XMLText* ToText() {
|
||||||
return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToText() );
|
||||||
}
|
}
|
||||||
/// Safe cast to XMLUnknown. This can return null.
|
/// Safe cast to XMLUnknown. This can return null.
|
||||||
XMLUnknown* ToUnknown() {
|
XMLUnknown* ToUnknown() {
|
||||||
return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
|
||||||
}
|
}
|
||||||
/// Safe cast to XMLDeclaration. This can return null.
|
/// Safe cast to XMLDeclaration. This can return null.
|
||||||
XMLDeclaration* ToDeclaration() {
|
XMLDeclaration* ToDeclaration() {
|
||||||
return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1888,16 +1945,16 @@ public:
|
|||||||
return _node;
|
return _node;
|
||||||
}
|
}
|
||||||
const XMLElement* ToElement() const {
|
const XMLElement* ToElement() const {
|
||||||
return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToElement() );
|
||||||
}
|
}
|
||||||
const XMLText* ToText() const {
|
const XMLText* ToText() const {
|
||||||
return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToText() );
|
||||||
}
|
}
|
||||||
const XMLUnknown* ToUnknown() const {
|
const XMLUnknown* ToUnknown() const {
|
||||||
return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
|
||||||
}
|
}
|
||||||
const XMLDeclaration* ToDeclaration() const {
|
const XMLDeclaration* ToDeclaration() const {
|
||||||
return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
|
return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1964,7 +2021,7 @@ public:
|
|||||||
/** If streaming, start writing an element.
|
/** If streaming, start writing an element.
|
||||||
The element must be closed with CloseElement()
|
The element must be closed with CloseElement()
|
||||||
*/
|
*/
|
||||||
void OpenElement( const char* name, bool compactMode );
|
void OpenElement( const char* name, bool compactMode=false );
|
||||||
/// If streaming, add an attribute to an open element.
|
/// If streaming, add an attribute to an open element.
|
||||||
void PushAttribute( const char* name, const char* value );
|
void PushAttribute( const char* name, const char* value );
|
||||||
void PushAttribute( const char* name, int value );
|
void PushAttribute( const char* name, int value );
|
||||||
@@ -1972,7 +2029,7 @@ public:
|
|||||||
void PushAttribute( const char* name, bool value );
|
void PushAttribute( const char* name, bool value );
|
||||||
void PushAttribute( const char* name, double value );
|
void PushAttribute( const char* name, double value );
|
||||||
/// If streaming, close the Element.
|
/// If streaming, close the Element.
|
||||||
virtual void CloseElement( bool compactMode );
|
virtual void CloseElement( bool compactMode=false );
|
||||||
|
|
||||||
/// Add a text node.
|
/// Add a text node.
|
||||||
void PushText( const char* text, bool cdata=false );
|
void PushText( const char* text, bool cdata=false );
|
||||||
@@ -2031,7 +2088,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool CompactMode( const XMLElement& ) { return _compactMode; };
|
virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
|
||||||
|
|
||||||
/** Prints out the space before an element. You may override to change
|
/** Prints out the space before an element. You may override to change
|
||||||
the space and tabs used. A PrintSpace() override should call Print().
|
the space and tabs used. A PrintSpace() override should call Print().
|
||||||
@@ -2039,7 +2096,7 @@ protected:
|
|||||||
virtual void PrintSpace( int depth );
|
virtual void PrintSpace( int depth );
|
||||||
void Print( const char* format, ... );
|
void Print( const char* format, ... );
|
||||||
|
|
||||||
void SealElement();
|
void SealElementIfJustOpened();
|
||||||
bool _elementJustOpened;
|
bool _elementJustOpened;
|
||||||
DynArray< const char*, 10 > _stack;
|
DynArray< const char*, 10 > _stack;
|
||||||
|
|
||||||
@@ -2061,9 +2118,6 @@ private:
|
|||||||
bool _restrictedEntityFlag[ENTITY_RANGE];
|
bool _restrictedEntityFlag[ENTITY_RANGE];
|
||||||
|
|
||||||
DynArray< char, 20 > _buffer;
|
DynArray< char, 20 > _buffer;
|
||||||
#ifdef _MSC_VER
|
|
||||||
DynArray< char, 20 > _accumulator;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,9 @@
|
|||||||
/* Begin PBXProject section */
|
/* Begin PBXProject section */
|
||||||
037AE058151CCC5200E0F29F /* Project object */ = {
|
037AE058151CCC5200E0F29F /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0610;
|
||||||
|
};
|
||||||
buildConfigurationList = 037AE05B151CCC5200E0F29F /* Build configuration list for PBXProject "tinyxml2" */;
|
buildConfigurationList = 037AE05B151CCC5200E0F29F /* Build configuration list for PBXProject "tinyxml2" */;
|
||||||
compatibilityVersion = "Xcode 3.2";
|
compatibilityVersion = "Xcode 3.2";
|
||||||
developmentRegion = English;
|
developmentRegion = English;
|
||||||
@@ -134,6 +137,8 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
CONFIGURATION_BUILD_DIR = "$(SYMROOT)/Debug";
|
CONFIGURATION_BUILD_DIR = "$(SYMROOT)/Debug";
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
|
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = DEBUG;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SYMROOT = build;
|
SYMROOT = build;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@@ -156,6 +161,7 @@
|
|||||||
GCC_MODEL_TUNING = G5;
|
GCC_MODEL_TUNING = G5;
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
INSTALL_PATH = /usr/local/bin;
|
INSTALL_PATH = /usr/local/bin;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = "";
|
||||||
PREBINDING = NO;
|
PREBINDING = NO;
|
||||||
PRODUCT_NAME = xmltest;
|
PRODUCT_NAME = xmltest;
|
||||||
};
|
};
|
||||||
@@ -171,6 +177,7 @@
|
|||||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||||
GCC_MODEL_TUNING = G5;
|
GCC_MODEL_TUNING = G5;
|
||||||
INSTALL_PATH = /usr/local/bin;
|
INSTALL_PATH = /usr/local/bin;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = "";
|
||||||
PREBINDING = NO;
|
PREBINDING = NO;
|
||||||
PRODUCT_NAME = tinyxml2;
|
PRODUCT_NAME = tinyxml2;
|
||||||
ZERO_LINK = NO;
|
ZERO_LINK = NO;
|
||||||
|
|||||||
74
xmltest.cpp
74
xmltest.cpp
@@ -1,5 +1,7 @@
|
|||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
#define _CRT_SECURE_NO_WARNINGS // This test file is not intended to be secure.
|
#if !defined( _CRT_SECURE_NO_WARNINGS )
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS // This test file is not intended to be secure.
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
@@ -21,6 +23,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
|
using namespace std;
|
||||||
int gPass = 0;
|
int gPass = 0;
|
||||||
int gFail = 0;
|
int gFail = 0;
|
||||||
|
|
||||||
@@ -277,6 +280,8 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
#if defined( _MSC_VER ) && defined( DEBUG )
|
#if defined( _MSC_VER ) && defined( DEBUG )
|
||||||
_CrtMemCheckpoint( &startMemState );
|
_CrtMemCheckpoint( &startMemState );
|
||||||
|
// Enable MS Visual C++ debug heap memory leaks dump on exit
|
||||||
|
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(MINGW32) || defined(__MINGW32__)
|
#if defined(_MSC_VER) || defined(MINGW32) || defined(__MINGW32__)
|
||||||
@@ -290,14 +295,18 @@ int main( int argc, const char ** argv )
|
|||||||
mkdir( "resources/out/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
mkdir( "resources/out/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
TIXMLASSERT( true );
|
||||||
|
}
|
||||||
|
|
||||||
if ( argc > 1 ) {
|
if ( argc > 1 ) {
|
||||||
XMLDocument* doc = new XMLDocument();
|
XMLDocument* doc = new XMLDocument();
|
||||||
clock_t startTime = clock();
|
clock_t startTime = clock();
|
||||||
doc->LoadFile( argv[1] );
|
doc->LoadFile( argv[1] );
|
||||||
clock_t loadTime = clock();
|
clock_t loadTime = clock();
|
||||||
int errorID = doc->ErrorID();
|
int errorID = doc->ErrorID();
|
||||||
delete doc; doc = 0;
|
delete doc; doc = 0;
|
||||||
clock_t deleteTime = clock();
|
clock_t deleteTime = clock();
|
||||||
|
|
||||||
printf( "Test file '%s' loaded. ErrorID=%d\n", argv[1], errorID );
|
printf( "Test file '%s' loaded. ErrorID=%d\n", argv[1], errorID );
|
||||||
if ( !errorID ) {
|
if ( !errorID ) {
|
||||||
@@ -858,12 +867,20 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Empty documents should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717
|
// Empty documents should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717
|
||||||
const char* str = " ";
|
const char* str = "";
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( str );
|
doc.Parse( str );
|
||||||
XMLTest( "Empty document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
|
XMLTest( "Empty document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Documents with all whitespaces should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717
|
||||||
|
const char* str = " ";
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse( str );
|
||||||
|
XMLTest( "All whitespaces document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Low entities
|
// Low entities
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
@@ -1151,6 +1168,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.LoadFile( "resources/dream.xml" );
|
doc.LoadFile( "resources/dream.xml" );
|
||||||
|
XMLTest( "Document has something to Clear()", doc.NoChildren(), false );
|
||||||
doc.Clear();
|
doc.Clear();
|
||||||
XMLTest( "Document Clear()'s", doc.NoChildren(), true );
|
XMLTest( "Document Clear()'s", doc.NoChildren(), true );
|
||||||
}
|
}
|
||||||
@@ -1220,6 +1238,8 @@ int main( int argc, const char ** argv )
|
|||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
XMLError error = doc.LoadFile( "resources/empty.xml" );
|
XMLError error = doc.LoadFile( "resources/empty.xml" );
|
||||||
XMLTest( "Loading an empty file", XML_ERROR_EMPTY_DOCUMENT, error );
|
XMLTest( "Loading an empty file", XML_ERROR_EMPTY_DOCUMENT, error );
|
||||||
|
XMLTest( "Loading an empty file and ErrorName as string", "XML_ERROR_EMPTY_DOCUMENT", doc.ErrorName() );
|
||||||
|
doc.PrintError();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -1325,6 +1345,14 @@ int main( int argc, const char ** argv )
|
|||||||
doc.Print();
|
doc.Print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Test that it doesn't crash.
|
||||||
|
const char* xml = "<?xml version=\"1.0\"?><root><sample><field0><1</field0><field1>2</field1></sample></root>";
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse(xml);
|
||||||
|
doc.PrintError();
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// the question being explored is what kind of print to use:
|
// the question being explored is what kind of print to use:
|
||||||
// https://github.com/leethomason/tinyxml2/issues/63
|
// https://github.com/leethomason/tinyxml2/issues/63
|
||||||
@@ -1360,7 +1388,43 @@ int main( int argc, const char ** argv )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
// Issue #184
|
||||||
|
// If it doesn't assert, it passes. Caused by objects
|
||||||
|
// getting created during parsing which are then
|
||||||
|
// inaccessible in the memory pools.
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>");
|
||||||
|
doc.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// If this doesn't assert in DEBUG, all is well.
|
||||||
|
tinyxml2::XMLDocument doc;
|
||||||
|
tinyxml2::XMLElement *pRoot = doc.NewElement("Root");
|
||||||
|
doc.DeleteNode(pRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Should not assert in DEBUG
|
||||||
|
XMLPrinter printer;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Issue 291. Should not crash
|
||||||
|
const char* xml = "�</a>";
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse( xml );
|
||||||
|
|
||||||
|
XMLPrinter printer;
|
||||||
|
doc.Print( &printer );
|
||||||
|
}
|
||||||
|
|
||||||
// ----------- Performance tracking --------------
|
// ----------- Performance tracking --------------
|
||||||
{
|
{
|
||||||
@@ -1413,12 +1477,10 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
#if defined( _MSC_VER ) && defined( DEBUG )
|
#if defined( _MSC_VER ) && defined( DEBUG )
|
||||||
_CrtMemCheckpoint( &endMemState );
|
_CrtMemCheckpoint( &endMemState );
|
||||||
//_CrtMemDumpStatistics( &endMemState );
|
|
||||||
|
|
||||||
_CrtMemState diffMemState;
|
_CrtMemState diffMemState;
|
||||||
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
|
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
|
||||||
_CrtMemDumpStatistics( &diffMemState );
|
_CrtMemDumpStatistics( &diffMemState );
|
||||||
//printf( "new total=%d\n", gNewTotal );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
||||||
|
|||||||
Reference in New Issue
Block a user