tinyxml2.h
Go to the documentation of this file.
1 /*
2 Original code by Lee Thomason (www.grinninglizard.com)
3 
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any
6 damages arising from the use of this software.
7 
8 Permission is granted to anyone to use this software for any
9 purpose, including commercial applications, and to alter it and
10 redistribute it freely, subject to the following restrictions:
11 
12 1. The origin of this software must not be misrepresented; you must
13 not claim that you wrote the original software. If you use this
14 software in a product, an acknowledgment in the product documentation
15 would be appreciated but is not required.
16 
17 2. Altered source versions must be plainly marked as such, and
18 must not be misrepresented as being the original software.
19 
20 3. This notice may not be removed or altered from any source
21 distribution.
22 */
23 
24 #ifndef TINYXML2_INCLUDED
25 #define TINYXML2_INCLUDED
26 
27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
28 # include <ctype.h>
29 # include <limits.h>
30 # include <stdio.h>
31 # include <stdlib.h>
32 # include <string.h>
33 # if defined(__PS3__)
34 # include <stddef.h>
35 # endif
36 #else
37 # include <cctype>
38 # include <climits>
39 # include <cstdio>
40 # include <cstdlib>
41 # include <cstring>
42 #endif
43 #include <stdint.h>
44 
45 /*
46  TODO: intern strings instead of allocation.
47 */
48 /*
49  gcc:
50  g++ -Wall -DTINYXML2_DEBUG 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__)
57 # ifndef TINYXML2_DEBUG
58 # define TINYXML2_DEBUG
59 # endif
60 #endif
61 
62 #ifdef _MSC_VER
63 # pragma warning(push)
64 # pragma warning(disable: 4251)
65 #endif
66 
67 #ifdef _WIN32
68 # ifdef TINYXML2_EXPORT
69 # define TINYXML2_LIB __declspec(dllexport)
70 # elif defined(TINYXML2_IMPORT)
71 # define TINYXML2_LIB __declspec(dllimport)
72 # else
73 # define TINYXML2_LIB
74 # endif
75 #elif __GNUC__ >= 4
76 # define TINYXML2_LIB __attribute__((visibility("default")))
77 #else
78 # define TINYXML2_LIB
79 #endif
80 
81 
82 #if !defined(TIXMLASSERT)
83 #if defined(TINYXML2_DEBUG)
84 # if defined(_MSC_VER)
85 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
86 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
87 # elif defined (ANDROID_NDK)
88 # include <android/log.h>
89 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
90 # else
91 # include <assert.h>
92 # define TIXMLASSERT assert
93 # endif
94 #else
95 # define TIXMLASSERT( x ) {}
96 #endif
97 #endif
98 
99 /* Versioning, past 1.0.14:
100  http://semver.org/
101 */
102 static const int TIXML2_MAJOR_VERSION = 9;
103 static const int TIXML2_MINOR_VERSION = 0;
104 static const int TIXML2_PATCH_VERSION = 0;
105 
106 #define TINYXML2_MAJOR_VERSION 9
107 #define TINYXML2_MINOR_VERSION 0
108 #define TINYXML2_PATCH_VERSION 0
109 
110 // A fixed element depth limit is problematic. There needs to be a
111 // limit to avoid a stack overflow. However, that limit varies per
112 // system, and the capacity of the stack. On the other hand, it's a trivial
113 // attack that can result from ill, malicious, or even correctly formed XML,
114 // so there needs to be a limit in place.
115 static const int TINYXML2_MAX_ELEMENT_DEPTH = 100;
116 
117 namespace tinyxml2
118 {
119 class XMLDocument;
120 class XMLElement;
121 class XMLAttribute;
122 class XMLComment;
123 class XMLText;
124 class XMLDeclaration;
125 class XMLUnknown;
126 class XMLPrinter;
127 
128 /*
129  A class that wraps strings. Normally stores the start and end
130  pointers into the XML file itself, and will apply normalization
131  and entity translation if actually read. Can also store (and memory
132  manage) a traditional char[]
133 
134  Isn't clear why TINYXML2_LIB is needed; but seems to fix #719
135 */
137 {
138 public:
139  enum Mode {
140  NEEDS_ENTITY_PROCESSING = 0x01,
141  NEEDS_NEWLINE_NORMALIZATION = 0x02,
142  NEEDS_WHITESPACE_COLLAPSING = 0x04,
143 
144  TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
145  TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
146  ATTRIBUTE_NAME = 0,
147  ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
148  ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
149  COMMENT = NEEDS_NEWLINE_NORMALIZATION
150  };
151 
152  StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
153  ~StrPair();
154 
155  void Set( char* start, char* end, int flags ) {
156  TIXMLASSERT( start );
157  TIXMLASSERT( end );
158  Reset();
159  _start = start;
160  _end = end;
161  _flags = flags | NEEDS_FLUSH;
162  }
163 
164  const char* GetStr();
165 
166  bool Empty() const {
167  return _start == _end;
168  }
169 
170  void SetInternedStr( const char* str ) {
171  Reset();
172  _start = const_cast<char*>(str);
173  }
174 
175  void SetStr( const char* str, int flags=0 );
176 
177  char* ParseText( char* in, const char* endTag, int strFlags, int* curLineNumPtr );
178  char* ParseName( char* in );
179 
180  void TransferTo( StrPair* other );
181  void Reset();
182 
183 private:
184  void CollapseWhitespace();
185 
186  enum {
187  NEEDS_FLUSH = 0x100,
188  NEEDS_DELETE = 0x200
189  };
190 
191  int _flags;
192  char* _start;
193  char* _end;
194 
195  StrPair( const StrPair& other ); // not supported
196  void operator=( const StrPair& other ); // not supported, use TransferTo()
197 };
198 
199 
200 /*
201  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
202  Has a small initial memory pool, so that low or no usage will not
203  cause a call to new/delete
204 */
205 template <class T, int INITIAL_SIZE>
206 class DynArray
207 {
208 public:
210  _mem( _pool ),
211  _allocated( INITIAL_SIZE ),
212  _size( 0 )
213  {
214  }
215 
217  if ( _mem != _pool ) {
218  delete [] _mem;
219  }
220  }
221 
222  void Clear() {
223  _size = 0;
224  }
225 
226  void Push( T t ) {
227  TIXMLASSERT( _size < INT_MAX );
228  EnsureCapacity( _size+1 );
229  _mem[_size] = t;
230  ++_size;
231  }
232 
233  T* PushArr( int count ) {
234  TIXMLASSERT( count >= 0 );
235  TIXMLASSERT( _size <= INT_MAX - count );
237  T* ret = &_mem[_size];
238  _size += count;
239  return ret;
240  }
241 
242  T Pop() {
243  TIXMLASSERT( _size > 0 );
244  --_size;
245  return _mem[_size];
246  }
247 
248  void PopArr( int count ) {
249  TIXMLASSERT( _size >= count );
250  _size -= count;
251  }
252 
253  bool Empty() const {
254  return _size == 0;
255  }
256 
257  T& operator[](int i) {
258  TIXMLASSERT( i>= 0 && i < _size );
259  return _mem[i];
260  }
261 
262  const T& operator[](int i) const {
263  TIXMLASSERT( i>= 0 && i < _size );
264  return _mem[i];
265  }
266 
267  const T& PeekTop() const {
268  TIXMLASSERT( _size > 0 );
269  return _mem[ _size - 1];
270  }
271 
272  int Size() const {
273  TIXMLASSERT( _size >= 0 );
274  return _size;
275  }
276 
277  int Capacity() const {
278  TIXMLASSERT( _allocated >= INITIAL_SIZE );
279  return _allocated;
280  }
281 
282  void SwapRemove(int i) {
283  TIXMLASSERT(i >= 0 && i < _size);
284  TIXMLASSERT(_size > 0);
285  _mem[i] = _mem[_size - 1];
286  --_size;
287  }
288 
289  const T* Mem() const {
290  TIXMLASSERT( _mem );
291  return _mem;
292  }
293 
294  T* Mem() {
295  TIXMLASSERT( _mem );
296  return _mem;
297  }
298 
299 private:
300  DynArray( const DynArray& ); // not supported
301  void operator=( const DynArray& ); // not supported
302 
303  void EnsureCapacity( int cap ) {
304  TIXMLASSERT( cap > 0 );
305  if ( cap > _allocated ) {
306  TIXMLASSERT( cap <= INT_MAX / 2 );
307  const int newAllocated = cap * 2;
308  T* newMem = new T[newAllocated];
309  TIXMLASSERT( newAllocated >= _size );
310  memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
311  if ( _mem != _pool ) {
312  delete [] _mem;
313  }
314  _mem = newMem;
315  _allocated = newAllocated;
316  }
317  }
318 
319  T* _mem;
320  T _pool[INITIAL_SIZE];
321  int _allocated; // objects allocated
322  int _size; // number objects in use
323 };
324 
325 
326 /*
327  Parent virtual class of a pool for fast allocation
328  and deallocation of objects.
329 */
330 class MemPool
331 {
332 public:
333  MemPool() {}
334  virtual ~MemPool() {}
335 
336  virtual int ItemSize() const = 0;
337  virtual void* Alloc() = 0;
338  virtual void Free( void* ) = 0;
339  virtual void SetTracked() = 0;
340 };
341 
342 
343 /*
344  Template child class to create pools of the correct type.
345 */
346 template< int ITEM_SIZE >
347 class MemPoolT : public MemPool
348 {
349 public:
353  }
354 
355  void Clear() {
356  // Delete the blocks.
357  while( !_blockPtrs.Empty()) {
358  Block* lastBlock = _blockPtrs.Pop();
359  delete lastBlock;
360  }
361  _root = 0;
362  _currentAllocs = 0;
363  _nAllocs = 0;
364  _maxAllocs = 0;
365  _nUntracked = 0;
366  }
367 
368  virtual int ItemSize() const {
369  return ITEM_SIZE;
370  }
371  int CurrentAllocs() const {
372  return _currentAllocs;
373  }
374 
375  virtual void* Alloc() {
376  if ( !_root ) {
377  // Need a new block.
378  Block* block = new Block();
379  _blockPtrs.Push( block );
380 
381  Item* blockItems = block->items;
382  for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
383  blockItems[i].next = &(blockItems[i + 1]);
384  }
385  blockItems[ITEMS_PER_BLOCK - 1].next = 0;
386  _root = blockItems;
387  }
388  Item* const result = _root;
389  TIXMLASSERT( result != 0 );
390  _root = _root->next;
391 
392  ++_currentAllocs;
393  if ( _currentAllocs > _maxAllocs ) {
395  }
396  ++_nAllocs;
397  ++_nUntracked;
398  return result;
399  }
400 
401  virtual void Free( void* mem ) {
402  if ( !mem ) {
403  return;
404  }
405  --_currentAllocs;
406  Item* item = static_cast<Item*>( mem );
407 #ifdef TINYXML2_DEBUG
408  memset( item, 0xfe, sizeof( *item ) );
409 #endif
410  item->next = _root;
411  _root = item;
412  }
413  void Trace( const char* name ) {
414  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
415  name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
416  ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
417  }
418 
419  void SetTracked() {
420  --_nUntracked;
421  }
422 
423  int Untracked() const {
424  return _nUntracked;
425  }
426 
427  // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
428  // The test file is large, 170k.
429  // Release: VS2010 gcc(no opt)
430  // 1k: 4000
431  // 2k: 4000
432  // 4k: 3900 21000
433  // 16k: 5200
434  // 32k: 4300
435  // 64k: 4000 21000
436  // Declared public because some compilers do not accept to use ITEMS_PER_BLOCK
437  // in private part if ITEMS_PER_BLOCK is private
438  enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
439 
440 private:
441  MemPoolT( const MemPoolT& ); // not supported
442  void operator=( const MemPoolT& ); // not supported
443 
444  union Item {
446  char itemData[ITEM_SIZE];
447  };
448  struct Block {
450  };
452  Item* _root;
453 
455  int _nAllocs;
458 };
459 
460 
461 
482 {
483 public:
484  virtual ~XMLVisitor() {}
485 
487  virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
488  return true;
489  }
491  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
492  return true;
493  }
494 
496  virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
497  return true;
498  }
500  virtual bool VisitExit( const XMLElement& /*element*/ ) {
501  return true;
502  }
503 
505  virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
506  return true;
507  }
509  virtual bool Visit( const XMLText& /*text*/ ) {
510  return true;
511  }
513  virtual bool Visit( const XMLComment& /*comment*/ ) {
514  return true;
515  }
517  virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
518  return true;
519  }
520 };
521 
522 // WARNING: must match XMLDocument::_errorNames[]
523 enum XMLError {
543 
545 };
546 
547 
548 /*
549  Utility functionality.
550 */
552 {
553 public:
554  static const char* SkipWhiteSpace( const char* p, int* curLineNumPtr ) {
555  TIXMLASSERT( p );
556 
557  while( IsWhiteSpace(*p) ) {
558  if (curLineNumPtr && *p == '\n') {
559  ++(*curLineNumPtr);
560  }
561  ++p;
562  }
563  TIXMLASSERT( p );
564  return p;
565  }
566  static char* SkipWhiteSpace( char* const p, int* curLineNumPtr ) {
567  return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p), curLineNumPtr ) );
568  }
569 
570  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
571  // correct, but simple, and usually works.
572  static bool IsWhiteSpace( char p ) {
573  return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
574  }
575 
576  inline static bool IsNameStartChar( unsigned char ch ) {
577  if ( ch >= 128 ) {
578  // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
579  return true;
580  }
581  if ( isalpha( ch ) ) {
582  return true;
583  }
584  return ch == ':' || ch == '_';
585  }
586 
587  inline static bool IsNameChar( unsigned char ch ) {
588  return IsNameStartChar( ch )
589  || isdigit( ch )
590  || ch == '.'
591  || ch == '-';
592  }
593 
594  inline static bool IsPrefixHex( const char* p) {
595  p = SkipWhiteSpace(p, 0);
596  return p && *p == '0' && ( *(p + 1) == 'x' || *(p + 1) == 'X');
597  }
598 
599  inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
600  if ( p == q ) {
601  return true;
602  }
603  TIXMLASSERT( p );
604  TIXMLASSERT( q );
605  TIXMLASSERT( nChar >= 0 );
606  return strncmp( p, q, nChar ) == 0;
607  }
608 
609  inline static bool IsUTF8Continuation( const char p ) {
610  return ( p & 0x80 ) != 0;
611  }
612 
613  static const char* ReadBOM( const char* p, bool* hasBOM );
614  // p is the starting location,
615  // the UTF-8 value of the entity will be placed in value, and length filled in.
616  static const char* GetCharacterRef( const char* p, char* value, int* length );
617  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
618 
619  // converts primitive types to strings
620  static void ToStr( int v, char* buffer, int bufferSize );
621  static void ToStr( unsigned v, char* buffer, int bufferSize );
622  static void ToStr( bool v, char* buffer, int bufferSize );
623  static void ToStr( float v, char* buffer, int bufferSize );
624  static void ToStr( double v, char* buffer, int bufferSize );
625  static void ToStr(int64_t v, char* buffer, int bufferSize);
626  static void ToStr(uint64_t v, char* buffer, int bufferSize);
627 
628  // converts strings to primitive types
629  static bool ToInt( const char* str, int* value );
630  static bool ToUnsigned( const char* str, unsigned* value );
631  static bool ToBool( const char* str, bool* value );
632  static bool ToFloat( const char* str, float* value );
633  static bool ToDouble( const char* str, double* value );
634  static bool ToInt64(const char* str, int64_t* value);
635  static bool ToUnsigned64(const char* str, uint64_t* value);
636  // Changes what is serialized for a boolean value.
637  // Default to "true" and "false". Shouldn't be changed
638  // unless you have a special testing or compatibility need.
639  // Be careful: static, global, & not thread safe.
640  // Be sure to set static const memory as parameters.
641  static void SetBoolSerialization(const char* writeTrue, const char* writeFalse);
642 
643 private:
644  static const char* writeBoolTrue;
645  static const char* writeBoolFalse;
646 };
647 
648 
675 {
676  friend class XMLDocument;
677  friend class XMLElement;
678 public:
679 
681  const XMLDocument* GetDocument() const {
682  TIXMLASSERT( _document );
683  return _document;
684  }
687  TIXMLASSERT( _document );
688  return _document;
689  }
690 
692  virtual XMLElement* ToElement() {
693  return 0;
694  }
696  virtual XMLText* ToText() {
697  return 0;
698  }
700  virtual XMLComment* ToComment() {
701  return 0;
702  }
704  virtual XMLDocument* ToDocument() {
705  return 0;
706  }
709  return 0;
710  }
712  virtual XMLUnknown* ToUnknown() {
713  return 0;
714  }
715 
716  virtual const XMLElement* ToElement() const {
717  return 0;
718  }
719  virtual const XMLText* ToText() const {
720  return 0;
721  }
722  virtual const XMLComment* ToComment() const {
723  return 0;
724  }
725  virtual const XMLDocument* ToDocument() const {
726  return 0;
727  }
728  virtual const XMLDeclaration* ToDeclaration() const {
729  return 0;
730  }
731  virtual const XMLUnknown* ToUnknown() const {
732  return 0;
733  }
734 
744  const char* Value() const;
745 
749  void SetValue( const char* val, bool staticMem=false );
750 
752  int GetLineNum() const { return _parseLineNum; }
753 
755  const XMLNode* Parent() const {
756  return _parent;
757  }
758 
760  return _parent;
761  }
762 
764  bool NoChildren() const {
765  return !_firstChild;
766  }
767 
769  const XMLNode* FirstChild() const {
770  return _firstChild;
771  }
772 
774  return _firstChild;
775  }
776 
780  const XMLElement* FirstChildElement( const char* name = 0 ) const;
781 
782  XMLElement* FirstChildElement( const char* name = 0 ) {
783  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
784  }
785 
787  const XMLNode* LastChild() const {
788  return _lastChild;
789  }
790 
792  return _lastChild;
793  }
794 
798  const XMLElement* LastChildElement( const char* name = 0 ) const;
799 
800  XMLElement* LastChildElement( const char* name = 0 ) {
801  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
802  }
803 
805  const XMLNode* PreviousSibling() const {
806  return _prev;
807  }
808 
810  return _prev;
811  }
812 
814  const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
815 
816  XMLElement* PreviousSiblingElement( const char* name = 0 ) {
817  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
818  }
819 
821  const XMLNode* NextSibling() const {
822  return _next;
823  }
824 
826  return _next;
827  }
828 
830  const XMLElement* NextSiblingElement( const char* name = 0 ) const;
831 
832  XMLElement* NextSiblingElement( const char* name = 0 ) {
833  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
834  }
835 
843  XMLNode* InsertEndChild( XMLNode* addThis );
844 
845  XMLNode* LinkEndChild( XMLNode* addThis ) {
846  return InsertEndChild( addThis );
847  }
855  XMLNode* InsertFirstChild( XMLNode* addThis );
864  XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
865 
869  void DeleteChildren();
870 
874  void DeleteChild( XMLNode* node );
875 
885  virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
886 
900  XMLNode* DeepClone( XMLDocument* target ) const;
901 
908  virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
909 
932  virtual bool Accept( XMLVisitor* visitor ) const = 0;
933 
939  void SetUserData(void* userData) { _userData = userData; }
940 
946  void* GetUserData() const { return _userData; }
947 
948 protected:
949  explicit XMLNode( XMLDocument* );
950  virtual ~XMLNode();
951 
952  virtual char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr);
953 
956  mutable StrPair _value;
958 
961 
964 
965  void* _userData;
966 
967 private:
969  void Unlink( XMLNode* child );
970  static void DeleteNode( XMLNode* node );
971  void InsertChildPreamble( XMLNode* insertThis ) const;
972  const XMLElement* ToElementWithName( const char* name ) const;
973 
974  XMLNode( const XMLNode& ); // not supported
975  XMLNode& operator=( const XMLNode& ); // not supported
976 };
977 
978 
992 {
993  friend class XMLDocument;
994 public:
995  virtual bool Accept( XMLVisitor* visitor ) const;
996 
997  virtual XMLText* ToText() {
998  return this;
999  }
1000  virtual const XMLText* ToText() const {
1001  return this;
1002  }
1003 
1005  void SetCData( bool isCData ) {
1006  _isCData = isCData;
1007  }
1009  bool CData() const {
1010  return _isCData;
1011  }
1012 
1013  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1014  virtual bool ShallowEqual( const XMLNode* compare ) const;
1015 
1016 protected:
1017  explicit XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
1018  virtual ~XMLText() {}
1019 
1020  char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1021 
1022 private:
1023  bool _isCData;
1024 
1025  XMLText( const XMLText& ); // not supported
1026  XMLText& operator=( const XMLText& ); // not supported
1027 };
1028 
1029 
1032 {
1033  friend class XMLDocument;
1034 public:
1035  virtual XMLComment* ToComment() {
1036  return this;
1037  }
1038  virtual const XMLComment* ToComment() const {
1039  return this;
1040  }
1041 
1042  virtual bool Accept( XMLVisitor* visitor ) const;
1043 
1044  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1045  virtual bool ShallowEqual( const XMLNode* compare ) const;
1046 
1047 protected:
1048  explicit XMLComment( XMLDocument* doc );
1049  virtual ~XMLComment();
1050 
1051  char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr);
1052 
1053 private:
1054  XMLComment( const XMLComment& ); // not supported
1055  XMLComment& operator=( const XMLComment& ); // not supported
1056 };
1057 
1058 
1071 {
1072  friend class XMLDocument;
1073 public:
1075  return this;
1076  }
1077  virtual const XMLDeclaration* ToDeclaration() const {
1078  return this;
1079  }
1080 
1081  virtual bool Accept( XMLVisitor* visitor ) const;
1082 
1083  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1084  virtual bool ShallowEqual( const XMLNode* compare ) const;
1085 
1086 protected:
1087  explicit XMLDeclaration( XMLDocument* doc );
1088  virtual ~XMLDeclaration();
1089 
1090  char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1091 
1092 private:
1093  XMLDeclaration( const XMLDeclaration& ); // not supported
1094  XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
1095 };
1096 
1097 
1106 {
1107  friend class XMLDocument;
1108 public:
1109  virtual XMLUnknown* ToUnknown() {
1110  return this;
1111  }
1112  virtual const XMLUnknown* ToUnknown() const {
1113  return this;
1114  }
1115 
1116  virtual bool Accept( XMLVisitor* visitor ) const;
1117 
1118  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1119  virtual bool ShallowEqual( const XMLNode* compare ) const;
1120 
1121 protected:
1122  explicit XMLUnknown( XMLDocument* doc );
1123  virtual ~XMLUnknown();
1124 
1125  char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1126 
1127 private:
1128  XMLUnknown( const XMLUnknown& ); // not supported
1129  XMLUnknown& operator=( const XMLUnknown& ); // not supported
1130 };
1131 
1132 
1133 
1141 {
1142  friend class XMLElement;
1143 public:
1145  const char* Name() const;
1146 
1148  const char* Value() const;
1149 
1151  int GetLineNum() const { return _parseLineNum; }
1152 
1154  const XMLAttribute* Next() const {
1155  return _next;
1156  }
1157 
1162  int IntValue() const {
1163  int i = 0;
1164  QueryIntValue(&i);
1165  return i;
1166  }
1167 
1168  int64_t Int64Value() const {
1169  int64_t i = 0;
1170  QueryInt64Value(&i);
1171  return i;
1172  }
1173 
1174  uint64_t Unsigned64Value() const {
1175  uint64_t i = 0;
1176  QueryUnsigned64Value(&i);
1177  return i;
1178  }
1179 
1181  unsigned UnsignedValue() const {
1182  unsigned i=0;
1183  QueryUnsignedValue( &i );
1184  return i;
1185  }
1187  bool BoolValue() const {
1188  bool b=false;
1189  QueryBoolValue( &b );
1190  return b;
1191  }
1193  double DoubleValue() const {
1194  double d=0;
1195  QueryDoubleValue( &d );
1196  return d;
1197  }
1199  float FloatValue() const {
1200  float f=0;
1201  QueryFloatValue( &f );
1202  return f;
1203  }
1204 
1209  XMLError QueryIntValue( int* value ) const;
1211  XMLError QueryUnsignedValue( unsigned int* value ) const;
1213  XMLError QueryInt64Value(int64_t* value) const;
1215  XMLError QueryUnsigned64Value(uint64_t* value) const;
1217  XMLError QueryBoolValue( bool* value ) const;
1219  XMLError QueryDoubleValue( double* value ) const;
1221  XMLError QueryFloatValue( float* value ) const;
1222 
1224  void SetAttribute( const char* value );
1226  void SetAttribute( int value );
1228  void SetAttribute( unsigned value );
1230  void SetAttribute(int64_t value);
1232  void SetAttribute(uint64_t value);
1234  void SetAttribute( bool value );
1236  void SetAttribute( double value );
1238  void SetAttribute( float value );
1239 
1240 private:
1241  enum { BUF_SIZE = 200 };
1242 
1243  XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1244  virtual ~XMLAttribute() {}
1245 
1246  XMLAttribute( const XMLAttribute& ); // not supported
1247  void operator=( const XMLAttribute& ); // not supported
1248  void SetName( const char* name );
1249 
1250  char* ParseDeep( char* p, bool processEntities, int* curLineNumPtr );
1251 
1252  mutable StrPair _name;
1253  mutable StrPair _value;
1257 };
1258 
1259 
1265 {
1266  friend class XMLDocument;
1267 public:
1269  const char* Name() const {
1270  return Value();
1271  }
1273  void SetName( const char* str, bool staticMem=false ) {
1274  SetValue( str, staticMem );
1275  }
1276 
1277  virtual XMLElement* ToElement() {
1278  return this;
1279  }
1280  virtual const XMLElement* ToElement() const {
1281  return this;
1282  }
1283  virtual bool Accept( XMLVisitor* visitor ) const;
1284 
1308  const char* Attribute( const char* name, const char* value=0 ) const;
1309 
1316  int IntAttribute(const char* name, int defaultValue = 0) const;
1318  unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;
1320  int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
1322  uint64_t Unsigned64Attribute(const char* name, uint64_t defaultValue = 0) const;
1324  bool BoolAttribute(const char* name, bool defaultValue = false) const;
1326  double DoubleAttribute(const char* name, double defaultValue = 0) const;
1328  float FloatAttribute(const char* name, float defaultValue = 0) const;
1329 
1343  XMLError QueryIntAttribute( const char* name, int* value ) const {
1344  const XMLAttribute* a = FindAttribute( name );
1345  if ( !a ) {
1346  return XML_NO_ATTRIBUTE;
1347  }
1348  return a->QueryIntValue( value );
1349  }
1350 
1352  XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
1353  const XMLAttribute* a = FindAttribute( name );
1354  if ( !a ) {
1355  return XML_NO_ATTRIBUTE;
1356  }
1357  return a->QueryUnsignedValue( value );
1358  }
1359 
1361  XMLError QueryInt64Attribute(const char* name, int64_t* value) const {
1362  const XMLAttribute* a = FindAttribute(name);
1363  if (!a) {
1364  return XML_NO_ATTRIBUTE;
1365  }
1366  return a->QueryInt64Value(value);
1367  }
1368 
1370  XMLError QueryUnsigned64Attribute(const char* name, uint64_t* value) const {
1371  const XMLAttribute* a = FindAttribute(name);
1372  if(!a) {
1373  return XML_NO_ATTRIBUTE;
1374  }
1375  return a->QueryUnsigned64Value(value);
1376  }
1377 
1379  XMLError QueryBoolAttribute( const char* name, bool* value ) const {
1380  const XMLAttribute* a = FindAttribute( name );
1381  if ( !a ) {
1382  return XML_NO_ATTRIBUTE;
1383  }
1384  return a->QueryBoolValue( value );
1385  }
1387  XMLError QueryDoubleAttribute( const char* name, double* value ) const {
1388  const XMLAttribute* a = FindAttribute( name );
1389  if ( !a ) {
1390  return XML_NO_ATTRIBUTE;
1391  }
1392  return a->QueryDoubleValue( value );
1393  }
1395  XMLError QueryFloatAttribute( const char* name, float* value ) const {
1396  const XMLAttribute* a = FindAttribute( name );
1397  if ( !a ) {
1398  return XML_NO_ATTRIBUTE;
1399  }
1400  return a->QueryFloatValue( value );
1401  }
1402 
1404  XMLError QueryStringAttribute(const char* name, const char** value) const {
1405  const XMLAttribute* a = FindAttribute(name);
1406  if (!a) {
1407  return XML_NO_ATTRIBUTE;
1408  }
1409  *value = a->Value();
1410  return XML_SUCCESS;
1411  }
1412 
1413 
1414 
1432  XMLError QueryAttribute( const char* name, int* value ) const {
1433  return QueryIntAttribute( name, value );
1434  }
1435 
1436  XMLError QueryAttribute( const char* name, unsigned int* value ) const {
1437  return QueryUnsignedAttribute( name, value );
1438  }
1439 
1440  XMLError QueryAttribute(const char* name, int64_t* value) const {
1441  return QueryInt64Attribute(name, value);
1442  }
1443 
1444  XMLError QueryAttribute(const char* name, uint64_t* value) const {
1445  return QueryUnsigned64Attribute(name, value);
1446  }
1447 
1448  XMLError QueryAttribute( const char* name, bool* value ) const {
1449  return QueryBoolAttribute( name, value );
1450  }
1451 
1452  XMLError QueryAttribute( const char* name, double* value ) const {
1453  return QueryDoubleAttribute( name, value );
1454  }
1455 
1456  XMLError QueryAttribute( const char* name, float* value ) const {
1457  return QueryFloatAttribute( name, value );
1458  }
1459 
1460  XMLError QueryAttribute(const char* name, const char** value) const {
1461  return QueryStringAttribute(name, value);
1462  }
1463 
1465  void SetAttribute( const char* name, const char* value ) {
1466  XMLAttribute* a = FindOrCreateAttribute( name );
1467  a->SetAttribute( value );
1468  }
1470  void SetAttribute( const char* name, int value ) {
1471  XMLAttribute* a = FindOrCreateAttribute( name );
1472  a->SetAttribute( value );
1473  }
1475  void SetAttribute( const char* name, unsigned value ) {
1476  XMLAttribute* a = FindOrCreateAttribute( name );
1477  a->SetAttribute( value );
1478  }
1479 
1481  void SetAttribute(const char* name, int64_t value) {
1482  XMLAttribute* a = FindOrCreateAttribute(name);
1483  a->SetAttribute(value);
1484  }
1485 
1487  void SetAttribute(const char* name, uint64_t value) {
1488  XMLAttribute* a = FindOrCreateAttribute(name);
1489  a->SetAttribute(value);
1490  }
1491 
1493  void SetAttribute( const char* name, bool value ) {
1494  XMLAttribute* a = FindOrCreateAttribute( name );
1495  a->SetAttribute( value );
1496  }
1498  void SetAttribute( const char* name, double value ) {
1499  XMLAttribute* a = FindOrCreateAttribute( name );
1500  a->SetAttribute( value );
1501  }
1503  void SetAttribute( const char* name, float value ) {
1504  XMLAttribute* a = FindOrCreateAttribute( name );
1505  a->SetAttribute( value );
1506  }
1507 
1511  void DeleteAttribute( const char* name );
1512 
1514  const XMLAttribute* FirstAttribute() const {
1515  return _rootAttribute;
1516  }
1518  const XMLAttribute* FindAttribute( const char* name ) const;
1519 
1548  const char* GetText() const;
1549 
1584  void SetText( const char* inText );
1586  void SetText( int value );
1588  void SetText( unsigned value );
1590  void SetText(int64_t value);
1592  void SetText(uint64_t value);
1594  void SetText( bool value );
1596  void SetText( double value );
1598  void SetText( float value );
1599 
1626  XMLError QueryIntText( int* ival ) const;
1628  XMLError QueryUnsignedText( unsigned* uval ) const;
1630  XMLError QueryInt64Text(int64_t* uval) const;
1632  XMLError QueryUnsigned64Text(uint64_t* uval) const;
1634  XMLError QueryBoolText( bool* bval ) const;
1636  XMLError QueryDoubleText( double* dval ) const;
1638  XMLError QueryFloatText( float* fval ) const;
1639 
1640  int IntText(int defaultValue = 0) const;
1641 
1643  unsigned UnsignedText(unsigned defaultValue = 0) const;
1645  int64_t Int64Text(int64_t defaultValue = 0) const;
1647  uint64_t Unsigned64Text(uint64_t defaultValue = 0) const;
1649  bool BoolText(bool defaultValue = false) const;
1651  double DoubleText(double defaultValue = 0) const;
1653  float FloatText(float defaultValue = 0) const;
1654 
1659  XMLElement* InsertNewChildElement(const char* name);
1661  XMLComment* InsertNewComment(const char* comment);
1663  XMLText* InsertNewText(const char* text);
1665  XMLDeclaration* InsertNewDeclaration(const char* text);
1667  XMLUnknown* InsertNewUnknown(const char* text);
1668 
1669 
1670  // internal:
1672  OPEN, // <foo>
1673  CLOSED, // <foo/>
1674  CLOSING // </foo>
1675  };
1677  return _closingType;
1678  }
1679  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1680  virtual bool ShallowEqual( const XMLNode* compare ) const;
1681 
1682 protected:
1683  char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1684 
1685 private:
1686  XMLElement( XMLDocument* doc );
1687  virtual ~XMLElement();
1688  XMLElement( const XMLElement& ); // not supported
1689  void operator=( const XMLElement& ); // not supported
1690 
1691  XMLAttribute* FindOrCreateAttribute( const char* name );
1692  char* ParseAttributes( char* p, int* curLineNumPtr );
1693  static void DeleteAttribute( XMLAttribute* attribute );
1694  XMLAttribute* CreateAttribute();
1695 
1696  enum { BUF_SIZE = 200 };
1698  // The attribute list is ordered; there is no 'lastAttribute'
1699  // because the list needs to be scanned for dupes before adding
1700  // a new attribute.
1702 };
1703 
1704 
1708 };
1709 
1710 
1717 {
1718  friend class XMLElement;
1719  // Gives access to SetError and Push/PopDepth, but over-access for everything else.
1720  // Wishing C++ had "internal" scope.
1721  friend class XMLNode;
1722  friend class XMLText;
1723  friend class XMLComment;
1724  friend class XMLDeclaration;
1725  friend class XMLUnknown;
1726 public:
1728  XMLDocument( bool processEntities = true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
1729  ~XMLDocument();
1730 
1732  TIXMLASSERT( this == _document );
1733  return this;
1734  }
1735  virtual const XMLDocument* ToDocument() const {
1736  TIXMLASSERT( this == _document );
1737  return this;
1738  }
1739 
1750  XMLError Parse( const char* xml, size_t nBytes=static_cast<size_t>(-1) );
1751 
1757  XMLError LoadFile( const char* filename );
1758 
1770  XMLError LoadFile( FILE* );
1771 
1777  XMLError SaveFile( const char* filename, bool compact = false );
1778 
1786  XMLError SaveFile( FILE* fp, bool compact = false );
1787 
1788  bool ProcessEntities() const {
1789  return _processEntities;
1790  }
1792  return _whitespaceMode;
1793  }
1794 
1798  bool HasBOM() const {
1799  return _writeBOM;
1800  }
1803  void SetBOM( bool useBOM ) {
1804  _writeBOM = useBOM;
1805  }
1806 
1811  return FirstChildElement();
1812  }
1813  const XMLElement* RootElement() const {
1814  return FirstChildElement();
1815  }
1816 
1831  void Print( XMLPrinter* streamer=0 ) const;
1832  virtual bool Accept( XMLVisitor* visitor ) const;
1833 
1839  XMLElement* NewElement( const char* name );
1845  XMLComment* NewComment( const char* comment );
1851  XMLText* NewText( const char* text );
1863  XMLDeclaration* NewDeclaration( const char* text=0 );
1869  XMLUnknown* NewUnknown( const char* text );
1870 
1875  void DeleteNode( XMLNode* node );
1876 
1878  void ClearError();
1879 
1881  bool Error() const {
1882  return _errorID != XML_SUCCESS;
1883  }
1885  XMLError ErrorID() const {
1886  return _errorID;
1887  }
1888  const char* ErrorName() const;
1889  static const char* ErrorIDToName(XMLError errorID);
1890 
1894  const char* ErrorStr() const;
1895 
1897  void PrintError() const;
1898 
1900  int ErrorLineNum() const
1901  {
1902  return _errorLineNum;
1903  }
1904 
1906  void Clear();
1907 
1915  void DeepCopy(XMLDocument* target) const;
1916 
1917  // internal
1918  char* Identify( char* p, XMLNode** node );
1919 
1920  // internal
1921  void MarkInUse(const XMLNode* const);
1922 
1923  virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
1924  return 0;
1925  }
1926  virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
1927  return false;
1928  }
1929 
1930 private:
1931  XMLDocument( const XMLDocument& ); // not supported
1932  void operator=( const XMLDocument& ); // not supported
1933 
1943  // Memory tracking does add some overhead.
1944  // However, the code assumes that you don't
1945  // have a bunch of unlinked nodes around.
1946  // Therefore it takes less memory to track
1947  // in the document vs. a linked list in the XMLNode,
1948  // and the performance is the same.
1950 
1951  MemPoolT< sizeof(XMLElement) > _elementPool;
1952  MemPoolT< sizeof(XMLAttribute) > _attributePool;
1953  MemPoolT< sizeof(XMLText) > _textPool;
1954  MemPoolT< sizeof(XMLComment) > _commentPool;
1955 
1956  static const char* _errorNames[XML_ERROR_COUNT];
1957 
1958  void Parse();
1959 
1960  void SetError( XMLError error, int lineNum, const char* format, ... );
1961 
1962  // Something of an obvious security hole, once it was discovered.
1963  // Either an ill-formed XML or an excessively deep one can overflow
1964  // the stack. Track stack depth, and error out if needed.
1966  public:
1967  explicit DepthTracker(XMLDocument * document) {
1968  this->_document = document;
1969  document->PushDepth();
1970  }
1972  _document->PopDepth();
1973  }
1974  private:
1976  };
1977  void PushDepth();
1978  void PopDepth();
1979 
1980  template<class NodeType, int PoolElementSize>
1981  NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
1982 };
1983 
1984 template<class NodeType, int PoolElementSize>
1986 {
1987  TIXMLASSERT( sizeof( NodeType ) == PoolElementSize );
1988  TIXMLASSERT( sizeof( NodeType ) == pool.ItemSize() );
1989  NodeType* returnNode = new (pool.Alloc()) NodeType( this );
1990  TIXMLASSERT( returnNode );
1991  returnNode->_memPool = &pool;
1992 
1993  _unlinked.Push(returnNode);
1994  return returnNode;
1995 }
1996 
2053 {
2054 public:
2056  explicit XMLHandle( XMLNode* node ) : _node( node ) {
2057  }
2059  explicit XMLHandle( XMLNode& node ) : _node( &node ) {
2060  }
2062  XMLHandle( const XMLHandle& ref ) : _node( ref._node ) {
2063  }
2065  XMLHandle& operator=( const XMLHandle& ref ) {
2066  _node = ref._node;
2067  return *this;
2068  }
2069 
2072  return XMLHandle( _node ? _node->FirstChild() : 0 );
2073  }
2075  XMLHandle FirstChildElement( const char* name = 0 ) {
2076  return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
2077  }
2080  return XMLHandle( _node ? _node->LastChild() : 0 );
2081  }
2083  XMLHandle LastChildElement( const char* name = 0 ) {
2084  return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2085  }
2088  return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2089  }
2091  XMLHandle PreviousSiblingElement( const char* name = 0 ) {
2092  return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2093  }
2096  return XMLHandle( _node ? _node->NextSibling() : 0 );
2097  }
2099  XMLHandle NextSiblingElement( const char* name = 0 ) {
2100  return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2101  }
2102 
2105  return _node;
2106  }
2109  return ( _node ? _node->ToElement() : 0 );
2110  }
2113  return ( _node ? _node->ToText() : 0 );
2114  }
2117  return ( _node ? _node->ToUnknown() : 0 );
2118  }
2121  return ( _node ? _node->ToDeclaration() : 0 );
2122  }
2123 
2124 private:
2126 };
2127 
2128 
2134 {
2135 public:
2136  explicit XMLConstHandle( const XMLNode* node ) : _node( node ) {
2137  }
2138  explicit XMLConstHandle( const XMLNode& node ) : _node( &node ) {
2139  }
2140  XMLConstHandle( const XMLConstHandle& ref ) : _node( ref._node ) {
2141  }
2142 
2144  _node = ref._node;
2145  return *this;
2146  }
2147 
2148  const XMLConstHandle FirstChild() const {
2149  return XMLConstHandle( _node ? _node->FirstChild() : 0 );
2150  }
2151  const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
2152  return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2153  }
2154  const XMLConstHandle LastChild() const {
2155  return XMLConstHandle( _node ? _node->LastChild() : 0 );
2156  }
2157  const XMLConstHandle LastChildElement( const char* name = 0 ) const {
2158  return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2159  }
2161  return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
2162  }
2163  const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
2164  return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2165  }
2166  const XMLConstHandle NextSibling() const {
2167  return XMLConstHandle( _node ? _node->NextSibling() : 0 );
2168  }
2169  const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
2170  return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2171  }
2172 
2173 
2174  const XMLNode* ToNode() const {
2175  return _node;
2176  }
2177  const XMLElement* ToElement() const {
2178  return ( _node ? _node->ToElement() : 0 );
2179  }
2180  const XMLText* ToText() const {
2181  return ( _node ? _node->ToText() : 0 );
2182  }
2183  const XMLUnknown* ToUnknown() const {
2184  return ( _node ? _node->ToUnknown() : 0 );
2185  }
2187  return ( _node ? _node->ToDeclaration() : 0 );
2188  }
2189 
2190 private:
2191  const XMLNode* _node;
2192 };
2193 
2194 
2238 {
2239 public:
2246  XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
2247  virtual ~XMLPrinter() {}
2248 
2250  void PushHeader( bool writeBOM, bool writeDeclaration );
2254  void OpenElement( const char* name, bool compactMode=false );
2256  void PushAttribute( const char* name, const char* value );
2257  void PushAttribute( const char* name, int value );
2258  void PushAttribute( const char* name, unsigned value );
2259  void PushAttribute( const char* name, int64_t value );
2260  void PushAttribute( const char* name, uint64_t value );
2261  void PushAttribute( const char* name, bool value );
2262  void PushAttribute( const char* name, double value );
2264  virtual void CloseElement( bool compactMode=false );
2265 
2267  void PushText( const char* text, bool cdata=false );
2269  void PushText( int value );
2271  void PushText( unsigned value );
2273  void PushText( int64_t value );
2275  void PushText( uint64_t value );
2277  void PushText( bool value );
2279  void PushText( float value );
2281  void PushText( double value );
2282 
2284  void PushComment( const char* comment );
2285 
2286  void PushDeclaration( const char* value );
2287  void PushUnknown( const char* value );
2288 
2289  virtual bool VisitEnter( const XMLDocument& /*doc*/ );
2290  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
2291  return true;
2292  }
2293 
2294  virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
2295  virtual bool VisitExit( const XMLElement& element );
2296 
2297  virtual bool Visit( const XMLText& text );
2298  virtual bool Visit( const XMLComment& comment );
2299  virtual bool Visit( const XMLDeclaration& declaration );
2300  virtual bool Visit( const XMLUnknown& unknown );
2301 
2306  const char* CStr() const {
2307  return _buffer.Mem();
2308  }
2314  int CStrSize() const {
2315  return _buffer.Size();
2316  }
2321  void ClearBuffer( bool resetToFirstElement = true ) {
2322  _buffer.Clear();
2323  _buffer.Push(0);
2324  _firstElement = resetToFirstElement;
2325  }
2326 
2327 protected:
2328  virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
2329 
2333  virtual void PrintSpace( int depth );
2334  virtual void Print( const char* format, ... );
2335  virtual void Write( const char* data, size_t size );
2336  virtual void Putc( char ch );
2337 
2338  inline void Write(const char* data) { Write(data, strlen(data)); }
2339 
2340  void SealElementIfJustOpened();
2343 
2344 private:
2349  void PrepareForNewNode( bool compactMode );
2350  void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
2351 
2353  FILE* _fp;
2354  int _depth;
2358 
2359  enum {
2360  ENTITY_RANGE = 64,
2361  BUF_SIZE = 200
2362  };
2363  bool _entityFlag[ENTITY_RANGE];
2364  bool _restrictedEntityFlag[ENTITY_RANGE];
2365 
2367 
2368  // Prohibit cloning, intentionally not implemented
2369  XMLPrinter( const XMLPrinter& );
2370  XMLPrinter& operator=( const XMLPrinter& );
2371 };
2372 
2373 
2374 } // tinyxml2
2375 
2376 #if defined(_MSC_VER)
2377 # pragma warning(pop)
2378 #endif
2379 
2380 #endif // TINYXML2_INCLUDED
tinyxml2::DynArray::operator=
void operator=(const DynArray &)
cx::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: wildcards.hpp:636
tinyxml2::MemPool::SetTracked
virtual void SetTracked()=0
tinyxml2::XMLDocument::ToDocument
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1735
tinyxml2::XMLDocument::HasBOM
bool HasBOM() const
Definition: tinyxml2.h:1798
tinyxml2::XMLAttribute::UnsignedValue
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1181
tinyxml2::XMLConstHandle::ToText
const XMLText * ToText() const
Definition: tinyxml2.h:2180
tinyxml2::XMLNode::ToText
virtual const XMLText * ToText() const
Definition: tinyxml2.h:719
tinyxml2::XMLDocument::DepthTracker::_document
XMLDocument * _document
Definition: tinyxml2.h:1975
tinyxml2::XMLElement::QueryUnsigned64Attribute
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1370
tinyxml2::MemPoolT::Item
Definition: tinyxml2.h:444
tinyxml2::XMLDocument::Error
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1881
tinyxml2::StrPair::_start
char * _start
Definition: tinyxml2.h:192
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:513
tinyxml2::XML_NO_TEXT_NODE
@ XML_NO_TEXT_NODE
Definition: tinyxml2.h:541
tinyxml2::XMLUtil
Definition: tinyxml2.h:551
tinyxml2::XMLAttribute::Value
const char * Value() const
The value of the attribute.
Definition: tinyxml2.cpp:1405
BT::NodeType
NodeType
Enumerates the possible types of nodes.
Definition: basic_types.h:20
tinyxml2::StrPair::Empty
bool Empty() const
Definition: tinyxml2.h:166
tinyxml2::XMLDocument::ErrorLineNum
int ErrorLineNum() const
Return the line where the error occurred, or zero if unknown.
Definition: tinyxml2.h:1900
tinyxml2::MemPoolT::Block::items
Item items[ITEMS_PER_BLOCK]
Definition: tinyxml2.h:449
tinyxml2::DynArray::Mem
T * Mem()
Definition: tinyxml2.h:294
tinyxml2::XMLText::CData
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:1009
tinyxml2::XMLNode::_lastChild
XMLNode * _lastChild
Definition: tinyxml2.h:960
tinyxml2::XMLNode::ToDeclaration
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:708
tinyxml2::XMLElement::ToElement
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1277
tinyxml2::DynArray::~DynArray
~DynArray()
Definition: tinyxml2.h:216
tinyxml2::COLLAPSE_WHITESPACE
@ COLLAPSE_WHITESPACE
Definition: tinyxml2.h:1707
tinyxml2::XMLElement::_rootAttribute
XMLAttribute * _rootAttribute
Definition: tinyxml2.h:1701
tinyxml2::XMLPrinter::_stack
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:2342
tinyxml2::XMLNode::NextSibling
XMLNode * NextSibling()
Definition: tinyxml2.h:825
tinyxml2::XMLConstHandle::ToNode
const XMLNode * ToNode() const
Definition: tinyxml2.h:2174
tinyxml2::XMLDocument::_charBuffer
char * _charBuffer
Definition: tinyxml2.h:1940
tinyxml2::MemPoolT::_currentAllocs
int _currentAllocs
Definition: tinyxml2.h:454
tinyxml2::XMLAttribute::SetAttribute
void SetAttribute(const char *value)
Set the attribute to a string value.
Definition: tinyxml2.cpp:1507
tinyxml2::XMLHandle::XMLHandle
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:2062
tinyxml2::XMLComment
Definition: tinyxml2.h:1031
tinyxml2::XMLVisitor::VisitExit
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:491
tinyxml2::XMLAttribute::_next
XMLAttribute * _next
Definition: tinyxml2.h:1255
tinyxml2::MemPool
Definition: tinyxml2.h:330
tinyxml2::DynArray::DynArray
DynArray()
Definition: tinyxml2.h:209
tinyxml2::XMLUtil::SkipWhiteSpace
static char * SkipWhiteSpace(char *const p, int *curLineNumPtr)
Definition: tinyxml2.h:566
tinyxml2::XMLNode::_memPool
MemPool * _memPool
Definition: tinyxml2.h:968
tinyxml2::MemPoolT::Trace
void Trace(const char *name)
Definition: tinyxml2.h:413
tinyxml2::XMLHandle::PreviousSiblingElement
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:2091
tinyxml2::XML_ERROR_PARSING_UNKNOWN
@ XML_ERROR_PARSING_UNKNOWN
Definition: tinyxml2.h:536
tinyxml2::MemPoolT::Free
virtual void Free(void *mem)
Definition: tinyxml2.h:401
tinyxml2::XMLError
XMLError
Definition: tinyxml2.h:523
tinyxml2::XMLElement::QueryBoolAttribute
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1379
tinyxml2::XMLVisitor::~XMLVisitor
virtual ~XMLVisitor()
Definition: tinyxml2.h:484
ToStr
static const char * ToStr(const Color &c)
Definition: gtest_enums.cpp:14
tinyxml2::XMLNode::_parent
XMLNode * _parent
Definition: tinyxml2.h:955
TIXMLASSERT
#define TIXMLASSERT(x)
Definition: tinyxml2.h:95
tinyxml2::DynArray::_size
int _size
Definition: tinyxml2.h:322
tinyxml2::XMLNode::NoChildren
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:764
tinyxml2::MemPoolT::~MemPoolT
~MemPoolT()
Definition: tinyxml2.h:351
tinyxml2::XMLElement::QueryStringAttribute
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1404
tinyxml2::XMLElement::SetName
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1273
tinyxml2::XML_ERROR_FILE_NOT_FOUND
@ XML_ERROR_FILE_NOT_FOUND
Definition: tinyxml2.h:527
tinyxml2::XMLDocument::ShallowClone
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1923
tinyxml2::StrPair::Mode
Mode
Definition: tinyxml2.h:139
tinyxml2::XMLNode::ToElement
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:716
tinyxml2::XMLDocument::_writeBOM
bool _writeBOM
Definition: tinyxml2.h:1934
tinyxml2::XMLDocument::_errorID
XMLError _errorID
Definition: tinyxml2.h:1936
tinyxml2::XMLPrinter
Definition: tinyxml2.h:2237
tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED
@ XML_ERROR_FILE_COULD_NOT_BE_OPENED
Definition: tinyxml2.h:528
tinyxml2::XML_WRONG_ATTRIBUTE_TYPE
@ XML_WRONG_ATTRIBUTE_TYPE
Definition: tinyxml2.h:526
tinyxml2::XMLDocument::CreateUnlinkedNode
NodeType * CreateUnlinkedNode(MemPoolT< PoolElementSize > &pool)
Definition: tinyxml2.h:1985
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1465
tinyxml2::DynArray::Mem
const T * Mem() const
Definition: tinyxml2.h:289
tinyxml2::MemPool::ItemSize
virtual int ItemSize() const =0
tinyxml2::XMLHandle
Definition: tinyxml2.h:2052
tinyxml2::DynArray::PeekTop
const T & PeekTop() const
Definition: tinyxml2.h:267
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:517
TIXML2_MAJOR_VERSION
static const int TIXML2_MAJOR_VERSION
Definition: tinyxml2.h:102
tinyxml2::XMLAttribute::DoubleValue
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1193
tinyxml2::XML_ERROR_PARSING_DECLARATION
@ XML_ERROR_PARSING_DECLARATION
Definition: tinyxml2.h:535
tinyxml2::XML_ERROR_FILE_READ_ERROR
@ XML_ERROR_FILE_READ_ERROR
Definition: tinyxml2.h:529
tinyxml2::XMLNode::_prev
XMLNode * _prev
Definition: tinyxml2.h:962
tinyxml2::XMLUnknown::ToUnknown
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1112
tinyxml2::XML_ERROR_PARSING_ELEMENT
@ XML_ERROR_PARSING_ELEMENT
Definition: tinyxml2.h:530
tinyxml2::XMLDocument::ErrorID
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1885
tinyxml2::StrPair::_flags
int _flags
Definition: tinyxml2.h:191
tinyxml2::XMLHandle::XMLHandle
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:2059
tinyxml2::XMLVisitor::VisitEnter
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:496
tinyxml2::DynArray::PopArr
void PopArr(int count)
Definition: tinyxml2.h:248
tinyxml2::XMLVisitor
Definition: tinyxml2.h:481
tinyxml2::XMLNode::FirstChildElement
XMLElement * FirstChildElement(const char *name=0)
Definition: tinyxml2.h:782
tinyxml2::XMLElement::QueryInt64Attribute
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1361
tinyxml2::XMLPrinter::_firstElement
bool _firstElement
Definition: tinyxml2.h:2352
tinyxml2::XMLConstHandle::ToDeclaration
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:2186
tinyxml2::XML_ERROR_PARSING_TEXT
@ XML_ERROR_PARSING_TEXT
Definition: tinyxml2.h:532
tinyxml2::DynArray::_mem
T * _mem
Definition: tinyxml2.h:319
tinyxml2::XMLHandle::_node
XMLNode * _node
Definition: tinyxml2.h:2125
tinyxml2::XMLDocument::WhitespaceMode
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1791
tinyxml2::XMLPrinter::VisitExit
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2290
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1498
TIXML2_MINOR_VERSION
static const int TIXML2_MINOR_VERSION
Definition: tinyxml2.h:103
tinyxml2::XMLPrinter::_textDepth
int _textDepth
Definition: tinyxml2.h:2355
magic_enum::detail::value
constexpr E value(std::size_t i) noexcept
Definition: magic_enum.hpp:664
tinyxml2::XMLUnknown::ToUnknown
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1109
tinyxml2::XMLNode::ToComment
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:722
tinyxml2::XMLVisitor::VisitExit
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:500
tinyxml2::XMLPrinter::_buffer
DynArray< char, 20 > _buffer
Definition: tinyxml2.h:2366
tinyxml2::XMLNode::NextSibling
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:821
TINYXML2_MAX_ELEMENT_DEPTH
static const int TINYXML2_MAX_ELEMENT_DEPTH
Definition: tinyxml2.h:115
TINYXML2_LIB
#define TINYXML2_LIB
Definition: tinyxml2.h:78
tinyxml2::XMLConstHandle::ToElement
const XMLElement * ToElement() const
Definition: tinyxml2.h:2177
tinyxml2::XMLText::~XMLText
virtual ~XMLText()
Definition: tinyxml2.h:1018
tinyxml2::XMLDocument::_whitespaceMode
Whitespace _whitespaceMode
Definition: tinyxml2.h:1937
tinyxml2::XMLNode::GetDocument
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:681
cx::end
constexpr auto end(const C &c) -> decltype(c.end())
Definition: wildcards.hpp:686
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, const char **value) const
Definition: tinyxml2.h:1460
tinyxml2::XML_ERROR_PARSING_COMMENT
@ XML_ERROR_PARSING_COMMENT
Definition: tinyxml2.h:534
tinyxml2::XMLHandle::operator=
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:2065
tinyxml2::StrPair::Set
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:155
tinyxml2::XMLConstHandle::XMLConstHandle
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:2136
tinyxml2::XMLAttribute
Definition: tinyxml2.h:1140
tinyxml2::XMLHandle::ToElement
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:2108
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, uint64_t *value) const
Definition: tinyxml2.h:1444
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1493
tinyxml2::XMLConstHandle::NextSibling
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:2166
tinyxml2::XMLDocument::ProcessEntities
bool ProcessEntities() const
Definition: tinyxml2.h:1788
tinyxml2::XMLDocument::RootElement
const XMLElement * RootElement() const
Definition: tinyxml2.h:1813
tinyxml2::XMLPrinter::CStr
const char * CStr() const
Definition: tinyxml2.h:2306
tinyxml2::XMLText
Definition: tinyxml2.h:991
tinyxml2::Whitespace
Whitespace
Definition: tinyxml2.h:1705
tinyxml2::XMLElement::_closingType
ElementClosingType _closingType
Definition: tinyxml2.h:1697
tinyxml2::XMLConstHandle::LastChildElement
const XMLConstHandle LastChildElement(const char *name=0) const
Definition: tinyxml2.h:2157
tinyxml2::XMLUtil::writeBoolTrue
static const char * writeBoolTrue
Definition: tinyxml2.h:644
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1487
tinyxml2::XMLNode::ToUnknown
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:712
tinyxml2::XMLElement::FirstAttribute
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1514
tinyxml2::MemPoolT::_maxAllocs
int _maxAllocs
Definition: tinyxml2.h:456
tinyxml2::MemPoolT::ITEMS_PER_BLOCK
@ ITEMS_PER_BLOCK
Definition: tinyxml2.h:438
lexy::count
constexpr auto count
Sink that counts all arguments.
Definition: fold.hpp:88
tinyxml2::XMLAttribute::QueryUnsignedValue
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1453
tinyxml2::XMLAttribute::QueryInt64Value
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1462
tinyxml2::XMLUtil::IsNameStartChar
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:576
tinyxml2::XML_SUCCESS
@ XML_SUCCESS
Definition: tinyxml2.h:524
tinyxml2::XMLPrinter::CStrSize
int CStrSize() const
Definition: tinyxml2.h:2314
tinyxml2::XMLAttribute::QueryDoubleValue
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1498
tinyxml2::XMLComment::ToComment
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:1035
tinyxml2::XMLAttribute::_value
StrPair _value
Definition: tinyxml2.h:1253
tinyxml2::XMLNode::FirstChild
XMLNode * FirstChild()
Definition: tinyxml2.h:773
tinyxml2::XMLPrinter::_compactMode
bool _compactMode
Definition: tinyxml2.h:2357
tinyxml2::XMLAttribute::QueryBoolValue
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1480
tinyxml2::XMLPrinter::_fp
FILE * _fp
Definition: tinyxml2.h:2353
tinyxml2::XMLDocument::_unlinked
DynArray< XMLNode *, 10 > _unlinked
Definition: tinyxml2.h:1949
tinyxml2::XMLNode::FirstChild
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:769
tinyxml2::DynArray::Pop
T Pop()
Definition: tinyxml2.h:242
tinyxml2::XMLUtil::writeBoolFalse
static const char * writeBoolFalse
Definition: tinyxml2.h:645
tinyxml2::XMLDocument::DepthTracker::DepthTracker
DepthTracker(XMLDocument *document)
Definition: tinyxml2.h:1967
tinyxml2::XMLNode::GetLineNum
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
Definition: tinyxml2.h:752
tinyxml2::XMLText::_isCData
bool _isCData
Definition: tinyxml2.h:1023
tinyxml2::DynArray::Size
int Size() const
Definition: tinyxml2.h:272
tinyxml2::XMLNode::_firstChild
XMLNode * _firstChild
Definition: tinyxml2.h:959
lexy::buffer
buffer(const CharT *, const CharT *) -> buffer< deduce_encoding< CharT >>
tinyxml2::XMLComment::ToComment
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:1038
tinyxml2::StrPair::SetInternedStr
void SetInternedStr(const char *str)
Definition: tinyxml2.h:170
tinyxml2::XMLNode::LinkEndChild
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:845
tinyxml2::XMLText::XMLText
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:1017
tinyxml2::XMLDeclaration
Definition: tinyxml2.h:1070
tinyxml2::XMLAttribute::_name
StrPair _name
Definition: tinyxml2.h:1252
tinyxml2::DynArray::Empty
bool Empty() const
Definition: tinyxml2.h:253
tinyxml2::XMLDocument::_parseCurLineNum
int _parseCurLineNum
Definition: tinyxml2.h:1941
lexy_ext::child
auto child(const lexy::parse_tree< Reader, TokenKind, MemoryResource > &tree, typename lexy::parse_tree< Reader, TokenKind, MemoryResource >::node node, Predicate predicate) -> std::optional< typename lexy::parse_tree< Reader, TokenKind, MemoryResource >::node >
Returns the first child that matches predicate, if there is any.
Definition: parse_tree_algorithm.hpp:244
tinyxml2::XMLConstHandle::FirstChild
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:2148
tinyxml2::XMLUnknown
Definition: tinyxml2.h:1105
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1475
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, double *value) const
Definition: tinyxml2.h:1452
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, unsigned int *value) const
Definition: tinyxml2.h:1436
tinyxml2::XMLText::SetCData
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:1005
tinyxml2::XMLConstHandle::ToUnknown
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:2183
tinyxml2::MemPoolT::_nUntracked
int _nUntracked
Definition: tinyxml2.h:457
tinyxml2::XMLHandle::ToText
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:2112
tinyxml2::XMLElement::ElementClosingType
ElementClosingType
Definition: tinyxml2.h:1671
tinyxml2::XMLElement
Definition: tinyxml2.h:1264
tinyxml2::MemPoolT::CurrentAllocs
int CurrentAllocs() const
Definition: tinyxml2.h:371
tinyxml2::XMLHandle::LastChild
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:2079
tinyxml2::XMLElement::ClosingType
ElementClosingType ClosingType() const
Definition: tinyxml2.h:1676
tinyxml2::XMLNode::ToDocument
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:725
tinyxml2::XMLDocument::ToDocument
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1731
tinyxml2::XMLNode::Parent
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:755
tinyxml2::XMLAttribute::_parseLineNum
int _parseLineNum
Definition: tinyxml2.h:1254
tinyxml2::XMLNode::_value
StrPair _value
Definition: tinyxml2.h:956
tinyxml2::XML_ERROR_PARSING_CDATA
@ XML_ERROR_PARSING_CDATA
Definition: tinyxml2.h:533
tinyxml2::XMLPrinter::CompactMode
virtual bool CompactMode(const XMLElement &)
Definition: tinyxml2.h:2328
tinyxml2::XMLDocument::RootElement
XMLElement * RootElement()
Definition: tinyxml2.h:1810
tinyxml2::XMLAttribute::QueryFloatValue
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1489
tinyxml2::XMLNode::SetUserData
void SetUserData(void *userData)
Definition: tinyxml2.h:939
tinyxml2::XMLElement::QueryDoubleAttribute
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1387
tinyxml2::MemPoolT
Definition: tinyxml2.h:347
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1503
tinyxml2::DynArray::Clear
void Clear()
Definition: tinyxml2.h:222
tinyxml2::XMLPrinter::_processEntities
bool _processEntities
Definition: tinyxml2.h:2356
tinyxml2::XMLNode::ToElement
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:692
tinyxml2::MemPool::~MemPool
virtual ~MemPool()
Definition: tinyxml2.h:334
tinyxml2::DynArray::PushArr
T * PushArr(int count)
Definition: tinyxml2.h:233
tinyxml2::XMLElement::CLOSED
@ CLOSED
Definition: tinyxml2.h:1673
tinyxml2::XMLUtil::IsUTF8Continuation
static bool IsUTF8Continuation(const char p)
Definition: tinyxml2.h:609
tinyxml2::XMLNode::GetUserData
void * GetUserData() const
Definition: tinyxml2.h:946
tinyxml2::XMLHandle::XMLHandle
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:2056
tinyxml2::MemPoolT::Alloc
virtual void * Alloc()
Definition: tinyxml2.h:375
tinyxml2::XMLUtil::IsPrefixHex
static bool IsPrefixHex(const char *p)
Definition: tinyxml2.h:594
tinyxml2::MemPoolT::ItemSize
virtual int ItemSize() const
Definition: tinyxml2.h:368
tinyxml2::XMLPrinter::ClearBuffer
void ClearBuffer(bool resetToFirstElement=true)
Definition: tinyxml2.h:2321
tinyxml2::XMLNode::_parseLineNum
int _parseLineNum
Definition: tinyxml2.h:957
tinyxml2::XMLElement::ToElement
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1280
tinyxml2::XMLConstHandle::LastChild
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:2154
tinyxml2::XMLElement::QueryUnsignedAttribute
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1352
tinyxml2::MemPool::MemPool
MemPool()
Definition: tinyxml2.h:333
f
static FILE * f
Definition: minitrace.cpp:74
tinyxml2::XML_ERROR_PARSING_ATTRIBUTE
@ XML_ERROR_PARSING_ATTRIBUTE
Definition: tinyxml2.h:531
tinyxml2::DynArray::operator[]
T & operator[](int i)
Definition: tinyxml2.h:257
tinyxml2::MemPoolT::SetTracked
void SetTracked()
Definition: tinyxml2.h:419
tinyxml2::XMLPrinter::~XMLPrinter
virtual ~XMLPrinter()
Definition: tinyxml2.h:2247
tinyxml2::MemPoolT::MemPoolT
MemPoolT()
Definition: tinyxml2.h:350
tinyxml2::XMLNode::LastChild
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:787
tinyxml2::XMLHandle::ToDeclaration
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:2120
tinyxml2::XMLAttribute::QueryUnsigned64Value
XMLError QueryUnsigned64Value(uint64_t *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1471
tinyxml2::XMLHandle::FirstChildElement
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:2075
tinyxml2::DynArray::operator[]
const T & operator[](int i) const
Definition: tinyxml2.h:262
tinyxml2::XMLConstHandle::NextSiblingElement
const XMLConstHandle NextSiblingElement(const char *name=0) const
Definition: tinyxml2.h:2169
tinyxml2::XMLDocument::_errorLineNum
int _errorLineNum
Definition: tinyxml2.h:1939
tinyxml2::PRESERVE_WHITESPACE
@ PRESERVE_WHITESPACE
Definition: tinyxml2.h:1706
tinyxml2::XMLNode::_next
XMLNode * _next
Definition: tinyxml2.h:963
tinyxml2::StrPair::StrPair
StrPair()
Definition: tinyxml2.h:152
tinyxml2::XMLNode::_userData
void * _userData
Definition: tinyxml2.h:965
tinyxml2::XMLHandle::PreviousSibling
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:2087
tinyxml2::XMLAttribute::BoolValue
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1187
tinyxml2::XMLNode
Definition: tinyxml2.h:674
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:509
tinyxml2::MemPool::Free
virtual void Free(void *)=0
tinyxml2::XMLConstHandle::_node
const XMLNode * _node
Definition: tinyxml2.h:2191
tinyxml2::XMLConstHandle::operator=
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:2143
tinyxml2::XMLNode::PreviousSiblingElement
XMLElement * PreviousSiblingElement(const char *name=0)
Definition: tinyxml2.h:816
tinyxml2::XMLDocument::DepthTracker::~DepthTracker
~DepthTracker()
Definition: tinyxml2.h:1971
tinyxml2::XMLAttribute::_memPool
MemPool * _memPool
Definition: tinyxml2.h:1256
tinyxml2::XMLDeclaration::ToDeclaration
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1077
tinyxml2::XMLNode::NextSiblingElement
XMLElement * NextSiblingElement(const char *name=0)
Definition: tinyxml2.h:832
tinyxml2::XMLHandle::ToNode
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:2104
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1470
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, float *value) const
Definition: tinyxml2.h:1456
tinyxml2::MemPoolT::_nAllocs
int _nAllocs
Definition: tinyxml2.h:455
tinyxml2::DynArray::Push
void Push(T t)
Definition: tinyxml2.h:226
tinyxml2::XMLUtil::IsWhiteSpace
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:572
tinyxml2::XMLConstHandle::PreviousSiblingElement
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
Definition: tinyxml2.h:2163
tinyxml2::XMLDeclaration::ToDeclaration
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1074
tinyxml2::XMLNode::LastChildElement
XMLElement * LastChildElement(const char *name=0)
Definition: tinyxml2.h:800
tinyxml2::XMLPrinter::Write
void Write(const char *data)
Definition: tinyxml2.h:2338
tinyxml2::MemPoolT::Item::next
Item * next
Definition: tinyxml2.h:445
tinyxml2::XMLNode::ToText
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:696
tinyxml2::XMLDocument::SetBOM
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1803
tinyxml2::XMLConstHandle::XMLConstHandle
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:2140
tinyxml2::XMLElement::QueryIntAttribute
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1343
tinyxml2::XMLUtil::StringEqual
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:599
tinyxml2::DynArray::SwapRemove
void SwapRemove(int i)
Definition: tinyxml2.h:282
tinyxml2::DynArray::_pool
T _pool[INITIAL_SIZE]
Definition: tinyxml2.h:320
tinyxml2::XML_CAN_NOT_CONVERT_TEXT
@ XML_CAN_NOT_CONVERT_TEXT
Definition: tinyxml2.h:540
tinyxml2::XMLHandle::ToUnknown
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:2116
tinyxml2::XMLDocument
Definition: tinyxml2.h:1716
tinyxml2::XMLAttribute::XMLAttribute
XMLAttribute()
Definition: tinyxml2.h:1243
tinyxml2::DynArray::EnsureCapacity
void EnsureCapacity(int cap)
Definition: tinyxml2.h:303
tinyxml2::XMLAttribute::GetLineNum
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition: tinyxml2.h:1151
tinyxml2::XMLNode::Parent
XMLNode * Parent()
Definition: tinyxml2.h:759
tinyxml2::XML_ELEMENT_DEPTH_EXCEEDED
@ XML_ELEMENT_DEPTH_EXCEEDED
Definition: tinyxml2.h:542
tinyxml2
Definition: tinyxml2.cpp:133
tinyxml2::XMLAttribute::~XMLAttribute
virtual ~XMLAttribute()
Definition: tinyxml2.h:1244
lexy::_detail::error
constexpr bool error
Definition: config.hpp:39
tinyxml2::XMLText::ToText
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:997
tinyxml2::XMLNode::ToComment
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:700
tinyxml2::MemPool::Alloc
virtual void * Alloc()=0
tinyxml2::XMLVisitor::VisitEnter
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:487
tinyxml2::XMLAttribute::FloatValue
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1199
tinyxml2::XMLAttribute::Int64Value
int64_t Int64Value() const
Definition: tinyxml2.h:1168
tinyxml2::XMLAttribute::Unsigned64Value
uint64_t Unsigned64Value() const
Definition: tinyxml2.h:1174
tinyxml2::XMLNode::_document
XMLDocument * _document
Definition: tinyxml2.h:954
tinyxml2::XMLAttribute::IntValue
int IntValue() const
Definition: tinyxml2.h:1162
tinyxml2::MemPoolT::Untracked
int Untracked() const
Definition: tinyxml2.h:423
tinyxml2::XMLText::ToText
virtual const XMLText * ToText() const
Definition: tinyxml2.h:1000
tinyxml2::XMLDocument::_processEntities
bool _processEntities
Definition: tinyxml2.h:1935
tinyxml2::XMLNode::ToDocument
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:704
tinyxml2::XMLHandle::NextSiblingElement
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:2099
tinyxml2::XMLUtil::SkipWhiteSpace
static const char * SkipWhiteSpace(const char *p, int *curLineNumPtr)
Definition: tinyxml2.h:554
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1481
tinyxml2::DynArray
Definition: tinyxml2.h:206
tinyxml2::XML_ERROR_MISMATCHED_ELEMENT
@ XML_ERROR_MISMATCHED_ELEMENT
Definition: tinyxml2.h:538
tinyxml2::MemPoolT::_blockPtrs
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:451
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1432
tinyxml2::XMLUtil::IsNameChar
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:587
tinyxml2::XMLDocument::_errorStr
StrPair _errorStr
Definition: tinyxml2.h:1938
tinyxml2::MemPoolT::operator=
void operator=(const MemPoolT &)
tinyxml2::XMLConstHandle::FirstChildElement
const XMLConstHandle FirstChildElement(const char *name=0) const
Definition: tinyxml2.h:2151
tinyxml2::MemPoolT::Item::itemData
char itemData[ITEM_SIZE]
Definition: tinyxml2.h:446
tinyxml2::XML_ERROR_COUNT
@ XML_ERROR_COUNT
Definition: tinyxml2.h:544
tinyxml2::XMLDocument::PushDepth
void PushDepth()
Definition: tinyxml2.cpp:2533
tinyxml2::XMLNode::PreviousSibling
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:805
tinyxml2::XMLDocument::ShallowEqual
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1926
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, bool *value) const
Definition: tinyxml2.h:1448
tinyxml2::XML_NO_ATTRIBUTE
@ XML_NO_ATTRIBUTE
Definition: tinyxml2.h:525
tinyxml2::MemPoolT::Clear
void Clear()
Definition: tinyxml2.h:355
tinyxml2::XMLNode::ToUnknown
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:731
TIXML2_PATCH_VERSION
static const int TIXML2_PATCH_VERSION
Definition: tinyxml2.h:104
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:505
tinyxml2::XMLNode::ToDeclaration
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:728
tinyxml2::XMLNode::GetDocument
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:686
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, int64_t *value) const
Definition: tinyxml2.h:1440
tinyxml2::XMLDocument::_parsingDepth
int _parsingDepth
Definition: tinyxml2.h:1942
tinyxml2::XMLElement::QueryFloatAttribute
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1395
tinyxml2::XML_ERROR_PARSING
@ XML_ERROR_PARSING
Definition: tinyxml2.h:539
lexyd::p
constexpr auto p
Parses the production.
Definition: production.hpp:127
tinyxml2::XMLNode::PreviousSibling
XMLNode * PreviousSibling()
Definition: tinyxml2.h:809
tinyxml2::MemPoolT::Block
Definition: tinyxml2.h:448
tinyxml2::DynArray::_allocated
int _allocated
Definition: tinyxml2.h:321
tinyxml2::XMLConstHandle::XMLConstHandle
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:2138
tinyxml2::XML_ERROR_EMPTY_DOCUMENT
@ XML_ERROR_EMPTY_DOCUMENT
Definition: tinyxml2.h:537
tinyxml2::XMLPrinter::_depth
int _depth
Definition: tinyxml2.h:2354
tinyxml2::XMLHandle::NextSibling
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:2095
tinyxml2::XMLDocument::DepthTracker
Definition: tinyxml2.h:1965
tinyxml2::XMLConstHandle
Definition: tinyxml2.h:2133
tinyxml2::MemPoolT::_root
Item * _root
Definition: tinyxml2.h:452
tinyxml2::DynArray::Capacity
int Capacity() const
Definition: tinyxml2.h:277
tinyxml2::XMLHandle::FirstChild
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:2071
tinyxml2::StrPair::_end
char * _end
Definition: tinyxml2.h:193
tinyxml2::XMLHandle::LastChildElement
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:2083
tinyxml2::XMLAttribute::QueryIntValue
XMLError QueryIntValue(int *value) const
Definition: tinyxml2.cpp:1444
tinyxml2::XMLAttribute::Next
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1154
tinyxml2::XMLElement::OPEN
@ OPEN
Definition: tinyxml2.h:1672
tinyxml2::XMLPrinter::_elementJustOpened
bool _elementJustOpened
Definition: tinyxml2.h:2341
tinyxml2::XMLNode::LastChild
XMLNode * LastChild()
Definition: tinyxml2.h:791
tinyxml2::XMLConstHandle::PreviousSibling
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:2160
tinyxml2::StrPair
Definition: tinyxml2.h:136
tinyxml2::XMLElement::Name
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1269


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:08