Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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__)
28 # include <ctype.h>
29 # include <limits.h>
30 # include <stdio.h>
31 # include <stdlib.h>
32 # include <string.h>
33 # include <stdarg.h>
34 #else
35 # include <cctype>
36 # include <climits>
37 # include <cstdio>
38 # include <cstdlib>
39 # include <cstring>
40 # include <cstdarg>
41 #endif
42 
43 /*
44  TODO: intern strings instead of allocation.
45 */
46 /*
47  gcc:
48  g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
49 
50  Formatting, Artistic Style:
51  AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
52 */
53 
54 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
55 # ifndef DEBUG
56 # define DEBUG
57 # endif
58 #endif
59 
60 
61 #if defined(DEBUG)
62 # if defined(_MSC_VER)
63 # define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
64 # elif defined (ANDROID_NDK)
65 # include <android/log.h>
66 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
67 # else
68 # include <assert.h>
69 # define TIXMLASSERT assert
70 # endif
71 # else
72 # define TIXMLASSERT( x ) {}
73 #endif
74 
75 
76 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
77 // Microsoft visual studio, version 2005 and higher.
78 /*int _snprintf_s(
79  char *buffer,
80  size_t sizeOfBuffer,
81  size_t count,
82  const char *format [,
83  argument] ...
84 );*/
85 inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
86 {
87  va_list va;
88  va_start( va, format );
89  int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
90  va_end( va );
91  return result;
92 }
93 #define TIXML_SSCANF sscanf_s
94 #else
95 // GCC version 3 and higher
96 //#warning( "Using sn* functions." )
97 #define TIXML_SNPRINTF snprintf
98 #define TIXML_SSCANF sscanf
99 #endif
100 
101 static const int TIXML2_MAJOR_VERSION = 1;
102 static const int TIXML2_MINOR_VERSION = 0;
103 static const int TIXML2_PATCH_VERSION = 9;
104 
105 namespace tinyxml2
106 {
107 class XMLDocument;
108 class XMLElement;
109 class XMLAttribute;
110 class XMLComment;
111 class XMLNode;
112 class XMLText;
113 class XMLDeclaration;
114 class XMLUnknown;
115 
116 class XMLPrinter;
117 
118 /*
119  A class that wraps strings. Normally stores the start and end
120  pointers into the XML file itself, and will apply normalization
121  and entity translation if actually read. Can also store (and memory
122  manage) a traditional char[]
123 */
124 class StrPair
125 {
126 public:
127  enum {
131 
138  };
139 
140  StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
141  ~StrPair();
142 
143  void Set( char* start, char* end, int flags ) {
144  Reset();
145  _start = start;
146  _end = end;
147  _flags = flags | NEEDS_FLUSH;
148  }
149 
150  const char* GetStr();
151 
152  bool Empty() const {
153  return _start == _end;
154  }
155 
156  void SetInternedStr( const char* str ) {
157  Reset();
158  _start = const_cast<char*>(str);
159  }
160 
161  void SetStr( const char* str, int flags=0 );
162 
163  char* ParseText( char* in, const char* endTag, int strFlags );
164  char* ParseName( char* in );
165 
166 private:
167  void Reset();
168  void CollapseWhitespace();
169 
170  enum {
171  NEEDS_FLUSH = 0x100,
172  NEEDS_DELETE = 0x200
173  };
174 
175  // After parsing, if *end != 0, it can be set to zero.
176  int _flags;
177  char* _start;
178  char* _end;
179 };
180 
181 
182 /*
183  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
184  Has a small initial memory pool, so that low or no usage will not
185  cause a call to new/delete
186 */
187 template <class T, int INIT>
188 class DynArray
189 {
190 public:
192  _mem = _pool;
193  _allocated = INIT;
194  _size = 0;
195  }
196 
198  if ( _mem != _pool ) {
199  delete [] _mem;
200  }
201  }
202 
203  void Push( T t ) {
204  EnsureCapacity( _size+1 );
205  _mem[_size++] = t;
206  }
207 
208  T* PushArr( int count ) {
209  EnsureCapacity( _size+count );
210  T* ret = &_mem[_size];
211  _size += count;
212  return ret;
213  }
214 
215  T Pop() {
216  return _mem[--_size];
217  }
218 
219  void PopArr( int count ) {
220  TIXMLASSERT( _size >= count );
221  _size -= count;
222  }
223 
224  bool Empty() const {
225  return _size == 0;
226  }
227 
228  T& operator[](int i) {
229  TIXMLASSERT( i>= 0 && i < _size );
230  return _mem[i];
231  }
232 
233  const T& operator[](int i) const {
234  TIXMLASSERT( i>= 0 && i < _size );
235  return _mem[i];
236  }
237 
238  int Size() const {
239  return _size;
240  }
241 
242  int Capacity() const {
243  return _allocated;
244  }
245 
246  const T* Mem() const {
247  return _mem;
248  }
249 
250  T* Mem() {
251  return _mem;
252  }
253 
254 private:
255  void EnsureCapacity( int cap ) {
256  if ( cap > _allocated ) {
257  int newAllocated = cap * 2;
258  T* newMem = new T[newAllocated];
259  memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
260  if ( _mem != _pool ) {
261  delete [] _mem;
262  }
263  _mem = newMem;
264  _allocated = newAllocated;
265  }
266  }
267 
268  T* _mem;
269  T _pool[INIT];
270  int _allocated; // objects allocated
271  int _size; // number objects in use
272 };
273 
274 
275 /*
276  Parent virtual class of a pool for fast allocation
277  and deallocation of objects.
278 */
279 class MemPool
280 {
281 public:
282  MemPool() {}
283  virtual ~MemPool() {}
284 
285  virtual int ItemSize() const = 0;
286  virtual void* Alloc() = 0;
287  virtual void Free( void* ) = 0;
288  virtual void SetTracked() = 0;
289 };
290 
291 
292 /*
293  Template child class to create pools of the correct type.
294 */
295 template< int SIZE >
296 class MemPoolT : public MemPool
297 {
298 public:
301  // Delete the blocks.
302  for( int i=0; i<_blockPtrs.Size(); ++i ) {
303  delete _blockPtrs[i];
304  }
305  }
306 
307  virtual int ItemSize() const {
308  return SIZE;
309  }
310  int CurrentAllocs() const {
311  return _currentAllocs;
312  }
313 
314  virtual void* Alloc() {
315  if ( !_root ) {
316  // Need a new block.
317  Block* block = new Block();
318  _blockPtrs.Push( block );
319 
320  for( int i=0; i<COUNT-1; ++i ) {
321  block->chunk[i].next = &block->chunk[i+1];
322  }
323  block->chunk[COUNT-1].next = 0;
324  _root = block->chunk;
325  }
326  void* result = _root;
327  _root = _root->next;
328 
329  ++_currentAllocs;
330  if ( _currentAllocs > _maxAllocs ) {
332  }
333  _nAllocs++;
334  _nUntracked++;
335  return result;
336  }
337  virtual void Free( void* mem ) {
338  if ( !mem ) {
339  return;
340  }
341  --_currentAllocs;
342  Chunk* chunk = (Chunk*)mem;
343 #ifdef DEBUG
344  memset( chunk, 0xfe, sizeof(Chunk) );
345 #endif
346  chunk->next = _root;
347  _root = chunk;
348  }
349  void Trace( const char* name ) {
350  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
351  name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
352  }
353 
354  void SetTracked() {
355  _nUntracked--;
356  }
357 
358  int Untracked() const {
359  return _nUntracked;
360  }
361 
362  enum { COUNT = 1024/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
363 
364 private:
365  union Chunk {
367  char mem[SIZE];
368  };
369  struct Block {
371  };
373  Chunk* _root;
374 
376  int _nAllocs;
379 };
380 
381 
382 
403 {
404 public:
405  virtual ~XMLVisitor() {}
406 
408  virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
409  return true;
410  }
412  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
413  return true;
414  }
415 
417  virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
418  return true;
419  }
421  virtual bool VisitExit( const XMLElement& /*element*/ ) {
422  return true;
423  }
424 
426  virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
427  return true;
428  }
430  virtual bool Visit( const XMLText& /*text*/ ) {
431  return true;
432  }
434  virtual bool Visit( const XMLComment& /*comment*/ ) {
435  return true;
436  }
438  virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
439  return true;
440  }
441 };
442 
443 
444 /*
445  Utility functionality.
446 */
447 class XMLUtil
448 {
449 public:
450  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
451  // correct, but simple, and usually works.
452  static const char* SkipWhiteSpace( const char* p ) {
453  while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
454  ++p;
455  }
456  return p;
457  }
458  static char* SkipWhiteSpace( char* p ) {
459  while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) {
460  ++p;
461  }
462  return p;
463  }
464  static bool IsWhiteSpace( char p ) {
465  return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
466  }
467 
468  inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
469  int n = 0;
470  if ( p == q ) {
471  return true;
472  }
473  while( *p && *q && *p == *q && n<nChar ) {
474  ++p;
475  ++q;
476  ++n;
477  }
478  if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
479  return true;
480  }
481  return false;
482  }
483  inline static int IsUTF8Continuation( const char p ) {
484  return p & 0x80;
485  }
486  inline static int IsAlphaNum( unsigned char anyByte ) {
487  return ( anyByte < 128 ) ? isalnum( anyByte ) : 1;
488  }
489  inline static int IsAlpha( unsigned char anyByte ) {
490  return ( anyByte < 128 ) ? isalpha( anyByte ) : 1;
491  }
492 
493  static const char* ReadBOM( const char* p, bool* hasBOM );
494  // p is the starting location,
495  // the UTF-8 value of the entity will be placed in value, and length filled in.
496  static const char* GetCharacterRef( const char* p, char* value, int* length );
497  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
498 
499  // converts primitive types to strings
500  static void ToStr( int v, char* buffer, int bufferSize );
501  static void ToStr( unsigned v, char* buffer, int bufferSize );
502  static void ToStr( bool v, char* buffer, int bufferSize );
503  static void ToStr( float v, char* buffer, int bufferSize );
504  static void ToStr( double v, char* buffer, int bufferSize );
505 
506  // converts strings to primitive types
507  static bool ToInt( const char* str, int* value );
508  static bool ToUnsigned( const char* str, unsigned* value );
509  static bool ToBool( const char* str, bool* value );
510  static bool ToFloat( const char* str, float* value );
511  static bool ToDouble( const char* str, double* value );
512 };
513 
514 
540 class XMLNode
541 {
542  friend class XMLDocument;
543  friend class XMLElement;
544 public:
545 
547  const XMLDocument* GetDocument() const {
548  return _document;
549  }
552  return _document;
553  }
554 
556  virtual XMLElement* ToElement() {
557  return 0;
558  }
560  virtual XMLText* ToText() {
561  return 0;
562  }
564  virtual XMLComment* ToComment() {
565  return 0;
566  }
568  virtual XMLDocument* ToDocument() {
569  return 0;
570  }
573  return 0;
574  }
576  virtual XMLUnknown* ToUnknown() {
577  return 0;
578  }
579 
580  virtual const XMLElement* ToElement() const {
581  return 0;
582  }
583  virtual const XMLText* ToText() const {
584  return 0;
585  }
586  virtual const XMLComment* ToComment() const {
587  return 0;
588  }
589  virtual const XMLDocument* ToDocument() const {
590  return 0;
591  }
592  virtual const XMLDeclaration* ToDeclaration() const {
593  return 0;
594  }
595  virtual const XMLUnknown* ToUnknown() const {
596  return 0;
597  }
598 
608  const char* Value() const {
609  return _value.GetStr();
610  }
611 
615  void SetValue( const char* val, bool staticMem=false );
616 
618  const XMLNode* Parent() const {
619  return _parent;
620  }
621 
623  return _parent;
624  }
625 
627  bool NoChildren() const {
628  return !_firstChild;
629  }
630 
632  const XMLNode* FirstChild() const {
633  return _firstChild;
634  }
635 
637  return _firstChild;
638  }
639 
643  const XMLElement* FirstChildElement( const char* value=0 ) const;
644 
645  XMLElement* FirstChildElement( const char* value=0 ) {
646  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value ));
647  }
648 
650  const XMLNode* LastChild() const {
651  return _lastChild;
652  }
653 
655  return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
656  }
657 
661  const XMLElement* LastChildElement( const char* value=0 ) const;
662 
663  XMLElement* LastChildElement( const char* value=0 ) {
664  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) );
665  }
666 
668  const XMLNode* PreviousSibling() const {
669  return _prev;
670  }
671 
673  return _prev;
674  }
675 
677  const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
678 
679  XMLElement* PreviousSiblingElement( const char* value=0 ) {
680  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) );
681  }
682 
684  const XMLNode* NextSibling() const {
685  return _next;
686  }
687 
689  return _next;
690  }
691 
693  const XMLElement* NextSiblingElement( const char* value=0 ) const;
694 
695  XMLElement* NextSiblingElement( const char* value=0 ) {
696  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) );
697  }
698 
702  XMLNode* InsertEndChild( XMLNode* addThis );
703 
704  XMLNode* LinkEndChild( XMLNode* addThis ) {
705  return InsertEndChild( addThis );
706  }
710  XMLNode* InsertFirstChild( XMLNode* addThis );
714  XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
715 
719  void DeleteChildren();
720 
724  void DeleteChild( XMLNode* node );
725 
735  virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
736 
743  virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
744 
767  virtual bool Accept( XMLVisitor* visitor ) const = 0;
768 
769  // internal
770  virtual char* ParseDeep( char*, StrPair* );
771 
772 protected:
773  XMLNode( XMLDocument* );
774  virtual ~XMLNode();
775  XMLNode( const XMLNode& ); // not supported
776  XMLNode& operator=( const XMLNode& ); // not supported
777 
780  mutable StrPair _value;
781 
784 
787 
788 private:
790  void Unlink( XMLNode* child );
791 };
792 
793 
806 class XMLText : public XMLNode
807 {
808  friend class XMLBase;
809  friend class XMLDocument;
810 public:
811  virtual bool Accept( XMLVisitor* visitor ) const;
812 
813  virtual XMLText* ToText() {
814  return this;
815  }
816  virtual const XMLText* ToText() const {
817  return this;
818  }
819 
821  void SetCData( bool isCData ) {
822  _isCData = isCData;
823  }
825  bool CData() const {
826  return _isCData;
827  }
828 
829  char* ParseDeep( char*, StrPair* endTag );
830  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
831  virtual bool ShallowEqual( const XMLNode* compare ) const;
832 
833 protected:
834  XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
835  virtual ~XMLText() {}
836  XMLText( const XMLText& ); // not supported
837  XMLText& operator=( const XMLText& ); // not supported
838 
839 private:
840  bool _isCData;
841 };
842 
843 
845 class XMLComment : public XMLNode
846 {
847  friend class XMLDocument;
848 public:
849  virtual XMLComment* ToComment() {
850  return this;
851  }
852  virtual const XMLComment* ToComment() const {
853  return this;
854  }
855 
856  virtual bool Accept( XMLVisitor* visitor ) const;
857 
858  char* ParseDeep( char*, StrPair* endTag );
859  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
860  virtual bool ShallowEqual( const XMLNode* compare ) const;
861 
862 protected:
863  XMLComment( XMLDocument* doc );
864  virtual ~XMLComment();
865  XMLComment( const XMLComment& ); // not supported
866  XMLComment& operator=( const XMLComment& ); // not supported
867 
868 private:
869 };
870 
871 
883 class XMLDeclaration : public XMLNode
884 {
885  friend class XMLDocument;
886 public:
888  return this;
889  }
890  virtual const XMLDeclaration* ToDeclaration() const {
891  return this;
892  }
893 
894  virtual bool Accept( XMLVisitor* visitor ) const;
895 
896  char* ParseDeep( char*, StrPair* endTag );
897  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
898  virtual bool ShallowEqual( const XMLNode* compare ) const;
899 
900 protected:
901  XMLDeclaration( XMLDocument* doc );
902  virtual ~XMLDeclaration();
903  XMLDeclaration( const XMLDeclaration& ); // not supported
904  XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
905 };
906 
907 
915 class XMLUnknown : public XMLNode
916 {
917  friend class XMLDocument;
918 public:
919  virtual XMLUnknown* ToUnknown() {
920  return this;
921  }
922  virtual const XMLUnknown* ToUnknown() const {
923  return this;
924  }
925 
926  virtual bool Accept( XMLVisitor* visitor ) const;
927 
928  char* ParseDeep( char*, StrPair* endTag );
929  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
930  virtual bool ShallowEqual( const XMLNode* compare ) const;
931 
932 protected:
933  XMLUnknown( XMLDocument* doc );
934  virtual ~XMLUnknown();
935  XMLUnknown( const XMLUnknown& ); // not supported
936  XMLUnknown& operator=( const XMLUnknown& ); // not supported
937 };
938 
939 
940 enum XMLError {
943 
946 
962 
965 };
966 
967 
975 {
976  friend class XMLElement;
977 public:
979  const char* Name() const {
980  return _name.GetStr();
981  }
983  const char* Value() const {
984  return _value.GetStr();
985  }
987  const XMLAttribute* Next() const {
988  return _next;
989  }
990 
995  int IntValue() const {
996  int i=0;
997  QueryIntValue( &i );
998  return i;
999  }
1001  unsigned UnsignedValue() const {
1002  unsigned i=0;
1003  QueryUnsignedValue( &i );
1004  return i;
1005  }
1007  bool BoolValue() const {
1008  bool b=false;
1009  QueryBoolValue( &b );
1010  return b;
1011  }
1013  double DoubleValue() const {
1014  double d=0;
1015  QueryDoubleValue( &d );
1016  return d;
1017  }
1019  float FloatValue() const {
1020  float f=0;
1021  QueryFloatValue( &f );
1022  return f;
1023  }
1024 
1029  XMLError QueryIntValue( int* value ) const;
1031  XMLError QueryUnsignedValue( unsigned int* value ) const;
1033  XMLError QueryBoolValue( bool* value ) const;
1035  XMLError QueryDoubleValue( double* value ) const;
1037  XMLError QueryFloatValue( float* value ) const;
1038 
1040  void SetAttribute( const char* value );
1042  void SetAttribute( int value );
1044  void SetAttribute( unsigned value );
1046  void SetAttribute( bool value );
1048  void SetAttribute( double value );
1050  void SetAttribute( float value );
1051 
1052 private:
1053  enum { BUF_SIZE = 200 };
1054 
1055  XMLAttribute() : _next( 0 ) {}
1056  virtual ~XMLAttribute() {}
1057 
1058  XMLAttribute( const XMLAttribute& ); // not supported
1059  void operator=( const XMLAttribute& ); // not supported
1060  void SetName( const char* name );
1061 
1062  char* ParseDeep( char* p, bool processEntities );
1063 
1064  mutable StrPair _name;
1065  mutable StrPair _value;
1068 };
1069 
1070 
1075 class XMLElement : public XMLNode
1076 {
1077  friend class XMLBase;
1078  friend class XMLDocument;
1079 public:
1081  const char* Name() const {
1082  return Value();
1083  }
1085  void SetName( const char* str, bool staticMem=false ) {
1086  SetValue( str, staticMem );
1087  }
1088 
1089  virtual XMLElement* ToElement() {
1090  return this;
1091  }
1092  virtual const XMLElement* ToElement() const {
1093  return this;
1094  }
1095  virtual bool Accept( XMLVisitor* visitor ) const;
1096 
1120  const char* Attribute( const char* name, const char* value=0 ) const;
1121 
1127  int IntAttribute( const char* name ) const {
1128  int i=0;
1129  QueryIntAttribute( name, &i );
1130  return i;
1131  }
1133  unsigned UnsignedAttribute( const char* name ) const {
1134  unsigned i=0;
1135  QueryUnsignedAttribute( name, &i );
1136  return i;
1137  }
1139  bool BoolAttribute( const char* name ) const {
1140  bool b=false;
1141  QueryBoolAttribute( name, &b );
1142  return b;
1143  }
1145  double DoubleAttribute( const char* name ) const {
1146  double d=0;
1147  QueryDoubleAttribute( name, &d );
1148  return d;
1149  }
1151  float FloatAttribute( const char* name ) const {
1152  float f=0;
1153  QueryFloatAttribute( name, &f );
1154  return f;
1155  }
1156 
1170  XMLError QueryIntAttribute( const char* name, int* value ) const {
1171  const XMLAttribute* a = FindAttribute( name );
1172  if ( !a ) {
1173  return XML_NO_ATTRIBUTE;
1174  }
1175  return a->QueryIntValue( value );
1176  }
1178  XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
1179  const XMLAttribute* a = FindAttribute( name );
1180  if ( !a ) {
1181  return XML_NO_ATTRIBUTE;
1182  }
1183  return a->QueryUnsignedValue( value );
1184  }
1186  XMLError QueryBoolAttribute( const char* name, bool* value ) const {
1187  const XMLAttribute* a = FindAttribute( name );
1188  if ( !a ) {
1189  return XML_NO_ATTRIBUTE;
1190  }
1191  return a->QueryBoolValue( value );
1192  }
1194  XMLError QueryDoubleAttribute( const char* name, double* value ) const {
1195  const XMLAttribute* a = FindAttribute( name );
1196  if ( !a ) {
1197  return XML_NO_ATTRIBUTE;
1198  }
1199  return a->QueryDoubleValue( value );
1200  }
1202  XMLError QueryFloatAttribute( const char* name, float* value ) const {
1203  const XMLAttribute* a = FindAttribute( name );
1204  if ( !a ) {
1205  return XML_NO_ATTRIBUTE;
1206  }
1207  return a->QueryFloatValue( value );
1208  }
1209 
1211  void SetAttribute( const char* name, const char* value ) {
1212  XMLAttribute* a = FindOrCreateAttribute( name );
1213  a->SetAttribute( value );
1214  }
1216  void SetAttribute( const char* name, int value ) {
1217  XMLAttribute* a = FindOrCreateAttribute( name );
1218  a->SetAttribute( value );
1219  }
1221  void SetAttribute( const char* name, unsigned value ) {
1222  XMLAttribute* a = FindOrCreateAttribute( name );
1223  a->SetAttribute( value );
1224  }
1226  void SetAttribute( const char* name, bool value ) {
1227  XMLAttribute* a = FindOrCreateAttribute( name );
1228  a->SetAttribute( value );
1229  }
1231  void SetAttribute( const char* name, double value ) {
1232  XMLAttribute* a = FindOrCreateAttribute( name );
1233  a->SetAttribute( value );
1234  }
1235 
1239  void DeleteAttribute( const char* name );
1240 
1242  const XMLAttribute* FirstAttribute() const {
1243  return _rootAttribute;
1244  }
1246  const XMLAttribute* FindAttribute( const char* name ) const;
1247 
1276  const char* GetText() const;
1277 
1304  XMLError QueryIntText( int* ival ) const;
1306  XMLError QueryUnsignedText( unsigned* uval ) const;
1308  XMLError QueryBoolText( bool* bval ) const;
1310  XMLError QueryDoubleText( double* dval ) const;
1312  XMLError QueryFloatText( float* fval ) const;
1313 
1314  // internal:
1315  enum {
1316  OPEN, // <foo>
1317  CLOSED, // <foo/>
1318  CLOSING // </foo>
1319  };
1320  int ClosingType() const {
1321  return _closingType;
1322  }
1323  char* ParseDeep( char* p, StrPair* endTag );
1324  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1325  virtual bool ShallowEqual( const XMLNode* compare ) const;
1326 
1327 private:
1328  XMLElement( XMLDocument* doc );
1329  virtual ~XMLElement();
1330  XMLElement( const XMLElement& ); // not supported
1331  void operator=( const XMLElement& ); // not supported
1332 
1333  XMLAttribute* FindAttribute( const char* name );
1334  XMLAttribute* FindOrCreateAttribute( const char* name );
1335  //void LinkAttribute( XMLAttribute* attrib );
1336  char* ParseAttributes( char* p );
1337 
1339  // The attribute list is ordered; there is no 'lastAttribute'
1340  // because the list needs to be scanned for dupes before adding
1341  // a new attribute.
1343 };
1344 
1345 
1349 };
1350 
1351 
1357 class XMLDocument : public XMLNode
1358 {
1359  friend class XMLElement;
1360 public:
1362  XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
1363  ~XMLDocument();
1364 
1366  return this;
1367  }
1368  virtual const XMLDocument* ToDocument() const {
1369  return this;
1370  }
1371 
1382  XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
1383 
1389  XMLError LoadFile( const char* filename );
1390 
1398  XMLError LoadFile( FILE* );
1399 
1405  XMLError SaveFile( const char* filename, bool compact = false );
1406 
1414  XMLError SaveFile( FILE* fp, bool compact = false );
1415 
1416  bool ProcessEntities() const {
1417  return _processEntities;
1418  }
1420  return _whitespace;
1421  }
1422 
1426  bool HasBOM() const {
1427  return _writeBOM;
1428  }
1431  void SetBOM( bool useBOM ) {
1432  _writeBOM = useBOM;
1433  }
1434 
1439  return FirstChildElement();
1440  }
1441  const XMLElement* RootElement() const {
1442  return FirstChildElement();
1443  }
1444 
1459  void Print( XMLPrinter* streamer=0 );
1460  virtual bool Accept( XMLVisitor* visitor ) const;
1461 
1467  XMLElement* NewElement( const char* name );
1473  XMLComment* NewComment( const char* comment );
1479  XMLText* NewText( const char* text );
1491  XMLDeclaration* NewDeclaration( const char* text=0 );
1497  XMLUnknown* NewUnknown( const char* text );
1498 
1503  void DeleteNode( XMLNode* node ) {
1504  node->_parent->DeleteChild( node );
1505  }
1506 
1507  void SetError( XMLError error, const char* str1, const char* str2 );
1508 
1510  bool Error() const {
1511  return _errorID != XML_NO_ERROR;
1512  }
1514  XMLError ErrorID() const {
1515  return _errorID;
1516  }
1518  const char* GetErrorStr1() const {
1519  return _errorStr1;
1520  }
1522  const char* GetErrorStr2() const {
1523  return _errorStr2;
1524  }
1526  void PrintError() const;
1527 
1528  // internal
1529  char* Identify( char* p, XMLNode** node );
1530 
1531  virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
1532  return 0;
1533  }
1534  virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
1535  return false;
1536  }
1537 
1538 private:
1539  XMLDocument( const XMLDocument& ); // not supported
1540  void operator=( const XMLDocument& ); // not supported
1541  void InitDocument();
1542 
1547  const char* _errorStr1;
1548  const char* _errorStr2;
1550 
1555 };
1556 
1557 
1614 {
1615 public:
1617  XMLHandle( XMLNode* node ) {
1618  _node = node;
1619  }
1621  XMLHandle( XMLNode& node ) {
1622  _node = &node;
1623  }
1625  XMLHandle( const XMLHandle& ref ) {
1626  _node = ref._node;
1627  }
1629  XMLHandle& operator=( const XMLHandle& ref ) {
1630  _node = ref._node;
1631  return *this;
1632  }
1633 
1636  return XMLHandle( _node ? _node->FirstChild() : 0 );
1637  }
1639  XMLHandle FirstChildElement( const char* value=0 ) {
1640  return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
1641  }
1644  return XMLHandle( _node ? _node->LastChild() : 0 );
1645  }
1647  XMLHandle LastChildElement( const char* _value=0 ) {
1648  return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
1649  }
1652  return XMLHandle( _node ? _node->PreviousSibling() : 0 );
1653  }
1655  XMLHandle PreviousSiblingElement( const char* _value=0 ) {
1656  return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
1657  }
1660  return XMLHandle( _node ? _node->NextSibling() : 0 );
1661  }
1663  XMLHandle NextSiblingElement( const char* _value=0 ) {
1664  return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
1665  }
1666 
1669  return _node;
1670  }
1673  return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
1674  }
1677  return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
1678  }
1681  return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
1682  }
1685  return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
1686  }
1687 
1688 private:
1690 };
1691 
1692 
1698 {
1699 public:
1700  XMLConstHandle( const XMLNode* node ) {
1701  _node = node;
1702  }
1703  XMLConstHandle( const XMLNode& node ) {
1704  _node = &node;
1705  }
1707  _node = ref._node;
1708  }
1709 
1711  _node = ref._node;
1712  return *this;
1713  }
1714 
1715  const XMLConstHandle FirstChild() const {
1716  return XMLConstHandle( _node ? _node->FirstChild() : 0 );
1717  }
1718  const XMLConstHandle FirstChildElement( const char* value=0 ) const {
1719  return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
1720  }
1721  const XMLConstHandle LastChild() const {
1722  return XMLConstHandle( _node ? _node->LastChild() : 0 );
1723  }
1724  const XMLConstHandle LastChildElement( const char* _value=0 ) const {
1725  return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
1726  }
1728  return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
1729  }
1730  const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const {
1731  return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
1732  }
1733  const XMLConstHandle NextSibling() const {
1734  return XMLConstHandle( _node ? _node->NextSibling() : 0 );
1735  }
1736  const XMLConstHandle NextSiblingElement( const char* _value=0 ) const {
1737  return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
1738  }
1739 
1740 
1741  const XMLNode* ToNode() const {
1742  return _node;
1743  }
1744  const XMLElement* ToElement() const {
1745  return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
1746  }
1747  const XMLText* ToText() const {
1748  return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
1749  }
1750  const XMLUnknown* ToUnknown() const {
1751  return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
1752  }
1754  return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
1755  }
1756 
1757 private:
1758  const XMLNode* _node;
1759 };
1760 
1761 
1804 class XMLPrinter : public XMLVisitor
1805 {
1806 public:
1813  XMLPrinter( FILE* file=0, bool compact = false );
1815 
1817  void PushHeader( bool writeBOM, bool writeDeclaration );
1821  void OpenElement( const char* name );
1823  void PushAttribute( const char* name, const char* value );
1824  void PushAttribute( const char* name, int value );
1825  void PushAttribute( const char* name, unsigned value );
1826  void PushAttribute( const char* name, bool value );
1827  void PushAttribute( const char* name, double value );
1829  void CloseElement();
1830 
1832  void PushText( const char* text, bool cdata=false );
1834  void PushText( int value );
1836  void PushText( unsigned value );
1838  void PushText( bool value );
1840  void PushText( float value );
1842  void PushText( double value );
1843 
1845  void PushComment( const char* comment );
1846 
1847  void PushDeclaration( const char* value );
1848  void PushUnknown( const char* value );
1849 
1850  virtual bool VisitEnter( const XMLDocument& /*doc*/ );
1851  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
1852  return true;
1853  }
1854 
1855  virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
1856  virtual bool VisitExit( const XMLElement& element );
1857 
1858  virtual bool Visit( const XMLText& text );
1859  virtual bool Visit( const XMLComment& comment );
1860  virtual bool Visit( const XMLDeclaration& declaration );
1861  virtual bool Visit( const XMLUnknown& unknown );
1862 
1867  const char* CStr() const {
1868  return _buffer.Mem();
1869  }
1875  int CStrSize() const {
1876  return _buffer.Size();
1877  }
1878 
1879 private:
1880  void SealElement();
1881  void PrintSpace( int depth );
1882  void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
1883  void Print( const char* format, ... );
1884 
1887  FILE* _fp;
1888  int _depth;
1892 
1893  enum {
1895  BUF_SIZE = 200
1896  };
1899 
1902 #ifdef _MSC_VER
1903  DynArray< char, 20 > _accumulator;
1904 #endif
1905 };
1906 
1907 
1908 } // tinyxml2
1909 
1910 
1911 #endif // TINYXML2_INCLUDED
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1089
XMLText * NewText(const char *text)
Definition: tinyxml2.cpp:1557
double DoubleAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1145
virtual bool Visit(const XMLText &text)
Visit a text node.
Definition: tinyxml2.cpp:2074
XMLNode(XMLDocument *)
Definition: tinyxml2.cpp:585
T & operator[](int i)
Definition: tinyxml2.h:228
Whitespace _whitespace
Definition: tinyxml2.h:1546
void SetError(XMLError error, const char *str1, const char *str2)
Definition: tinyxml2.cpp:1706
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1753
void OpenElement(const char *name)
Definition: tinyxml2.cpp:1854
void CollapseWhitespace()
Definition: tinyxml2.cpp:156
const char * _errorStr1
Definition: tinyxml2.h:1547
bool BoolValue() const
Query as a boolean. See IntAttribute()
Definition: tinyxml2.h:1007
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1510
virtual ~XMLText()
Definition: tinyxml2.h:835
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:1715
static void ToStr(int v, char *buffer, int bufferSize)
Definition: tinyxml2.cpp:413
XMLAttribute * FindOrCreateAttribute(const char *name)
Definition: tinyxml2.cpp:1300
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:1721
XMLError QueryIntValue(int *value) const
Definition: tinyxml2.cpp:1081
const XMLText * ToText() const
Definition: tinyxml2.h:1747
virtual void Free(void *mem)
Definition: tinyxml2.h:337
static const int TIXML2_PATCH_VERSION
Definition: tinyxml2.h:103
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1178
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:592
T * PushArr(int count)
Definition: tinyxml2.h:208
XMLError Parse(const char *xml, size_t nBytes=(size_t)(-1))
Definition: tinyxml2.cpp:1668
static const char * GetCharacterRef(const char *p, char *value, int *length)
Definition: tinyxml2.cpp:335
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:568
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1617
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:586
virtual void * Alloc()
Definition: tinyxml2.h:314
const XMLNode * _node
Definition: tinyxml2.h:1758
virtual ~MemPool()
Definition: tinyxml2.h:283
XMLError LoadFile(const char *filename)
Definition: tinyxml2.cpp:1584
void PushComment(const char *comment)
Add a comment.
Definition: tinyxml2.cpp:2004
char * ParseDeep(char *p, StrPair *endTag)
Definition: tinyxml2.cpp:1407
XMLError QueryFloatValue(float *value) const
See QueryIntAttribute.
Definition: tinyxml2.cpp:1108
virtual ~XMLComment()
Definition: tinyxml2.cpp:914
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2.cpp:901
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.cpp:931
void PopArr(int count)
Definition: tinyxml2.h:219
XMLAttribute * _rootAttribute
Definition: tinyxml2.h:1342
MemPoolT< sizeof(XMLAttribute) > _attributePool
Definition: tinyxml2.h:1552
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:452
const T & operator[](int i) const
Definition: tinyxml2.h:233
int CurrentAllocs() const
Definition: tinyxml2.h:310
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1221
virtual ~XMLAttribute()
Definition: tinyxml2.h:1056
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
__BEGIN_NAMESPACE_STD void * memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n) __THROW __nonnull((1
static bool ToFloat(const char *str, float *value)
Definition: tinyxml2.cpp:478
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:564
char * ParseDeep(char *, StrPair *endTag)
Definition: tinyxml2.cpp:856
XMLNode * FirstChild()
Definition: tinyxml2.h:636
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:1710
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
Definition: tinyxml2.cpp:1260
virtual const XMLText * ToText() const
Definition: tinyxml2.h:583
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:417
XMLNode * _lastChild
Definition: tinyxml2.h:783
virtual ~XMLVisitor()
Definition: tinyxml2.h:405
void PushHeader(bool writeBOM, bool writeDeclaration)
Definition: tinyxml2.cpp:1842
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:825
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:143
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:372
void Unlink(XMLNode *child)
Definition: tinyxml2.cpp:626
void PushDeclaration(const char *value)
Definition: tinyxml2.cpp:2018
virtual void Free(void *)=0
void PrintError() const
If there is an error, print it to stdout.
Definition: tinyxml2.cpp:1714
int ClosingType() const
Definition: tinyxml2.h:1320
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:464
XMLHandle LastChildElement(const char *_value=0)
Get the last child element of this handle.
Definition: tinyxml2.h:1647
static const char * ReadBOM(const char *p, bool *hasBOM)
Definition: tinyxml2.cpp:272
char * ParseDeep(char *p, bool processEntities)
Definition: tinyxml2.cpp:1047
XMLNode * _next
Definition: tinyxml2.h:786
const XMLElement * RootElement() const
Definition: tinyxml2.h:1441
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:919
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:430
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
Definition: tinyxml2.cpp:1200
XMLComment & operator=(const XMLComment &)
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:632
XMLNode * _firstChild
Definition: tinyxml2.h:782
const char * Name() const
The name of the attribute.
Definition: tinyxml2.h:979
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1534
static char * SkipWhiteSpace(char *p)
Definition: tinyxml2.h:458
double DoubleValue() const
Query as a double. See IntAttribute()
Definition: tinyxml2.h:1013
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:1700
XMLNode * PreviousSibling()
Definition: tinyxml2.h:672
static bool ToBool(const char *str, bool *value)
Definition: tinyxml2.cpp:459
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:412
char * ParseName(char *in)
Definition: tinyxml2.cpp:131
virtual bool ShallowEqual(const XMLNode *compare) const =0
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:1703
void SetAttribute(const char *value)
Set the attribute to a string value.
Definition: tinyxml2.cpp:1126
virtual const XMLText * ToText() const
Definition: tinyxml2.h:816
int Capacity() const
Definition: tinyxml2.h:242
XMLText & operator=(const XMLText &)
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1202
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:595
XMLNode * _parent
Definition: tinyxml2.h:779
const XMLNode * ToNode() const
Definition: tinyxml2.h:1741
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:1727
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:813
MemPool * _memPool
Definition: tinyxml2.h:789
void Print(const char *format,...)
Definition: tinyxml2.cpp:1760
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:434
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2.cpp:895
int IntAttribute(const char *name) const
Definition: tinyxml2.h:1127
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:1643
XMLNode * Parent()
Definition: tinyxml2.h:622
const char * Value() const
The value of the attribute.
Definition: tinyxml2.h:983
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1531
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1211
virtual char * ParseDeep(char *, StrPair *)
Definition: tinyxml2.cpp:777
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
Definition: tinyxml2.cpp:1273
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition: tinyxml2.h:1522
static const int TIXML2_MINOR_VERSION
Definition: tinyxml2.h:102
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1750
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:1629
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:1733
void DeleteChildren()
Definition: tinyxml2.cpp:614
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1431
XMLElement * NewElement(const char *name)
Definition: tinyxml2.cpp:1539
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.cpp:884
XMLError QueryDoubleValue(double *value) const
See QueryIntAttribute.
Definition: tinyxml2.cpp:1117
bool ProcessEntities() const
Definition: tinyxml2.h:1416
DynArray< char, 20 > _buffer
Definition: tinyxml2.h:1901
const XMLConstHandle NextSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1736
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1514
XMLElement * RootElement()
Definition: tinyxml2.h:1438
char * ParseDeep(char *, StrPair *endTag)
Definition: tinyxml2.cpp:966
static bool ToInt(const char *str, int *value)
Definition: tinyxml2.cpp:443
void SetName(const char *name)
Definition: tinyxml2.cpp:1075
XMLError SaveFile(const char *filename, bool compact=false)
Definition: tinyxml2.cpp:1641
static bool ToUnsigned(const char *str, unsigned *value)
Definition: tinyxml2.cpp:451
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:618
void PushText(const char *text, bool cdata=false)
Add a text node.
Definition: tinyxml2.cpp:1947
XMLAttribute * _next
Definition: tinyxml2.h:1066
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:987
void operator=(const XMLAttribute &)
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1194
const XMLElement * LastChildElement(const char *value=0) const
Definition: tinyxml2.cpp:739
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1085
virtual int ItemSize() const
Definition: tinyxml2.h:307
XMLComment * NewComment(const char *comment)
Definition: tinyxml2.cpp:1548
const XMLElement * FirstChildElement(const char *value=0) const
Definition: tinyxml2.cpp:725
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1231
int IntValue() const
Definition: tinyxml2.h:995
static const int TIXML2_MAJOR_VERSION
Definition: tinyxml2.h:101
XMLPrinter(FILE *file=0, bool compact=false)
Definition: tinyxml2.cpp:1734
const char * Value() const
Definition: tinyxml2.h:608
XMLDeclaration & operator=(const XMLDeclaration &)
StrPair _value
Definition: tinyxml2.h:780
void DeleteNode(XMLNode *node)
Definition: tinyxml2.h:1503
virtual void SetTracked()=0
const char * Attribute(const char *name, const char *value=0) const
Definition: tinyxml2.cpp:1212
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.cpp:2046
static bool ToDouble(const char *str, double *value)
Definition: tinyxml2.cpp:486
XMLComment(XMLDocument *doc)
Definition: tinyxml2.cpp:909
MemPoolT< sizeof(XMLComment) > _commentPool
Definition: tinyxml2.h:1554
virtual void * Alloc()=0
XMLHandle NextSiblingElement(const char *_value=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:1663
const char * GetText() const
Definition: tinyxml2.cpp:1225
XMLError QueryIntText(int *ival) const
Definition: tinyxml2.cpp:1234
bool BoolAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1139
const char * GetStr()
Definition: tinyxml2.cpp:183
const XMLConstHandle LastChildElement(const char *_value=0) const
Definition: tinyxml2.h:1724
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:1851
void SetStr(const char *str, int flags=0)
Definition: tinyxml2.cpp:100
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:1621
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.cpp:978
char * ParseDeep(char *, StrPair *endTag)
Definition: tinyxml2.cpp:919
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:821
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2.cpp:1041
XMLDeclaration(XMLDocument *doc)
Definition: tinyxml2.cpp:955
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:551
XMLUnknown & operator=(const XMLUnknown &)
XMLNode * InsertFirstChild(XMLNode *addThis)
Definition: tinyxml2.cpp:677
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:547
XMLElement(XMLDocument *doc)
Definition: tinyxml2.cpp:1171
char * ParseAttributes(char *p)
Definition: tinyxml2.cpp:1346
void operator=(const XMLElement &)
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:887
XMLDocument(bool processEntities=true, Whitespace=PRESERVE_WHITESPACE)
constructor
Definition: tinyxml2.cpp:1491
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:576
char * Identify(char *p, XMLNode **node)
Definition: tinyxml2.cpp:495
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:468
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2.cpp:1035
int Untracked() const
Definition: tinyxml2.h:358
const char * _errorStr2
Definition: tinyxml2.h:1548
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1133
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:421
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.cpp:1025
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1092
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:438
void operator=(const XMLDocument &)
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:1706
#define TIXML_SNPRINTF
Definition: tinyxml2.h:97
XMLError QueryFloatText(float *fval) const
See QueryIntText()
Definition: tinyxml2.cpp:1286
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:668
void SetValue(const char *val, bool staticMem=false)
Definition: tinyxml2.cpp:603
void CloseElement()
If streaming, close the Element.
Definition: tinyxml2.cpp:1914
const XMLConstHandle FirstChildElement(const char *value=0) const
Definition: tinyxml2.h:1718
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:890
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:704
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
Definition: tinyxml2.cpp:1247
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1226
void PushUnknown(const char *value)
Definition: tinyxml2.cpp:2032
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition: tinyxml2.h:1518
static int IsAlphaNum(unsigned char anyByte)
Definition: tinyxml2.h:486
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2.cpp:995
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
Definition: tinyxml2.cpp:1873
virtual ~XMLNode()
Definition: tinyxml2.cpp:594
friend class XMLBase
Definition: tinyxml2.h:1077
const XMLElement * NextSiblingElement(const char *value=0) const
Get the next (right) sibling element of this node, with an opitionally supplied name.
Definition: tinyxml2.cpp:753
#define TIXMLASSERT(x)
Definition: tinyxml2.h:72
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:1900
XMLNode * NextSibling()
Definition: tinyxml2.h:688
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1170
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
Definition: tinyxml2.cpp:287
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1668
void Trace(const char *name)
Definition: tinyxml2.h:349
void DeleteAttribute(const char *name)
Definition: tinyxml2.cpp:1327
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1659
void PrintString(const char *, bool restrictedEntitySet)
Definition: tinyxml2.cpp:1804
unsigned UnsignedValue() const
Query as an unsigned integer. See IntAttribute()
Definition: tinyxml2.h:1001
friend class XMLBase
Definition: tinyxml2.h:808
int Size() const
Definition: tinyxml2.h:238
XMLUnknown(XMLDocument *doc)
Definition: tinyxml2.cpp:1002
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntAttribute.
Definition: tinyxml2.cpp:1090
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:834
__BEGIN_NAMESPACE_STD void void __END_NAMESPACE_STD void __BEGIN_NAMESPACE_STD void * memset(void *__s, int __c, size_t __n) __THROW __nonnull((1))
const XMLElement * ToElement() const
Definition: tinyxml2.h:1744
virtual bool Accept(XMLVisitor *visitor) const =0
void DeleteChild(XMLNode *node)
Definition: tinyxml2.cpp:646
XMLDocument * _document
Definition: tinyxml2.h:778
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:560
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1216
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.cpp:1439
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1186
bool HasBOM() const
Definition: tinyxml2.h:1426
void EnsureCapacity(int cap)
Definition: tinyxml2.h:255
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:1676
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2.cpp:570
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:650
static int IsUTF8Continuation(const char p)
Definition: tinyxml2.h:483
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2.cpp:947
void PrintSpace(int depth)
Definition: tinyxml2.cpp:1796
const T * Mem() const
Definition: tinyxml2.h:246
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2.cpp:941
XMLNode * LastChild()
Definition: tinyxml2.h:654
XMLUnknown * NewUnknown(const char *text)
Definition: tinyxml2.cpp:1575
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:1651
MemPoolT< sizeof(XMLText) > _textPool
Definition: tinyxml2.h:1553
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:1684
char * ParseDeep(char *, StrPair *endTag)
Definition: tinyxml2.cpp:1012
XMLDeclaration * NewDeclaration(const char *text=0)
Definition: tinyxml2.cpp:1566
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:627
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:589
int CStrSize() const
Definition: tinyxml2.h:1875
MemPoolT< sizeof(XMLElement) > _elementPool
Definition: tinyxml2.h:1551
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1242
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:1680
const XMLConstHandle PreviousSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1730
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1635
XMLElement * FirstChildElement(const char *value=0)
Definition: tinyxml2.h:645
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2.cpp:988
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:922
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1672
XMLNode & operator=(const XMLNode &)
float FloatAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1151
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:426
bool Empty() const
Definition: tinyxml2.h:224
void Push(T t)
Definition: tinyxml2.h:203
bool _restrictedEntityFlag[ENTITY_RANGE]
Definition: tinyxml2.h:1898
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:408
XMLNode * _prev
Definition: tinyxml2.h:785
XMLElement * NextSiblingElement(const char *value=0)
Definition: tinyxml2.h:695
XMLElement * LastChildElement(const char *value=0)
Definition: tinyxml2.h:663
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:580
void Print(XMLPrinter *streamer=0)
Definition: tinyxml2.cpp:1696
char * ParseText(char *in, const char *endTag, int strFlags)
Definition: tinyxml2.cpp:111
XMLError QueryBoolValue(bool *value) const
See QueryIntAttribute.
Definition: tinyxml2.cpp:1099
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1365
virtual int ItemSize() const =0
const XMLElement * PreviousSiblingElement(const char *value=0) const
Get the previous (left) sibling element of this node, with an opitionally supplied name...
Definition: tinyxml2.cpp:765
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1419
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
Definition: tinyxml2.cpp:702
float FloatValue() const
Query as a float. See IntAttribute()
Definition: tinyxml2.h:1019
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:572
XMLHandle PreviousSiblingElement(const char *_value=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:1655
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:556
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:849
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2.cpp:1477
XMLNode * InsertEndChild(XMLNode *addThis)
Definition: tinyxml2.cpp:653
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:852
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:684
bool _entityFlag[ENTITY_RANGE]
Definition: tinyxml2.h:1897
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1625
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1368
XMLElement * PreviousSiblingElement(const char *value=0)
Definition: tinyxml2.h:679
static int IsAlpha(unsigned char anyByte)
Definition: tinyxml2.h:489
bool Empty() const
Definition: tinyxml2.h:152
const char * CStr() const
Definition: tinyxml2.h:1867
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1081
XMLHandle FirstChildElement(const char *value=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1639
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2.cpp:1452
void SetInternedStr(const char *str)
Definition: tinyxml2.h:156