goat3d

diff libs/tinyxml2/tinyxml2.h @ 73:9862541fdcf5

- build qt goatview on linux - fixed line endings in a bunch of files
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 May 2014 03:57:11 +0300
parents b35427826b60
children
line diff
     1.1 --- a/libs/tinyxml2/tinyxml2.h	Tue May 06 03:31:35 2014 +0300
     1.2 +++ b/libs/tinyxml2/tinyxml2.h	Tue May 06 03:57:11 2014 +0300
     1.3 @@ -1,1987 +1,1987 @@
     1.4 -/*
     1.5 -Original code by Lee Thomason (www.grinninglizard.com)
     1.6 -
     1.7 -This software is provided 'as-is', without any express or implied
     1.8 -warranty. In no event will the authors be held liable for any
     1.9 -damages arising from the use of this software.
    1.10 -
    1.11 -Permission is granted to anyone to use this software for any
    1.12 -purpose, including commercial applications, and to alter it and
    1.13 -redistribute it freely, subject to the following restrictions:
    1.14 -
    1.15 -1. The origin of this software must not be misrepresented; you must
    1.16 -not claim that you wrote the original software. If you use this
    1.17 -software in a product, an acknowledgment in the product documentation
    1.18 -would be appreciated but is not required.
    1.19 -
    1.20 -
    1.21 -2. Altered source versions must be plainly marked as such, and
    1.22 -must not be misrepresented as being the original software.
    1.23 -
    1.24 -3. This notice may not be removed or altered from any source
    1.25 -distribution.
    1.26 -*/
    1.27 -
    1.28 -#ifndef TINYXML2_INCLUDED
    1.29 -#define TINYXML2_INCLUDED
    1.30 -
    1.31 -#if defined(ANDROID_NDK) || defined(__BORLANDC__)
    1.32 -#   include <ctype.h>
    1.33 -#   include <limits.h>
    1.34 -#   include <stdio.h>
    1.35 -#   include <stdlib.h>
    1.36 -#   include <string.h>
    1.37 -#   include <stdarg.h>
    1.38 -#else
    1.39 -#   include <cctype>
    1.40 -#   include <climits>
    1.41 -#   include <cstdio>
    1.42 -#   include <cstdlib>
    1.43 -#   include <cstring>
    1.44 -#   include <cstdarg>
    1.45 -#endif
    1.46 -
    1.47 -/*
    1.48 -   TODO: intern strings instead of allocation.
    1.49 -*/
    1.50 -/*
    1.51 -	gcc:
    1.52 -        g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
    1.53 -
    1.54 -    Formatting, Artistic Style:
    1.55 -        AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
    1.56 -*/
    1.57 -
    1.58 -#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
    1.59 -#   ifndef DEBUG
    1.60 -#       define DEBUG
    1.61 -#   endif
    1.62 -#endif
    1.63 -
    1.64 -#ifdef _MSC_VER
    1.65 -#   pragma warning(push)
    1.66 -#   pragma warning(disable: 4251)
    1.67 -#endif
    1.68 -
    1.69 -#ifdef _WIN32
    1.70 -#   ifdef TINYXML2_EXPORT
    1.71 -#       define TINYXML2_LIB __declspec(dllexport)
    1.72 -#   elif defined(TINYXML2_IMPORT)
    1.73 -#       define TINYXML2_LIB __declspec(dllimport)
    1.74 -#   else
    1.75 -#       define TINYXML2_LIB
    1.76 -#   endif
    1.77 -#else
    1.78 -#   define TINYXML2_LIB
    1.79 -#endif
    1.80 -
    1.81 -
    1.82 -#if defined(DEBUG)
    1.83 -#   if defined(_MSC_VER)
    1.84 -#       define TIXMLASSERT( x )           if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
    1.85 -#   elif defined (ANDROID_NDK)
    1.86 -#       include <android/log.h>
    1.87 -#       define TIXMLASSERT( x )           if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
    1.88 -#   else
    1.89 -#       include <assert.h>
    1.90 -#       define TIXMLASSERT                assert
    1.91 -#   endif
    1.92 -#   else
    1.93 -#       define TIXMLASSERT( x )           {}
    1.94 -#endif
    1.95 -
    1.96 -
    1.97 -#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
    1.98 -// Microsoft visual studio, version 2005 and higher.
    1.99 -/*int _snprintf_s(
   1.100 -   char *buffer,
   1.101 -   size_t sizeOfBuffer,
   1.102 -   size_t count,
   1.103 -   const char *format [,
   1.104 -	  argument] ...
   1.105 -);*/
   1.106 -inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
   1.107 -{
   1.108 -    va_list va;
   1.109 -    va_start( va, format );
   1.110 -    int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
   1.111 -    va_end( va );
   1.112 -    return result;
   1.113 -}
   1.114 -#define TIXML_SSCANF   sscanf_s
   1.115 -#else
   1.116 -// GCC version 3 and higher
   1.117 -//#warning( "Using sn* functions." )
   1.118 -#define TIXML_SNPRINTF snprintf
   1.119 -#define TIXML_SSCANF   sscanf
   1.120 -#endif
   1.121 -
   1.122 -static const int TIXML2_MAJOR_VERSION = 1;
   1.123 -static const int TIXML2_MINOR_VERSION = 0;
   1.124 -static const int TIXML2_PATCH_VERSION = 11;
   1.125 -
   1.126 -namespace tinyxml2
   1.127 -{
   1.128 -class XMLDocument;
   1.129 -class XMLElement;
   1.130 -class XMLAttribute;
   1.131 -class XMLComment;
   1.132 -class XMLText;
   1.133 -class XMLDeclaration;
   1.134 -class XMLUnknown;
   1.135 -class XMLPrinter;
   1.136 -
   1.137 -/*
   1.138 -	A class that wraps strings. Normally stores the start and end
   1.139 -	pointers into the XML file itself, and will apply normalization
   1.140 -	and entity translation if actually read. Can also store (and memory
   1.141 -	manage) a traditional char[]
   1.142 -*/
   1.143 -class StrPair
   1.144 -{
   1.145 -public:
   1.146 -    enum {
   1.147 -        NEEDS_ENTITY_PROCESSING			= 0x01,
   1.148 -        NEEDS_NEWLINE_NORMALIZATION		= 0x02,
   1.149 -        COLLAPSE_WHITESPACE	                = 0x04,
   1.150 -
   1.151 -        TEXT_ELEMENT		            	= NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
   1.152 -        TEXT_ELEMENT_LEAVE_ENTITIES		= NEEDS_NEWLINE_NORMALIZATION,
   1.153 -        ATTRIBUTE_NAME		            	= 0,
   1.154 -        ATTRIBUTE_VALUE		            	= NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
   1.155 -        ATTRIBUTE_VALUE_LEAVE_ENTITIES  	= NEEDS_NEWLINE_NORMALIZATION,
   1.156 -        COMMENT				        = NEEDS_NEWLINE_NORMALIZATION
   1.157 -    };
   1.158 -
   1.159 -    StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
   1.160 -    ~StrPair();
   1.161 -
   1.162 -    void Set( char* start, char* end, int flags ) {
   1.163 -        Reset();
   1.164 -        _start  = start;
   1.165 -        _end    = end;
   1.166 -        _flags  = flags | NEEDS_FLUSH;
   1.167 -    }
   1.168 -
   1.169 -    const char* GetStr();
   1.170 -
   1.171 -    bool Empty() const {
   1.172 -        return _start == _end;
   1.173 -    }
   1.174 -
   1.175 -    void SetInternedStr( const char* str ) {
   1.176 -        Reset();
   1.177 -        _start = const_cast<char*>(str);
   1.178 -    }
   1.179 -
   1.180 -    void SetStr( const char* str, int flags=0 );
   1.181 -
   1.182 -    char* ParseText( char* in, const char* endTag, int strFlags );
   1.183 -    char* ParseName( char* in );
   1.184 -
   1.185 -private:
   1.186 -    void Reset();
   1.187 -    void CollapseWhitespace();
   1.188 -
   1.189 -    enum {
   1.190 -        NEEDS_FLUSH = 0x100,
   1.191 -        NEEDS_DELETE = 0x200
   1.192 -    };
   1.193 -
   1.194 -    // After parsing, if *_end != 0, it can be set to zero.
   1.195 -    int     _flags;
   1.196 -    char*   _start;
   1.197 -    char*   _end;
   1.198 -};
   1.199 -
   1.200 -
   1.201 -/*
   1.202 -	A dynamic array of Plain Old Data. Doesn't support constructors, etc.
   1.203 -	Has a small initial memory pool, so that low or no usage will not
   1.204 -	cause a call to new/delete
   1.205 -*/
   1.206 -template <class T, int INIT>
   1.207 -class DynArray
   1.208 -{
   1.209 -public:
   1.210 -    DynArray< T, INIT >() {
   1.211 -        _mem = _pool;
   1.212 -        _allocated = INIT;
   1.213 -        _size = 0;
   1.214 -    }
   1.215 -
   1.216 -    ~DynArray() {
   1.217 -        if ( _mem != _pool ) {
   1.218 -            delete [] _mem;
   1.219 -        }
   1.220 -    }
   1.221 -
   1.222 -    void Push( T t ) {
   1.223 -        EnsureCapacity( _size+1 );
   1.224 -        _mem[_size++] = t;
   1.225 -    }
   1.226 -
   1.227 -    T* PushArr( int count ) {
   1.228 -        EnsureCapacity( _size+count );
   1.229 -        T* ret = &_mem[_size];
   1.230 -        _size += count;
   1.231 -        return ret;
   1.232 -    }
   1.233 -
   1.234 -    T Pop() {
   1.235 -        return _mem[--_size];
   1.236 -    }
   1.237 -
   1.238 -    void PopArr( int count ) {
   1.239 -        TIXMLASSERT( _size >= count );
   1.240 -        _size -= count;
   1.241 -    }
   1.242 -
   1.243 -    bool Empty() const					{
   1.244 -        return _size == 0;
   1.245 -    }
   1.246 -
   1.247 -    T& operator[](int i)				{
   1.248 -        TIXMLASSERT( i>= 0 && i < _size );
   1.249 -        return _mem[i];
   1.250 -    }
   1.251 -
   1.252 -    const T& operator[](int i) const	{
   1.253 -        TIXMLASSERT( i>= 0 && i < _size );
   1.254 -        return _mem[i];
   1.255 -    }
   1.256 -
   1.257 -    int Size() const					{
   1.258 -        return _size;
   1.259 -    }
   1.260 -
   1.261 -    int Capacity() const				{
   1.262 -        return _allocated;
   1.263 -    }
   1.264 -
   1.265 -    const T* Mem() const				{
   1.266 -        return _mem;
   1.267 -    }
   1.268 -
   1.269 -    T* Mem()							{
   1.270 -        return _mem;
   1.271 -    }
   1.272 -
   1.273 -private:
   1.274 -    void EnsureCapacity( int cap ) {
   1.275 -        if ( cap > _allocated ) {
   1.276 -            int newAllocated = cap * 2;
   1.277 -            T* newMem = new T[newAllocated];
   1.278 -            memcpy( newMem, _mem, sizeof(T)*_size );	// warning: not using constructors, only works for PODs
   1.279 -            if ( _mem != _pool ) {
   1.280 -                delete [] _mem;
   1.281 -            }
   1.282 -            _mem = newMem;
   1.283 -            _allocated = newAllocated;
   1.284 -        }
   1.285 -    }
   1.286 -
   1.287 -    T*  _mem;
   1.288 -    T   _pool[INIT];
   1.289 -    int _allocated;		// objects allocated
   1.290 -    int _size;			// number objects in use
   1.291 -};
   1.292 -
   1.293 -
   1.294 -/*
   1.295 -	Parent virtual class of a pool for fast allocation
   1.296 -	and deallocation of objects.
   1.297 -*/
   1.298 -class MemPool
   1.299 -{
   1.300 -public:
   1.301 -    MemPool() {}
   1.302 -    virtual ~MemPool() {}
   1.303 -
   1.304 -    virtual int ItemSize() const = 0;
   1.305 -    virtual void* Alloc() = 0;
   1.306 -    virtual void Free( void* ) = 0;
   1.307 -    virtual void SetTracked() = 0;
   1.308 -};
   1.309 -
   1.310 -
   1.311 -/*
   1.312 -	Template child class to create pools of the correct type.
   1.313 -*/
   1.314 -template< int SIZE >
   1.315 -class MemPoolT : public MemPool
   1.316 -{
   1.317 -public:
   1.318 -    MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0)	{}
   1.319 -    ~MemPoolT() {
   1.320 -        // Delete the blocks.
   1.321 -        for( int i=0; i<_blockPtrs.Size(); ++i ) {
   1.322 -            delete _blockPtrs[i];
   1.323 -        }
   1.324 -    }
   1.325 -
   1.326 -    virtual int ItemSize() const	{
   1.327 -        return SIZE;
   1.328 -    }
   1.329 -    int CurrentAllocs() const		{
   1.330 -        return _currentAllocs;
   1.331 -    }
   1.332 -
   1.333 -    virtual void* Alloc() {
   1.334 -        if ( !_root ) {
   1.335 -            // Need a new block.
   1.336 -            Block* block = new Block();
   1.337 -            _blockPtrs.Push( block );
   1.338 -
   1.339 -            for( int i=0; i<COUNT-1; ++i ) {
   1.340 -                block->chunk[i].next = &block->chunk[i+1];
   1.341 -            }
   1.342 -            block->chunk[COUNT-1].next = 0;
   1.343 -            _root = block->chunk;
   1.344 -        }
   1.345 -        void* result = _root;
   1.346 -        _root = _root->next;
   1.347 -
   1.348 -        ++_currentAllocs;
   1.349 -        if ( _currentAllocs > _maxAllocs ) {
   1.350 -            _maxAllocs = _currentAllocs;
   1.351 -        }
   1.352 -        _nAllocs++;
   1.353 -        _nUntracked++;
   1.354 -        return result;
   1.355 -    }
   1.356 -    virtual void Free( void* mem ) {
   1.357 -        if ( !mem ) {
   1.358 -            return;
   1.359 -        }
   1.360 -        --_currentAllocs;
   1.361 -        Chunk* chunk = (Chunk*)mem;
   1.362 -#ifdef DEBUG
   1.363 -        memset( chunk, 0xfe, sizeof(Chunk) );
   1.364 -#endif
   1.365 -        chunk->next = _root;
   1.366 -        _root = chunk;
   1.367 -    }
   1.368 -    void Trace( const char* name ) {
   1.369 -        printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
   1.370 -                name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
   1.371 -    }
   1.372 -
   1.373 -    void SetTracked() {
   1.374 -        _nUntracked--;
   1.375 -    }
   1.376 -
   1.377 -    int Untracked() const {
   1.378 -        return _nUntracked;
   1.379 -    }
   1.380 -
   1.381 -	// This number is perf sensitive. 4k seems like a good tradeoff on my machine.
   1.382 -	// The test file is large, 170k.
   1.383 -	// Release:		VS2010 gcc(no opt)
   1.384 -	//		1k:		4000
   1.385 -	//		2k:		4000
   1.386 -	//		4k:		3900	21000
   1.387 -	//		16k:	5200
   1.388 -	//		32k:	4300
   1.389 -	//		64k:	4000	21000
   1.390 -    enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
   1.391 -
   1.392 -private:
   1.393 -    union Chunk {
   1.394 -        Chunk*  next;
   1.395 -        char    mem[SIZE];
   1.396 -    };
   1.397 -    struct Block {
   1.398 -        Chunk chunk[COUNT];
   1.399 -    };
   1.400 -    DynArray< Block*, 10 > _blockPtrs;
   1.401 -    Chunk* _root;
   1.402 -
   1.403 -    int _currentAllocs;
   1.404 -    int _nAllocs;
   1.405 -    int _maxAllocs;
   1.406 -    int _nUntracked;
   1.407 -};
   1.408 -
   1.409 -
   1.410 -
   1.411 -/**
   1.412 -	Implements the interface to the "Visitor pattern" (see the Accept() method.)
   1.413 -	If you call the Accept() method, it requires being passed a XMLVisitor
   1.414 -	class to handle callbacks. For nodes that contain other nodes (Document, Element)
   1.415 -	you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs
   1.416 -	are simply called with Visit().
   1.417 -
   1.418 -	If you return 'true' from a Visit method, recursive parsing will continue. If you return
   1.419 -	false, <b>no children of this node or its siblings</b> will be visited.
   1.420 -
   1.421 -	All flavors of Visit methods have a default implementation that returns 'true' (continue
   1.422 -	visiting). You need to only override methods that are interesting to you.
   1.423 -
   1.424 -	Generally Accept() is called on the XMLDocument, although all nodes support visiting.
   1.425 -
   1.426 -	You should never change the document from a callback.
   1.427 -
   1.428 -	@sa XMLNode::Accept()
   1.429 -*/
   1.430 -class TINYXML2_LIB XMLVisitor
   1.431 -{
   1.432 -public:
   1.433 -    virtual ~XMLVisitor() {}
   1.434 -
   1.435 -    /// Visit a document.
   1.436 -    virtual bool VisitEnter( const XMLDocument& /*doc*/ )			{
   1.437 -        return true;
   1.438 -    }
   1.439 -    /// Visit a document.
   1.440 -    virtual bool VisitExit( const XMLDocument& /*doc*/ )			{
   1.441 -        return true;
   1.442 -    }
   1.443 -
   1.444 -    /// Visit an element.
   1.445 -    virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ )	{
   1.446 -        return true;
   1.447 -    }
   1.448 -    /// Visit an element.
   1.449 -    virtual bool VisitExit( const XMLElement& /*element*/ )			{
   1.450 -        return true;
   1.451 -    }
   1.452 -
   1.453 -    /// Visit a declaration.
   1.454 -    virtual bool Visit( const XMLDeclaration& /*declaration*/ )		{
   1.455 -        return true;
   1.456 -    }
   1.457 -    /// Visit a text node.
   1.458 -    virtual bool Visit( const XMLText& /*text*/ )					{
   1.459 -        return true;
   1.460 -    }
   1.461 -    /// Visit a comment node.
   1.462 -    virtual bool Visit( const XMLComment& /*comment*/ )				{
   1.463 -        return true;
   1.464 -    }
   1.465 -    /// Visit an unknown node.
   1.466 -    virtual bool Visit( const XMLUnknown& /*unknown*/ )				{
   1.467 -        return true;
   1.468 -    }
   1.469 -};
   1.470 -
   1.471 -
   1.472 -/*
   1.473 -	Utility functionality.
   1.474 -*/
   1.475 -class XMLUtil
   1.476 -{
   1.477 -public:
   1.478 -    // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
   1.479 -    // correct, but simple, and usually works.
   1.480 -    static const char* SkipWhiteSpace( const char* p )	{
   1.481 -        while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
   1.482 -            ++p;
   1.483 -        }
   1.484 -        return p;
   1.485 -    }
   1.486 -    static char* SkipWhiteSpace( char* p )				{
   1.487 -        while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) )		{
   1.488 -            ++p;
   1.489 -        }
   1.490 -        return p;
   1.491 -    }
   1.492 -    static bool IsWhiteSpace( char p )					{
   1.493 -        return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
   1.494 -    }
   1.495 -    
   1.496 -    inline static bool IsNameStartChar( unsigned char ch ) {
   1.497 -        return ( ( ch < 128 ) ? isalpha( ch ) : 1 )
   1.498 -               || ch == ':'
   1.499 -               || ch == '_';
   1.500 -    }
   1.501 -    
   1.502 -    inline static bool IsNameChar( unsigned char ch ) {
   1.503 -        return IsNameStartChar( ch )
   1.504 -               || isdigit( ch )
   1.505 -               || ch == '.'
   1.506 -               || ch == '-';
   1.507 -    }
   1.508 -
   1.509 -    inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX )  {
   1.510 -        int n = 0;
   1.511 -        if ( p == q ) {
   1.512 -            return true;
   1.513 -        }
   1.514 -        while( *p && *q && *p == *q && n<nChar ) {
   1.515 -            ++p;
   1.516 -            ++q;
   1.517 -            ++n;
   1.518 -        }
   1.519 -        if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
   1.520 -            return true;
   1.521 -        }
   1.522 -        return false;
   1.523 -    }
   1.524 -    
   1.525 -    inline static int IsUTF8Continuation( const char p ) {
   1.526 -        return p & 0x80;
   1.527 -    }
   1.528 -
   1.529 -    static const char* ReadBOM( const char* p, bool* hasBOM );
   1.530 -    // p is the starting location,
   1.531 -    // the UTF-8 value of the entity will be placed in value, and length filled in.
   1.532 -    static const char* GetCharacterRef( const char* p, char* value, int* length );
   1.533 -    static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
   1.534 -
   1.535 -    // converts primitive types to strings
   1.536 -    static void ToStr( int v, char* buffer, int bufferSize );
   1.537 -    static void ToStr( unsigned v, char* buffer, int bufferSize );
   1.538 -    static void ToStr( bool v, char* buffer, int bufferSize );
   1.539 -    static void ToStr( float v, char* buffer, int bufferSize );
   1.540 -    static void ToStr( double v, char* buffer, int bufferSize );
   1.541 -
   1.542 -    // converts strings to primitive types
   1.543 -    static bool	ToInt( const char* str, int* value );
   1.544 -    static bool ToUnsigned( const char* str, unsigned* value );
   1.545 -    static bool	ToBool( const char* str, bool* value );
   1.546 -    static bool	ToFloat( const char* str, float* value );
   1.547 -    static bool ToDouble( const char* str, double* value );
   1.548 -};
   1.549 -
   1.550 -
   1.551 -/** XMLNode is a base class for every object that is in the
   1.552 -	XML Document Object Model (DOM), except XMLAttributes.
   1.553 -	Nodes have siblings, a parent, and children which can
   1.554 -	be navigated. A node is always in a XMLDocument.
   1.555 -	The type of a XMLNode can be queried, and it can
   1.556 -	be cast to its more defined type.
   1.557 -
   1.558 -	A XMLDocument allocates memory for all its Nodes.
   1.559 -	When the XMLDocument gets deleted, all its Nodes
   1.560 -	will also be deleted.
   1.561 -
   1.562 -	@verbatim
   1.563 -	A Document can contain:	Element	(container or leaf)
   1.564 -							Comment (leaf)
   1.565 -							Unknown (leaf)
   1.566 -							Declaration( leaf )
   1.567 -
   1.568 -	An Element can contain:	Element (container or leaf)
   1.569 -							Text	(leaf)
   1.570 -							Attributes (not on tree)
   1.571 -							Comment (leaf)
   1.572 -							Unknown (leaf)
   1.573 -
   1.574 -	@endverbatim
   1.575 -*/
   1.576 -class TINYXML2_LIB XMLNode
   1.577 -{
   1.578 -    friend class XMLDocument;
   1.579 -    friend class XMLElement;
   1.580 -public:
   1.581 -
   1.582 -    /// Get the XMLDocument that owns this XMLNode.
   1.583 -    const XMLDocument* GetDocument() const	{
   1.584 -        return _document;
   1.585 -    }
   1.586 -    /// Get the XMLDocument that owns this XMLNode.
   1.587 -    XMLDocument* GetDocument()				{
   1.588 -        return _document;
   1.589 -    }
   1.590 -
   1.591 -    /// Safely cast to an Element, or null.
   1.592 -    virtual XMLElement*		ToElement()		{
   1.593 -        return 0;
   1.594 -    }
   1.595 -    /// Safely cast to Text, or null.
   1.596 -    virtual XMLText*		ToText()		{
   1.597 -        return 0;
   1.598 -    }
   1.599 -    /// Safely cast to a Comment, or null.
   1.600 -    virtual XMLComment*		ToComment()		{
   1.601 -        return 0;
   1.602 -    }
   1.603 -    /// Safely cast to a Document, or null.
   1.604 -    virtual XMLDocument*	ToDocument()	{
   1.605 -        return 0;
   1.606 -    }
   1.607 -    /// Safely cast to a Declaration, or null.
   1.608 -    virtual XMLDeclaration*	ToDeclaration()	{
   1.609 -        return 0;
   1.610 -    }
   1.611 -    /// Safely cast to an Unknown, or null.
   1.612 -    virtual XMLUnknown*		ToUnknown()		{
   1.613 -        return 0;
   1.614 -    }
   1.615 -
   1.616 -    virtual const XMLElement*		ToElement() const		{
   1.617 -        return 0;
   1.618 -    }
   1.619 -    virtual const XMLText*			ToText() const			{
   1.620 -        return 0;
   1.621 -    }
   1.622 -    virtual const XMLComment*		ToComment() const		{
   1.623 -        return 0;
   1.624 -    }
   1.625 -    virtual const XMLDocument*		ToDocument() const		{
   1.626 -        return 0;
   1.627 -    }
   1.628 -    virtual const XMLDeclaration*	ToDeclaration() const	{
   1.629 -        return 0;
   1.630 -    }
   1.631 -    virtual const XMLUnknown*		ToUnknown() const		{
   1.632 -        return 0;
   1.633 -    }
   1.634 -
   1.635 -    /** The meaning of 'value' changes for the specific type.
   1.636 -    	@verbatim
   1.637 -    	Document:	empty
   1.638 -    	Element:	name of the element
   1.639 -    	Comment:	the comment text
   1.640 -    	Unknown:	the tag contents
   1.641 -    	Text:		the text string
   1.642 -    	@endverbatim
   1.643 -    */
   1.644 -    const char* Value() const			{
   1.645 -        return _value.GetStr();
   1.646 -    }
   1.647 -
   1.648 -    /** Set the Value of an XML node.
   1.649 -    	@sa Value()
   1.650 -    */
   1.651 -    void SetValue( const char* val, bool staticMem=false );
   1.652 -
   1.653 -    /// Get the parent of this node on the DOM.
   1.654 -    const XMLNode*	Parent() const			{
   1.655 -        return _parent;
   1.656 -    }
   1.657 -
   1.658 -    XMLNode* Parent()						{
   1.659 -        return _parent;
   1.660 -    }
   1.661 -
   1.662 -    /// Returns true if this node has no children.
   1.663 -    bool NoChildren() const					{
   1.664 -        return !_firstChild;
   1.665 -    }
   1.666 -
   1.667 -    /// Get the first child node, or null if none exists.
   1.668 -    const XMLNode*  FirstChild() const		{
   1.669 -        return _firstChild;
   1.670 -    }
   1.671 -
   1.672 -    XMLNode*		FirstChild()			{
   1.673 -        return _firstChild;
   1.674 -    }
   1.675 -
   1.676 -    /** Get the first child element, or optionally the first child
   1.677 -        element with the specified name.
   1.678 -    */
   1.679 -    const XMLElement* FirstChildElement( const char* value=0 ) const;
   1.680 -
   1.681 -    XMLElement* FirstChildElement( const char* value=0 )	{
   1.682 -        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value ));
   1.683 -    }
   1.684 -
   1.685 -    /// Get the last child node, or null if none exists.
   1.686 -    const XMLNode*	LastChild() const						{
   1.687 -        return _lastChild;
   1.688 -    }
   1.689 -
   1.690 -    XMLNode*		LastChild()								{
   1.691 -        return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
   1.692 -    }
   1.693 -
   1.694 -    /** Get the last child element or optionally the last child
   1.695 -        element with the specified name.
   1.696 -    */
   1.697 -    const XMLElement* LastChildElement( const char* value=0 ) const;
   1.698 -
   1.699 -    XMLElement* LastChildElement( const char* value=0 )	{
   1.700 -        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) );
   1.701 -    }
   1.702 -
   1.703 -    /// Get the previous (left) sibling node of this node.
   1.704 -    const XMLNode*	PreviousSibling() const					{
   1.705 -        return _prev;
   1.706 -    }
   1.707 -
   1.708 -    XMLNode*	PreviousSibling()							{
   1.709 -        return _prev;
   1.710 -    }
   1.711 -
   1.712 -    /// Get the previous (left) sibling element of this node, with an optionally supplied name.
   1.713 -    const XMLElement*	PreviousSiblingElement( const char* value=0 ) const ;
   1.714 -
   1.715 -    XMLElement*	PreviousSiblingElement( const char* value=0 ) {
   1.716 -        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) );
   1.717 -    }
   1.718 -
   1.719 -    /// Get the next (right) sibling node of this node.
   1.720 -    const XMLNode*	NextSibling() const						{
   1.721 -        return _next;
   1.722 -    }
   1.723 -
   1.724 -    XMLNode*	NextSibling()								{
   1.725 -        return _next;
   1.726 -    }
   1.727 -
   1.728 -    /// Get the next (right) sibling element of this node, with an optionally supplied name.
   1.729 -    const XMLElement*	NextSiblingElement( const char* value=0 ) const;
   1.730 -
   1.731 -    XMLElement*	NextSiblingElement( const char* value=0 )	{
   1.732 -        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) );
   1.733 -    }
   1.734 -
   1.735 -    /**
   1.736 -    	Add a child node as the last (right) child.
   1.737 -    */
   1.738 -    XMLNode* InsertEndChild( XMLNode* addThis );
   1.739 -
   1.740 -    XMLNode* LinkEndChild( XMLNode* addThis )	{
   1.741 -        return InsertEndChild( addThis );
   1.742 -    }
   1.743 -    /**
   1.744 -    	Add a child node as the first (left) child.
   1.745 -    */
   1.746 -    XMLNode* InsertFirstChild( XMLNode* addThis );
   1.747 -    /**
   1.748 -    	Add a node after the specified child node.
   1.749 -    */
   1.750 -    XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
   1.751 -
   1.752 -    /**
   1.753 -    	Delete all the children of this node.
   1.754 -    */
   1.755 -    void DeleteChildren();
   1.756 -
   1.757 -    /**
   1.758 -    	Delete a child of this node.
   1.759 -    */
   1.760 -    void DeleteChild( XMLNode* node );
   1.761 -
   1.762 -    /**
   1.763 -    	Make a copy of this node, but not its children.
   1.764 -    	You may pass in a Document pointer that will be
   1.765 -    	the owner of the new Node. If the 'document' is
   1.766 -    	null, then the node returned will be allocated
   1.767 -    	from the current Document. (this->GetDocument())
   1.768 -
   1.769 -    	Note: if called on a XMLDocument, this will return null.
   1.770 -    */
   1.771 -    virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
   1.772 -
   1.773 -    /**
   1.774 -    	Test if 2 nodes are the same, but don't test children.
   1.775 -    	The 2 nodes do not need to be in the same Document.
   1.776 -
   1.777 -    	Note: if called on a XMLDocument, this will return false.
   1.778 -    */
   1.779 -    virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
   1.780 -
   1.781 -    /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the
   1.782 -    	XML tree will be conditionally visited and the host will be called back
   1.783 -    	via the XMLVisitor interface.
   1.784 -
   1.785 -    	This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse
   1.786 -    	the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this
   1.787 -    	interface versus any other.)
   1.788 -
   1.789 -    	The interface has been based on ideas from:
   1.790 -
   1.791 -    	- http://www.saxproject.org/
   1.792 -    	- http://c2.com/cgi/wiki?HierarchicalVisitorPattern
   1.793 -
   1.794 -    	Which are both good references for "visiting".
   1.795 -
   1.796 -    	An example of using Accept():
   1.797 -    	@verbatim
   1.798 -    	XMLPrinter printer;
   1.799 -    	tinyxmlDoc.Accept( &printer );
   1.800 -    	const char* xmlcstr = printer.CStr();
   1.801 -    	@endverbatim
   1.802 -    */
   1.803 -    virtual bool Accept( XMLVisitor* visitor ) const = 0;
   1.804 -
   1.805 -    // internal
   1.806 -    virtual char* ParseDeep( char*, StrPair* );
   1.807 -
   1.808 -protected:
   1.809 -    XMLNode( XMLDocument* );
   1.810 -    virtual ~XMLNode();
   1.811 -    XMLNode( const XMLNode& );	// not supported
   1.812 -    XMLNode& operator=( const XMLNode& );	// not supported
   1.813 -
   1.814 -    XMLDocument*	_document;
   1.815 -    XMLNode*		_parent;
   1.816 -    mutable StrPair	_value;
   1.817 -
   1.818 -    XMLNode*		_firstChild;
   1.819 -    XMLNode*		_lastChild;
   1.820 -
   1.821 -    XMLNode*		_prev;
   1.822 -    XMLNode*		_next;
   1.823 -
   1.824 -private:
   1.825 -    MemPool*		_memPool;
   1.826 -    void Unlink( XMLNode* child );
   1.827 -};
   1.828 -
   1.829 -
   1.830 -/** XML text.
   1.831 -
   1.832 -	Note that a text node can have child element nodes, for example:
   1.833 -	@verbatim
   1.834 -	<root>This is <b>bold</b></root>
   1.835 -	@endverbatim
   1.836 -
   1.837 -	A text node can have 2 ways to output the next. "normal" output
   1.838 -	and CDATA. It will default to the mode it was parsed from the XML file and
   1.839 -	you generally want to leave it alone, but you can change the output mode with
   1.840 -	SetCData() and query it with CData().
   1.841 -*/
   1.842 -class TINYXML2_LIB XMLText : public XMLNode
   1.843 -{
   1.844 -    friend class XMLBase;
   1.845 -    friend class XMLDocument;
   1.846 -public:
   1.847 -    virtual bool Accept( XMLVisitor* visitor ) const;
   1.848 -
   1.849 -    virtual XMLText* ToText()			{
   1.850 -        return this;
   1.851 -    }
   1.852 -    virtual const XMLText* ToText() const	{
   1.853 -        return this;
   1.854 -    }
   1.855 -
   1.856 -    /// Declare whether this should be CDATA or standard text.
   1.857 -    void SetCData( bool isCData )			{
   1.858 -        _isCData = isCData;
   1.859 -    }
   1.860 -    /// Returns true if this is a CDATA text element.
   1.861 -    bool CData() const						{
   1.862 -        return _isCData;
   1.863 -    }
   1.864 -
   1.865 -    char* ParseDeep( char*, StrPair* endTag );
   1.866 -    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
   1.867 -    virtual bool ShallowEqual( const XMLNode* compare ) const;
   1.868 -
   1.869 -protected:
   1.870 -    XMLText( XMLDocument* doc )	: XMLNode( doc ), _isCData( false )	{}
   1.871 -    virtual ~XMLText()												{}
   1.872 -    XMLText( const XMLText& );	// not supported
   1.873 -    XMLText& operator=( const XMLText& );	// not supported
   1.874 -
   1.875 -private:
   1.876 -    bool _isCData;
   1.877 -};
   1.878 -
   1.879 -
   1.880 -/** An XML Comment. */
   1.881 -class TINYXML2_LIB XMLComment : public XMLNode
   1.882 -{
   1.883 -    friend class XMLDocument;
   1.884 -public:
   1.885 -    virtual XMLComment*	ToComment()					{
   1.886 -        return this;
   1.887 -    }
   1.888 -    virtual const XMLComment* ToComment() const		{
   1.889 -        return this;
   1.890 -    }
   1.891 -
   1.892 -    virtual bool Accept( XMLVisitor* visitor ) const;
   1.893 -
   1.894 -    char* ParseDeep( char*, StrPair* endTag );
   1.895 -    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
   1.896 -    virtual bool ShallowEqual( const XMLNode* compare ) const;
   1.897 -
   1.898 -protected:
   1.899 -    XMLComment( XMLDocument* doc );
   1.900 -    virtual ~XMLComment();
   1.901 -    XMLComment( const XMLComment& );	// not supported
   1.902 -    XMLComment& operator=( const XMLComment& );	// not supported
   1.903 -
   1.904 -private:
   1.905 -};
   1.906 -
   1.907 -
   1.908 -/** In correct XML the declaration is the first entry in the file.
   1.909 -	@verbatim
   1.910 -		<?xml version="1.0" standalone="yes"?>
   1.911 -	@endverbatim
   1.912 -
   1.913 -	TinyXML-2 will happily read or write files without a declaration,
   1.914 -	however.
   1.915 -
   1.916 -	The text of the declaration isn't interpreted. It is parsed
   1.917 -	and written as a string.
   1.918 -*/
   1.919 -class TINYXML2_LIB XMLDeclaration : public XMLNode
   1.920 -{
   1.921 -    friend class XMLDocument;
   1.922 -public:
   1.923 -    virtual XMLDeclaration*	ToDeclaration()					{
   1.924 -        return this;
   1.925 -    }
   1.926 -    virtual const XMLDeclaration* ToDeclaration() const		{
   1.927 -        return this;
   1.928 -    }
   1.929 -
   1.930 -    virtual bool Accept( XMLVisitor* visitor ) const;
   1.931 -
   1.932 -    char* ParseDeep( char*, StrPair* endTag );
   1.933 -    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
   1.934 -    virtual bool ShallowEqual( const XMLNode* compare ) const;
   1.935 -
   1.936 -protected:
   1.937 -    XMLDeclaration( XMLDocument* doc );
   1.938 -    virtual ~XMLDeclaration();
   1.939 -    XMLDeclaration( const XMLDeclaration& );	// not supported
   1.940 -    XMLDeclaration& operator=( const XMLDeclaration& );	// not supported
   1.941 -};
   1.942 -
   1.943 -
   1.944 -/** Any tag that TinyXML-2 doesn't recognize is saved as an
   1.945 -	unknown. It is a tag of text, but should not be modified.
   1.946 -	It will be written back to the XML, unchanged, when the file
   1.947 -	is saved.
   1.948 -
   1.949 -	DTD tags get thrown into XMLUnknowns.
   1.950 -*/
   1.951 -class TINYXML2_LIB XMLUnknown : public XMLNode
   1.952 -{
   1.953 -    friend class XMLDocument;
   1.954 -public:
   1.955 -    virtual XMLUnknown*	ToUnknown()					{
   1.956 -        return this;
   1.957 -    }
   1.958 -    virtual const XMLUnknown* ToUnknown() const		{
   1.959 -        return this;
   1.960 -    }
   1.961 -
   1.962 -    virtual bool Accept( XMLVisitor* visitor ) const;
   1.963 -
   1.964 -    char* ParseDeep( char*, StrPair* endTag );
   1.965 -    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
   1.966 -    virtual bool ShallowEqual( const XMLNode* compare ) const;
   1.967 -
   1.968 -protected:
   1.969 -    XMLUnknown( XMLDocument* doc );
   1.970 -    virtual ~XMLUnknown();
   1.971 -    XMLUnknown( const XMLUnknown& );	// not supported
   1.972 -    XMLUnknown& operator=( const XMLUnknown& );	// not supported
   1.973 -};
   1.974 -
   1.975 -
   1.976 -enum XMLError {
   1.977 -    XML_NO_ERROR = 0,
   1.978 -    XML_SUCCESS = 0,
   1.979 -
   1.980 -    XML_NO_ATTRIBUTE,
   1.981 -    XML_WRONG_ATTRIBUTE_TYPE,
   1.982 -
   1.983 -    XML_ERROR_FILE_NOT_FOUND,
   1.984 -    XML_ERROR_FILE_COULD_NOT_BE_OPENED,
   1.985 -    XML_ERROR_FILE_READ_ERROR,
   1.986 -    XML_ERROR_ELEMENT_MISMATCH,
   1.987 -    XML_ERROR_PARSING_ELEMENT,
   1.988 -    XML_ERROR_PARSING_ATTRIBUTE,
   1.989 -    XML_ERROR_IDENTIFYING_TAG,
   1.990 -    XML_ERROR_PARSING_TEXT,
   1.991 -    XML_ERROR_PARSING_CDATA,
   1.992 -    XML_ERROR_PARSING_COMMENT,
   1.993 -    XML_ERROR_PARSING_DECLARATION,
   1.994 -    XML_ERROR_PARSING_UNKNOWN,
   1.995 -    XML_ERROR_EMPTY_DOCUMENT,
   1.996 -    XML_ERROR_MISMATCHED_ELEMENT,
   1.997 -    XML_ERROR_PARSING,
   1.998 -
   1.999 -    XML_CAN_NOT_CONVERT_TEXT,
  1.1000 -    XML_NO_TEXT_NODE
  1.1001 -};
  1.1002 -
  1.1003 -
  1.1004 -/** An attribute is a name-value pair. Elements have an arbitrary
  1.1005 -	number of attributes, each with a unique name.
  1.1006 -
  1.1007 -	@note The attributes are not XMLNodes. You may only query the
  1.1008 -	Next() attribute in a list.
  1.1009 -*/
  1.1010 -class TINYXML2_LIB XMLAttribute
  1.1011 -{
  1.1012 -    friend class XMLElement;
  1.1013 -public:
  1.1014 -    /// The name of the attribute.
  1.1015 -    const char* Name() const {
  1.1016 -        return _name.GetStr();
  1.1017 -    }
  1.1018 -    /// The value of the attribute.
  1.1019 -    const char* Value() const {
  1.1020 -        return _value.GetStr();
  1.1021 -    }
  1.1022 -    /// The next attribute in the list.
  1.1023 -    const XMLAttribute* Next() const {
  1.1024 -        return _next;
  1.1025 -    }
  1.1026 -
  1.1027 -    /** IntValue interprets the attribute as an integer, and returns the value.
  1.1028 -        If the value isn't an integer, 0 will be returned. There is no error checking;
  1.1029 -    	use QueryIntValue() if you need error checking.
  1.1030 -    */
  1.1031 -    int		 IntValue() const				{
  1.1032 -        int i=0;
  1.1033 -        QueryIntValue( &i );
  1.1034 -        return i;
  1.1035 -    }
  1.1036 -    /// Query as an unsigned integer. See IntValue()
  1.1037 -    unsigned UnsignedValue() const			{
  1.1038 -        unsigned i=0;
  1.1039 -        QueryUnsignedValue( &i );
  1.1040 -        return i;
  1.1041 -    }
  1.1042 -    /// Query as a boolean. See IntValue()
  1.1043 -    bool	 BoolValue() const				{
  1.1044 -        bool b=false;
  1.1045 -        QueryBoolValue( &b );
  1.1046 -        return b;
  1.1047 -    }
  1.1048 -    /// Query as a double. See IntValue()
  1.1049 -    double 	 DoubleValue() const			{
  1.1050 -        double d=0;
  1.1051 -        QueryDoubleValue( &d );
  1.1052 -        return d;
  1.1053 -    }
  1.1054 -    /// Query as a float. See IntValue()
  1.1055 -    float	 FloatValue() const				{
  1.1056 -        float f=0;
  1.1057 -        QueryFloatValue( &f );
  1.1058 -        return f;
  1.1059 -    }
  1.1060 -
  1.1061 -    /** QueryIntValue interprets the attribute as an integer, and returns the value
  1.1062 -    	in the provided parameter. The function will return XML_NO_ERROR on success,
  1.1063 -    	and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
  1.1064 -    */
  1.1065 -    XMLError QueryIntValue( int* value ) const;
  1.1066 -    /// See QueryIntValue
  1.1067 -    XMLError QueryUnsignedValue( unsigned int* value ) const;
  1.1068 -    /// See QueryIntValue
  1.1069 -    XMLError QueryBoolValue( bool* value ) const;
  1.1070 -    /// See QueryIntValue
  1.1071 -    XMLError QueryDoubleValue( double* value ) const;
  1.1072 -    /// See QueryIntValue
  1.1073 -    XMLError QueryFloatValue( float* value ) const;
  1.1074 -
  1.1075 -    /// Set the attribute to a string value.
  1.1076 -    void SetAttribute( const char* value );
  1.1077 -    /// Set the attribute to value.
  1.1078 -    void SetAttribute( int value );
  1.1079 -    /// Set the attribute to value.
  1.1080 -    void SetAttribute( unsigned value );
  1.1081 -    /// Set the attribute to value.
  1.1082 -    void SetAttribute( bool value );
  1.1083 -    /// Set the attribute to value.
  1.1084 -    void SetAttribute( double value );
  1.1085 -    /// Set the attribute to value.
  1.1086 -    void SetAttribute( float value );
  1.1087 -
  1.1088 -private:
  1.1089 -    enum { BUF_SIZE = 200 };
  1.1090 -
  1.1091 -    XMLAttribute() : _next( 0 ), _memPool( 0 ) {}
  1.1092 -    virtual ~XMLAttribute()	{}
  1.1093 -
  1.1094 -    XMLAttribute( const XMLAttribute& );	// not supported
  1.1095 -    void operator=( const XMLAttribute& );	// not supported
  1.1096 -    void SetName( const char* name );
  1.1097 -
  1.1098 -    char* ParseDeep( char* p, bool processEntities );
  1.1099 -
  1.1100 -    mutable StrPair _name;
  1.1101 -    mutable StrPair _value;
  1.1102 -    XMLAttribute*   _next;
  1.1103 -    MemPool*        _memPool;
  1.1104 -};
  1.1105 -
  1.1106 -
  1.1107 -/** The element is a container class. It has a value, the element name,
  1.1108 -	and can contain other elements, text, comments, and unknowns.
  1.1109 -	Elements also contain an arbitrary number of attributes.
  1.1110 -*/
  1.1111 -class TINYXML2_LIB XMLElement : public XMLNode
  1.1112 -{
  1.1113 -    friend class XMLBase;
  1.1114 -    friend class XMLDocument;
  1.1115 -public:
  1.1116 -    /// Get the name of an element (which is the Value() of the node.)
  1.1117 -    const char* Name() const		{
  1.1118 -        return Value();
  1.1119 -    }
  1.1120 -    /// Set the name of the element.
  1.1121 -    void SetName( const char* str, bool staticMem=false )	{
  1.1122 -        SetValue( str, staticMem );
  1.1123 -    }
  1.1124 -
  1.1125 -    virtual XMLElement* ToElement()				{
  1.1126 -        return this;
  1.1127 -    }
  1.1128 -    virtual const XMLElement* ToElement() const {
  1.1129 -        return this;
  1.1130 -    }
  1.1131 -    virtual bool Accept( XMLVisitor* visitor ) const;
  1.1132 -
  1.1133 -    /** Given an attribute name, Attribute() returns the value
  1.1134 -    	for the attribute of that name, or null if none
  1.1135 -    	exists. For example:
  1.1136 -
  1.1137 -    	@verbatim
  1.1138 -    	const char* value = ele->Attribute( "foo" );
  1.1139 -    	@endverbatim
  1.1140 -
  1.1141 -    	The 'value' parameter is normally null. However, if specified,
  1.1142 -    	the attribute will only be returned if the 'name' and 'value'
  1.1143 -    	match. This allow you to write code:
  1.1144 -
  1.1145 -    	@verbatim
  1.1146 -    	if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();
  1.1147 -    	@endverbatim
  1.1148 -
  1.1149 -    	rather than:
  1.1150 -    	@verbatim
  1.1151 -    	if ( ele->Attribute( "foo" ) ) {
  1.1152 -    		if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();
  1.1153 -    	}
  1.1154 -    	@endverbatim
  1.1155 -    */
  1.1156 -    const char* Attribute( const char* name, const char* value=0 ) const;
  1.1157 -
  1.1158 -    /** Given an attribute name, IntAttribute() returns the value
  1.1159 -    	of the attribute interpreted as an integer. 0 will be
  1.1160 -    	returned if there is an error. For a method with error
  1.1161 -    	checking, see QueryIntAttribute()
  1.1162 -    */
  1.1163 -    int		 IntAttribute( const char* name ) const		{
  1.1164 -        int i=0;
  1.1165 -        QueryIntAttribute( name, &i );
  1.1166 -        return i;
  1.1167 -    }
  1.1168 -    /// See IntAttribute()
  1.1169 -    unsigned UnsignedAttribute( const char* name ) const {
  1.1170 -        unsigned i=0;
  1.1171 -        QueryUnsignedAttribute( name, &i );
  1.1172 -        return i;
  1.1173 -    }
  1.1174 -    /// See IntAttribute()
  1.1175 -    bool	 BoolAttribute( const char* name ) const	{
  1.1176 -        bool b=false;
  1.1177 -        QueryBoolAttribute( name, &b );
  1.1178 -        return b;
  1.1179 -    }
  1.1180 -    /// See IntAttribute()
  1.1181 -    double 	 DoubleAttribute( const char* name ) const	{
  1.1182 -        double d=0;
  1.1183 -        QueryDoubleAttribute( name, &d );
  1.1184 -        return d;
  1.1185 -    }
  1.1186 -    /// See IntAttribute()
  1.1187 -    float	 FloatAttribute( const char* name ) const	{
  1.1188 -        float f=0;
  1.1189 -        QueryFloatAttribute( name, &f );
  1.1190 -        return f;
  1.1191 -    }
  1.1192 -
  1.1193 -    /** Given an attribute name, QueryIntAttribute() returns
  1.1194 -    	XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
  1.1195 -    	can't be performed, or XML_NO_ATTRIBUTE if the attribute
  1.1196 -    	doesn't exist. If successful, the result of the conversion
  1.1197 -    	will be written to 'value'. If not successful, nothing will
  1.1198 -    	be written to 'value'. This allows you to provide default
  1.1199 -    	value:
  1.1200 -
  1.1201 -    	@verbatim
  1.1202 -    	int value = 10;
  1.1203 -    	QueryIntAttribute( "foo", &value );		// if "foo" isn't found, value will still be 10
  1.1204 -    	@endverbatim
  1.1205 -    */
  1.1206 -    XMLError QueryIntAttribute( const char* name, int* value ) const				{
  1.1207 -        const XMLAttribute* a = FindAttribute( name );
  1.1208 -        if ( !a ) {
  1.1209 -            return XML_NO_ATTRIBUTE;
  1.1210 -        }
  1.1211 -        return a->QueryIntValue( value );
  1.1212 -    }
  1.1213 -    /// See QueryIntAttribute()
  1.1214 -    XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const	{
  1.1215 -        const XMLAttribute* a = FindAttribute( name );
  1.1216 -        if ( !a ) {
  1.1217 -            return XML_NO_ATTRIBUTE;
  1.1218 -        }
  1.1219 -        return a->QueryUnsignedValue( value );
  1.1220 -    }
  1.1221 -    /// See QueryIntAttribute()
  1.1222 -    XMLError QueryBoolAttribute( const char* name, bool* value ) const				{
  1.1223 -        const XMLAttribute* a = FindAttribute( name );
  1.1224 -        if ( !a ) {
  1.1225 -            return XML_NO_ATTRIBUTE;
  1.1226 -        }
  1.1227 -        return a->QueryBoolValue( value );
  1.1228 -    }
  1.1229 -    /// See QueryIntAttribute()
  1.1230 -    XMLError QueryDoubleAttribute( const char* name, double* value ) const			{
  1.1231 -        const XMLAttribute* a = FindAttribute( name );
  1.1232 -        if ( !a ) {
  1.1233 -            return XML_NO_ATTRIBUTE;
  1.1234 -        }
  1.1235 -        return a->QueryDoubleValue( value );
  1.1236 -    }
  1.1237 -    /// See QueryIntAttribute()
  1.1238 -    XMLError QueryFloatAttribute( const char* name, float* value ) const			{
  1.1239 -        const XMLAttribute* a = FindAttribute( name );
  1.1240 -        if ( !a ) {
  1.1241 -            return XML_NO_ATTRIBUTE;
  1.1242 -        }
  1.1243 -        return a->QueryFloatValue( value );
  1.1244 -    }
  1.1245 -
  1.1246 -	
  1.1247 -    /** Given an attribute name, QueryAttribute() returns
  1.1248 -    	XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
  1.1249 -    	can't be performed, or XML_NO_ATTRIBUTE if the attribute
  1.1250 -    	doesn't exist. It is overloaded for the primitive types,
  1.1251 -		and is a generally more convenient replacement of
  1.1252 -		QueryIntAttribute() and related functions.
  1.1253 -		
  1.1254 -		If successful, the result of the conversion
  1.1255 -    	will be written to 'value'. If not successful, nothing will
  1.1256 -    	be written to 'value'. This allows you to provide default
  1.1257 -    	value:
  1.1258 -
  1.1259 -    	@verbatim
  1.1260 -    	int value = 10;
  1.1261 -    	QueryAttribute( "foo", &value );		// if "foo" isn't found, value will still be 10
  1.1262 -    	@endverbatim
  1.1263 -    */
  1.1264 -	int QueryAttribute( const char* name, int* value ) const {
  1.1265 -		return QueryIntAttribute( name, value );
  1.1266 -	}
  1.1267 -
  1.1268 -	int QueryAttribute( const char* name, unsigned int* value ) const {
  1.1269 -		return QueryUnsignedAttribute( name, value );
  1.1270 -	}
  1.1271 -
  1.1272 -	int QueryAttribute( const char* name, bool* value ) const {
  1.1273 -		return QueryBoolAttribute( name, value );
  1.1274 -	}
  1.1275 -
  1.1276 -	int QueryAttribute( const char* name, double* value ) const {
  1.1277 -		return QueryDoubleAttribute( name, value );
  1.1278 -	}
  1.1279 -
  1.1280 -	int QueryAttribute( const char* name, float* value ) const {
  1.1281 -		return QueryFloatAttribute( name, value );
  1.1282 -	}
  1.1283 -
  1.1284 -	/// Sets the named attribute to value.
  1.1285 -    void SetAttribute( const char* name, const char* value )	{
  1.1286 -        XMLAttribute* a = FindOrCreateAttribute( name );
  1.1287 -        a->SetAttribute( value );
  1.1288 -    }
  1.1289 -    /// Sets the named attribute to value.
  1.1290 -    void SetAttribute( const char* name, int value )			{
  1.1291 -        XMLAttribute* a = FindOrCreateAttribute( name );
  1.1292 -        a->SetAttribute( value );
  1.1293 -    }
  1.1294 -    /// Sets the named attribute to value.
  1.1295 -    void SetAttribute( const char* name, unsigned value )		{
  1.1296 -        XMLAttribute* a = FindOrCreateAttribute( name );
  1.1297 -        a->SetAttribute( value );
  1.1298 -    }
  1.1299 -    /// Sets the named attribute to value.
  1.1300 -    void SetAttribute( const char* name, bool value )			{
  1.1301 -        XMLAttribute* a = FindOrCreateAttribute( name );
  1.1302 -        a->SetAttribute( value );
  1.1303 -    }
  1.1304 -    /// Sets the named attribute to value.
  1.1305 -    void SetAttribute( const char* name, double value )		{
  1.1306 -        XMLAttribute* a = FindOrCreateAttribute( name );
  1.1307 -        a->SetAttribute( value );
  1.1308 -    }
  1.1309 -
  1.1310 -    /**
  1.1311 -    	Delete an attribute.
  1.1312 -    */
  1.1313 -    void DeleteAttribute( const char* name );
  1.1314 -
  1.1315 -    /// Return the first attribute in the list.
  1.1316 -    const XMLAttribute* FirstAttribute() const {
  1.1317 -        return _rootAttribute;
  1.1318 -    }
  1.1319 -    /// Query a specific attribute in the list.
  1.1320 -    const XMLAttribute* FindAttribute( const char* name ) const;
  1.1321 -
  1.1322 -    /** Convenience function for easy access to the text inside an element. Although easy
  1.1323 -    	and concise, GetText() is limited compared to getting the XMLText child
  1.1324 -    	and accessing it directly.
  1.1325 -
  1.1326 -    	If the first child of 'this' is a XMLText, the GetText()
  1.1327 -    	returns the character string of the Text node, else null is returned.
  1.1328 -
  1.1329 -    	This is a convenient method for getting the text of simple contained text:
  1.1330 -    	@verbatim
  1.1331 -    	<foo>This is text</foo>
  1.1332 -    		const char* str = fooElement->GetText();
  1.1333 -    	@endverbatim
  1.1334 -
  1.1335 -    	'str' will be a pointer to "This is text".
  1.1336 -
  1.1337 -    	Note that this function can be misleading. If the element foo was created from
  1.1338 -    	this XML:
  1.1339 -    	@verbatim
  1.1340 -    		<foo><b>This is text</b></foo>
  1.1341 -    	@endverbatim
  1.1342 -
  1.1343 -    	then the value of str would be null. The first child node isn't a text node, it is
  1.1344 -    	another element. From this XML:
  1.1345 -    	@verbatim
  1.1346 -    		<foo>This is <b>text</b></foo>
  1.1347 -    	@endverbatim
  1.1348 -    	GetText() will return "This is ".
  1.1349 -    */
  1.1350 -    const char* GetText() const;
  1.1351 -
  1.1352 -    /**
  1.1353 -    	Convenience method to query the value of a child text node. This is probably best
  1.1354 -    	shown by example. Given you have a document is this form:
  1.1355 -    	@verbatim
  1.1356 -    		<point>
  1.1357 -    			<x>1</x>
  1.1358 -    			<y>1.4</y>
  1.1359 -    		</point>
  1.1360 -    	@endverbatim
  1.1361 -
  1.1362 -    	The QueryIntText() and similar functions provide a safe and easier way to get to the
  1.1363 -    	"value" of x and y.
  1.1364 -
  1.1365 -    	@verbatim
  1.1366 -    		int x = 0;
  1.1367 -    		float y = 0;	// types of x and y are contrived for example
  1.1368 -    		const XMLElement* xElement = pointElement->FirstChildElement( "x" );
  1.1369 -    		const XMLElement* yElement = pointElement->FirstChildElement( "y" );
  1.1370 -    		xElement->QueryIntText( &x );
  1.1371 -    		yElement->QueryFloatText( &y );
  1.1372 -    	@endverbatim
  1.1373 -
  1.1374 -    	@returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted
  1.1375 -    			 to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.
  1.1376 -
  1.1377 -    */
  1.1378 -    XMLError QueryIntText( int* ival ) const;
  1.1379 -    /// See QueryIntText()
  1.1380 -    XMLError QueryUnsignedText( unsigned* uval ) const;
  1.1381 -    /// See QueryIntText()
  1.1382 -    XMLError QueryBoolText( bool* bval ) const;
  1.1383 -    /// See QueryIntText()
  1.1384 -    XMLError QueryDoubleText( double* dval ) const;
  1.1385 -    /// See QueryIntText()
  1.1386 -    XMLError QueryFloatText( float* fval ) const;
  1.1387 -
  1.1388 -    // internal:
  1.1389 -    enum {
  1.1390 -        OPEN,		// <foo>
  1.1391 -        CLOSED,		// <foo/>
  1.1392 -        CLOSING		// </foo>
  1.1393 -    };
  1.1394 -    int ClosingType() const {
  1.1395 -        return _closingType;
  1.1396 -    }
  1.1397 -    char* ParseDeep( char* p, StrPair* endTag );
  1.1398 -    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
  1.1399 -    virtual bool ShallowEqual( const XMLNode* compare ) const;
  1.1400 -
  1.1401 -private:
  1.1402 -    XMLElement( XMLDocument* doc );
  1.1403 -    virtual ~XMLElement();
  1.1404 -    XMLElement( const XMLElement& );	// not supported
  1.1405 -    void operator=( const XMLElement& );	// not supported
  1.1406 -
  1.1407 -    XMLAttribute* FindAttribute( const char* name );
  1.1408 -    XMLAttribute* FindOrCreateAttribute( const char* name );
  1.1409 -    //void LinkAttribute( XMLAttribute* attrib );
  1.1410 -    char* ParseAttributes( char* p );
  1.1411 -
  1.1412 -    int _closingType;
  1.1413 -    // The attribute list is ordered; there is no 'lastAttribute'
  1.1414 -    // because the list needs to be scanned for dupes before adding
  1.1415 -    // a new attribute.
  1.1416 -    XMLAttribute* _rootAttribute;
  1.1417 -};
  1.1418 -
  1.1419 -
  1.1420 -enum Whitespace {
  1.1421 -    PRESERVE_WHITESPACE,
  1.1422 -    COLLAPSE_WHITESPACE
  1.1423 -};
  1.1424 -
  1.1425 -
  1.1426 -/** A Document binds together all the functionality.
  1.1427 -	It can be saved, loaded, and printed to the screen.
  1.1428 -	All Nodes are connected and allocated to a Document.
  1.1429 -	If the Document is deleted, all its Nodes are also deleted.
  1.1430 -*/
  1.1431 -class TINYXML2_LIB XMLDocument : public XMLNode
  1.1432 -{
  1.1433 -    friend class XMLElement;
  1.1434 -public:
  1.1435 -    /// constructor
  1.1436 -    XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
  1.1437 -    ~XMLDocument();
  1.1438 -
  1.1439 -    virtual XMLDocument* ToDocument()				{
  1.1440 -        return this;
  1.1441 -    }
  1.1442 -    virtual const XMLDocument* ToDocument() const	{
  1.1443 -        return this;
  1.1444 -    }
  1.1445 -
  1.1446 -    /**
  1.1447 -    	Parse an XML file from a character string.
  1.1448 -    	Returns XML_NO_ERROR (0) on success, or
  1.1449 -    	an errorID.
  1.1450 -
  1.1451 -    	You may optionally pass in the 'nBytes', which is
  1.1452 -    	the number of bytes which will be parsed. If not
  1.1453 -    	specified, TinyXML-2 will assume 'xml' points to a
  1.1454 -    	null terminated string.
  1.1455 -    */
  1.1456 -    XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
  1.1457 -
  1.1458 -    /**
  1.1459 -    	Load an XML file from disk.
  1.1460 -    	Returns XML_NO_ERROR (0) on success, or
  1.1461 -    	an errorID.
  1.1462 -    */
  1.1463 -    XMLError LoadFile( const char* filename );
  1.1464 -
  1.1465 -    /**
  1.1466 -    	Load an XML file from disk. You are responsible
  1.1467 -    	for providing and closing the FILE*.
  1.1468 -
  1.1469 -    	Returns XML_NO_ERROR (0) on success, or
  1.1470 -    	an errorID.
  1.1471 -    */
  1.1472 -    XMLError LoadFile( FILE* );
  1.1473 -
  1.1474 -    /**
  1.1475 -    	Save the XML file to disk.
  1.1476 -    	Returns XML_NO_ERROR (0) on success, or
  1.1477 -    	an errorID.
  1.1478 -    */
  1.1479 -    XMLError SaveFile( const char* filename, bool compact = false );
  1.1480 -
  1.1481 -    /**
  1.1482 -    	Save the XML file to disk. You are responsible
  1.1483 -    	for providing and closing the FILE*.
  1.1484 -
  1.1485 -    	Returns XML_NO_ERROR (0) on success, or
  1.1486 -    	an errorID.
  1.1487 -    */
  1.1488 -    XMLError SaveFile( FILE* fp, bool compact = false );
  1.1489 -
  1.1490 -    bool ProcessEntities() const		{
  1.1491 -        return _processEntities;
  1.1492 -    }
  1.1493 -    Whitespace WhitespaceMode() const	{
  1.1494 -        return _whitespace;
  1.1495 -    }
  1.1496 -
  1.1497 -    /**
  1.1498 -    	Returns true if this document has a leading Byte Order Mark of UTF8.
  1.1499 -    */
  1.1500 -    bool HasBOM() const {
  1.1501 -        return _writeBOM;
  1.1502 -    }
  1.1503 -    /** Sets whether to write the BOM when writing the file.
  1.1504 -    */
  1.1505 -    void SetBOM( bool useBOM ) {
  1.1506 -        _writeBOM = useBOM;
  1.1507 -    }
  1.1508 -
  1.1509 -    /** Return the root element of DOM. Equivalent to FirstChildElement().
  1.1510 -        To get the first node, use FirstChild().
  1.1511 -    */
  1.1512 -    XMLElement* RootElement()				{
  1.1513 -        return FirstChildElement();
  1.1514 -    }
  1.1515 -    const XMLElement* RootElement() const	{
  1.1516 -        return FirstChildElement();
  1.1517 -    }
  1.1518 -
  1.1519 -    /** Print the Document. If the Printer is not provided, it will
  1.1520 -        print to stdout. If you provide Printer, this can print to a file:
  1.1521 -    	@verbatim
  1.1522 -    	XMLPrinter printer( fp );
  1.1523 -    	doc.Print( &printer );
  1.1524 -    	@endverbatim
  1.1525 -
  1.1526 -    	Or you can use a printer to print to memory:
  1.1527 -    	@verbatim
  1.1528 -    	XMLPrinter printer;
  1.1529 -    	doc.Print( &printer );
  1.1530 -    	// printer.CStr() has a const char* to the XML
  1.1531 -    	@endverbatim
  1.1532 -    */
  1.1533 -    void Print( XMLPrinter* streamer=0 ) const;
  1.1534 -    virtual bool Accept( XMLVisitor* visitor ) const;
  1.1535 -
  1.1536 -    /**
  1.1537 -    	Create a new Element associated with
  1.1538 -    	this Document. The memory for the Element
  1.1539 -    	is managed by the Document.
  1.1540 -    */
  1.1541 -    XMLElement* NewElement( const char* name );
  1.1542 -    /**
  1.1543 -    	Create a new Comment associated with
  1.1544 -    	this Document. The memory for the Comment
  1.1545 -    	is managed by the Document.
  1.1546 -    */
  1.1547 -    XMLComment* NewComment( const char* comment );
  1.1548 -    /**
  1.1549 -    	Create a new Text associated with
  1.1550 -    	this Document. The memory for the Text
  1.1551 -    	is managed by the Document.
  1.1552 -    */
  1.1553 -    XMLText* NewText( const char* text );
  1.1554 -    /**
  1.1555 -    	Create a new Declaration associated with
  1.1556 -    	this Document. The memory for the object
  1.1557 -    	is managed by the Document.
  1.1558 -
  1.1559 -    	If the 'text' param is null, the standard
  1.1560 -    	declaration is used.:
  1.1561 -    	@verbatim
  1.1562 -    		<?xml version="1.0" encoding="UTF-8"?>
  1.1563 -    	@endverbatim
  1.1564 -    */
  1.1565 -    XMLDeclaration* NewDeclaration( const char* text=0 );
  1.1566 -    /**
  1.1567 -    	Create a new Unknown associated with
  1.1568 -    	this Document. The memory for the object
  1.1569 -    	is managed by the Document.
  1.1570 -    */
  1.1571 -    XMLUnknown* NewUnknown( const char* text );
  1.1572 -
  1.1573 -    /**
  1.1574 -    	Delete a node associated with this document.
  1.1575 -    	It will be unlinked from the DOM.
  1.1576 -    */
  1.1577 -    void DeleteNode( XMLNode* node )	{
  1.1578 -        node->_parent->DeleteChild( node );
  1.1579 -    }
  1.1580 -
  1.1581 -    void SetError( XMLError error, const char* str1, const char* str2 );
  1.1582 -
  1.1583 -    /// Return true if there was an error parsing the document.
  1.1584 -    bool Error() const {
  1.1585 -        return _errorID != XML_NO_ERROR;
  1.1586 -    }
  1.1587 -    /// Return the errorID.
  1.1588 -    XMLError  ErrorID() const {
  1.1589 -        return _errorID;
  1.1590 -    }
  1.1591 -    /// Return a possibly helpful diagnostic location or string.
  1.1592 -    const char* GetErrorStr1() const {
  1.1593 -        return _errorStr1;
  1.1594 -    }
  1.1595 -    /// Return a possibly helpful secondary diagnostic location or string.
  1.1596 -    const char* GetErrorStr2() const {
  1.1597 -        return _errorStr2;
  1.1598 -    }
  1.1599 -    /// If there is an error, print it to stdout.
  1.1600 -    void PrintError() const;
  1.1601 -    
  1.1602 -    /// Clear the document, resetting it to the initial state.
  1.1603 -    void Clear();
  1.1604 -
  1.1605 -    // internal
  1.1606 -    char* Identify( char* p, XMLNode** node );
  1.1607 -
  1.1608 -    virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const	{
  1.1609 -        return 0;
  1.1610 -    }
  1.1611 -    virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const	{
  1.1612 -        return false;
  1.1613 -    }
  1.1614 -
  1.1615 -private:
  1.1616 -    XMLDocument( const XMLDocument& );	// not supported
  1.1617 -    void operator=( const XMLDocument& );	// not supported
  1.1618 -
  1.1619 -    bool        _writeBOM;
  1.1620 -    bool        _processEntities;
  1.1621 -    XMLError    _errorID;
  1.1622 -    Whitespace  _whitespace;
  1.1623 -    const char* _errorStr1;
  1.1624 -    const char* _errorStr2;
  1.1625 -    char*       _charBuffer;
  1.1626 -
  1.1627 -    MemPoolT< sizeof(XMLElement) >	 _elementPool;
  1.1628 -    MemPoolT< sizeof(XMLAttribute) > _attributePool;
  1.1629 -    MemPoolT< sizeof(XMLText) >		 _textPool;
  1.1630 -    MemPoolT< sizeof(XMLComment) >	 _commentPool;
  1.1631 -};
  1.1632 -
  1.1633 -
  1.1634 -/**
  1.1635 -	A XMLHandle is a class that wraps a node pointer with null checks; this is
  1.1636 -	an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2
  1.1637 -	DOM structure. It is a separate utility class.
  1.1638 -
  1.1639 -	Take an example:
  1.1640 -	@verbatim
  1.1641 -	<Document>
  1.1642 -		<Element attributeA = "valueA">
  1.1643 -			<Child attributeB = "value1" />
  1.1644 -			<Child attributeB = "value2" />
  1.1645 -		</Element>
  1.1646 -	</Document>
  1.1647 -	@endverbatim
  1.1648 -
  1.1649 -	Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
  1.1650 -	easy to write a *lot* of code that looks like:
  1.1651 -
  1.1652 -	@verbatim
  1.1653 -	XMLElement* root = document.FirstChildElement( "Document" );
  1.1654 -	if ( root )
  1.1655 -	{
  1.1656 -		XMLElement* element = root->FirstChildElement( "Element" );
  1.1657 -		if ( element )
  1.1658 -		{
  1.1659 -			XMLElement* child = element->FirstChildElement( "Child" );
  1.1660 -			if ( child )
  1.1661 -			{
  1.1662 -				XMLElement* child2 = child->NextSiblingElement( "Child" );
  1.1663 -				if ( child2 )
  1.1664 -				{
  1.1665 -					// Finally do something useful.
  1.1666 -	@endverbatim
  1.1667 -
  1.1668 -	And that doesn't even cover "else" cases. XMLHandle addresses the verbosity
  1.1669 -	of such code. A XMLHandle checks for null pointers so it is perfectly safe
  1.1670 -	and correct to use:
  1.1671 -
  1.1672 -	@verbatim
  1.1673 -	XMLHandle docHandle( &document );
  1.1674 -	XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
  1.1675 -	if ( child2 )
  1.1676 -	{
  1.1677 -		// do something useful
  1.1678 -	@endverbatim
  1.1679 -
  1.1680 -	Which is MUCH more concise and useful.
  1.1681 -
  1.1682 -	It is also safe to copy handles - internally they are nothing more than node pointers.
  1.1683 -	@verbatim
  1.1684 -	XMLHandle handleCopy = handle;
  1.1685 -	@endverbatim
  1.1686 -
  1.1687 -	See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
  1.1688 -*/
  1.1689 -class TINYXML2_LIB XMLHandle
  1.1690 -{
  1.1691 -public:
  1.1692 -    /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
  1.1693 -    XMLHandle( XMLNode* node )												{
  1.1694 -        _node = node;
  1.1695 -    }
  1.1696 -    /// Create a handle from a node.
  1.1697 -    XMLHandle( XMLNode& node )												{
  1.1698 -        _node = &node;
  1.1699 -    }
  1.1700 -    /// Copy constructor
  1.1701 -    XMLHandle( const XMLHandle& ref )										{
  1.1702 -        _node = ref._node;
  1.1703 -    }
  1.1704 -    /// Assignment
  1.1705 -    XMLHandle& operator=( const XMLHandle& ref )							{
  1.1706 -        _node = ref._node;
  1.1707 -        return *this;
  1.1708 -    }
  1.1709 -
  1.1710 -    /// Get the first child of this handle.
  1.1711 -    XMLHandle FirstChild() 													{
  1.1712 -        return XMLHandle( _node ? _node->FirstChild() : 0 );
  1.1713 -    }
  1.1714 -    /// Get the first child element of this handle.
  1.1715 -    XMLHandle FirstChildElement( const char* value=0 )						{
  1.1716 -        return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
  1.1717 -    }
  1.1718 -    /// Get the last child of this handle.
  1.1719 -    XMLHandle LastChild()													{
  1.1720 -        return XMLHandle( _node ? _node->LastChild() : 0 );
  1.1721 -    }
  1.1722 -    /// Get the last child element of this handle.
  1.1723 -    XMLHandle LastChildElement( const char* _value=0 )						{
  1.1724 -        return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
  1.1725 -    }
  1.1726 -    /// Get the previous sibling of this handle.
  1.1727 -    XMLHandle PreviousSibling()												{
  1.1728 -        return XMLHandle( _node ? _node->PreviousSibling() : 0 );
  1.1729 -    }
  1.1730 -    /// Get the previous sibling element of this handle.
  1.1731 -    XMLHandle PreviousSiblingElement( const char* _value=0 )				{
  1.1732 -        return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
  1.1733 -    }
  1.1734 -    /// Get the next sibling of this handle.
  1.1735 -    XMLHandle NextSibling()													{
  1.1736 -        return XMLHandle( _node ? _node->NextSibling() : 0 );
  1.1737 -    }
  1.1738 -    /// Get the next sibling element of this handle.
  1.1739 -    XMLHandle NextSiblingElement( const char* _value=0 )					{
  1.1740 -        return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
  1.1741 -    }
  1.1742 -
  1.1743 -    /// Safe cast to XMLNode. This can return null.
  1.1744 -    XMLNode* ToNode()							{
  1.1745 -        return _node;
  1.1746 -    }
  1.1747 -    /// Safe cast to XMLElement. This can return null.
  1.1748 -    XMLElement* ToElement() 					{
  1.1749 -        return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
  1.1750 -    }
  1.1751 -    /// Safe cast to XMLText. This can return null.
  1.1752 -    XMLText* ToText() 							{
  1.1753 -        return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
  1.1754 -    }
  1.1755 -    /// Safe cast to XMLUnknown. This can return null.
  1.1756 -    XMLUnknown* ToUnknown() 					{
  1.1757 -        return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
  1.1758 -    }
  1.1759 -    /// Safe cast to XMLDeclaration. This can return null.
  1.1760 -    XMLDeclaration* ToDeclaration() 			{
  1.1761 -        return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
  1.1762 -    }
  1.1763 -
  1.1764 -private:
  1.1765 -    XMLNode* _node;
  1.1766 -};
  1.1767 -
  1.1768 -
  1.1769 -/**
  1.1770 -	A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the
  1.1771 -	same in all regards, except for the 'const' qualifiers. See XMLHandle for API.
  1.1772 -*/
  1.1773 -class TINYXML2_LIB XMLConstHandle
  1.1774 -{
  1.1775 -public:
  1.1776 -    XMLConstHandle( const XMLNode* node )											{
  1.1777 -        _node = node;
  1.1778 -    }
  1.1779 -    XMLConstHandle( const XMLNode& node )											{
  1.1780 -        _node = &node;
  1.1781 -    }
  1.1782 -    XMLConstHandle( const XMLConstHandle& ref )										{
  1.1783 -        _node = ref._node;
  1.1784 -    }
  1.1785 -
  1.1786 -    XMLConstHandle& operator=( const XMLConstHandle& ref )							{
  1.1787 -        _node = ref._node;
  1.1788 -        return *this;
  1.1789 -    }
  1.1790 -
  1.1791 -    const XMLConstHandle FirstChild() const											{
  1.1792 -        return XMLConstHandle( _node ? _node->FirstChild() : 0 );
  1.1793 -    }
  1.1794 -    const XMLConstHandle FirstChildElement( const char* value=0 ) const				{
  1.1795 -        return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
  1.1796 -    }
  1.1797 -    const XMLConstHandle LastChild()	const										{
  1.1798 -        return XMLConstHandle( _node ? _node->LastChild() : 0 );
  1.1799 -    }
  1.1800 -    const XMLConstHandle LastChildElement( const char* _value=0 ) const				{
  1.1801 -        return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
  1.1802 -    }
  1.1803 -    const XMLConstHandle PreviousSibling() const									{
  1.1804 -        return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
  1.1805 -    }
  1.1806 -    const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const		{
  1.1807 -        return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
  1.1808 -    }
  1.1809 -    const XMLConstHandle NextSibling() const										{
  1.1810 -        return XMLConstHandle( _node ? _node->NextSibling() : 0 );
  1.1811 -    }
  1.1812 -    const XMLConstHandle NextSiblingElement( const char* _value=0 ) const			{
  1.1813 -        return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
  1.1814 -    }
  1.1815 -
  1.1816 -
  1.1817 -    const XMLNode* ToNode() const				{
  1.1818 -        return _node;
  1.1819 -    }
  1.1820 -    const XMLElement* ToElement() const			{
  1.1821 -        return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
  1.1822 -    }
  1.1823 -    const XMLText* ToText() const				{
  1.1824 -        return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
  1.1825 -    }
  1.1826 -    const XMLUnknown* ToUnknown() const			{
  1.1827 -        return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
  1.1828 -    }
  1.1829 -    const XMLDeclaration* ToDeclaration() const	{
  1.1830 -        return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
  1.1831 -    }
  1.1832 -
  1.1833 -private:
  1.1834 -    const XMLNode* _node;
  1.1835 -};
  1.1836 -
  1.1837 -
  1.1838 -/**
  1.1839 -	Printing functionality. The XMLPrinter gives you more
  1.1840 -	options than the XMLDocument::Print() method.
  1.1841 -
  1.1842 -	It can:
  1.1843 -	-# Print to memory.
  1.1844 -	-# Print to a file you provide.
  1.1845 -	-# Print XML without a XMLDocument.
  1.1846 -
  1.1847 -	Print to Memory
  1.1848 -
  1.1849 -	@verbatim
  1.1850 -	XMLPrinter printer;
  1.1851 -	doc.Print( &printer );
  1.1852 -	SomeFunction( printer.CStr() );
  1.1853 -	@endverbatim
  1.1854 -
  1.1855 -	Print to a File
  1.1856 -
  1.1857 -	You provide the file pointer.
  1.1858 -	@verbatim
  1.1859 -	XMLPrinter printer( fp );
  1.1860 -	doc.Print( &printer );
  1.1861 -	@endverbatim
  1.1862 -
  1.1863 -	Print without a XMLDocument
  1.1864 -
  1.1865 -	When loading, an XML parser is very useful. However, sometimes
  1.1866 -	when saving, it just gets in the way. The code is often set up
  1.1867 -	for streaming, and constructing the DOM is just overhead.
  1.1868 -
  1.1869 -	The Printer supports the streaming case. The following code
  1.1870 -	prints out a trivially simple XML file without ever creating
  1.1871 -	an XML document.
  1.1872 -
  1.1873 -	@verbatim
  1.1874 -	XMLPrinter printer( fp );
  1.1875 -	printer.OpenElement( "foo" );
  1.1876 -	printer.PushAttribute( "foo", "bar" );
  1.1877 -	printer.CloseElement();
  1.1878 -	@endverbatim
  1.1879 -*/
  1.1880 -class TINYXML2_LIB XMLPrinter : public XMLVisitor
  1.1881 -{
  1.1882 -public:
  1.1883 -    /** Construct the printer. If the FILE* is specified,
  1.1884 -    	this will print to the FILE. Else it will print
  1.1885 -    	to memory, and the result is available in CStr().
  1.1886 -    	If 'compact' is set to true, then output is created
  1.1887 -    	with only required whitespace and newlines.
  1.1888 -    */
  1.1889 -    XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
  1.1890 -    ~XMLPrinter()	{}
  1.1891 -
  1.1892 -    /** If streaming, write the BOM and declaration. */
  1.1893 -    void PushHeader( bool writeBOM, bool writeDeclaration );
  1.1894 -    /** If streaming, start writing an element.
  1.1895 -        The element must be closed with CloseElement()
  1.1896 -    */
  1.1897 -    void OpenElement( const char* name );
  1.1898 -    /// If streaming, add an attribute to an open element.
  1.1899 -    void PushAttribute( const char* name, const char* value );
  1.1900 -    void PushAttribute( const char* name, int value );
  1.1901 -    void PushAttribute( const char* name, unsigned value );
  1.1902 -    void PushAttribute( const char* name, bool value );
  1.1903 -    void PushAttribute( const char* name, double value );
  1.1904 -    /// If streaming, close the Element.
  1.1905 -    void CloseElement();
  1.1906 -
  1.1907 -    /// Add a text node.
  1.1908 -    void PushText( const char* text, bool cdata=false );
  1.1909 -    /// Add a text node from an integer.
  1.1910 -    void PushText( int value );
  1.1911 -    /// Add a text node from an unsigned.
  1.1912 -    void PushText( unsigned value );
  1.1913 -    /// Add a text node from a bool.
  1.1914 -    void PushText( bool value );
  1.1915 -    /// Add a text node from a float.
  1.1916 -    void PushText( float value );
  1.1917 -    /// Add a text node from a double.
  1.1918 -    void PushText( double value );
  1.1919 -
  1.1920 -    /// Add a comment
  1.1921 -    void PushComment( const char* comment );
  1.1922 -
  1.1923 -    void PushDeclaration( const char* value );
  1.1924 -    void PushUnknown( const char* value );
  1.1925 -
  1.1926 -    virtual bool VisitEnter( const XMLDocument& /*doc*/ );
  1.1927 -    virtual bool VisitExit( const XMLDocument& /*doc*/ )			{
  1.1928 -        return true;
  1.1929 -    }
  1.1930 -
  1.1931 -    virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
  1.1932 -    virtual bool VisitExit( const XMLElement& element );
  1.1933 -
  1.1934 -    virtual bool Visit( const XMLText& text );
  1.1935 -    virtual bool Visit( const XMLComment& comment );
  1.1936 -    virtual bool Visit( const XMLDeclaration& declaration );
  1.1937 -    virtual bool Visit( const XMLUnknown& unknown );
  1.1938 -
  1.1939 -    /**
  1.1940 -    	If in print to memory mode, return a pointer to
  1.1941 -    	the XML file in memory.
  1.1942 -    */
  1.1943 -    const char* CStr() const {
  1.1944 -        return _buffer.Mem();
  1.1945 -    }
  1.1946 -    /**
  1.1947 -    	If in print to memory mode, return the size
  1.1948 -    	of the XML file in memory. (Note the size returned
  1.1949 -    	includes the terminating null.)
  1.1950 -    */
  1.1951 -    int CStrSize() const {
  1.1952 -        return _buffer.Size();
  1.1953 -    }
  1.1954 -
  1.1955 -private:
  1.1956 -    void SealElement();
  1.1957 -    void PrintSpace( int depth );
  1.1958 -    void PrintString( const char*, bool restrictedEntitySet );	// prints out, after detecting entities.
  1.1959 -    void Print( const char* format, ... );
  1.1960 -
  1.1961 -    bool _elementJustOpened;
  1.1962 -    bool _firstElement;
  1.1963 -    FILE* _fp;
  1.1964 -    int _depth;
  1.1965 -    int _textDepth;
  1.1966 -    bool _processEntities;
  1.1967 -    bool _compactMode;
  1.1968 -
  1.1969 -    enum {
  1.1970 -        ENTITY_RANGE = 64,
  1.1971 -        BUF_SIZE = 200
  1.1972 -    };
  1.1973 -    bool _entityFlag[ENTITY_RANGE];
  1.1974 -    bool _restrictedEntityFlag[ENTITY_RANGE];
  1.1975 -
  1.1976 -    DynArray< const char*, 10 > _stack;
  1.1977 -    DynArray< char, 20 > _buffer;
  1.1978 -#ifdef _MSC_VER
  1.1979 -    DynArray< char, 20 > _accumulator;
  1.1980 -#endif
  1.1981 -};
  1.1982 -
  1.1983 -
  1.1984 -}	// tinyxml2
  1.1985 -
  1.1986 -#if defined(_MSC_VER)
  1.1987 -#   pragma warning(pop)
  1.1988 -#endif
  1.1989 -
  1.1990 -#endif // TINYXML2_INCLUDED
  1.1991 +/*
  1.1992 +Original code by Lee Thomason (www.grinninglizard.com)
  1.1993 +
  1.1994 +This software is provided 'as-is', without any express or implied
  1.1995 +warranty. In no event will the authors be held liable for any
  1.1996 +damages arising from the use of this software.
  1.1997 +
  1.1998 +Permission is granted to anyone to use this software for any
  1.1999 +purpose, including commercial applications, and to alter it and
  1.2000 +redistribute it freely, subject to the following restrictions:
  1.2001 +
  1.2002 +1. The origin of this software must not be misrepresented; you must
  1.2003 +not claim that you wrote the original software. If you use this
  1.2004 +software in a product, an acknowledgment in the product documentation
  1.2005 +would be appreciated but is not required.
  1.2006 +
  1.2007 +
  1.2008 +2. Altered source versions must be plainly marked as such, and
  1.2009 +must not be misrepresented as being the original software.
  1.2010 +
  1.2011 +3. This notice may not be removed or altered from any source
  1.2012 +distribution.
  1.2013 +*/
  1.2014 +
  1.2015 +#ifndef TINYXML2_INCLUDED
  1.2016 +#define TINYXML2_INCLUDED
  1.2017 +
  1.2018 +#if defined(ANDROID_NDK) || defined(__BORLANDC__)
  1.2019 +#   include <ctype.h>
  1.2020 +#   include <limits.h>
  1.2021 +#   include <stdio.h>
  1.2022 +#   include <stdlib.h>
  1.2023 +#   include <string.h>
  1.2024 +#   include <stdarg.h>
  1.2025 +#else
  1.2026 +#   include <cctype>
  1.2027 +#   include <climits>
  1.2028 +#   include <cstdio>
  1.2029 +#   include <cstdlib>
  1.2030 +#   include <cstring>
  1.2031 +#   include <cstdarg>
  1.2032 +#endif
  1.2033 +
  1.2034 +/*
  1.2035 +   TODO: intern strings instead of allocation.
  1.2036 +*/
  1.2037 +/*
  1.2038 +	gcc:
  1.2039 +        g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
  1.2040 +
  1.2041 +    Formatting, Artistic Style:
  1.2042 +        AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
  1.2043 +*/
  1.2044 +
  1.2045 +#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
  1.2046 +#   ifndef DEBUG
  1.2047 +#       define DEBUG
  1.2048 +#   endif
  1.2049 +#endif
  1.2050 +
  1.2051 +#ifdef _MSC_VER
  1.2052 +#   pragma warning(push)
  1.2053 +#   pragma warning(disable: 4251)
  1.2054 +#endif
  1.2055 +
  1.2056 +#ifdef _WIN32
  1.2057 +#   ifdef TINYXML2_EXPORT
  1.2058 +#       define TINYXML2_LIB __declspec(dllexport)
  1.2059 +#   elif defined(TINYXML2_IMPORT)
  1.2060 +#       define TINYXML2_LIB __declspec(dllimport)
  1.2061 +#   else
  1.2062 +#       define TINYXML2_LIB
  1.2063 +#   endif
  1.2064 +#else
  1.2065 +#   define TINYXML2_LIB
  1.2066 +#endif
  1.2067 +
  1.2068 +
  1.2069 +#if defined(DEBUG)
  1.2070 +#   if defined(_MSC_VER)
  1.2071 +#       define TIXMLASSERT( x )           if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
  1.2072 +#   elif defined (ANDROID_NDK)
  1.2073 +#       include <android/log.h>
  1.2074 +#       define TIXMLASSERT( x )           if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
  1.2075 +#   else
  1.2076 +#       include <assert.h>
  1.2077 +#       define TIXMLASSERT                assert
  1.2078 +#   endif
  1.2079 +#   else
  1.2080 +#       define TIXMLASSERT( x )           {}
  1.2081 +#endif
  1.2082 +
  1.2083 +
  1.2084 +#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
  1.2085 +// Microsoft visual studio, version 2005 and higher.
  1.2086 +/*int _snprintf_s(
  1.2087 +   char *buffer,
  1.2088 +   size_t sizeOfBuffer,
  1.2089 +   size_t count,
  1.2090 +   const char *format [,
  1.2091 +	  argument] ...
  1.2092 +);*/
  1.2093 +inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
  1.2094 +{
  1.2095 +    va_list va;
  1.2096 +    va_start( va, format );
  1.2097 +    int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
  1.2098 +    va_end( va );
  1.2099 +    return result;
  1.2100 +}
  1.2101 +#define TIXML_SSCANF   sscanf_s
  1.2102 +#else
  1.2103 +// GCC version 3 and higher
  1.2104 +//#warning( "Using sn* functions." )
  1.2105 +#define TIXML_SNPRINTF snprintf
  1.2106 +#define TIXML_SSCANF   sscanf
  1.2107 +#endif
  1.2108 +
  1.2109 +static const int TIXML2_MAJOR_VERSION = 1;
  1.2110 +static const int TIXML2_MINOR_VERSION = 0;
  1.2111 +static const int TIXML2_PATCH_VERSION = 11;
  1.2112 +
  1.2113 +namespace tinyxml2
  1.2114 +{
  1.2115 +class XMLDocument;
  1.2116 +class XMLElement;
  1.2117 +class XMLAttribute;
  1.2118 +class XMLComment;
  1.2119 +class XMLText;
  1.2120 +class XMLDeclaration;
  1.2121 +class XMLUnknown;
  1.2122 +class XMLPrinter;
  1.2123 +
  1.2124 +/*
  1.2125 +	A class that wraps strings. Normally stores the start and end
  1.2126 +	pointers into the XML file itself, and will apply normalization
  1.2127 +	and entity translation if actually read. Can also store (and memory
  1.2128 +	manage) a traditional char[]
  1.2129 +*/
  1.2130 +class StrPair
  1.2131 +{
  1.2132 +public:
  1.2133 +    enum {
  1.2134 +        NEEDS_ENTITY_PROCESSING			= 0x01,
  1.2135 +        NEEDS_NEWLINE_NORMALIZATION		= 0x02,
  1.2136 +        COLLAPSE_WHITESPACE	                = 0x04,
  1.2137 +
  1.2138 +        TEXT_ELEMENT		            	= NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
  1.2139 +        TEXT_ELEMENT_LEAVE_ENTITIES		= NEEDS_NEWLINE_NORMALIZATION,
  1.2140 +        ATTRIBUTE_NAME		            	= 0,
  1.2141 +        ATTRIBUTE_VALUE		            	= NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
  1.2142 +        ATTRIBUTE_VALUE_LEAVE_ENTITIES  	= NEEDS_NEWLINE_NORMALIZATION,
  1.2143 +        COMMENT				        = NEEDS_NEWLINE_NORMALIZATION
  1.2144 +    };
  1.2145 +
  1.2146 +    StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
  1.2147 +    ~StrPair();
  1.2148 +
  1.2149 +    void Set( char* start, char* end, int flags ) {
  1.2150 +        Reset();
  1.2151 +        _start  = start;
  1.2152 +        _end    = end;
  1.2153 +        _flags  = flags | NEEDS_FLUSH;
  1.2154 +    }
  1.2155 +
  1.2156 +    const char* GetStr();
  1.2157 +
  1.2158 +    bool Empty() const {
  1.2159 +        return _start == _end;
  1.2160 +    }
  1.2161 +
  1.2162 +    void SetInternedStr( const char* str ) {
  1.2163 +        Reset();
  1.2164 +        _start = const_cast<char*>(str);
  1.2165 +    }
  1.2166 +
  1.2167 +    void SetStr( const char* str, int flags=0 );
  1.2168 +
  1.2169 +    char* ParseText( char* in, const char* endTag, int strFlags );
  1.2170 +    char* ParseName( char* in );
  1.2171 +
  1.2172 +private:
  1.2173 +    void Reset();
  1.2174 +    void CollapseWhitespace();
  1.2175 +
  1.2176 +    enum {
  1.2177 +        NEEDS_FLUSH = 0x100,
  1.2178 +        NEEDS_DELETE = 0x200
  1.2179 +    };
  1.2180 +
  1.2181 +    // After parsing, if *_end != 0, it can be set to zero.
  1.2182 +    int     _flags;
  1.2183 +    char*   _start;
  1.2184 +    char*   _end;
  1.2185 +};
  1.2186 +
  1.2187 +
  1.2188 +/*
  1.2189 +	A dynamic array of Plain Old Data. Doesn't support constructors, etc.
  1.2190 +	Has a small initial memory pool, so that low or no usage will not
  1.2191 +	cause a call to new/delete
  1.2192 +*/
  1.2193 +template <class T, int INIT>
  1.2194 +class DynArray
  1.2195 +{
  1.2196 +public:
  1.2197 +    DynArray< T, INIT >() {
  1.2198 +        _mem = _pool;
  1.2199 +        _allocated = INIT;
  1.2200 +        _size = 0;
  1.2201 +    }
  1.2202 +
  1.2203 +    ~DynArray() {
  1.2204 +        if ( _mem != _pool ) {
  1.2205 +            delete [] _mem;
  1.2206 +        }
  1.2207 +    }
  1.2208 +
  1.2209 +    void Push( T t ) {
  1.2210 +        EnsureCapacity( _size+1 );
  1.2211 +        _mem[_size++] = t;
  1.2212 +    }
  1.2213 +
  1.2214 +    T* PushArr( int count ) {
  1.2215 +        EnsureCapacity( _size+count );
  1.2216 +        T* ret = &_mem[_size];
  1.2217 +        _size += count;
  1.2218 +        return ret;
  1.2219 +    }
  1.2220 +
  1.2221 +    T Pop() {
  1.2222 +        return _mem[--_size];
  1.2223 +    }
  1.2224 +
  1.2225 +    void PopArr( int count ) {
  1.2226 +        TIXMLASSERT( _size >= count );
  1.2227 +        _size -= count;
  1.2228 +    }
  1.2229 +
  1.2230 +    bool Empty() const					{
  1.2231 +        return _size == 0;
  1.2232 +    }
  1.2233 +
  1.2234 +    T& operator[](int i)				{
  1.2235 +        TIXMLASSERT( i>= 0 && i < _size );
  1.2236 +        return _mem[i];
  1.2237 +    }
  1.2238 +
  1.2239 +    const T& operator[](int i) const	{
  1.2240 +        TIXMLASSERT( i>= 0 && i < _size );
  1.2241 +        return _mem[i];
  1.2242 +    }
  1.2243 +
  1.2244 +    int Size() const					{
  1.2245 +        return _size;
  1.2246 +    }
  1.2247 +
  1.2248 +    int Capacity() const				{
  1.2249 +        return _allocated;
  1.2250 +    }
  1.2251 +
  1.2252 +    const T* Mem() const				{
  1.2253 +        return _mem;
  1.2254 +    }
  1.2255 +
  1.2256 +    T* Mem()							{
  1.2257 +        return _mem;
  1.2258 +    }
  1.2259 +
  1.2260 +private:
  1.2261 +    void EnsureCapacity( int cap ) {
  1.2262 +        if ( cap > _allocated ) {
  1.2263 +            int newAllocated = cap * 2;
  1.2264 +            T* newMem = new T[newAllocated];
  1.2265 +            memcpy( newMem, _mem, sizeof(T)*_size );	// warning: not using constructors, only works for PODs
  1.2266 +            if ( _mem != _pool ) {
  1.2267 +                delete [] _mem;
  1.2268 +            }
  1.2269 +            _mem = newMem;
  1.2270 +            _allocated = newAllocated;
  1.2271 +        }
  1.2272 +    }
  1.2273 +
  1.2274 +    T*  _mem;
  1.2275 +    T   _pool[INIT];
  1.2276 +    int _allocated;		// objects allocated
  1.2277 +    int _size;			// number objects in use
  1.2278 +};
  1.2279 +
  1.2280 +
  1.2281 +/*
  1.2282 +	Parent virtual class of a pool for fast allocation
  1.2283 +	and deallocation of objects.
  1.2284 +*/
  1.2285 +class MemPool
  1.2286 +{
  1.2287 +public:
  1.2288 +    MemPool() {}
  1.2289 +    virtual ~MemPool() {}
  1.2290 +
  1.2291 +    virtual int ItemSize() const = 0;
  1.2292 +    virtual void* Alloc() = 0;
  1.2293 +    virtual void Free( void* ) = 0;
  1.2294 +    virtual void SetTracked() = 0;
  1.2295 +};
  1.2296 +
  1.2297 +
  1.2298 +/*
  1.2299 +	Template child class to create pools of the correct type.
  1.2300 +*/
  1.2301 +template< int SIZE >
  1.2302 +class MemPoolT : public MemPool
  1.2303 +{
  1.2304 +public:
  1.2305 +    MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0)	{}
  1.2306 +    ~MemPoolT() {
  1.2307 +        // Delete the blocks.
  1.2308 +        for( int i=0; i<_blockPtrs.Size(); ++i ) {
  1.2309 +            delete _blockPtrs[i];
  1.2310 +        }
  1.2311 +    }
  1.2312 +
  1.2313 +    virtual int ItemSize() const	{
  1.2314 +        return SIZE;
  1.2315 +    }
  1.2316 +    int CurrentAllocs() const		{
  1.2317 +        return _currentAllocs;
  1.2318 +    }
  1.2319 +
  1.2320 +    virtual void* Alloc() {
  1.2321 +        if ( !_root ) {
  1.2322 +            // Need a new block.
  1.2323 +            Block* block = new Block();
  1.2324 +            _blockPtrs.Push( block );
  1.2325 +
  1.2326 +            for( int i=0; i<COUNT-1; ++i ) {
  1.2327 +                block->chunk[i].next = &block->chunk[i+1];
  1.2328 +            }
  1.2329 +            block->chunk[COUNT-1].next = 0;
  1.2330 +            _root = block->chunk;
  1.2331 +        }
  1.2332 +        void* result = _root;
  1.2333 +        _root = _root->next;
  1.2334 +
  1.2335 +        ++_currentAllocs;
  1.2336 +        if ( _currentAllocs > _maxAllocs ) {
  1.2337 +            _maxAllocs = _currentAllocs;
  1.2338 +        }
  1.2339 +        _nAllocs++;
  1.2340 +        _nUntracked++;
  1.2341 +        return result;
  1.2342 +    }
  1.2343 +    virtual void Free( void* mem ) {
  1.2344 +        if ( !mem ) {
  1.2345 +            return;
  1.2346 +        }
  1.2347 +        --_currentAllocs;
  1.2348 +        Chunk* chunk = (Chunk*)mem;
  1.2349 +#ifdef DEBUG
  1.2350 +        memset( chunk, 0xfe, sizeof(Chunk) );
  1.2351 +#endif
  1.2352 +        chunk->next = _root;
  1.2353 +        _root = chunk;
  1.2354 +    }
  1.2355 +    void Trace( const char* name ) {
  1.2356 +        printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
  1.2357 +                name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
  1.2358 +    }
  1.2359 +
  1.2360 +    void SetTracked() {
  1.2361 +        _nUntracked--;
  1.2362 +    }
  1.2363 +
  1.2364 +    int Untracked() const {
  1.2365 +        return _nUntracked;
  1.2366 +    }
  1.2367 +
  1.2368 +	// This number is perf sensitive. 4k seems like a good tradeoff on my machine.
  1.2369 +	// The test file is large, 170k.
  1.2370 +	// Release:		VS2010 gcc(no opt)
  1.2371 +	//		1k:		4000
  1.2372 +	//		2k:		4000
  1.2373 +	//		4k:		3900	21000
  1.2374 +	//		16k:	5200
  1.2375 +	//		32k:	4300
  1.2376 +	//		64k:	4000	21000
  1.2377 +    enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
  1.2378 +
  1.2379 +private:
  1.2380 +    union Chunk {
  1.2381 +        Chunk*  next;
  1.2382 +        char    mem[SIZE];
  1.2383 +    };
  1.2384 +    struct Block {
  1.2385 +        Chunk chunk[COUNT];
  1.2386 +    };
  1.2387 +    DynArray< Block*, 10 > _blockPtrs;
  1.2388 +    Chunk* _root;
  1.2389 +
  1.2390 +    int _currentAllocs;
  1.2391 +    int _nAllocs;
  1.2392 +    int _maxAllocs;
  1.2393 +    int _nUntracked;
  1.2394 +};
  1.2395 +
  1.2396 +
  1.2397 +
  1.2398 +/**
  1.2399 +	Implements the interface to the "Visitor pattern" (see the Accept() method.)
  1.2400 +	If you call the Accept() method, it requires being passed a XMLVisitor
  1.2401 +	class to handle callbacks. For nodes that contain other nodes (Document, Element)
  1.2402 +	you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs
  1.2403 +	are simply called with Visit().
  1.2404 +
  1.2405 +	If you return 'true' from a Visit method, recursive parsing will continue. If you return
  1.2406 +	false, <b>no children of this node or its siblings</b> will be visited.
  1.2407 +
  1.2408 +	All flavors of Visit methods have a default implementation that returns 'true' (continue
  1.2409 +	visiting). You need to only override methods that are interesting to you.
  1.2410 +
  1.2411 +	Generally Accept() is called on the XMLDocument, although all nodes support visiting.
  1.2412 +
  1.2413 +	You should never change the document from a callback.
  1.2414 +
  1.2415 +	@sa XMLNode::Accept()
  1.2416 +*/
  1.2417 +class TINYXML2_LIB XMLVisitor
  1.2418 +{
  1.2419 +public:
  1.2420 +    virtual ~XMLVisitor() {}
  1.2421 +
  1.2422 +    /// Visit a document.
  1.2423 +    virtual bool VisitEnter( const XMLDocument& /*doc*/ )			{
  1.2424 +        return true;
  1.2425 +    }
  1.2426 +    /// Visit a document.
  1.2427 +    virtual bool VisitExit( const XMLDocument& /*doc*/ )			{
  1.2428 +        return true;
  1.2429 +    }
  1.2430 +
  1.2431 +    /// Visit an element.
  1.2432 +    virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ )	{
  1.2433 +        return true;
  1.2434 +    }
  1.2435 +    /// Visit an element.
  1.2436 +    virtual bool VisitExit( const XMLElement& /*element*/ )			{
  1.2437 +        return true;
  1.2438 +    }
  1.2439 +
  1.2440 +    /// Visit a declaration.
  1.2441 +    virtual bool Visit( const XMLDeclaration& /*declaration*/ )		{
  1.2442 +        return true;
  1.2443 +    }
  1.2444 +    /// Visit a text node.
  1.2445 +    virtual bool Visit( const XMLText& /*text*/ )					{
  1.2446 +        return true;
  1.2447 +    }
  1.2448 +    /// Visit a comment node.
  1.2449 +    virtual bool Visit( const XMLComment& /*comment*/ )				{
  1.2450 +        return true;
  1.2451 +    }
  1.2452 +    /// Visit an unknown node.
  1.2453 +    virtual bool Visit( const XMLUnknown& /*unknown*/ )				{
  1.2454 +        return true;
  1.2455 +    }
  1.2456 +};
  1.2457 +
  1.2458 +
  1.2459 +/*
  1.2460 +	Utility functionality.
  1.2461 +*/
  1.2462 +class XMLUtil
  1.2463 +{
  1.2464 +public:
  1.2465 +    // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
  1.2466 +    // correct, but simple, and usually works.
  1.2467 +    static const char* SkipWhiteSpace( const char* p )	{
  1.2468 +        while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
  1.2469 +            ++p;
  1.2470 +        }
  1.2471 +        return p;
  1.2472 +    }
  1.2473 +    static char* SkipWhiteSpace( char* p )				{
  1.2474 +        while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) )		{
  1.2475 +            ++p;
  1.2476 +        }
  1.2477 +        return p;
  1.2478 +    }
  1.2479 +    static bool IsWhiteSpace( char p )					{
  1.2480 +        return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
  1.2481 +    }
  1.2482 +    
  1.2483 +    inline static bool IsNameStartChar( unsigned char ch ) {
  1.2484 +        return ( ( ch < 128 ) ? isalpha( ch ) : 1 )
  1.2485 +               || ch == ':'
  1.2486 +               || ch == '_';
  1.2487 +    }
  1.2488 +    
  1.2489 +    inline static bool IsNameChar( unsigned char ch ) {
  1.2490 +        return IsNameStartChar( ch )
  1.2491 +               || isdigit( ch )
  1.2492 +               || ch == '.'
  1.2493 +               || ch == '-';
  1.2494 +    }
  1.2495 +
  1.2496 +    inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX )  {
  1.2497 +        int n = 0;
  1.2498 +        if ( p == q ) {
  1.2499 +            return true;
  1.2500 +        }
  1.2501 +        while( *p && *q && *p == *q && n<nChar ) {
  1.2502 +            ++p;
  1.2503 +            ++q;
  1.2504 +            ++n;
  1.2505 +        }
  1.2506 +        if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
  1.2507 +            return true;
  1.2508 +        }
  1.2509 +        return false;
  1.2510 +    }
  1.2511 +    
  1.2512 +    inline static int IsUTF8Continuation( const char p ) {
  1.2513 +        return p & 0x80;
  1.2514 +    }
  1.2515 +
  1.2516 +    static const char* ReadBOM( const char* p, bool* hasBOM );
  1.2517 +    // p is the starting location,
  1.2518 +    // the UTF-8 value of the entity will be placed in value, and length filled in.
  1.2519 +    static const char* GetCharacterRef( const char* p, char* value, int* length );
  1.2520 +    static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
  1.2521 +
  1.2522 +    // converts primitive types to strings
  1.2523 +    static void ToStr( int v, char* buffer, int bufferSize );
  1.2524 +    static void ToStr( unsigned v, char* buffer, int bufferSize );
  1.2525 +    static void ToStr( bool v, char* buffer, int bufferSize );
  1.2526 +    static void ToStr( float v, char* buffer, int bufferSize );
  1.2527 +    static void ToStr( double v, char* buffer, int bufferSize );
  1.2528 +
  1.2529 +    // converts strings to primitive types
  1.2530 +    static bool	ToInt( const char* str, int* value );
  1.2531 +    static bool ToUnsigned( const char* str, unsigned* value );
  1.2532 +    static bool	ToBool( const char* str, bool* value );
  1.2533 +    static bool	ToFloat( const char* str, float* value );
  1.2534 +    static bool ToDouble( const char* str, double* value );
  1.2535 +};
  1.2536 +
  1.2537 +
  1.2538 +/** XMLNode is a base class for every object that is in the
  1.2539 +	XML Document Object Model (DOM), except XMLAttributes.
  1.2540 +	Nodes have siblings, a parent, and children which can
  1.2541 +	be navigated. A node is always in a XMLDocument.
  1.2542 +	The type of a XMLNode can be queried, and it can
  1.2543 +	be cast to its more defined type.
  1.2544 +
  1.2545 +	A XMLDocument allocates memory for all its Nodes.
  1.2546 +	When the XMLDocument gets deleted, all its Nodes
  1.2547 +	will also be deleted.
  1.2548 +
  1.2549 +	@verbatim
  1.2550 +	A Document can contain:	Element	(container or leaf)
  1.2551 +							Comment (leaf)
  1.2552 +							Unknown (leaf)
  1.2553 +							Declaration( leaf )
  1.2554 +
  1.2555 +	An Element can contain:	Element (container or leaf)
  1.2556 +							Text	(leaf)
  1.2557 +							Attributes (not on tree)
  1.2558 +							Comment (leaf)
  1.2559 +							Unknown (leaf)
  1.2560 +
  1.2561 +	@endverbatim
  1.2562 +*/
  1.2563 +class TINYXML2_LIB XMLNode
  1.2564 +{
  1.2565 +    friend class XMLDocument;
  1.2566 +    friend class XMLElement;
  1.2567 +public:
  1.2568 +
  1.2569 +    /// Get the XMLDocument that owns this XMLNode.
  1.2570 +    const XMLDocument* GetDocument() const	{
  1.2571 +        return _document;
  1.2572 +    }
  1.2573 +    /// Get the XMLDocument that owns this XMLNode.
  1.2574 +    XMLDocument* GetDocument()				{
  1.2575 +        return _document;
  1.2576 +    }
  1.2577 +
  1.2578 +    /// Safely cast to an Element, or null.
  1.2579 +    virtual XMLElement*		ToElement()		{
  1.2580 +        return 0;
  1.2581 +    }
  1.2582 +    /// Safely cast to Text, or null.
  1.2583 +    virtual XMLText*		ToText()		{
  1.2584 +        return 0;
  1.2585 +    }
  1.2586 +    /// Safely cast to a Comment, or null.
  1.2587 +    virtual XMLComment*		ToComment()		{
  1.2588 +        return 0;
  1.2589 +    }
  1.2590 +    /// Safely cast to a Document, or null.
  1.2591 +    virtual XMLDocument*	ToDocument()	{
  1.2592 +        return 0;
  1.2593 +    }
  1.2594 +    /// Safely cast to a Declaration, or null.
  1.2595 +    virtual XMLDeclaration*	ToDeclaration()	{
  1.2596 +        return 0;
  1.2597 +    }
  1.2598 +    /// Safely cast to an Unknown, or null.
  1.2599 +    virtual XMLUnknown*		ToUnknown()		{
  1.2600 +        return 0;
  1.2601 +    }
  1.2602 +
  1.2603 +    virtual const XMLElement*		ToElement() const		{
  1.2604 +        return 0;
  1.2605 +    }
  1.2606 +    virtual const XMLText*			ToText() const			{
  1.2607 +        return 0;
  1.2608 +    }
  1.2609 +    virtual const XMLComment*		ToComment() const		{
  1.2610 +        return 0;
  1.2611 +    }
  1.2612 +    virtual const XMLDocument*		ToDocument() const		{
  1.2613 +        return 0;
  1.2614 +    }
  1.2615 +    virtual const XMLDeclaration*	ToDeclaration() const	{
  1.2616 +        return 0;
  1.2617 +    }
  1.2618 +    virtual const XMLUnknown*		ToUnknown() const		{
  1.2619 +        return 0;
  1.2620 +    }
  1.2621 +
  1.2622 +    /** The meaning of 'value' changes for the specific type.
  1.2623 +    	@verbatim
  1.2624 +    	Document:	empty
  1.2625 +    	Element:	name of the element
  1.2626 +    	Comment:	the comment text
  1.2627 +    	Unknown:	the tag contents
  1.2628 +    	Text:		the text string
  1.2629 +    	@endverbatim
  1.2630 +    */
  1.2631 +    const char* Value() const			{
  1.2632 +        return _value.GetStr();
  1.2633 +    }
  1.2634 +
  1.2635 +    /** Set the Value of an XML node.
  1.2636 +    	@sa Value()
  1.2637 +    */
  1.2638 +    void SetValue( const char* val, bool staticMem=false );
  1.2639 +
  1.2640 +    /// Get the parent of this node on the DOM.
  1.2641 +    const XMLNode*	Parent() const			{
  1.2642 +        return _parent;
  1.2643 +    }
  1.2644 +
  1.2645 +    XMLNode* Parent()						{
  1.2646 +        return _parent;
  1.2647 +    }
  1.2648 +
  1.2649 +    /// Returns true if this node has no children.
  1.2650 +    bool NoChildren() const					{
  1.2651 +        return !_firstChild;
  1.2652 +    }
  1.2653 +
  1.2654 +    /// Get the first child node, or null if none exists.
  1.2655 +    const XMLNode*  FirstChild() const		{
  1.2656 +        return _firstChild;
  1.2657 +    }
  1.2658 +
  1.2659 +    XMLNode*		FirstChild()			{
  1.2660 +        return _firstChild;
  1.2661 +    }
  1.2662 +
  1.2663 +    /** Get the first child element, or optionally the first child
  1.2664 +        element with the specified name.
  1.2665 +    */
  1.2666 +    const XMLElement* FirstChildElement( const char* value=0 ) const;
  1.2667 +
  1.2668 +    XMLElement* FirstChildElement( const char* value=0 )	{
  1.2669 +        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value ));
  1.2670 +    }
  1.2671 +
  1.2672 +    /// Get the last child node, or null if none exists.
  1.2673 +    const XMLNode*	LastChild() const						{
  1.2674 +        return _lastChild;
  1.2675 +    }
  1.2676 +
  1.2677 +    XMLNode*		LastChild()								{
  1.2678 +        return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
  1.2679 +    }
  1.2680 +
  1.2681 +    /** Get the last child element or optionally the last child
  1.2682 +        element with the specified name.
  1.2683 +    */
  1.2684 +    const XMLElement* LastChildElement( const char* value=0 ) const;
  1.2685 +
  1.2686 +    XMLElement* LastChildElement( const char* value=0 )	{
  1.2687 +        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) );
  1.2688 +    }
  1.2689 +
  1.2690 +    /// Get the previous (left) sibling node of this node.
  1.2691 +    const XMLNode*	PreviousSibling() const					{
  1.2692 +        return _prev;
  1.2693 +    }
  1.2694 +
  1.2695 +    XMLNode*	PreviousSibling()							{
  1.2696 +        return _prev;
  1.2697 +    }
  1.2698 +
  1.2699 +    /// Get the previous (left) sibling element of this node, with an optionally supplied name.
  1.2700 +    const XMLElement*	PreviousSiblingElement( const char* value=0 ) const ;
  1.2701 +
  1.2702 +    XMLElement*	PreviousSiblingElement( const char* value=0 ) {
  1.2703 +        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) );
  1.2704 +    }
  1.2705 +
  1.2706 +    /// Get the next (right) sibling node of this node.
  1.2707 +    const XMLNode*	NextSibling() const						{
  1.2708 +        return _next;
  1.2709 +    }
  1.2710 +
  1.2711 +    XMLNode*	NextSibling()								{
  1.2712 +        return _next;
  1.2713 +    }
  1.2714 +
  1.2715 +    /// Get the next (right) sibling element of this node, with an optionally supplied name.
  1.2716 +    const XMLElement*	NextSiblingElement( const char* value=0 ) const;
  1.2717 +
  1.2718 +    XMLElement*	NextSiblingElement( const char* value=0 )	{
  1.2719 +        return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) );
  1.2720 +    }
  1.2721 +
  1.2722 +    /**
  1.2723 +    	Add a child node as the last (right) child.
  1.2724 +    */
  1.2725 +    XMLNode* InsertEndChild( XMLNode* addThis );
  1.2726 +
  1.2727 +    XMLNode* LinkEndChild( XMLNode* addThis )	{
  1.2728 +        return InsertEndChild( addThis );
  1.2729 +    }
  1.2730 +    /**
  1.2731 +    	Add a child node as the first (left) child.
  1.2732 +    */
  1.2733 +    XMLNode* InsertFirstChild( XMLNode* addThis );
  1.2734 +    /**
  1.2735 +    	Add a node after the specified child node.
  1.2736 +    */
  1.2737 +    XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
  1.2738 +
  1.2739 +    /**
  1.2740 +    	Delete all the children of this node.
  1.2741 +    */
  1.2742 +    void DeleteChildren();
  1.2743 +
  1.2744 +    /**
  1.2745 +    	Delete a child of this node.
  1.2746 +    */
  1.2747 +    void DeleteChild( XMLNode* node );
  1.2748 +
  1.2749 +    /**
  1.2750 +    	Make a copy of this node, but not its children.
  1.2751 +    	You may pass in a Document pointer that will be
  1.2752 +    	the owner of the new Node. If the 'document' is
  1.2753 +    	null, then the node returned will be allocated
  1.2754 +    	from the current Document. (this->GetDocument())
  1.2755 +
  1.2756 +    	Note: if called on a XMLDocument, this will return null.
  1.2757 +    */
  1.2758 +    virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
  1.2759 +
  1.2760 +    /**
  1.2761 +    	Test if 2 nodes are the same, but don't test children.
  1.2762 +    	The 2 nodes do not need to be in the same Document.
  1.2763 +
  1.2764 +    	Note: if called on a XMLDocument, this will return false.
  1.2765 +    */
  1.2766 +    virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
  1.2767 +
  1.2768 +    /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the
  1.2769 +    	XML tree will be conditionally visited and the host will be called back
  1.2770 +    	via the XMLVisitor interface.
  1.2771 +
  1.2772 +    	This is essentially a SAX interface for TinyXML-2. (Note however it doesn't re-parse
  1.2773 +    	the XML for the callbacks, so the performance of TinyXML-2 is unchanged by using this
  1.2774 +    	interface versus any other.)
  1.2775 +
  1.2776 +    	The interface has been based on ideas from:
  1.2777 +
  1.2778 +    	- http://www.saxproject.org/
  1.2779 +    	- http://c2.com/cgi/wiki?HierarchicalVisitorPattern
  1.2780 +
  1.2781 +    	Which are both good references for "visiting".
  1.2782 +
  1.2783 +    	An example of using Accept():
  1.2784 +    	@verbatim
  1.2785 +    	XMLPrinter printer;
  1.2786 +    	tinyxmlDoc.Accept( &printer );
  1.2787 +    	const char* xmlcstr = printer.CStr();
  1.2788 +    	@endverbatim
  1.2789 +    */
  1.2790 +    virtual bool Accept( XMLVisitor* visitor ) const = 0;
  1.2791 +
  1.2792 +    // internal
  1.2793 +    virtual char* ParseDeep( char*, StrPair* );
  1.2794 +
  1.2795 +protected:
  1.2796 +    XMLNode( XMLDocument* );
  1.2797 +    virtual ~XMLNode();
  1.2798 +    XMLNode( const XMLNode& );	// not supported
  1.2799 +    XMLNode& operator=( const XMLNode& );	// not supported
  1.2800 +
  1.2801 +    XMLDocument*	_document;
  1.2802 +    XMLNode*		_parent;
  1.2803 +    mutable StrPair	_value;
  1.2804 +
  1.2805 +    XMLNode*		_firstChild;
  1.2806 +    XMLNode*		_lastChild;
  1.2807 +
  1.2808 +    XMLNode*		_prev;
  1.2809 +    XMLNode*		_next;
  1.2810 +
  1.2811 +private:
  1.2812 +    MemPool*		_memPool;
  1.2813 +    void Unlink( XMLNode* child );
  1.2814 +};
  1.2815 +
  1.2816 +
  1.2817 +/** XML text.
  1.2818 +
  1.2819 +	Note that a text node can have child element nodes, for example:
  1.2820 +	@verbatim
  1.2821 +	<root>This is <b>bold</b></root>
  1.2822 +	@endverbatim
  1.2823 +
  1.2824 +	A text node can have 2 ways to output the next. "normal" output
  1.2825 +	and CDATA. It will default to the mode it was parsed from the XML file and
  1.2826 +	you generally want to leave it alone, but you can change the output mode with
  1.2827 +	SetCData() and query it with CData().
  1.2828 +*/
  1.2829 +class TINYXML2_LIB XMLText : public XMLNode
  1.2830 +{
  1.2831 +    friend class XMLBase;
  1.2832 +    friend class XMLDocument;
  1.2833 +public:
  1.2834 +    virtual bool Accept( XMLVisitor* visitor ) const;
  1.2835 +
  1.2836 +    virtual XMLText* ToText()			{
  1.2837 +        return this;
  1.2838 +    }
  1.2839 +    virtual const XMLText* ToText() const	{
  1.2840 +        return this;
  1.2841 +    }
  1.2842 +
  1.2843 +    /// Declare whether this should be CDATA or standard text.
  1.2844 +    void SetCData( bool isCData )			{
  1.2845 +        _isCData = isCData;
  1.2846 +    }
  1.2847 +    /// Returns true if this is a CDATA text element.
  1.2848 +    bool CData() const						{
  1.2849 +        return _isCData;
  1.2850 +    }
  1.2851 +
  1.2852 +    char* ParseDeep( char*, StrPair* endTag );
  1.2853 +    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
  1.2854 +    virtual bool ShallowEqual( const XMLNode* compare ) const;
  1.2855 +
  1.2856 +protected:
  1.2857 +    XMLText( XMLDocument* doc )	: XMLNode( doc ), _isCData( false )	{}
  1.2858 +    virtual ~XMLText()												{}
  1.2859 +    XMLText( const XMLText& );	// not supported
  1.2860 +    XMLText& operator=( const XMLText& );	// not supported
  1.2861 +
  1.2862 +private:
  1.2863 +    bool _isCData;
  1.2864 +};
  1.2865 +
  1.2866 +
  1.2867 +/** An XML Comment. */
  1.2868 +class TINYXML2_LIB XMLComment : public XMLNode
  1.2869 +{
  1.2870 +    friend class XMLDocument;
  1.2871 +public:
  1.2872 +    virtual XMLComment*	ToComment()					{
  1.2873 +        return this;
  1.2874 +    }
  1.2875 +    virtual const XMLComment* ToComment() const		{
  1.2876 +        return this;
  1.2877 +    }
  1.2878 +
  1.2879 +    virtual bool Accept( XMLVisitor* visitor ) const;
  1.2880 +
  1.2881 +    char* ParseDeep( char*, StrPair* endTag );
  1.2882 +    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
  1.2883 +    virtual bool ShallowEqual( const XMLNode* compare ) const;
  1.2884 +
  1.2885 +protected:
  1.2886 +    XMLComment( XMLDocument* doc );
  1.2887 +    virtual ~XMLComment();
  1.2888 +    XMLComment( const XMLComment& );	// not supported
  1.2889 +    XMLComment& operator=( const XMLComment& );	// not supported
  1.2890 +
  1.2891 +private:
  1.2892 +};
  1.2893 +
  1.2894 +
  1.2895 +/** In correct XML the declaration is the first entry in the file.
  1.2896 +	@verbatim
  1.2897 +		<?xml version="1.0" standalone="yes"?>
  1.2898 +	@endverbatim
  1.2899 +
  1.2900 +	TinyXML-2 will happily read or write files without a declaration,
  1.2901 +	however.
  1.2902 +
  1.2903 +	The text of the declaration isn't interpreted. It is parsed
  1.2904 +	and written as a string.
  1.2905 +*/
  1.2906 +class TINYXML2_LIB XMLDeclaration : public XMLNode
  1.2907 +{
  1.2908 +    friend class XMLDocument;
  1.2909 +public:
  1.2910 +    virtual XMLDeclaration*	ToDeclaration()					{
  1.2911 +        return this;
  1.2912 +    }
  1.2913 +    virtual const XMLDeclaration* ToDeclaration() const		{
  1.2914 +        return this;
  1.2915 +    }
  1.2916 +
  1.2917 +    virtual bool Accept( XMLVisitor* visitor ) const;
  1.2918 +
  1.2919 +    char* ParseDeep( char*, StrPair* endTag );
  1.2920 +    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
  1.2921 +    virtual bool ShallowEqual( const XMLNode* compare ) const;
  1.2922 +
  1.2923 +protected:
  1.2924 +    XMLDeclaration( XMLDocument* doc );
  1.2925 +    virtual ~XMLDeclaration();
  1.2926 +    XMLDeclaration( const XMLDeclaration& );	// not supported
  1.2927 +    XMLDeclaration& operator=( const XMLDeclaration& );	// not supported
  1.2928 +};
  1.2929 +
  1.2930 +
  1.2931 +/** Any tag that TinyXML-2 doesn't recognize is saved as an
  1.2932 +	unknown. It is a tag of text, but should not be modified.
  1.2933 +	It will be written back to the XML, unchanged, when the file
  1.2934 +	is saved.
  1.2935 +
  1.2936 +	DTD tags get thrown into XMLUnknowns.
  1.2937 +*/
  1.2938 +class TINYXML2_LIB XMLUnknown : public XMLNode
  1.2939 +{
  1.2940 +    friend class XMLDocument;
  1.2941 +public:
  1.2942 +    virtual XMLUnknown*	ToUnknown()					{
  1.2943 +        return this;
  1.2944 +    }
  1.2945 +    virtual const XMLUnknown* ToUnknown() const		{
  1.2946 +        return this;
  1.2947 +    }
  1.2948 +
  1.2949 +    virtual bool Accept( XMLVisitor* visitor ) const;
  1.2950 +
  1.2951 +    char* ParseDeep( char*, StrPair* endTag );
  1.2952 +    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
  1.2953 +    virtual bool ShallowEqual( const XMLNode* compare ) const;
  1.2954 +
  1.2955 +protected:
  1.2956 +    XMLUnknown( XMLDocument* doc );
  1.2957 +    virtual ~XMLUnknown();
  1.2958 +    XMLUnknown( const XMLUnknown& );	// not supported
  1.2959 +    XMLUnknown& operator=( const XMLUnknown& );	// not supported
  1.2960 +};
  1.2961 +
  1.2962 +
  1.2963 +enum XMLError {
  1.2964 +    XML_NO_ERROR = 0,
  1.2965 +    XML_SUCCESS = 0,
  1.2966 +
  1.2967 +    XML_NO_ATTRIBUTE,
  1.2968 +    XML_WRONG_ATTRIBUTE_TYPE,
  1.2969 +
  1.2970 +    XML_ERROR_FILE_NOT_FOUND,
  1.2971 +    XML_ERROR_FILE_COULD_NOT_BE_OPENED,
  1.2972 +    XML_ERROR_FILE_READ_ERROR,
  1.2973 +    XML_ERROR_ELEMENT_MISMATCH,
  1.2974 +    XML_ERROR_PARSING_ELEMENT,
  1.2975 +    XML_ERROR_PARSING_ATTRIBUTE,
  1.2976 +    XML_ERROR_IDENTIFYING_TAG,
  1.2977 +    XML_ERROR_PARSING_TEXT,
  1.2978 +    XML_ERROR_PARSING_CDATA,
  1.2979 +    XML_ERROR_PARSING_COMMENT,
  1.2980 +    XML_ERROR_PARSING_DECLARATION,
  1.2981 +    XML_ERROR_PARSING_UNKNOWN,
  1.2982 +    XML_ERROR_EMPTY_DOCUMENT,
  1.2983 +    XML_ERROR_MISMATCHED_ELEMENT,
  1.2984 +    XML_ERROR_PARSING,
  1.2985 +
  1.2986 +    XML_CAN_NOT_CONVERT_TEXT,
  1.2987 +    XML_NO_TEXT_NODE
  1.2988 +};
  1.2989 +
  1.2990 +
  1.2991 +/** An attribute is a name-value pair. Elements have an arbitrary
  1.2992 +	number of attributes, each with a unique name.
  1.2993 +
  1.2994 +	@note The attributes are not XMLNodes. You may only query the
  1.2995 +	Next() attribute in a list.
  1.2996 +*/
  1.2997 +class TINYXML2_LIB XMLAttribute
  1.2998 +{
  1.2999 +    friend class XMLElement;
  1.3000 +public:
  1.3001 +    /// The name of the attribute.
  1.3002 +    const char* Name() const {
  1.3003 +        return _name.GetStr();
  1.3004 +    }
  1.3005 +    /// The value of the attribute.
  1.3006 +    const char* Value() const {
  1.3007 +        return _value.GetStr();
  1.3008 +    }
  1.3009 +    /// The next attribute in the list.
  1.3010 +    const XMLAttribute* Next() const {
  1.3011 +        return _next;
  1.3012 +    }
  1.3013 +
  1.3014 +    /** IntValue interprets the attribute as an integer, and returns the value.
  1.3015 +        If the value isn't an integer, 0 will be returned. There is no error checking;
  1.3016 +    	use QueryIntValue() if you need error checking.
  1.3017 +    */
  1.3018 +    int		 IntValue() const				{
  1.3019 +        int i=0;
  1.3020 +        QueryIntValue( &i );
  1.3021 +        return i;
  1.3022 +    }
  1.3023 +    /// Query as an unsigned integer. See IntValue()
  1.3024 +    unsigned UnsignedValue() const			{
  1.3025 +        unsigned i=0;
  1.3026 +        QueryUnsignedValue( &i );
  1.3027 +        return i;
  1.3028 +    }
  1.3029 +    /// Query as a boolean. See IntValue()
  1.3030 +    bool	 BoolValue() const				{
  1.3031 +        bool b=false;
  1.3032 +        QueryBoolValue( &b );
  1.3033 +        return b;
  1.3034 +    }
  1.3035 +    /// Query as a double. See IntValue()
  1.3036 +    double 	 DoubleValue() const			{
  1.3037 +        double d=0;
  1.3038 +        QueryDoubleValue( &d );
  1.3039 +        return d;
  1.3040 +    }
  1.3041 +    /// Query as a float. See IntValue()
  1.3042 +    float	 FloatValue() const				{
  1.3043 +        float f=0;
  1.3044 +        QueryFloatValue( &f );
  1.3045 +        return f;
  1.3046 +    }
  1.3047 +
  1.3048 +    /** QueryIntValue interprets the attribute as an integer, and returns the value
  1.3049 +    	in the provided parameter. The function will return XML_NO_ERROR on success,
  1.3050 +    	and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
  1.3051 +    */
  1.3052 +    XMLError QueryIntValue( int* value ) const;
  1.3053 +    /// See QueryIntValue
  1.3054 +    XMLError QueryUnsignedValue( unsigned int* value ) const;
  1.3055 +    /// See QueryIntValue
  1.3056 +    XMLError QueryBoolValue( bool* value ) const;
  1.3057 +    /// See QueryIntValue
  1.3058 +    XMLError QueryDoubleValue( double* value ) const;
  1.3059 +    /// See QueryIntValue
  1.3060 +    XMLError QueryFloatValue( float* value ) const;
  1.3061 +
  1.3062 +    /// Set the attribute to a string value.
  1.3063 +    void SetAttribute( const char* value );
  1.3064 +    /// Set the attribute to value.
  1.3065 +    void SetAttribute( int value );
  1.3066 +    /// Set the attribute to value.
  1.3067 +    void SetAttribute( unsigned value );
  1.3068 +    /// Set the attribute to value.
  1.3069 +    void SetAttribute( bool value );
  1.3070 +    /// Set the attribute to value.
  1.3071 +    void SetAttribute( double value );
  1.3072 +    /// Set the attribute to value.
  1.3073 +    void SetAttribute( float value );
  1.3074 +
  1.3075 +private:
  1.3076 +    enum { BUF_SIZE = 200 };
  1.3077 +
  1.3078 +    XMLAttribute() : _next( 0 ), _memPool( 0 ) {}
  1.3079 +    virtual ~XMLAttribute()	{}
  1.3080 +
  1.3081 +    XMLAttribute( const XMLAttribute& );	// not supported
  1.3082 +    void operator=( const XMLAttribute& );	// not supported
  1.3083 +    void SetName( const char* name );
  1.3084 +
  1.3085 +    char* ParseDeep( char* p, bool processEntities );
  1.3086 +
  1.3087 +    mutable StrPair _name;
  1.3088 +    mutable StrPair _value;
  1.3089 +    XMLAttribute*   _next;
  1.3090 +    MemPool*        _memPool;
  1.3091 +};
  1.3092 +
  1.3093 +
  1.3094 +/** The element is a container class. It has a value, the element name,
  1.3095 +	and can contain other elements, text, comments, and unknowns.
  1.3096 +	Elements also contain an arbitrary number of attributes.
  1.3097 +*/
  1.3098 +class TINYXML2_LIB XMLElement : public XMLNode
  1.3099 +{
  1.3100 +    friend class XMLBase;
  1.3101 +    friend class XMLDocument;
  1.3102 +public:
  1.3103 +    /// Get the name of an element (which is the Value() of the node.)
  1.3104 +    const char* Name() const		{
  1.3105 +        return Value();
  1.3106 +    }
  1.3107 +    /// Set the name of the element.
  1.3108 +    void SetName( const char* str, bool staticMem=false )	{
  1.3109 +        SetValue( str, staticMem );
  1.3110 +    }
  1.3111 +
  1.3112 +    virtual XMLElement* ToElement()				{
  1.3113 +        return this;
  1.3114 +    }
  1.3115 +    virtual const XMLElement* ToElement() const {
  1.3116 +        return this;
  1.3117 +    }
  1.3118 +    virtual bool Accept( XMLVisitor* visitor ) const;
  1.3119 +
  1.3120 +    /** Given an attribute name, Attribute() returns the value
  1.3121 +    	for the attribute of that name, or null if none
  1.3122 +    	exists. For example:
  1.3123 +
  1.3124 +    	@verbatim
  1.3125 +    	const char* value = ele->Attribute( "foo" );
  1.3126 +    	@endverbatim
  1.3127 +
  1.3128 +    	The 'value' parameter is normally null. However, if specified,
  1.3129 +    	the attribute will only be returned if the 'name' and 'value'
  1.3130 +    	match. This allow you to write code:
  1.3131 +
  1.3132 +    	@verbatim
  1.3133 +    	if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();
  1.3134 +    	@endverbatim
  1.3135 +
  1.3136 +    	rather than:
  1.3137 +    	@verbatim
  1.3138 +    	if ( ele->Attribute( "foo" ) ) {
  1.3139 +    		if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();
  1.3140 +    	}
  1.3141 +    	@endverbatim
  1.3142 +    */
  1.3143 +    const char* Attribute( const char* name, const char* value=0 ) const;
  1.3144 +
  1.3145 +    /** Given an attribute name, IntAttribute() returns the value
  1.3146 +    	of the attribute interpreted as an integer. 0 will be
  1.3147 +    	returned if there is an error. For a method with error
  1.3148 +    	checking, see QueryIntAttribute()
  1.3149 +    */
  1.3150 +    int		 IntAttribute( const char* name ) const		{
  1.3151 +        int i=0;
  1.3152 +        QueryIntAttribute( name, &i );
  1.3153 +        return i;
  1.3154 +    }
  1.3155 +    /// See IntAttribute()
  1.3156 +    unsigned UnsignedAttribute( const char* name ) const {
  1.3157 +        unsigned i=0;
  1.3158 +        QueryUnsignedAttribute( name, &i );
  1.3159 +        return i;
  1.3160 +    }
  1.3161 +    /// See IntAttribute()
  1.3162 +    bool	 BoolAttribute( const char* name ) const	{
  1.3163 +        bool b=false;
  1.3164 +        QueryBoolAttribute( name, &b );
  1.3165 +        return b;
  1.3166 +    }
  1.3167 +    /// See IntAttribute()
  1.3168 +    double 	 DoubleAttribute( const char* name ) const	{
  1.3169 +        double d=0;
  1.3170 +        QueryDoubleAttribute( name, &d );
  1.3171 +        return d;
  1.3172 +    }
  1.3173 +    /// See IntAttribute()
  1.3174 +    float	 FloatAttribute( const char* name ) const	{
  1.3175 +        float f=0;
  1.3176 +        QueryFloatAttribute( name, &f );
  1.3177 +        return f;
  1.3178 +    }
  1.3179 +
  1.3180 +    /** Given an attribute name, QueryIntAttribute() returns
  1.3181 +    	XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
  1.3182 +    	can't be performed, or XML_NO_ATTRIBUTE if the attribute
  1.3183 +    	doesn't exist. If successful, the result of the conversion
  1.3184 +    	will be written to 'value'. If not successful, nothing will
  1.3185 +    	be written to 'value'. This allows you to provide default
  1.3186 +    	value:
  1.3187 +
  1.3188 +    	@verbatim
  1.3189 +    	int value = 10;
  1.3190 +    	QueryIntAttribute( "foo", &value );		// if "foo" isn't found, value will still be 10
  1.3191 +    	@endverbatim
  1.3192 +    */
  1.3193 +    XMLError QueryIntAttribute( const char* name, int* value ) const				{
  1.3194 +        const XMLAttribute* a = FindAttribute( name );
  1.3195 +        if ( !a ) {
  1.3196 +            return XML_NO_ATTRIBUTE;
  1.3197 +        }
  1.3198 +        return a->QueryIntValue( value );
  1.3199 +    }
  1.3200 +    /// See QueryIntAttribute()
  1.3201 +    XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const	{
  1.3202 +        const XMLAttribute* a = FindAttribute( name );
  1.3203 +        if ( !a ) {
  1.3204 +            return XML_NO_ATTRIBUTE;
  1.3205 +        }
  1.3206 +        return a->QueryUnsignedValue( value );
  1.3207 +    }
  1.3208 +    /// See QueryIntAttribute()
  1.3209 +    XMLError QueryBoolAttribute( const char* name, bool* value ) const				{
  1.3210 +        const XMLAttribute* a = FindAttribute( name );
  1.3211 +        if ( !a ) {
  1.3212 +            return XML_NO_ATTRIBUTE;
  1.3213 +        }
  1.3214 +        return a->QueryBoolValue( value );
  1.3215 +    }
  1.3216 +    /// See QueryIntAttribute()
  1.3217 +    XMLError QueryDoubleAttribute( const char* name, double* value ) const			{
  1.3218 +        const XMLAttribute* a = FindAttribute( name );
  1.3219 +        if ( !a ) {
  1.3220 +            return XML_NO_ATTRIBUTE;
  1.3221 +        }
  1.3222 +        return a->QueryDoubleValue( value );
  1.3223 +    }
  1.3224 +    /// See QueryIntAttribute()
  1.3225 +    XMLError QueryFloatAttribute( const char* name, float* value ) const			{
  1.3226 +        const XMLAttribute* a = FindAttribute( name );
  1.3227 +        if ( !a ) {
  1.3228 +            return XML_NO_ATTRIBUTE;
  1.3229 +        }
  1.3230 +        return a->QueryFloatValue( value );
  1.3231 +    }
  1.3232 +
  1.3233 +	
  1.3234 +    /** Given an attribute name, QueryAttribute() returns
  1.3235 +    	XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
  1.3236 +    	can't be performed, or XML_NO_ATTRIBUTE if the attribute
  1.3237 +    	doesn't exist. It is overloaded for the primitive types,
  1.3238 +		and is a generally more convenient replacement of
  1.3239 +		QueryIntAttribute() and related functions.
  1.3240 +		
  1.3241 +		If successful, the result of the conversion
  1.3242 +    	will be written to 'value'. If not successful, nothing will
  1.3243 +    	be written to 'value'. This allows you to provide default
  1.3244 +    	value:
  1.3245 +
  1.3246 +    	@verbatim
  1.3247 +    	int value = 10;
  1.3248 +    	QueryAttribute( "foo", &value );		// if "foo" isn't found, value will still be 10
  1.3249 +    	@endverbatim
  1.3250 +    */
  1.3251 +	int QueryAttribute( const char* name, int* value ) const {
  1.3252 +		return QueryIntAttribute( name, value );
  1.3253 +	}
  1.3254 +
  1.3255 +	int QueryAttribute( const char* name, unsigned int* value ) const {
  1.3256 +		return QueryUnsignedAttribute( name, value );
  1.3257 +	}
  1.3258 +
  1.3259 +	int QueryAttribute( const char* name, bool* value ) const {
  1.3260 +		return QueryBoolAttribute( name, value );
  1.3261 +	}
  1.3262 +
  1.3263 +	int QueryAttribute( const char* name, double* value ) const {
  1.3264 +		return QueryDoubleAttribute( name, value );
  1.3265 +	}
  1.3266 +
  1.3267 +	int QueryAttribute( const char* name, float* value ) const {
  1.3268 +		return QueryFloatAttribute( name, value );
  1.3269 +	}
  1.3270 +
  1.3271 +	/// Sets the named attribute to value.
  1.3272 +    void SetAttribute( const char* name, const char* value )	{
  1.3273 +        XMLAttribute* a = FindOrCreateAttribute( name );
  1.3274 +        a->SetAttribute( value );
  1.3275 +    }
  1.3276 +    /// Sets the named attribute to value.
  1.3277 +    void SetAttribute( const char* name, int value )			{
  1.3278 +        XMLAttribute* a = FindOrCreateAttribute( name );
  1.3279 +        a->SetAttribute( value );
  1.3280 +    }
  1.3281 +    /// Sets the named attribute to value.
  1.3282 +    void SetAttribute( const char* name, unsigned value )		{
  1.3283 +        XMLAttribute* a = FindOrCreateAttribute( name );
  1.3284 +        a->SetAttribute( value );
  1.3285 +    }
  1.3286 +    /// Sets the named attribute to value.
  1.3287 +    void SetAttribute( const char* name, bool value )			{
  1.3288 +        XMLAttribute* a = FindOrCreateAttribute( name );
  1.3289 +        a->SetAttribute( value );
  1.3290 +    }
  1.3291 +    /// Sets the named attribute to value.
  1.3292 +    void SetAttribute( const char* name, double value )		{
  1.3293 +        XMLAttribute* a = FindOrCreateAttribute( name );
  1.3294 +        a->SetAttribute( value );
  1.3295 +    }
  1.3296 +
  1.3297 +    /**
  1.3298 +    	Delete an attribute.
  1.3299 +    */
  1.3300 +    void DeleteAttribute( const char* name );
  1.3301 +
  1.3302 +    /// Return the first attribute in the list.
  1.3303 +    const XMLAttribute* FirstAttribute() const {
  1.3304 +        return _rootAttribute;
  1.3305 +    }
  1.3306 +    /// Query a specific attribute in the list.
  1.3307 +    const XMLAttribute* FindAttribute( const char* name ) const;
  1.3308 +
  1.3309 +    /** Convenience function for easy access to the text inside an element. Although easy
  1.3310 +    	and concise, GetText() is limited compared to getting the XMLText child
  1.3311 +    	and accessing it directly.
  1.3312 +
  1.3313 +    	If the first child of 'this' is a XMLText, the GetText()
  1.3314 +    	returns the character string of the Text node, else null is returned.
  1.3315 +
  1.3316 +    	This is a convenient method for getting the text of simple contained text:
  1.3317 +    	@verbatim
  1.3318 +    	<foo>This is text</foo>
  1.3319 +    		const char* str = fooElement->GetText();
  1.3320 +    	@endverbatim
  1.3321 +
  1.3322 +    	'str' will be a pointer to "This is text".
  1.3323 +
  1.3324 +    	Note that this function can be misleading. If the element foo was created from
  1.3325 +    	this XML:
  1.3326 +    	@verbatim
  1.3327 +    		<foo><b>This is text</b></foo>
  1.3328 +    	@endverbatim
  1.3329 +
  1.3330 +    	then the value of str would be null. The first child node isn't a text node, it is
  1.3331 +    	another element. From this XML:
  1.3332 +    	@verbatim
  1.3333 +    		<foo>This is <b>text</b></foo>
  1.3334 +    	@endverbatim
  1.3335 +    	GetText() will return "This is ".
  1.3336 +    */
  1.3337 +    const char* GetText() const;
  1.3338 +
  1.3339 +    /**
  1.3340 +    	Convenience method to query the value of a child text node. This is probably best
  1.3341 +    	shown by example. Given you have a document is this form:
  1.3342 +    	@verbatim
  1.3343 +    		<point>
  1.3344 +    			<x>1</x>
  1.3345 +    			<y>1.4</y>
  1.3346 +    		</point>
  1.3347 +    	@endverbatim
  1.3348 +
  1.3349 +    	The QueryIntText() and similar functions provide a safe and easier way to get to the
  1.3350 +    	"value" of x and y.
  1.3351 +
  1.3352 +    	@verbatim
  1.3353 +    		int x = 0;
  1.3354 +    		float y = 0;	// types of x and y are contrived for example
  1.3355 +    		const XMLElement* xElement = pointElement->FirstChildElement( "x" );
  1.3356 +    		const XMLElement* yElement = pointElement->FirstChildElement( "y" );
  1.3357 +    		xElement->QueryIntText( &x );
  1.3358 +    		yElement->QueryFloatText( &y );
  1.3359 +    	@endverbatim
  1.3360 +
  1.3361 +    	@returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted
  1.3362 +    			 to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.
  1.3363 +
  1.3364 +    */
  1.3365 +    XMLError QueryIntText( int* ival ) const;
  1.3366 +    /// See QueryIntText()
  1.3367 +    XMLError QueryUnsignedText( unsigned* uval ) const;
  1.3368 +    /// See QueryIntText()
  1.3369 +    XMLError QueryBoolText( bool* bval ) const;
  1.3370 +    /// See QueryIntText()
  1.3371 +    XMLError QueryDoubleText( double* dval ) const;
  1.3372 +    /// See QueryIntText()
  1.3373 +    XMLError QueryFloatText( float* fval ) const;
  1.3374 +
  1.3375 +    // internal:
  1.3376 +    enum {
  1.3377 +        OPEN,		// <foo>
  1.3378 +        CLOSED,		// <foo/>
  1.3379 +        CLOSING		// </foo>
  1.3380 +    };
  1.3381 +    int ClosingType() const {
  1.3382 +        return _closingType;
  1.3383 +    }
  1.3384 +    char* ParseDeep( char* p, StrPair* endTag );
  1.3385 +    virtual XMLNode* ShallowClone( XMLDocument* document ) const;
  1.3386 +    virtual bool ShallowEqual( const XMLNode* compare ) const;
  1.3387 +
  1.3388 +private:
  1.3389 +    XMLElement( XMLDocument* doc );
  1.3390 +    virtual ~XMLElement();
  1.3391 +    XMLElement( const XMLElement& );	// not supported
  1.3392 +    void operator=( const XMLElement& );	// not supported
  1.3393 +
  1.3394 +    XMLAttribute* FindAttribute( const char* name );
  1.3395 +    XMLAttribute* FindOrCreateAttribute( const char* name );
  1.3396 +    //void LinkAttribute( XMLAttribute* attrib );
  1.3397 +    char* ParseAttributes( char* p );
  1.3398 +
  1.3399 +    int _closingType;
  1.3400 +    // The attribute list is ordered; there is no 'lastAttribute'
  1.3401 +    // because the list needs to be scanned for dupes before adding
  1.3402 +    // a new attribute.
  1.3403 +    XMLAttribute* _rootAttribute;
  1.3404 +};
  1.3405 +
  1.3406 +
  1.3407 +enum Whitespace {
  1.3408 +    PRESERVE_WHITESPACE,
  1.3409 +    COLLAPSE_WHITESPACE
  1.3410 +};
  1.3411 +
  1.3412 +
  1.3413 +/** A Document binds together all the functionality.
  1.3414 +	It can be saved, loaded, and printed to the screen.
  1.3415 +	All Nodes are connected and allocated to a Document.
  1.3416 +	If the Document is deleted, all its Nodes are also deleted.
  1.3417 +*/
  1.3418 +class TINYXML2_LIB XMLDocument : public XMLNode
  1.3419 +{
  1.3420 +    friend class XMLElement;
  1.3421 +public:
  1.3422 +    /// constructor
  1.3423 +    XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
  1.3424 +    ~XMLDocument();
  1.3425 +
  1.3426 +    virtual XMLDocument* ToDocument()				{
  1.3427 +        return this;
  1.3428 +    }
  1.3429 +    virtual const XMLDocument* ToDocument() const	{
  1.3430 +        return this;
  1.3431 +    }
  1.3432 +
  1.3433 +    /**
  1.3434 +    	Parse an XML file from a character string.
  1.3435 +    	Returns XML_NO_ERROR (0) on success, or
  1.3436 +    	an errorID.
  1.3437 +
  1.3438 +    	You may optionally pass in the 'nBytes', which is
  1.3439 +    	the number of bytes which will be parsed. If not
  1.3440 +    	specified, TinyXML-2 will assume 'xml' points to a
  1.3441 +    	null terminated string.
  1.3442 +    */
  1.3443 +    XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
  1.3444 +
  1.3445 +    /**
  1.3446 +    	Load an XML file from disk.
  1.3447 +    	Returns XML_NO_ERROR (0) on success, or
  1.3448 +    	an errorID.
  1.3449 +    */
  1.3450 +    XMLError LoadFile( const char* filename );
  1.3451 +
  1.3452 +    /**
  1.3453 +    	Load an XML file from disk. You are responsible
  1.3454 +    	for providing and closing the FILE*.
  1.3455 +
  1.3456 +    	Returns XML_NO_ERROR (0) on success, or
  1.3457 +    	an errorID.
  1.3458 +    */
  1.3459 +    XMLError LoadFile( FILE* );
  1.3460 +
  1.3461 +    /**
  1.3462 +    	Save the XML file to disk.
  1.3463 +    	Returns XML_NO_ERROR (0) on success, or
  1.3464 +    	an errorID.
  1.3465 +    */
  1.3466 +    XMLError SaveFile( const char* filename, bool compact = false );
  1.3467 +
  1.3468 +    /**
  1.3469 +    	Save the XML file to disk. You are responsible
  1.3470 +    	for providing and closing the FILE*.
  1.3471 +
  1.3472 +    	Returns XML_NO_ERROR (0) on success, or
  1.3473 +    	an errorID.
  1.3474 +    */
  1.3475 +    XMLError SaveFile( FILE* fp, bool compact = false );
  1.3476 +
  1.3477 +    bool ProcessEntities() const		{
  1.3478 +        return _processEntities;
  1.3479 +    }
  1.3480 +    Whitespace WhitespaceMode() const	{
  1.3481 +        return _whitespace;
  1.3482 +    }
  1.3483 +
  1.3484 +    /**
  1.3485 +    	Returns true if this document has a leading Byte Order Mark of UTF8.
  1.3486 +    */
  1.3487 +    bool HasBOM() const {
  1.3488 +        return _writeBOM;
  1.3489 +    }
  1.3490 +    /** Sets whether to write the BOM when writing the file.
  1.3491 +    */
  1.3492 +    void SetBOM( bool useBOM ) {
  1.3493 +        _writeBOM = useBOM;
  1.3494 +    }
  1.3495 +
  1.3496 +    /** Return the root element of DOM. Equivalent to FirstChildElement().
  1.3497 +        To get the first node, use FirstChild().
  1.3498 +    */
  1.3499 +    XMLElement* RootElement()				{
  1.3500 +        return FirstChildElement();
  1.3501 +    }
  1.3502 +    const XMLElement* RootElement() const	{
  1.3503 +        return FirstChildElement();
  1.3504 +    }
  1.3505 +
  1.3506 +    /** Print the Document. If the Printer is not provided, it will
  1.3507 +        print to stdout. If you provide Printer, this can print to a file:
  1.3508 +    	@verbatim
  1.3509 +    	XMLPrinter printer( fp );
  1.3510 +    	doc.Print( &printer );
  1.3511 +    	@endverbatim
  1.3512 +
  1.3513 +    	Or you can use a printer to print to memory:
  1.3514 +    	@verbatim
  1.3515 +    	XMLPrinter printer;
  1.3516 +    	doc.Print( &printer );
  1.3517 +    	// printer.CStr() has a const char* to the XML
  1.3518 +    	@endverbatim
  1.3519 +    */
  1.3520 +    void Print( XMLPrinter* streamer=0 ) const;
  1.3521 +    virtual bool Accept( XMLVisitor* visitor ) const;
  1.3522 +
  1.3523 +    /**
  1.3524 +    	Create a new Element associated with
  1.3525 +    	this Document. The memory for the Element
  1.3526 +    	is managed by the Document.
  1.3527 +    */
  1.3528 +    XMLElement* NewElement( const char* name );
  1.3529 +    /**
  1.3530 +    	Create a new Comment associated with
  1.3531 +    	this Document. The memory for the Comment
  1.3532 +    	is managed by the Document.
  1.3533 +    */
  1.3534 +    XMLComment* NewComment( const char* comment );
  1.3535 +    /**
  1.3536 +    	Create a new Text associated with
  1.3537 +    	this Document. The memory for the Text
  1.3538 +    	is managed by the Document.
  1.3539 +    */
  1.3540 +    XMLText* NewText( const char* text );
  1.3541 +    /**
  1.3542 +    	Create a new Declaration associated with
  1.3543 +    	this Document. The memory for the object
  1.3544 +    	is managed by the Document.
  1.3545 +
  1.3546 +    	If the 'text' param is null, the standard
  1.3547 +    	declaration is used.:
  1.3548 +    	@verbatim
  1.3549 +    		<?xml version="1.0" encoding="UTF-8"?>
  1.3550 +    	@endverbatim
  1.3551 +    */
  1.3552 +    XMLDeclaration* NewDeclaration( const char* text=0 );
  1.3553 +    /**
  1.3554 +    	Create a new Unknown associated with
  1.3555 +    	this Document. The memory for the object
  1.3556 +    	is managed by the Document.
  1.3557 +    */
  1.3558 +    XMLUnknown* NewUnknown( const char* text );
  1.3559 +
  1.3560 +    /**
  1.3561 +    	Delete a node associated with this document.
  1.3562 +    	It will be unlinked from the DOM.
  1.3563 +    */
  1.3564 +    void DeleteNode( XMLNode* node )	{
  1.3565 +        node->_parent->DeleteChild( node );
  1.3566 +    }
  1.3567 +
  1.3568 +    void SetError( XMLError error, const char* str1, const char* str2 );
  1.3569 +
  1.3570 +    /// Return true if there was an error parsing the document.
  1.3571 +    bool Error() const {
  1.3572 +        return _errorID != XML_NO_ERROR;
  1.3573 +    }
  1.3574 +    /// Return the errorID.
  1.3575 +    XMLError  ErrorID() const {
  1.3576 +        return _errorID;
  1.3577 +    }
  1.3578 +    /// Return a possibly helpful diagnostic location or string.
  1.3579 +    const char* GetErrorStr1() const {
  1.3580 +        return _errorStr1;
  1.3581 +    }
  1.3582 +    /// Return a possibly helpful secondary diagnostic location or string.
  1.3583 +    const char* GetErrorStr2() const {
  1.3584 +        return _errorStr2;
  1.3585 +    }
  1.3586 +    /// If there is an error, print it to stdout.
  1.3587 +    void PrintError() const;
  1.3588 +    
  1.3589 +    /// Clear the document, resetting it to the initial state.
  1.3590 +    void Clear();
  1.3591 +
  1.3592 +    // internal
  1.3593 +    char* Identify( char* p, XMLNode** node );
  1.3594 +
  1.3595 +    virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const	{
  1.3596 +        return 0;
  1.3597 +    }
  1.3598 +    virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const	{
  1.3599 +        return false;
  1.3600 +    }
  1.3601 +
  1.3602 +private:
  1.3603 +    XMLDocument( const XMLDocument& );	// not supported
  1.3604 +    void operator=( const XMLDocument& );	// not supported
  1.3605 +
  1.3606 +    bool        _writeBOM;
  1.3607 +    bool        _processEntities;
  1.3608 +    XMLError    _errorID;
  1.3609 +    Whitespace  _whitespace;
  1.3610 +    const char* _errorStr1;
  1.3611 +    const char* _errorStr2;
  1.3612 +    char*       _charBuffer;
  1.3613 +
  1.3614 +    MemPoolT< sizeof(XMLElement) >	 _elementPool;
  1.3615 +    MemPoolT< sizeof(XMLAttribute) > _attributePool;
  1.3616 +    MemPoolT< sizeof(XMLText) >		 _textPool;
  1.3617 +    MemPoolT< sizeof(XMLComment) >	 _commentPool;
  1.3618 +};
  1.3619 +
  1.3620 +
  1.3621 +/**
  1.3622 +	A XMLHandle is a class that wraps a node pointer with null checks; this is
  1.3623 +	an incredibly useful thing. Note that XMLHandle is not part of the TinyXML-2
  1.3624 +	DOM structure. It is a separate utility class.
  1.3625 +
  1.3626 +	Take an example:
  1.3627 +	@verbatim
  1.3628 +	<Document>
  1.3629 +		<Element attributeA = "valueA">
  1.3630 +			<Child attributeB = "value1" />
  1.3631 +			<Child attributeB = "value2" />
  1.3632 +		</Element>
  1.3633 +	</Document>
  1.3634 +	@endverbatim
  1.3635 +
  1.3636 +	Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
  1.3637 +	easy to write a *lot* of code that looks like:
  1.3638 +
  1.3639 +	@verbatim
  1.3640 +	XMLElement* root = document.FirstChildElement( "Document" );
  1.3641 +	if ( root )
  1.3642 +	{
  1.3643 +		XMLElement* element = root->FirstChildElement( "Element" );
  1.3644 +		if ( element )
  1.3645 +		{
  1.3646 +			XMLElement* child = element->FirstChildElement( "Child" );
  1.3647 +			if ( child )
  1.3648 +			{
  1.3649 +				XMLElement* child2 = child->NextSiblingElement( "Child" );
  1.3650 +				if ( child2 )
  1.3651 +				{
  1.3652 +					// Finally do something useful.
  1.3653 +	@endverbatim
  1.3654 +
  1.3655 +	And that doesn't even cover "else" cases. XMLHandle addresses the verbosity
  1.3656 +	of such code. A XMLHandle checks for null pointers so it is perfectly safe
  1.3657 +	and correct to use:
  1.3658 +
  1.3659 +	@verbatim
  1.3660 +	XMLHandle docHandle( &document );
  1.3661 +	XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
  1.3662 +	if ( child2 )
  1.3663 +	{
  1.3664 +		// do something useful
  1.3665 +	@endverbatim
  1.3666 +
  1.3667 +	Which is MUCH more concise and useful.
  1.3668 +
  1.3669 +	It is also safe to copy handles - internally they are nothing more than node pointers.
  1.3670 +	@verbatim
  1.3671 +	XMLHandle handleCopy = handle;
  1.3672 +	@endverbatim
  1.3673 +
  1.3674 +	See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
  1.3675 +*/
  1.3676 +class TINYXML2_LIB XMLHandle
  1.3677 +{
  1.3678 +public:
  1.3679 +    /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
  1.3680 +    XMLHandle( XMLNode* node )												{
  1.3681 +        _node = node;
  1.3682 +    }
  1.3683 +    /// Create a handle from a node.
  1.3684 +    XMLHandle( XMLNode& node )												{
  1.3685 +        _node = &node;
  1.3686 +    }
  1.3687 +    /// Copy constructor
  1.3688 +    XMLHandle( const XMLHandle& ref )										{
  1.3689 +        _node = ref._node;
  1.3690 +    }
  1.3691 +    /// Assignment
  1.3692 +    XMLHandle& operator=( const XMLHandle& ref )							{
  1.3693 +        _node = ref._node;
  1.3694 +        return *this;
  1.3695 +    }
  1.3696 +
  1.3697 +    /// Get the first child of this handle.
  1.3698 +    XMLHandle FirstChild() 													{
  1.3699 +        return XMLHandle( _node ? _node->FirstChild() : 0 );
  1.3700 +    }
  1.3701 +    /// Get the first child element of this handle.
  1.3702 +    XMLHandle FirstChildElement( const char* value=0 )						{
  1.3703 +        return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
  1.3704 +    }
  1.3705 +    /// Get the last child of this handle.
  1.3706 +    XMLHandle LastChild()													{
  1.3707 +        return XMLHandle( _node ? _node->LastChild() : 0 );
  1.3708 +    }
  1.3709 +    /// Get the last child element of this handle.
  1.3710 +    XMLHandle LastChildElement( const char* _value=0 )						{
  1.3711 +        return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
  1.3712 +    }
  1.3713 +    /// Get the previous sibling of this handle.
  1.3714 +    XMLHandle PreviousSibling()												{
  1.3715 +        return XMLHandle( _node ? _node->PreviousSibling() : 0 );
  1.3716 +    }
  1.3717 +    /// Get the previous sibling element of this handle.
  1.3718 +    XMLHandle PreviousSiblingElement( const char* _value=0 )				{
  1.3719 +        return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
  1.3720 +    }
  1.3721 +    /// Get the next sibling of this handle.
  1.3722 +    XMLHandle NextSibling()													{
  1.3723 +        return XMLHandle( _node ? _node->NextSibling() : 0 );
  1.3724 +    }
  1.3725 +    /// Get the next sibling element of this handle.
  1.3726 +    XMLHandle NextSiblingElement( const char* _value=0 )					{
  1.3727 +        return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
  1.3728 +    }
  1.3729 +
  1.3730 +    /// Safe cast to XMLNode. This can return null.
  1.3731 +    XMLNode* ToNode()							{
  1.3732 +        return _node;
  1.3733 +    }
  1.3734 +    /// Safe cast to XMLElement. This can return null.
  1.3735 +    XMLElement* ToElement() 					{
  1.3736 +        return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
  1.3737 +    }
  1.3738 +    /// Safe cast to XMLText. This can return null.
  1.3739 +    XMLText* ToText() 							{
  1.3740 +        return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
  1.3741 +    }
  1.3742 +    /// Safe cast to XMLUnknown. This can return null.
  1.3743 +    XMLUnknown* ToUnknown() 					{
  1.3744 +        return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
  1.3745 +    }
  1.3746 +    /// Safe cast to XMLDeclaration. This can return null.
  1.3747 +    XMLDeclaration* ToDeclaration() 			{
  1.3748 +        return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
  1.3749 +    }
  1.3750 +
  1.3751 +private:
  1.3752 +    XMLNode* _node;
  1.3753 +};
  1.3754 +
  1.3755 +
  1.3756 +/**
  1.3757 +	A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the
  1.3758 +	same in all regards, except for the 'const' qualifiers. See XMLHandle for API.
  1.3759 +*/
  1.3760 +class TINYXML2_LIB XMLConstHandle
  1.3761 +{
  1.3762 +public:
  1.3763 +    XMLConstHandle( const XMLNode* node )											{
  1.3764 +        _node = node;
  1.3765 +    }
  1.3766 +    XMLConstHandle( const XMLNode& node )											{
  1.3767 +        _node = &node;
  1.3768 +    }
  1.3769 +    XMLConstHandle( const XMLConstHandle& ref )										{
  1.3770 +        _node = ref._node;
  1.3771 +    }
  1.3772 +
  1.3773 +    XMLConstHandle& operator=( const XMLConstHandle& ref )							{
  1.3774 +        _node = ref._node;
  1.3775 +        return *this;
  1.3776 +    }
  1.3777 +
  1.3778 +    const XMLConstHandle FirstChild() const											{
  1.3779 +        return XMLConstHandle( _node ? _node->FirstChild() : 0 );
  1.3780 +    }
  1.3781 +    const XMLConstHandle FirstChildElement( const char* value=0 ) const				{
  1.3782 +        return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
  1.3783 +    }
  1.3784 +    const XMLConstHandle LastChild()	const										{
  1.3785 +        return XMLConstHandle( _node ? _node->LastChild() : 0 );
  1.3786 +    }
  1.3787 +    const XMLConstHandle LastChildElement( const char* _value=0 ) const				{
  1.3788 +        return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
  1.3789 +    }
  1.3790 +    const XMLConstHandle PreviousSibling() const									{
  1.3791 +        return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
  1.3792 +    }
  1.3793 +    const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const		{
  1.3794 +        return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
  1.3795 +    }
  1.3796 +    const XMLConstHandle NextSibling() const										{
  1.3797 +        return XMLConstHandle( _node ? _node->NextSibling() : 0 );
  1.3798 +    }
  1.3799 +    const XMLConstHandle NextSiblingElement( const char* _value=0 ) const			{
  1.3800 +        return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
  1.3801 +    }
  1.3802 +
  1.3803 +
  1.3804 +    const XMLNode* ToNode() const				{
  1.3805 +        return _node;
  1.3806 +    }
  1.3807 +    const XMLElement* ToElement() const			{
  1.3808 +        return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
  1.3809 +    }
  1.3810 +    const XMLText* ToText() const				{
  1.3811 +        return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
  1.3812 +    }
  1.3813 +    const XMLUnknown* ToUnknown() const			{
  1.3814 +        return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
  1.3815 +    }
  1.3816 +    const XMLDeclaration* ToDeclaration() const	{
  1.3817 +        return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
  1.3818 +    }
  1.3819 +
  1.3820 +private:
  1.3821 +    const XMLNode* _node;
  1.3822 +};
  1.3823 +
  1.3824 +
  1.3825 +/**
  1.3826 +	Printing functionality. The XMLPrinter gives you more
  1.3827 +	options than the XMLDocument::Print() method.
  1.3828 +
  1.3829 +	It can:
  1.3830 +	-# Print to memory.
  1.3831 +	-# Print to a file you provide.
  1.3832 +	-# Print XML without a XMLDocument.
  1.3833 +
  1.3834 +	Print to Memory
  1.3835 +
  1.3836 +	@verbatim
  1.3837 +	XMLPrinter printer;
  1.3838 +	doc.Print( &printer );
  1.3839 +	SomeFunction( printer.CStr() );
  1.3840 +	@endverbatim
  1.3841 +
  1.3842 +	Print to a File
  1.3843 +
  1.3844 +	You provide the file pointer.
  1.3845 +	@verbatim
  1.3846 +	XMLPrinter printer( fp );
  1.3847 +	doc.Print( &printer );
  1.3848 +	@endverbatim
  1.3849 +
  1.3850 +	Print without a XMLDocument
  1.3851 +
  1.3852 +	When loading, an XML parser is very useful. However, sometimes
  1.3853 +	when saving, it just gets in the way. The code is often set up
  1.3854 +	for streaming, and constructing the DOM is just overhead.
  1.3855 +
  1.3856 +	The Printer supports the streaming case. The following code
  1.3857 +	prints out a trivially simple XML file without ever creating
  1.3858 +	an XML document.
  1.3859 +
  1.3860 +	@verbatim
  1.3861 +	XMLPrinter printer( fp );
  1.3862 +	printer.OpenElement( "foo" );
  1.3863 +	printer.PushAttribute( "foo", "bar" );
  1.3864 +	printer.CloseElement();
  1.3865 +	@endverbatim
  1.3866 +*/
  1.3867 +class TINYXML2_LIB XMLPrinter : public XMLVisitor
  1.3868 +{
  1.3869 +public:
  1.3870 +    /** Construct the printer. If the FILE* is specified,
  1.3871 +    	this will print to the FILE. Else it will print
  1.3872 +    	to memory, and the result is available in CStr().
  1.3873 +    	If 'compact' is set to true, then output is created
  1.3874 +    	with only required whitespace and newlines.
  1.3875 +    */
  1.3876 +    XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
  1.3877 +    ~XMLPrinter()	{}
  1.3878 +
  1.3879 +    /** If streaming, write the BOM and declaration. */
  1.3880 +    void PushHeader( bool writeBOM, bool writeDeclaration );
  1.3881 +    /** If streaming, start writing an element.
  1.3882 +        The element must be closed with CloseElement()
  1.3883 +    */
  1.3884 +    void OpenElement( const char* name );
  1.3885 +    /// If streaming, add an attribute to an open element.
  1.3886 +    void PushAttribute( const char* name, const char* value );
  1.3887 +    void PushAttribute( const char* name, int value );
  1.3888 +    void PushAttribute( const char* name, unsigned value );
  1.3889 +    void PushAttribute( const char* name, bool value );
  1.3890 +    void PushAttribute( const char* name, double value );
  1.3891 +    /// If streaming, close the Element.
  1.3892 +    void CloseElement();
  1.3893 +
  1.3894 +    /// Add a text node.
  1.3895 +    void PushText( const char* text, bool cdata=false );
  1.3896 +    /// Add a text node from an integer.
  1.3897 +    void PushText( int value );
  1.3898 +    /// Add a text node from an unsigned.
  1.3899 +    void PushText( unsigned value );
  1.3900 +    /// Add a text node from a bool.
  1.3901 +    void PushText( bool value );
  1.3902 +    /// Add a text node from a float.
  1.3903 +    void PushText( float value );
  1.3904 +    /// Add a text node from a double.
  1.3905 +    void PushText( double value );
  1.3906 +
  1.3907 +    /// Add a comment
  1.3908 +    void PushComment( const char* comment );
  1.3909 +
  1.3910 +    void PushDeclaration( const char* value );
  1.3911 +    void PushUnknown( const char* value );
  1.3912 +
  1.3913 +    virtual bool VisitEnter( const XMLDocument& /*doc*/ );
  1.3914 +    virtual bool VisitExit( const XMLDocument& /*doc*/ )			{
  1.3915 +        return true;
  1.3916 +    }
  1.3917 +
  1.3918 +    virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
  1.3919 +    virtual bool VisitExit( const XMLElement& element );
  1.3920 +
  1.3921 +    virtual bool Visit( const XMLText& text );
  1.3922 +    virtual bool Visit( const XMLComment& comment );
  1.3923 +    virtual bool Visit( const XMLDeclaration& declaration );
  1.3924 +    virtual bool Visit( const XMLUnknown& unknown );
  1.3925 +
  1.3926 +    /**
  1.3927 +    	If in print to memory mode, return a pointer to
  1.3928 +    	the XML file in memory.
  1.3929 +    */
  1.3930 +    const char* CStr() const {
  1.3931 +        return _buffer.Mem();
  1.3932 +    }
  1.3933 +    /**
  1.3934 +    	If in print to memory mode, return the size
  1.3935 +    	of the XML file in memory. (Note the size returned
  1.3936 +    	includes the terminating null.)
  1.3937 +    */
  1.3938 +    int CStrSize() const {
  1.3939 +        return _buffer.Size();
  1.3940 +    }
  1.3941 +
  1.3942 +private:
  1.3943 +    void SealElement();
  1.3944 +    void PrintSpace( int depth );
  1.3945 +    void PrintString( const char*, bool restrictedEntitySet );	// prints out, after detecting entities.
  1.3946 +    void Print( const char* format, ... );
  1.3947 +
  1.3948 +    bool _elementJustOpened;
  1.3949 +    bool _firstElement;
  1.3950 +    FILE* _fp;
  1.3951 +    int _depth;
  1.3952 +    int _textDepth;
  1.3953 +    bool _processEntities;
  1.3954 +    bool _compactMode;
  1.3955 +
  1.3956 +    enum {
  1.3957 +        ENTITY_RANGE = 64,
  1.3958 +        BUF_SIZE = 200
  1.3959 +    };
  1.3960 +    bool _entityFlag[ENTITY_RANGE];
  1.3961 +    bool _restrictedEntityFlag[ENTITY_RANGE];
  1.3962 +
  1.3963 +    DynArray< const char*, 10 > _stack;
  1.3964 +    DynArray< char, 20 > _buffer;
  1.3965 +#ifdef _MSC_VER
  1.3966 +    DynArray< char, 20 > _accumulator;
  1.3967 +#endif
  1.3968 +};
  1.3969 +
  1.3970 +
  1.3971 +}	// tinyxml2
  1.3972 +
  1.3973 +#if defined(_MSC_VER)
  1.3974 +#   pragma warning(pop)
  1.3975 +#endif
  1.3976 +
  1.3977 +#endif // TINYXML2_INCLUDED