Advertisement
Guest User

tinyxml2 unicode wchar_t version header

a guest
Jan 20th, 2013
1,364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 56.60 KB | None | 0 0
  1. /*
  2. Original code by Lee Thomason (www.grinninglizard.com)
  3. wchar_t port by dUkk
  4.  
  5. This software is provided 'as-is', without any express or implied
  6. warranty. In no event will the authors be held liable for any
  7. damages arising from the use of this software.
  8.  
  9. Permission is granted to anyone to use this software for any
  10. purpose, including commercial applications, and to alter it and
  11. redistribute it freely, subject to the following restrictions:
  12.  
  13. 1. The origin of this software must not be misrepresented; you must
  14. not claim that you wrote the original software. If you use this
  15. software in a product, an acknowledgment in the product documentation
  16. would be appreciated but is not required.
  17.  
  18. 2. Altered source versions must be plainly marked as such, and
  19. must not be misrepresented as being the original software.
  20.  
  21. 3. This notice may not be removed or altered from any source
  22. distribution.
  23. */
  24. #include <wchar.h>
  25.  
  26. #ifndef TINYXML2_INCLUDED
  27. #define TINYXML2_INCLUDED
  28.  
  29. #if defined(ANDROID_NDK) || defined(__BORLANDC__)
  30. #   include <ctype.h>
  31. #   include <limits.h>
  32. #   include <stdio.h>
  33. #   include <stdlib.h>
  34. #   include <string.h>
  35. #   include <stdarg.h>
  36. #else
  37. #   include <cctype>
  38. #   include <climits>
  39. #   include <cstdio>
  40. #   include <cstdlib>
  41. #   include <cstring>
  42. #   include <cstdarg>
  43. #endif
  44.  
  45. /*
  46.    TODO: intern strings instead of allocation.
  47. */
  48. /*
  49.     gcc:
  50.         g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
  51.  
  52.     Formatting, Artistic Style:
  53.         AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
  54. */
  55.  
  56. #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
  57. #   ifndef DEBUG
  58. #       define DEBUG
  59. #   endif
  60. #endif
  61.  
  62.  
  63. #if defined(DEBUG)
  64. #   if defined(_MSC_VER)
  65. #       define TIXMLASSERT( x )           if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
  66. #   elif defined (ANDROID_NDK)
  67. #       include <android/log.h>
  68. #       define TIXMLASSERT( x )           if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
  69. #   else
  70. #       include <assert.h>
  71. #       define TIXMLASSERT                assert
  72. #   endif
  73. #   else
  74. #       define TIXMLASSERT( x )           {}
  75. #endif
  76.  
  77.  
  78. #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
  79. // Microsoft visual studio, version 2005 and higher.
  80. /*int _snprintf_s(
  81.    char *buffer,
  82.    size_t sizeOfBuffer,
  83.    size_t count,
  84.    const char *format [,
  85.       argument] ...
  86. );*/
  87. inline int TIXML_SNPRINTF( wchar_t* buffer, size_t size, const wchar_t* format, ... )
  88. {
  89.     va_list va;
  90.     va_start( va, format );
  91.     int result = _vsnwprintf_s( buffer, size, _TRUNCATE, format, va );
  92.     va_end( va );
  93.     return result;
  94. }
  95. #define TIXML_SSCANF   swscanf_s
  96. #else
  97. // GCC version 3 and higher
  98. //#warning( "Using sn* functions." )
  99. #define TIXML_SNPRINTF snprintf
  100. #define TIXML_SSCANF   sscanf
  101. #endif
  102.  
  103. static const int TIXML2_MAJOR_VERSION = 1;
  104. static const int TIXML2_MINOR_VERSION = 0;
  105. static const int TIXML2_PATCH_VERSION = 9;
  106.  
  107. namespace tinyxml2
  108. {
  109. class TiXMLDocument;
  110. class XMLElement;
  111. class XMLAttribute;
  112. class XMLComment;
  113. class XMLNode;
  114. class XMLText;
  115. class XMLDeclaration;
  116. class XMLUnknown;
  117.  
  118. class XMLPrinter;
  119.  
  120. /*
  121.     A class that wraps strings. Normally stores the start and end
  122.     pointers into the XML file itself, and will apply normalization
  123.     and entity translation if actually read. Can also store (and memory
  124.     manage) a traditional char[]
  125. */
  126. class StrPair
  127. {
  128. public:
  129.     enum {
  130.         NEEDS_ENTITY_PROCESSING         = 0x01,
  131.         NEEDS_NEWLINE_NORMALIZATION     = 0x02,
  132.         COLLAPSE_WHITESPACE             = 0x04,
  133.  
  134.         TEXT_ELEMENT                    = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
  135.         TEXT_ELEMENT_LEAVE_ENTITIES     = NEEDS_NEWLINE_NORMALIZATION,
  136.         ATTRIBUTE_NAME                  = 0,
  137.         ATTRIBUTE_VALUE                 = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
  138.         ATTRIBUTE_VALUE_LEAVE_ENTITIES  = NEEDS_NEWLINE_NORMALIZATION,
  139.         COMMENT                         = NEEDS_NEWLINE_NORMALIZATION
  140.     };
  141.  
  142.     StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
  143.     ~StrPair();
  144.  
  145.     void Set( wchar_t* start, wchar_t* end, int flags ) {
  146.         Reset();
  147.         _start  = start;
  148.         _end    = end;
  149.         _flags  = flags | NEEDS_FLUSH;
  150.     }
  151.  
  152.     const wchar_t* GetStr();
  153.  
  154.     bool Empty() const {
  155.         return _start == _end;
  156.     }
  157.  
  158.     void SetInternedStr( const wchar_t* str ) {
  159.         Reset();
  160.         _start = const_cast<wchar_t*>(str);
  161.     }
  162.  
  163.     void SetStr( const wchar_t* str, int flags=0 );
  164.  
  165.     wchar_t* ParseText( wchar_t* in, const wchar_t* endTag, int strFlags );
  166.     wchar_t* ParseName( wchar_t* in );
  167.  
  168. private:
  169.     void Reset();
  170.     void CollapseWhitespace();
  171.  
  172.     enum {
  173.         NEEDS_FLUSH = 0x100,
  174.         NEEDS_DELETE = 0x200
  175.     };
  176.  
  177.     // After parsing, if *end != 0, it can be set to zero.
  178.     int     _flags;
  179.     wchar_t*   _start;
  180.     wchar_t*   _end;
  181. };
  182.  
  183.  
  184. /*
  185.     A dynamic array of Plain Old Data. Doesn't support constructors, etc.
  186.     Has a small initial memory pool, so that low or no usage will not
  187.     cause a call to new/delete
  188. */
  189. template <class T, int INIT>
  190. class DynArray
  191. {
  192. public:
  193.     DynArray< T, INIT >() {
  194.         _mem = _pool;
  195.         _allocated = INIT;
  196.         _size = 0;
  197.     }
  198.  
  199.     ~DynArray() {
  200.         if ( _mem != _pool ) {
  201.             delete [] _mem;
  202.         }
  203.     }
  204.  
  205.     void Push( T t ) {
  206.         EnsureCapacity( _size+1 );
  207.         _mem[_size++] = t;
  208.     }
  209.  
  210.     T* PushArr( int count ) {
  211.         EnsureCapacity( _size+count );
  212.         T* ret = &_mem[_size];
  213.         _size += count;
  214.         return ret;
  215.     }
  216.  
  217.     T Pop() {
  218.         return _mem[--_size];
  219.     }
  220.  
  221.     void PopArr( int count ) {
  222.         TIXMLASSERT( _size >= count );
  223.         _size -= count;
  224.     }
  225.  
  226.     bool Empty() const                  {
  227.         return _size == 0;
  228.     }
  229.  
  230.     T& operator[](int i)                {
  231.         TIXMLASSERT( i>= 0 && i < _size );
  232.         return _mem[i];
  233.     }
  234.  
  235.     const T& operator[](int i) const    {
  236.         TIXMLASSERT( i>= 0 && i < _size );
  237.         return _mem[i];
  238.     }
  239.  
  240.     int Size() const                    {
  241.         return _size;
  242.     }
  243.  
  244.     int Capacity() const                {
  245.         return _allocated;
  246.     }
  247.  
  248.     const T* Mem() const                {
  249.         return _mem;
  250.     }
  251.  
  252.     T* Mem()                            {
  253.         return _mem;
  254.     }
  255.  
  256. private:
  257.     void EnsureCapacity( int cap ) {
  258.         if ( cap > _allocated ) {
  259.             int newAllocated = cap * 2;
  260.             T* newMem = new T[newAllocated];
  261.             memcpy( newMem, _mem, sizeof(T)*_size );    // warning: not using constructors, only works for PODs
  262.             if ( _mem != _pool ) {
  263.                 delete [] _mem;
  264.             }
  265.             _mem = newMem;
  266.             _allocated = newAllocated;
  267.         }
  268.     }
  269.  
  270.     T*  _mem;
  271.     T   _pool[INIT];
  272.     int _allocated;     // objects allocated
  273.     int _size;          // number objects in use
  274. };
  275.  
  276.  
  277. /*
  278.     Parent virtual class of a pool for fast allocation
  279.     and deallocation of objects.
  280. */
  281. class MemPool
  282. {
  283. public:
  284.     MemPool() {}
  285.     virtual ~MemPool() {}
  286.  
  287.     virtual int ItemSize() const = 0;
  288.     virtual void* Alloc() = 0;
  289.     virtual void Free( void* ) = 0;
  290.     virtual void SetTracked() = 0;
  291. };
  292.  
  293.  
  294. /*
  295.     Template child class to create pools of the correct type.
  296. */
  297. template< int SIZE >
  298. class MemPoolT : public MemPool
  299. {
  300. public:
  301.     MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0)    {}
  302.     ~MemPoolT() {
  303.         // Delete the blocks.
  304.         for( int i=0; i<_blockPtrs.Size(); ++i ) {
  305.             delete _blockPtrs[i];
  306.         }
  307.     }
  308.  
  309.     virtual int ItemSize() const    {
  310.         return SIZE;
  311.     }
  312.     int CurrentAllocs() const       {
  313.         return _currentAllocs;
  314.     }
  315.  
  316.     virtual void* Alloc() {
  317.         if ( !_root ) {
  318.             // Need a new block.
  319.             Block* block = new Block();
  320.             _blockPtrs.Push( block );
  321.  
  322.             for( int i=0; i<COUNT-1; ++i ) {
  323.                 block->chunk[i].next = &block->chunk[i+1];
  324.             }
  325.             block->chunk[COUNT-1].next = 0;
  326.             _root = block->chunk;
  327.         }
  328.         void* result = _root;
  329.         _root = _root->next;
  330.  
  331.         ++_currentAllocs;
  332.         if ( _currentAllocs > _maxAllocs ) {
  333.             _maxAllocs = _currentAllocs;
  334.         }
  335.         _nAllocs++;
  336.         _nUntracked++;
  337.         return result;
  338.     }
  339.     virtual void Free( void* mem ) {
  340.         if ( !mem ) {
  341.             return;
  342.         }
  343.         --_currentAllocs;
  344.         Chunk* chunk = (Chunk*)mem;
  345. #ifdef DEBUG
  346.         memset( chunk, 0xfe, sizeof(Chunk) );
  347. #endif
  348.         chunk->next = _root;
  349.         _root = chunk;
  350.     }
  351.     void Trace( const wchar_t* name ) {
  352.         wprintf( L"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
  353.                 name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
  354.     }
  355.  
  356.     void SetTracked() {
  357.         _nUntracked--;
  358.     }
  359.  
  360.     int Untracked() const {
  361.         return _nUntracked;
  362.     }
  363.  
  364.     enum { COUNT = 1024/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
  365.  
  366. private:
  367.     union Chunk {
  368.         Chunk*  next;
  369.         char    mem[SIZE];
  370.     };
  371.     struct Block {
  372.         Chunk chunk[COUNT];
  373.     };
  374.     DynArray< Block*, 10 > _blockPtrs;
  375.     Chunk* _root;
  376.  
  377.     int _currentAllocs;
  378.     int _nAllocs;
  379.     int _maxAllocs;
  380.     int _nUntracked;
  381. };
  382.  
  383.  
  384.  
  385. /**
  386.     Implements the interface to the "Visitor pattern" (see the Accept() method.)
  387.     If you call the Accept() method, it requires being passed a XMLVisitor
  388.     class to handle callbacks. For nodes that contain other nodes (Document, Element)
  389.     you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs
  390.     are simply called with Visit().
  391.  
  392.     If you return 'true' from a Visit method, recursive parsing will continue. If you return
  393.     false, <b>no children of this node or its sibilings</b> will be visited.
  394.  
  395.     All flavors of Visit methods have a default implementation that returns 'true' (continue
  396.     visiting). You need to only override methods that are interesting to you.
  397.  
  398.     Generally Accept() is called on the TiXmlDocument, although all nodes support visiting.
  399.  
  400.     You should never change the document from a callback.
  401.  
  402.     @sa XMLNode::Accept()
  403. */
  404. class XMLVisitor
  405. {
  406. public:
  407.     virtual ~XMLVisitor() {}
  408.  
  409.     /// Visit a document.
  410.     virtual bool VisitEnter( const TiXMLDocument& /*doc*/ )         {
  411.         return true;
  412.     }
  413.     /// Visit a document.
  414.     virtual bool VisitExit( const TiXMLDocument& /*doc*/ )          {
  415.         return true;
  416.     }
  417.  
  418.     /// Visit an element.
  419.     virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ )    {
  420.         return true;
  421.     }
  422.     /// Visit an element.
  423.     virtual bool VisitExit( const XMLElement& /*element*/ )         {
  424.         return true;
  425.     }
  426.  
  427.     /// Visit a declaration.
  428.     virtual bool Visit( const XMLDeclaration& /*declaration*/ )     {
  429.         return true;
  430.     }
  431.     /// Visit a text node.
  432.     virtual bool Visit( const XMLText& /*text*/ )                   {
  433.         return true;
  434.     }
  435.     /// Visit a comment node.
  436.     virtual bool Visit( const XMLComment& /*comment*/ )             {
  437.         return true;
  438.     }
  439.     /// Visit an unknown node.
  440.     virtual bool Visit( const XMLUnknown& /*unknown*/ )             {
  441.         return true;
  442.     }
  443. };
  444.  
  445.  
  446. /*
  447.     Utility functionality.
  448. */
  449. class XMLUtil
  450. {
  451. public:
  452.     // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
  453.     // correct, but simple, and usually works.
  454.     static const wchar_t* SkipWhiteSpace( const wchar_t* p )    {
  455.         while( !IsUTF8Continuation(*p) && iswspace( *(p) ) ) {
  456.             ++p;
  457.         }
  458.         return p;
  459.     }
  460.     static wchar_t* SkipWhiteSpace( wchar_t* p )                {
  461.         while( !IsUTF8Continuation(*p) && iswspace( *(p) ) )        {
  462.             ++p;
  463.         }
  464.         return p;
  465.     }
  466.     static bool IsWhiteSpace( wchar_t p )                   {
  467.         return !IsUTF8Continuation(p) && iswspace( (p) );
  468.     }
  469.  
  470.     inline static bool StringEqual( const wchar_t* p, const wchar_t* q, int nChar=INT_MAX )  {
  471.         int n = 0;
  472.         if ( p == q ) {
  473.             return true;
  474.         }
  475.         while( *p && *q && *p == *q && n<nChar ) {
  476.             ++p;
  477.             ++q;
  478.             ++n;
  479.         }
  480.         if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
  481.             return true;
  482.         }
  483.         return false;
  484.     }
  485.     inline static int IsUTF8Continuation( const wchar_t p ) {
  486.         return p & 0x80;
  487.     }
  488.     inline static int IsAlphaNum( wint_t anyByte )  {
  489.         return ( anyByte < 128 ) ? isalnum( anyByte ) : 1;
  490.     }
  491.     inline static int IsAlpha( wint_t anyByte )     {
  492.         return ( anyByte < 128 ) ? isalpha( anyByte ) : 1;
  493.     }
  494.  
  495.     static const wchar_t* ReadBOM( const wchar_t* p, bool* hasBOM );
  496.     // p is the starting location,
  497.     // the UTF-8 value of the entity will be placed in value, and length filled in.
  498.     static const wchar_t* GetCharacterRef( const wchar_t* p, wchar_t* value, int* length );
  499.     static void ConvertUTF32ToUTF8( unsigned long input, wchar_t* output, int* length );
  500.  
  501.     // converts primitive types to strings
  502.     static void ToStr( int v, wchar_t* buffer, int bufferSize );
  503.     static void ToStr( unsigned v, wchar_t* buffer, int bufferSize );
  504.     static void ToStr( bool v, wchar_t* buffer, int bufferSize );
  505.     static void ToStr( float v, wchar_t* buffer, int bufferSize );
  506.     static void ToStr( double v, wchar_t* buffer, int bufferSize );
  507.     static void ToStr( __int64 v, wchar_t* buffer, int bufferSize );
  508.  
  509.     // converts strings to primitive types
  510.     static bool ToInt( const wchar_t* str, int* value );
  511.     static bool ToUnsigned( const wchar_t* str, unsigned* value );
  512.     static bool ToBool( const wchar_t* str, bool* value );
  513.     static bool ToFloat( const wchar_t* str, float* value );
  514.     static bool ToDouble( const wchar_t* str, double* value );
  515. };
  516.  
  517.  
  518. /** XMLNode is a base class for every object that is in the
  519.     XML Document Object Model (DOM), except XMLAttributes.
  520.     Nodes have siblings, a parent, and children which can
  521.     be navigated. A node is always in a TiXMLDocument.
  522.     The type of a XMLNode can be queried, and it can
  523.     be cast to its more defined type.
  524.  
  525.     A TiXMLDocument allocates memory for all its Nodes.
  526.     When the TiXMLDocument gets deleted, all its Nodes
  527.     will also be deleted.
  528.  
  529.     @verbatim
  530.     A Document can contain: Element (container or leaf)
  531.                             Comment (leaf)
  532.                             Unknown (leaf)
  533.                             Declaration( leaf )
  534.  
  535.     An Element can contain: Element (container or leaf)
  536.                             Text    (leaf)
  537.                             Attributes (not on tree)
  538.                             Comment (leaf)
  539.                             Unknown (leaf)
  540.  
  541.     @endverbatim
  542. */
  543. class XMLNode
  544. {
  545.     friend class TiXMLDocument;
  546.     friend class XMLElement;
  547. public:
  548.  
  549.     /// Get the TiXMLDocument that owns this XMLNode.
  550.     const TiXMLDocument* GetDocument() const    {
  551.         return _document;
  552.     }
  553.     /// Get the TiXMLDocument that owns this XMLNode.
  554.     TiXMLDocument* GetDocument()                {
  555.         return _document;
  556.     }
  557.  
  558.     /// Safely cast to an Element, or null.
  559.     virtual XMLElement*     ToElement()     {
  560.         return 0;
  561.     }
  562.     /// Safely cast to Text, or null.
  563.     virtual XMLText*        ToText()        {
  564.         return 0;
  565.     }
  566.     /// Safely cast to a Comment, or null.
  567.     virtual XMLComment*     ToComment()     {
  568.         return 0;
  569.     }
  570.     /// Safely cast to a Document, or null.
  571.     virtual TiXMLDocument*  ToDocument()    {
  572.         return 0;
  573.     }
  574.     /// Safely cast to a Declaration, or null.
  575.     virtual XMLDeclaration* ToDeclaration() {
  576.         return 0;
  577.     }
  578.     /// Safely cast to an Unknown, or null.
  579.     virtual XMLUnknown*     ToUnknown()     {
  580.         return 0;
  581.     }
  582.  
  583.     virtual const XMLElement*       ToElement() const       {
  584.         return 0;
  585.     }
  586.     virtual const XMLText*          ToText() const          {
  587.         return 0;
  588.     }
  589.     virtual const XMLComment*       ToComment() const       {
  590.         return 0;
  591.     }
  592.     virtual const TiXMLDocument*        ToDocument() const      {
  593.         return 0;
  594.     }
  595.     virtual const XMLDeclaration*   ToDeclaration() const   {
  596.         return 0;
  597.     }
  598.     virtual const XMLUnknown*       ToUnknown() const       {
  599.         return 0;
  600.     }
  601.  
  602.     /** The meaning of 'value' changes for the specific type.
  603.         @verbatim
  604.         Document:   empty
  605.         Element:    name of the element
  606.         Comment:    the comment text
  607.         Unknown:    the tag contents
  608.         Text:       the text string
  609.         @endverbatim
  610.     */
  611.     const wchar_t* Value() const            {
  612.         return _value.GetStr();
  613.     }
  614.  
  615.     /** Set the Value of an XML node.
  616.         @sa Value()
  617.     */
  618.     void SetValue( const wchar_t* val, bool staticMem=false );
  619.  
  620.     /// Get the parent of this node on the DOM.
  621.     const XMLNode*  Parent() const          {
  622.         return _parent;
  623.     }
  624.  
  625.     XMLNode* Parent()                       {
  626.         return _parent;
  627.     }
  628.    
  629.     XMLNode* IterateChildren( XMLNode* previous )
  630.     {
  631.         if ( !previous )
  632.         {
  633.                 return FirstChild();
  634.         }
  635.         else
  636.         {
  637.                 return previous->NextSibling();
  638.         }
  639.     }
  640.  
  641.     /// Returns true if this node has no children.
  642.     bool NoChildren() const                 {
  643.         return !_firstChild;
  644.     }
  645.  
  646.     /// Get the first child node, or null if none exists.
  647.     const XMLNode*  FirstChild() const      {
  648.         return _firstChild;
  649.     }
  650.  
  651.     XMLNode*        FirstChild()            {
  652.         return _firstChild;
  653.     }
  654.  
  655.     /** Get the first child element, or optionally the first child
  656.         element with the specified name.
  657.     */
  658.     const XMLElement* FirstChildElement( const wchar_t* value=0 ) const;
  659.  
  660.     XMLElement* FirstChildElement( const wchar_t* value=0 ) {
  661.         return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value ));
  662.     }
  663.  
  664.     /// Get the last child node, or null if none exists.
  665.     const XMLNode*  LastChild() const                       {
  666.         return _lastChild;
  667.     }
  668.  
  669.     XMLNode*        LastChild()                             {
  670.         return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
  671.     }
  672.  
  673.     /** Get the last child element or optionally the last child
  674.         element with the specified name.
  675.     */
  676.     const XMLElement* LastChildElement( const wchar_t* value=0 ) const;
  677.  
  678.     XMLElement* LastChildElement( const wchar_t* value=0 )  {
  679.         return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) );
  680.     }
  681.  
  682.     /// Get the previous (left) sibling node of this node.
  683.     const XMLNode*  PreviousSibling() const                 {
  684.         return _prev;
  685.     }
  686.  
  687.     XMLNode*    PreviousSibling()                           {
  688.         return _prev;
  689.     }
  690.  
  691.     /// Get the previous (left) sibling element of this node, with an opitionally supplied name.
  692.     const XMLElement*   PreviousSiblingElement( const wchar_t* value=0 ) const ;
  693.  
  694.     XMLElement* PreviousSiblingElement( const wchar_t* value=0 ) {
  695.         return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) );
  696.     }
  697.  
  698.     /// Get the next (right) sibling node of this node.
  699.     const XMLNode*  NextSibling() const                     {
  700.         return _next;
  701.     }
  702.  
  703.     XMLNode*    NextSibling()                               {
  704.         return _next;
  705.     }
  706.  
  707.     /// Get the next (right) sibling element of this node, with an opitionally supplied name.
  708.     const XMLElement*   NextSiblingElement( const wchar_t* value=0 ) const;
  709.  
  710.     XMLElement* NextSiblingElement( const wchar_t* value=0 )    {
  711.         return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) );
  712.     }
  713.  
  714.     /**
  715.         Add a child node as the last (right) child.
  716.     */
  717.     XMLNode* InsertEndChild( XMLNode* addThis );
  718.  
  719.     XMLNode* LinkEndChild( XMLNode* addThis )   {
  720.         return InsertEndChild( addThis );
  721.     }
  722.     /**
  723.         Add a child node as the first (left) child.
  724.     */
  725.     XMLNode* InsertFirstChild( XMLNode* addThis );
  726.     /**
  727.         Add a node after the specified child node.
  728.     */
  729.     XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
  730.  
  731.     /**
  732.         Delete all the children of this node.
  733.     */
  734.     void DeleteChildren();
  735.  
  736.     /**
  737.         Delete a child of this node.
  738.     */
  739.     void DeleteChild( XMLNode* node );
  740.  
  741.     /**
  742.         Make a copy of this node, but not its children.
  743.         You may pass in a Document pointer that will be
  744.         the owner of the new Node. If the 'document' is
  745.         null, then the node returned will be allocated
  746.         from the current Document. (this->GetDocument())
  747.  
  748.         Note: if called on a TiXMLDocument, this will return null.
  749.     */
  750.     virtual XMLNode* ShallowClone( TiXMLDocument* document ) const = 0;
  751.  
  752.     /**
  753.         Test if 2 nodes are the same, but don't test children.
  754.         The 2 nodes do not need to be in the same Document.
  755.  
  756.         Note: if called on a TiXMLDocument, this will return false.
  757.     */
  758.     virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
  759.  
  760.     /** Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the
  761.         XML tree will be conditionally visited and the host will be called back
  762.         via the TiXmlVisitor interface.
  763.  
  764.         This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse
  765.         the XML for the callbacks, so the performance of TinyXML is unchanged by using this
  766.         interface versus any other.)
  767.  
  768.         The interface has been based on ideas from:
  769.  
  770.         - http://www.saxproject.org/
  771.         - http://c2.com/cgi/wiki?HierarchicalVisitorPattern
  772.  
  773.         Which are both good references for "visiting".
  774.  
  775.         An example of using Accept():
  776.         @verbatim
  777.         TiXmlPrinter printer;
  778.         tinyxmlDoc.Accept( &printer );
  779.         const char* xmlcstr = printer.CStr();
  780.         @endverbatim
  781.     */
  782.     virtual bool Accept( XMLVisitor* visitor ) const = 0;
  783.  
  784.     // internal
  785.     virtual wchar_t* ParseDeep( wchar_t*, StrPair* );
  786.  
  787. protected:
  788.     XMLNode( TiXMLDocument* );
  789.     virtual ~XMLNode();
  790.     XMLNode( const XMLNode& );  // not supported
  791.     XMLNode& operator=( const XMLNode& );   // not supported
  792.  
  793.     TiXMLDocument*  _document;
  794.     XMLNode*        _parent;
  795.     mutable StrPair _value;
  796.  
  797.     XMLNode*        _firstChild;
  798.     XMLNode*        _lastChild;
  799.  
  800.     XMLNode*        _prev;
  801.     XMLNode*        _next;
  802.  
  803. private:
  804.     MemPool*        _memPool;
  805.     void Unlink( XMLNode* child );
  806. };
  807.  
  808.  
  809. /** XML text.
  810.  
  811.     Note that a text node can have child element nodes, for example:
  812.     @verbatim
  813.     <root>This is <b>bold</b></root>
  814.     @endverbatim
  815.  
  816.     A text node can have 2 ways to output the next. "normal" output
  817.     and CDATA. It will default to the mode it was parsed from the XML file and
  818.     you generally want to leave it alone, but you can change the output mode with
  819.     SetCDATA() and query it with CDATA().
  820. */
  821. class XMLText : public XMLNode
  822. {
  823.     friend class XMLBase;
  824.     friend class TiXMLDocument;
  825. public:
  826.     virtual bool Accept( XMLVisitor* visitor ) const;
  827.  
  828.     virtual XMLText* ToText()           {
  829.         return this;
  830.     }
  831.     virtual const XMLText* ToText() const   {
  832.         return this;
  833.     }
  834.  
  835.     /// Declare whether this should be CDATA or standard text.
  836.     void SetCData( bool isCData )           {
  837.         _isCData = isCData;
  838.     }
  839.     /// Returns true if this is a CDATA text element.
  840.     bool CData() const                      {
  841.         return _isCData;
  842.     }
  843.  
  844.     wchar_t* ParseDeep( wchar_t*, StrPair* endTag );
  845.     virtual XMLNode* ShallowClone( TiXMLDocument* document ) const;
  846.     virtual bool ShallowEqual( const XMLNode* compare ) const;
  847.  
  848. protected:
  849.     XMLText( TiXMLDocument* doc )   : XMLNode( doc ), _isCData( false ) {}
  850.     virtual ~XMLText()                                              {}
  851.     XMLText( const XMLText& );  // not supported
  852.     XMLText& operator=( const XMLText& );   // not supported
  853.  
  854. private:
  855.     bool _isCData;
  856. };
  857.  
  858.  
  859. /** An XML Comment. */
  860. class XMLComment : public XMLNode
  861. {
  862.     friend class TiXMLDocument;
  863. public:
  864.     virtual XMLComment* ToComment()                 {
  865.         return this;
  866.     }
  867.     virtual const XMLComment* ToComment() const     {
  868.         return this;
  869.     }
  870.  
  871.     virtual bool Accept( XMLVisitor* visitor ) const;
  872.  
  873.     wchar_t* ParseDeep( wchar_t*, StrPair* endTag );
  874.     virtual XMLNode* ShallowClone( TiXMLDocument* document ) const;
  875.     virtual bool ShallowEqual( const XMLNode* compare ) const;
  876.  
  877. protected:
  878.     XMLComment( TiXMLDocument* doc );
  879.     virtual ~XMLComment();
  880.     XMLComment( const XMLComment& );    // not supported
  881.     XMLComment& operator=( const XMLComment& ); // not supported
  882.  
  883. private:
  884. };
  885.  
  886.  
  887. /** In correct XML the declaration is the first entry in the file.
  888.     @verbatim
  889.         <?xml version="1.0" standalone="yes"?>
  890.     @endverbatim
  891.  
  892.     TinyXML2 will happily read or write files without a declaration,
  893.     however.
  894.  
  895.     The text of the declaration isn't interpreted. It is parsed
  896.     and written as a string.
  897. */
  898. class XMLDeclaration : public XMLNode
  899. {
  900.     friend class TiXMLDocument;
  901. public:
  902.     virtual XMLDeclaration* ToDeclaration()                 {
  903.         return this;
  904.     }
  905.     virtual const XMLDeclaration* ToDeclaration() const     {
  906.         return this;
  907.     }
  908.  
  909.     virtual bool Accept( XMLVisitor* visitor ) const;
  910.  
  911.     wchar_t* ParseDeep( wchar_t*, StrPair* endTag );
  912.     virtual XMLNode* ShallowClone( TiXMLDocument* document ) const;
  913.     virtual bool ShallowEqual( const XMLNode* compare ) const;
  914.  
  915. protected:
  916.     XMLDeclaration( TiXMLDocument* doc );
  917.     virtual ~XMLDeclaration();
  918.     XMLDeclaration( const XMLDeclaration& );    // not supported
  919.     XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
  920. };
  921.  
  922.  
  923. /** Any tag that tinyXml doesn't recognize is saved as an
  924.     unknown. It is a tag of text, but should not be modified.
  925.     It will be written back to the XML, unchanged, when the file
  926.     is saved.
  927.  
  928.     DTD tags get thrown into TiXmlUnknowns.
  929. */
  930. class XMLUnknown : public XMLNode
  931. {
  932.     friend class TiXMLDocument;
  933. public:
  934.     virtual XMLUnknown* ToUnknown()                 {
  935.         return this;
  936.     }
  937.     virtual const XMLUnknown* ToUnknown() const     {
  938.         return this;
  939.     }
  940.  
  941.     virtual bool Accept( XMLVisitor* visitor ) const;
  942.  
  943.     wchar_t* ParseDeep( wchar_t*, StrPair* endTag );
  944.     virtual XMLNode* ShallowClone( TiXMLDocument* document ) const;
  945.     virtual bool ShallowEqual( const XMLNode* compare ) const;
  946.  
  947. protected:
  948.     XMLUnknown( TiXMLDocument* doc );
  949.     virtual ~XMLUnknown();
  950.     XMLUnknown( const XMLUnknown& );    // not supported
  951.     XMLUnknown& operator=( const XMLUnknown& ); // not supported
  952. };
  953.  
  954.  
  955. enum XMLError {
  956.     XML_NO_ERROR = 0,
  957.     XML_SUCCESS = 0,
  958.  
  959.     XML_NO_ATTRIBUTE,
  960.     XML_WRONG_ATTRIBUTE_TYPE,
  961.  
  962.     XML_ERROR_FILE_NOT_FOUND,
  963.     XML_ERROR_FILE_COULD_NOT_BE_OPENED,
  964.     XML_ERROR_FILE_READ_ERROR,
  965.     XML_ERROR_ELEMENT_MISMATCH,
  966.     XML_ERROR_PARSING_ELEMENT,
  967.     XML_ERROR_PARSING_ATTRIBUTE,
  968.     XML_ERROR_IDENTIFYING_TAG,
  969.     XML_ERROR_PARSING_TEXT,
  970.     XML_ERROR_PARSING_CDATA,
  971.     XML_ERROR_PARSING_COMMENT,
  972.     XML_ERROR_PARSING_DECLARATION,
  973.     XML_ERROR_PARSING_UNKNOWN,
  974.     XML_ERROR_EMPTY_DOCUMENT,
  975.     XML_ERROR_MISMATCHED_ELEMENT,
  976.     XML_ERROR_PARSING,
  977.  
  978.     XML_CAN_NOT_CONVERT_TEXT,
  979.     XML_NO_TEXT_NODE
  980. };
  981.  
  982.  
  983. /** An attribute is a name-value pair. Elements have an arbitrary
  984.     number of attributes, each with a unique name.
  985.  
  986.     @note The attributes are not XMLNodes. You may only query the
  987.     Next() attribute in a list.
  988. */
  989. class XMLAttribute
  990. {
  991.     friend class XMLElement;
  992. public:
  993.     /// The name of the attribute.
  994.     const wchar_t* Name() const {
  995.         return _name.GetStr();
  996.     }
  997.     /// The value of the attribute.
  998.     const wchar_t* Value() const {
  999.         return _value.GetStr();
  1000.     }
  1001.     /// The next attribute in the list.
  1002.     const XMLAttribute* Next() const {
  1003.         return _next;
  1004.     }
  1005.  
  1006.     /** IntAttribute interprets the attribute as an integer, and returns the value.
  1007.         If the value isn't an integer, 0 will be returned. There is no error checking;
  1008.         use QueryIntAttribute() if you need error checking.
  1009.     */
  1010.     int      IntValue() const               {
  1011.         int i=0;
  1012.         QueryIntValue( &i );
  1013.         return i;
  1014.     }
  1015.     /// Query as an unsigned integer. See IntAttribute()
  1016.     unsigned UnsignedValue() const          {
  1017.         unsigned i=0;
  1018.         QueryUnsignedValue( &i );
  1019.         return i;
  1020.     }
  1021.     /// Query as a boolean. See IntAttribute()
  1022.     bool     BoolValue() const              {
  1023.         bool b=false;
  1024.         QueryBoolValue( &b );
  1025.         return b;
  1026.     }
  1027.     /// Query as a double. See IntAttribute()
  1028.     double   DoubleValue() const            {
  1029.         double d=0;
  1030.         QueryDoubleValue( &d );
  1031.         return d;
  1032.     }
  1033.     /// Query as a float. See IntAttribute()
  1034.     float    FloatValue() const             {
  1035.         float f=0;
  1036.         QueryFloatValue( &f );
  1037.         return f;
  1038.     }
  1039.  
  1040.     /** QueryIntAttribute interprets the attribute as an integer, and returns the value
  1041.         in the provided paremeter. The function will return XML_NO_ERROR on success,
  1042.         and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
  1043.     */
  1044.     XMLError QueryIntValue( int* value ) const;
  1045.     /// See QueryIntAttribute
  1046.     XMLError QueryUnsignedValue( unsigned int* value ) const;
  1047.     /// See QueryIntAttribute
  1048.     XMLError QueryBoolValue( bool* value ) const;
  1049.     /// See QueryIntAttribute
  1050.     XMLError QueryDoubleValue( double* value ) const;
  1051.     /// See QueryIntAttribute
  1052.     XMLError QueryFloatValue( float* value ) const;
  1053.  
  1054.     /// Set the attribute to a string value.
  1055.     void SetAttribute( const wchar_t* value );
  1056.     /// Set the attribute to value.
  1057.     void SetAttribute( int value );
  1058.     /// Set the attribute to value.
  1059.     void SetAttribute( unsigned value );
  1060.     /// Set the attribute to value.
  1061.     void SetAttribute( bool value );
  1062.     /// Set the attribute to value.
  1063.     void SetAttribute( double value );
  1064.     /// Set the attribute to value.
  1065.     void SetAttribute( float value );
  1066.     /// Set the attribute to value.
  1067.     void SetAttribute( __int64 value );
  1068.  
  1069. private:
  1070.     enum { BUF_SIZE = 200 };
  1071.  
  1072.     XMLAttribute() : _next( 0 ) {}
  1073.     virtual ~XMLAttribute() {}
  1074.  
  1075.     XMLAttribute( const XMLAttribute& );    // not supported
  1076.     void operator=( const XMLAttribute& );  // not supported
  1077.     void SetName( const wchar_t* name );
  1078.  
  1079.     wchar_t* ParseDeep( wchar_t* p, bool processEntities );
  1080.  
  1081.     mutable StrPair _name;
  1082.     mutable StrPair _value;
  1083.     XMLAttribute*   _next;
  1084.     MemPool*        _memPool;
  1085. };
  1086.  
  1087.  
  1088. /** The element is a container class. It has a value, the element name,
  1089.     and can contain other elements, text, comments, and unknowns.
  1090.     Elements also contain an arbitrary number of attributes.
  1091. */
  1092. class XMLElement : public XMLNode
  1093. {
  1094.     friend class XMLBase;
  1095.     friend class TiXMLDocument;
  1096. public:
  1097.     /// Get the name of an element (which is the Value() of the node.)
  1098.     const wchar_t* Name() const     {
  1099.         return Value();
  1100.     }
  1101.     /// Set the name of the element.
  1102.     void SetName( const wchar_t* str, bool staticMem=false )    {
  1103.         SetValue( str, staticMem );
  1104.     }
  1105.  
  1106.     virtual XMLElement* ToElement()             {
  1107.         return this;
  1108.     }
  1109.     virtual const XMLElement* ToElement() const {
  1110.         return this;
  1111.     }
  1112.     virtual bool Accept( XMLVisitor* visitor ) const;
  1113.  
  1114.     /** Given an attribute name, Attribute() returns the value
  1115.         for the attribute of that name, or null if none
  1116.         exists. For example:
  1117.  
  1118.         @verbatim
  1119.         const char* value = ele->Attribute( "foo" );
  1120.         @endverbatim
  1121.  
  1122.         The 'value' parameter is normally null. However, if specified,
  1123.         the attribute will only be returned if the 'name' and 'value'
  1124.         match. This allow you to write code:
  1125.  
  1126.         @verbatim
  1127.         if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();
  1128.         @endverbatim
  1129.  
  1130.         rather than:
  1131.         @verbatim
  1132.         if ( ele->Attribute( "foo" ) ) {
  1133.             if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();
  1134.         }
  1135.         @endverbatim
  1136.     */
  1137.     const wchar_t* Attribute( const wchar_t* name, const wchar_t* value=0 ) const;
  1138.  
  1139.     /** Given an attribute name, IntAttribute() returns the value
  1140.         of the attribute interpreted as an integer. 0 will be
  1141.         returned if there is an error. For a method with error
  1142.         checking, see QueryIntAttribute()
  1143.     */
  1144.     int      IntAttribute( const wchar_t* name ) const      {
  1145.         int i=0;
  1146.         QueryIntAttribute( name, &i );
  1147.         return i;
  1148.     }
  1149.     /// See IntAttribute()
  1150.     unsigned UnsignedAttribute( const wchar_t* name ) const {
  1151.         unsigned i=0;
  1152.         QueryUnsignedAttribute( name, &i );
  1153.         return i;
  1154.     }
  1155.     /// See IntAttribute()
  1156.     bool     BoolAttribute( const wchar_t* name ) const {
  1157.         bool b=false;
  1158.         QueryBoolAttribute( name, &b );
  1159.         return b;
  1160.     }
  1161.     /// See IntAttribute()
  1162.     double   DoubleAttribute( const wchar_t* name ) const   {
  1163.         double d=0;
  1164.         QueryDoubleAttribute( name, &d );
  1165.         return d;
  1166.     }
  1167.     /// See IntAttribute()
  1168.     float    FloatAttribute( const wchar_t* name ) const    {
  1169.         float f=0;
  1170.         QueryFloatAttribute( name, &f );
  1171.         return f;
  1172.     }
  1173.  
  1174.     /** Given an attribute name, QueryIntAttribute() returns
  1175.         XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
  1176.         can't be performed, or XML_NO_ATTRIBUTE if the attribute
  1177.         doesn't exist. If successful, the result of the conversion
  1178.         will be written to 'value'. If not successful, nothing will
  1179.         be written to 'value'. This allows you to provide default
  1180.         value:
  1181.  
  1182.         @verbatim
  1183.         int value = 10;
  1184.         QueryIntAttribute( "foo", &value );     // if "foo" isn't found, value will still be 10
  1185.         @endverbatim
  1186.     */
  1187.     XMLError QueryIntAttribute( const wchar_t* name, int* value ) const             {
  1188.         const XMLAttribute* a = FindAttribute( name );
  1189.         if ( !a ) {
  1190.             return XML_NO_ATTRIBUTE;
  1191.         }
  1192.         return a->QueryIntValue( value );
  1193.     }
  1194.     /// See QueryIntAttribute()
  1195.     XMLError QueryUnsignedAttribute( const wchar_t* name, unsigned int* value ) const   {
  1196.         const XMLAttribute* a = FindAttribute( name );
  1197.         if ( !a ) {
  1198.             return XML_NO_ATTRIBUTE;
  1199.         }
  1200.         return a->QueryUnsignedValue( value );
  1201.     }
  1202.     /// See QueryIntAttribute()
  1203.     XMLError QueryBoolAttribute( const wchar_t* name, bool* value ) const               {
  1204.         const XMLAttribute* a = FindAttribute( name );
  1205.         if ( !a ) {
  1206.             return XML_NO_ATTRIBUTE;
  1207.         }
  1208.         return a->QueryBoolValue( value );
  1209.     }
  1210.     /// See QueryIntAttribute()
  1211.     XMLError QueryDoubleAttribute( const wchar_t* name, double* value ) const           {
  1212.         const XMLAttribute* a = FindAttribute( name );
  1213.         if ( !a ) {
  1214.             return XML_NO_ATTRIBUTE;
  1215.         }
  1216.         return a->QueryDoubleValue( value );
  1217.     }
  1218.     /// See QueryIntAttribute()
  1219.     XMLError QueryFloatAttribute( const wchar_t* name, float* value ) const         {
  1220.         const XMLAttribute* a = FindAttribute( name );
  1221.         if ( !a ) {
  1222.             return XML_NO_ATTRIBUTE;
  1223.         }
  1224.         return a->QueryFloatValue( value );
  1225.     }
  1226.  
  1227.     /// Sets the named attribute to value.
  1228.     void SetAttribute( const wchar_t* name, const wchar_t* value )  {
  1229.         XMLAttribute* a = FindOrCreateAttribute( name );
  1230.         a->SetAttribute( value );
  1231.     }
  1232.     /// Sets the named attribute to value.
  1233.     void SetAttribute( const wchar_t* name, int value )         {
  1234.         XMLAttribute* a = FindOrCreateAttribute( name );
  1235.         a->SetAttribute( value );
  1236.     }
  1237.     /// Sets the named attribute to value.
  1238.     void SetAttribute( const wchar_t* name, unsigned value )        {
  1239.         XMLAttribute* a = FindOrCreateAttribute( name );
  1240.         a->SetAttribute( value );
  1241.     }
  1242.     /// Sets the named attribute to value.
  1243.     void SetAttribute( const wchar_t* name, bool value )            {
  1244.         XMLAttribute* a = FindOrCreateAttribute( name );
  1245.         a->SetAttribute( value );
  1246.     }
  1247.     /// Sets the named attribute to value.
  1248.     void SetAttribute( const wchar_t* name, double value )      {
  1249.         XMLAttribute* a = FindOrCreateAttribute( name );
  1250.         a->SetAttribute( value );
  1251.     }
  1252.     /// Sets the named attribute to value.
  1253.     void SetAttribute( const wchar_t* name, __int64 value )     {
  1254.         XMLAttribute* a = FindOrCreateAttribute( name );
  1255.         a->SetAttribute( value );
  1256.     }
  1257.  
  1258.     /**
  1259.         Delete an attribute.
  1260.     */
  1261.     void DeleteAttribute( const wchar_t* name );
  1262.  
  1263.     /// Return the first attribute in the list.
  1264.     const XMLAttribute* FirstAttribute() const {
  1265.         return _rootAttribute;
  1266.     }
  1267.     /// Query a specific attribute in the list.
  1268.     const XMLAttribute* FindAttribute( const wchar_t* name ) const;
  1269.  
  1270.     /** Convenience function for easy access to the text inside an element. Although easy
  1271.         and concise, GetText() is limited compared to getting the TiXmlText child
  1272.         and accessing it directly.
  1273.  
  1274.         If the first child of 'this' is a TiXmlText, the GetText()
  1275.         returns the character string of the Text node, else null is returned.
  1276.  
  1277.         This is a convenient method for getting the text of simple contained text:
  1278.         @verbatim
  1279.         <foo>This is text</foo>
  1280.             const char* str = fooElement->GetText();
  1281.         @endverbatim
  1282.  
  1283.         'str' will be a pointer to "This is text".
  1284.  
  1285.         Note that this function can be misleading. If the element foo was created from
  1286.         this XML:
  1287.         @verbatim
  1288.             <foo><b>This is text</b></foo>
  1289.         @endverbatim
  1290.  
  1291.         then the value of str would be null. The first child node isn't a text node, it is
  1292.         another element. From this XML:
  1293.         @verbatim
  1294.             <foo>This is <b>text</b></foo>
  1295.         @endverbatim
  1296.         GetText() will return "This is ".
  1297.     */
  1298.     const wchar_t* GetText() const;
  1299.  
  1300.     /**
  1301.         Convenience method to query the value of a child text node. This is probably best
  1302.         shown by example. Given you have a document is this form:
  1303.         @verbatim
  1304.             <point>
  1305.                 <x>1</x>
  1306.                 <y>1.4</y>
  1307.             </point>
  1308.         @endverbatim
  1309.  
  1310.         The QueryIntText() and similar functions provide a safe and easier way to get to the
  1311.         "value" of x and y.
  1312.  
  1313.         @verbatim
  1314.             int x = 0;
  1315.             float y = 0;    // types of x and y are contrived for example
  1316.             const XMLElement* xElement = pointElement->FirstChildElement( "x" );
  1317.             const XMLElement* yElement = pointElement->FirstChildElement( "y" );
  1318.             xElement->QueryIntText( &x );
  1319.             yElement->QueryFloatText( &y );
  1320.         @endverbatim
  1321.  
  1322.         @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted
  1323.                  to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.
  1324.  
  1325.     */
  1326.     XMLError QueryIntText( int* ival ) const;
  1327.     /// See QueryIntText()
  1328.     XMLError QueryUnsignedText( unsigned* uval ) const;
  1329.     /// See QueryIntText()
  1330.     XMLError QueryBoolText( bool* bval ) const;
  1331.     /// See QueryIntText()
  1332.     XMLError QueryDoubleText( double* dval ) const;
  1333.     /// See QueryIntText()
  1334.     XMLError QueryFloatText( float* fval ) const;
  1335.  
  1336.     // internal:
  1337.     enum {
  1338.         OPEN,       // <foo>
  1339.         CLOSED,     // <foo/>
  1340.         CLOSING     // </foo>
  1341.     };
  1342.     int ClosingType() const {
  1343.         return _closingType;
  1344.     }
  1345.     wchar_t* ParseDeep( wchar_t* p, StrPair* endTag );
  1346.     virtual XMLNode* ShallowClone( TiXMLDocument* document ) const;
  1347.     virtual bool ShallowEqual( const XMLNode* compare ) const;
  1348.  
  1349. private:
  1350.     XMLElement( TiXMLDocument* doc );
  1351.     virtual ~XMLElement();
  1352.     XMLElement( const XMLElement& );    // not supported
  1353.     void operator=( const XMLElement& );    // not supported
  1354.  
  1355.     XMLAttribute* FindAttribute( const wchar_t* name );
  1356.     XMLAttribute* FindOrCreateAttribute( const wchar_t* name );
  1357.     //void LinkAttribute( XMLAttribute* attrib );
  1358.     wchar_t* ParseAttributes( wchar_t* p );
  1359.  
  1360.     int _closingType;
  1361.     // The attribute list is ordered; there is no 'lastAttribute'
  1362.     // because the list needs to be scanned for dupes before adding
  1363.     // a new attribute.
  1364.     XMLAttribute* _rootAttribute;
  1365. };
  1366.  
  1367.  
  1368. enum Whitespace {
  1369.     PRESERVE_WHITESPACE,
  1370.     COLLAPSE_WHITESPACE
  1371. };
  1372.  
  1373.  
  1374. /** A Document binds together all the functionality.
  1375.     It can be saved, loaded, and printed to the screen.
  1376.     All Nodes are connected and allocated to a Document.
  1377.     If the Document is deleted, all its Nodes are also deleted.
  1378. */
  1379. class TiXMLDocument : public XMLNode
  1380. {
  1381.     friend class XMLElement;
  1382. public:
  1383.     /// constructor
  1384.     TiXMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
  1385.     ~TiXMLDocument();
  1386.  
  1387.     virtual TiXMLDocument* ToDocument()             {
  1388.         return this;
  1389.     }
  1390.     virtual const TiXMLDocument* ToDocument() const {
  1391.         return this;
  1392.     }
  1393.  
  1394.     /**
  1395.         Parse an XML file from a character string.
  1396.         Returns XML_NO_ERROR (0) on success, or
  1397.         an errorID.
  1398.  
  1399.         You may optionally pass in the 'nBytes', which is
  1400.         the number of bytes which will be parsed. If not
  1401.         specified, TinyXML will assume 'xml' points to a
  1402.         null terminated string.
  1403.     */
  1404.     XMLError Parse( const wchar_t* xml, size_t nBytes=(size_t)(-1) );
  1405.  
  1406.     /**
  1407.         Load an XML file from disk.
  1408.         Returns XML_NO_ERROR (0) on success, or
  1409.         an errorID.
  1410.     */
  1411.     XMLError LoadFile( const wchar_t* filename );
  1412.  
  1413.     /**
  1414.         Load an XML file from disk. You are responsible
  1415.         for providing and closing the FILE*.
  1416.  
  1417.         Returns XML_NO_ERROR (0) on success, or
  1418.         an errorID.
  1419.     */
  1420.     XMLError LoadFile( FILE* );
  1421.  
  1422.     /**
  1423.         Save the XML file to disk.
  1424.         Returns XML_NO_ERROR (0) on success, or
  1425.         an errorID.
  1426.     */
  1427.     XMLError SaveFile( const wchar_t* filename, bool compact = false );
  1428.  
  1429.     /**
  1430.         Save the XML file to disk. You are responsible
  1431.         for providing and closing the FILE*.
  1432.  
  1433.         Returns XML_NO_ERROR (0) on success, or
  1434.         an errorID.
  1435.     */
  1436.     XMLError SaveFile( FILE* fp, bool compact = false );
  1437.  
  1438.     bool ProcessEntities() const        {
  1439.         return _processEntities;
  1440.     }
  1441.     Whitespace WhitespaceMode() const   {
  1442.         return _whitespace;
  1443.     }
  1444.  
  1445.     /**
  1446.         Returns true if this document has a leading Byte Order Mark of UTF8.
  1447.     */
  1448.     bool HasBOM() const {
  1449.         return _writeBOM;
  1450.     }
  1451.     /** Sets whether to write the BOM when writing the file.
  1452.     */
  1453.     void SetBOM( bool useBOM ) {
  1454.         _writeBOM = useBOM;
  1455.     }
  1456.  
  1457.     /** Return the root element of DOM. Equivalent to FirstChildElement().
  1458.         To get the first node, use FirstChild().
  1459.     */
  1460.     XMLElement* RootElement()               {
  1461.         return FirstChildElement();
  1462.     }
  1463.     const XMLElement* RootElement() const   {
  1464.         return FirstChildElement();
  1465.     }
  1466.  
  1467.     /** Print the Document. If the Printer is not provided, it will
  1468.         print to stdout. If you provide Printer, this can print to a file:
  1469.         @verbatim
  1470.         XMLPrinter printer( fp );
  1471.         doc.Print( &printer );
  1472.         @endverbatim
  1473.  
  1474.         Or you can use a printer to print to memory:
  1475.         @verbatim
  1476.         XMLPrinter printer;
  1477.         doc->Print( &printer );
  1478.         // printer.CStr() has a const char* to the XML
  1479.         @endverbatim
  1480.     */
  1481.     void Print( XMLPrinter* streamer=0 );
  1482.     virtual bool Accept( XMLVisitor* visitor ) const;
  1483.  
  1484.     /**
  1485.         Create a new Element associated with
  1486.         this Document. The memory for the Element
  1487.         is managed by the Document.
  1488.     */
  1489.     XMLElement* NewElement( const wchar_t* name );
  1490.     /**
  1491.         Create a new Comment associated with
  1492.         this Document. The memory for the Comment
  1493.         is managed by the Document.
  1494.     */
  1495.     XMLComment* NewComment( const wchar_t* comment );
  1496.     /**
  1497.         Create a new Text associated with
  1498.         this Document. The memory for the Text
  1499.         is managed by the Document.
  1500.     */
  1501.     XMLText* NewText( const wchar_t* text );
  1502.     /**
  1503.         Create a new Declaration associated with
  1504.         this Document. The memory for the object
  1505.         is managed by the Document.
  1506.  
  1507.         If the 'text' param is null, the standard
  1508.         declaration is used.:
  1509.         @verbatim
  1510.             <?xml version="1.0" encoding="UTF-8"?>
  1511.         @endverbatim
  1512.     */
  1513.     XMLDeclaration* NewDeclaration( const wchar_t* text=0 );
  1514.     /**
  1515.         Create a new Unknown associated with
  1516.         this Document. The memory forthe object
  1517.         is managed by the Document.
  1518.     */
  1519.     XMLUnknown* NewUnknown( const wchar_t* text );
  1520.  
  1521.     /**
  1522.         Delete a node associated with this document.
  1523.         It will be unlinked from the DOM.
  1524.     */
  1525.     void DeleteNode( XMLNode* node )    {
  1526.         node->_parent->DeleteChild( node );
  1527.     }
  1528.  
  1529.     void SetError( XMLError error, const wchar_t* str1, const wchar_t* str2 );
  1530.  
  1531.     /// Return true if there was an error parsing the document.
  1532.     bool Error() const {
  1533.         return _errorID != XML_NO_ERROR;
  1534.     }
  1535.     /// Return the errorID.
  1536.     XMLError  ErrorID() const {
  1537.         return _errorID;
  1538.     }
  1539.     /// Return a possibly helpful diagnostic location or string.
  1540.     const wchar_t* GetErrorStr1() const {
  1541.         return _errorStr1;
  1542.     }
  1543.     /// Return a possibly helpful secondary diagnostic location or string.
  1544.     const wchar_t* GetErrorStr2() const {
  1545.         return _errorStr2;
  1546.     }
  1547.     /// If there is an error, print it to stdout.
  1548.     void PrintError() const;
  1549.  
  1550.     // internal
  1551.     wchar_t* Identify( wchar_t* p, XMLNode** node );
  1552.  
  1553.     virtual XMLNode* ShallowClone( TiXMLDocument* /*document*/ ) const  {
  1554.         return 0;
  1555.     }
  1556.     virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const   {
  1557.         return false;
  1558.     }
  1559.  
  1560. private:
  1561.     TiXMLDocument( const TiXMLDocument& );  // not supported
  1562.     void operator=( const TiXMLDocument& ); // not supported
  1563.     void InitDocument();
  1564.  
  1565.     bool        _writeBOM;
  1566.     bool        _processEntities;
  1567.     XMLError    _errorID;
  1568.     Whitespace  _whitespace;
  1569.     const wchar_t* _errorStr1;
  1570.     const wchar_t* _errorStr2;
  1571.     wchar_t*       _charBuffer;
  1572.  
  1573.     MemPoolT< sizeof(XMLElement) >   _elementPool;
  1574.     MemPoolT< sizeof(XMLAttribute) > _attributePool;
  1575.     MemPoolT< sizeof(XMLText) >      _textPool;
  1576.     MemPoolT< sizeof(XMLComment) >   _commentPool;
  1577. };
  1578.  
  1579.  
  1580. /**
  1581.     A XMLHandle is a class that wraps a node pointer with null checks; this is
  1582.     an incredibly useful thing. Note that XMLHandle is not part of the TinyXML
  1583.     DOM structure. It is a separate utility class.
  1584.  
  1585.     Take an example:
  1586.     @verbatim
  1587.     <Document>
  1588.         <Element attributeA = "valueA">
  1589.             <Child attributeB = "value1" />
  1590.             <Child attributeB = "value2" />
  1591.         </Element>
  1592.     </Document>
  1593.     @endverbatim
  1594.  
  1595.     Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
  1596.     easy to write a *lot* of code that looks like:
  1597.  
  1598.     @verbatim
  1599.     XMLElement* root = document.FirstChildElement( "Document" );
  1600.     if ( root )
  1601.     {
  1602.         XMLElement* element = root->FirstChildElement( "Element" );
  1603.         if ( element )
  1604.         {
  1605.             XMLElement* child = element->FirstChildElement( "Child" );
  1606.             if ( child )
  1607.             {
  1608.                 XMLElement* child2 = child->NextSiblingElement( "Child" );
  1609.                 if ( child2 )
  1610.                 {
  1611.                     // Finally do something useful.
  1612.     @endverbatim
  1613.  
  1614.     And that doesn't even cover "else" cases. XMLHandle addresses the verbosity
  1615.     of such code. A XMLHandle checks for null pointers so it is perfectly safe
  1616.     and correct to use:
  1617.  
  1618.     @verbatim
  1619.     XMLHandle docHandle( &document );
  1620.     XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
  1621.     if ( child2 )
  1622.     {
  1623.         // do something useful
  1624.     @endverbatim
  1625.  
  1626.     Which is MUCH more concise and useful.
  1627.  
  1628.     It is also safe to copy handles - internally they are nothing more than node pointers.
  1629.     @verbatim
  1630.     XMLHandle handleCopy = handle;
  1631.     @endverbatim
  1632.  
  1633.     See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
  1634. */
  1635. class XMLHandle
  1636. {
  1637. public:
  1638.     /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
  1639.     XMLHandle( XMLNode* node )                                              {
  1640.         _node = node;
  1641.     }
  1642.     /// Create a handle from a node.
  1643.     XMLHandle( XMLNode& node )                                              {
  1644.         _node = &node;
  1645.     }
  1646.     /// Copy constructor
  1647.     XMLHandle( const XMLHandle& ref )                                       {
  1648.         _node = ref._node;
  1649.     }
  1650.     /// Assignment
  1651.     XMLHandle& operator=( const XMLHandle& ref )                            {
  1652.         _node = ref._node;
  1653.         return *this;
  1654.     }
  1655.  
  1656.     /// Get the first child of this handle.
  1657.     XMLHandle FirstChild()                                                  {
  1658.         return XMLHandle( _node ? _node->FirstChild() : 0 );
  1659.     }
  1660.     /// Get the first child element of this handle.
  1661.     XMLHandle FirstChildElement( const wchar_t* value=0 )                       {
  1662.         return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
  1663.     }
  1664.     /// Get the last child of this handle.
  1665.     XMLHandle LastChild()                                                   {
  1666.         return XMLHandle( _node ? _node->LastChild() : 0 );
  1667.     }
  1668.     /// Get the last child element of this handle.
  1669.     XMLHandle LastChildElement( const wchar_t* _value=0 )                       {
  1670.         return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
  1671.     }
  1672.     /// Get the previous sibling of this handle.
  1673.     XMLHandle PreviousSibling()                                             {
  1674.         return XMLHandle( _node ? _node->PreviousSibling() : 0 );
  1675.     }
  1676.     /// Get the previous sibling element of this handle.
  1677.     XMLHandle PreviousSiblingElement( const wchar_t* _value=0 )             {
  1678.         return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
  1679.     }
  1680.     /// Get the next sibling of this handle.
  1681.     XMLHandle NextSibling()                                                 {
  1682.         return XMLHandle( _node ? _node->NextSibling() : 0 );
  1683.     }
  1684.     /// Get the next sibling element of this handle.
  1685.     XMLHandle NextSiblingElement( const wchar_t* _value=0 )                 {
  1686.         return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
  1687.     }
  1688.  
  1689.     /// Safe cast to XMLNode. This can return null.
  1690.     XMLNode* ToNode()                           {
  1691.         return _node;
  1692.     }
  1693.     /// Safe cast to XMLElement. This can return null.
  1694.     XMLElement* ToElement()                     {
  1695.         return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
  1696.     }
  1697.     /// Safe cast to XMLText. This can return null.
  1698.     XMLText* ToText()                           {
  1699.         return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
  1700.     }
  1701.     /// Safe cast to XMLUnknown. This can return null.
  1702.     XMLUnknown* ToUnknown()                     {
  1703.         return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
  1704.     }
  1705.     /// Safe cast to XMLDeclaration. This can return null.
  1706.     XMLDeclaration* ToDeclaration()             {
  1707.         return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
  1708.     }
  1709.  
  1710. private:
  1711.     XMLNode* _node;
  1712. };
  1713.  
  1714.  
  1715. /**
  1716.     A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the
  1717.     same in all regards, except for the 'const' qualifiers. See XMLHandle for API.
  1718. */
  1719. class XMLConstHandle
  1720. {
  1721. public:
  1722.     XMLConstHandle( const XMLNode* node )                                           {
  1723.         _node = node;
  1724.     }
  1725.     XMLConstHandle( const XMLNode& node )                                           {
  1726.         _node = &node;
  1727.     }
  1728.     XMLConstHandle( const XMLConstHandle& ref )                                     {
  1729.         _node = ref._node;
  1730.     }
  1731.  
  1732.     XMLConstHandle& operator=( const XMLConstHandle& ref )                          {
  1733.         _node = ref._node;
  1734.         return *this;
  1735.     }
  1736.  
  1737.     const XMLConstHandle FirstChild() const                                         {
  1738.         return XMLConstHandle( _node ? _node->FirstChild() : 0 );
  1739.     }
  1740.     const XMLConstHandle FirstChildElement( const wchar_t* value=0 ) const              {
  1741.         return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
  1742.     }
  1743.     const XMLConstHandle LastChild()    const                                       {
  1744.         return XMLConstHandle( _node ? _node->LastChild() : 0 );
  1745.     }
  1746.     const XMLConstHandle LastChildElement( const wchar_t* _value=0 ) const              {
  1747.         return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
  1748.     }
  1749.     const XMLConstHandle PreviousSibling() const                                    {
  1750.         return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
  1751.     }
  1752.     const XMLConstHandle PreviousSiblingElement( const wchar_t* _value=0 ) const        {
  1753.         return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
  1754.     }
  1755.     const XMLConstHandle NextSibling() const                                        {
  1756.         return XMLConstHandle( _node ? _node->NextSibling() : 0 );
  1757.     }
  1758.     const XMLConstHandle NextSiblingElement( const wchar_t* _value=0 ) const            {
  1759.         return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
  1760.     }
  1761.  
  1762.  
  1763.     const XMLNode* ToNode() const               {
  1764.         return _node;
  1765.     }
  1766.     const XMLElement* ToElement() const         {
  1767.         return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
  1768.     }
  1769.     const XMLText* ToText() const               {
  1770.         return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
  1771.     }
  1772.     const XMLUnknown* ToUnknown() const         {
  1773.         return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
  1774.     }
  1775.     const XMLDeclaration* ToDeclaration() const {
  1776.         return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
  1777.     }
  1778.  
  1779. private:
  1780.     const XMLNode* _node;
  1781. };
  1782.  
  1783.  
  1784. /**
  1785.     Printing functionality. The XMLPrinter gives you more
  1786.     options than the TiXMLDocument::Print() method.
  1787.  
  1788.     It can:
  1789.     -# Print to memory.
  1790.     -# Print to a file you provide.
  1791.     -# Print XML without a TiXMLDocument.
  1792.  
  1793.     Print to Memory
  1794.  
  1795.     @verbatim
  1796.     XMLPrinter printer;
  1797.     doc->Print( &printer );
  1798.     SomeFunction( printer.CStr() );
  1799.     @endverbatim
  1800.  
  1801.     Print to a File
  1802.  
  1803.     You provide the file pointer.
  1804.     @verbatim
  1805.     XMLPrinter printer( fp );
  1806.     doc.Print( &printer );
  1807.     @endverbatim
  1808.  
  1809.     Print without a TiXMLDocument
  1810.  
  1811.     When loading, an XML parser is very useful. However, sometimes
  1812.     when saving, it just gets in the way. The code is often set up
  1813.     for streaming, and constructing the DOM is just overhead.
  1814.  
  1815.     The Printer supports the streaming case. The following code
  1816.     prints out a trivially simple XML file without ever creating
  1817.     an XML document.
  1818.  
  1819.     @verbatim
  1820.     XMLPrinter printer( fp );
  1821.     printer.OpenElement( "foo" );
  1822.     printer.PushAttribute( "foo", "bar" );
  1823.     printer.CloseElement();
  1824.     @endverbatim
  1825. */
  1826. class XMLPrinter : public XMLVisitor
  1827. {
  1828. public:
  1829.     /** Construct the printer. If the FILE* is specified,
  1830.         this will print to the FILE. Else it will print
  1831.         to memory, and the result is available in CStr().
  1832.         If 'compact' is set to true, then output is created
  1833.         with only required whitespace and newlines.
  1834.     */
  1835.     XMLPrinter( FILE* file=0, bool compact = false );
  1836.     ~XMLPrinter()   {}
  1837.  
  1838.     /** If streaming, write the BOM and declaration. */
  1839.     void PushHeader( bool writeBOM, bool writeDeclaration );
  1840.     /** If streaming, start writing an element.
  1841.         The element must be closed with CloseElement()
  1842.     */
  1843.     void OpenElement( const wchar_t* name );
  1844.     /// If streaming, add an attribute to an open element.
  1845.     void PushAttribute( const wchar_t* name, const wchar_t* value );
  1846.     void PushAttribute( const wchar_t* name, int value );
  1847.     void PushAttribute( const wchar_t* name, unsigned value );
  1848.     void PushAttribute( const wchar_t* name, bool value );
  1849.     void PushAttribute( const wchar_t* name, double value );
  1850.     /// If streaming, close the Element.
  1851.     void CloseElement();
  1852.  
  1853.     /// Add a text node.
  1854.     void PushText( const wchar_t* text, bool cdata=false );
  1855.     /// Add a text node from an integer.
  1856.     void PushText( int value );
  1857.     /// Add a text node from an unsigned.
  1858.     void PushText( unsigned value );
  1859.     /// Add a text node from a bool.
  1860.     void PushText( bool value );
  1861.     /// Add a text node from a float.
  1862.     void PushText( float value );
  1863.     /// Add a text node from a double.
  1864.     void PushText( double value );
  1865.  
  1866.     /// Add a comment
  1867.     void PushComment( const wchar_t* comment );
  1868.  
  1869.     void PushDeclaration( const wchar_t* value );
  1870.     void PushUnknown( const wchar_t* value );
  1871.  
  1872.     virtual bool VisitEnter( const TiXMLDocument& /*doc*/ );
  1873.     virtual bool VisitExit( const TiXMLDocument& /*doc*/ )          {
  1874.         return true;
  1875.     }
  1876.  
  1877.     virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
  1878.     virtual bool VisitExit( const XMLElement& element );
  1879.  
  1880.     virtual bool Visit( const XMLText& text );
  1881.     virtual bool Visit( const XMLComment& comment );
  1882.     virtual bool Visit( const XMLDeclaration& declaration );
  1883.     virtual bool Visit( const XMLUnknown& unknown );
  1884.  
  1885.     /**
  1886.         If in print to memory mode, return a pointer to
  1887.         the XML file in memory.
  1888.     */
  1889.     const wchar_t* CStr() const {
  1890.         return _buffer.Mem();
  1891.     }
  1892.     /**
  1893.         If in print to memory mode, return the size
  1894.         of the XML file in memory. (Note the size returned
  1895.         includes the terminating null.)
  1896.     */
  1897.     int CStrSize() const {
  1898.         return _buffer.Size();
  1899.     }
  1900.  
  1901. private:
  1902.     void SealElement();
  1903.     void PrintSpace( int depth );
  1904.     void PrintString( const wchar_t*, bool restrictedEntitySet );   // prints out, after detecting entities.
  1905.     void Print( const wchar_t* format, ... );
  1906.  
  1907.     bool _elementJustOpened;
  1908.     bool _firstElement;
  1909.     FILE* _fp;
  1910.     int _depth;
  1911.     int _textDepth;
  1912.     bool _processEntities;
  1913.     bool _compactMode;
  1914.  
  1915.     enum {
  1916.         ENTITY_RANGE = 64,
  1917.         BUF_SIZE = 200
  1918.     };
  1919.     bool _entityFlag[ENTITY_RANGE];
  1920.     bool _restrictedEntityFlag[ENTITY_RANGE];
  1921.  
  1922.     DynArray< const wchar_t*, 10 > _stack;
  1923.     DynArray< wchar_t, 20 > _buffer;
  1924. #ifdef _MSC_VER
  1925.     DynArray< wchar_t, 20 > _accumulator;
  1926. #endif
  1927. };
  1928.  
  1929.  
  1930. }   // tinyxml2
  1931.  
  1932.  
  1933. #endif // TINYXML2_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement