antioch-0.4.0
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 #ifdef ANDROID_NDK
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: g++ -Wall tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
48 */
49 
50 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
51  #ifndef DEBUG
52  #define DEBUG
53  #endif
54 #endif
55 
56 
57 #if defined(DEBUG)
58  #if defined(_MSC_VER)
59  #define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
60  #elif defined (ANDROID_NDK)
61  #include <android/log.h>
62  #define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
63  #else
64  #include <assert.h>
65  #define TIXMLASSERT assert
66  #endif
67 #else
68  #define TIXMLASSERT( x ) {}
69 #endif
70 
71 
72 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
73  // Microsoft visual studio, version 2005 and higher.
74  /*int _snprintf_s(
75  char *buffer,
76  size_t sizeOfBuffer,
77  size_t count,
78  const char *format [,
79  argument] ...
80  );*/
81  inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) {
82  va_list va;
83  va_start( va, format );
84  int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
85  va_end( va );
86  return result;
87  }
88  #define TIXML_SSCANF sscanf_s
89 #else
90  // GCC version 3 and higher
91  //#warning( "Using sn* functions." )
92  #define TIXML_SNPRINTF snprintf
93  #define TIXML_SSCANF sscanf
94 #endif
95 
96 static const int TIXML2_MAJOR_VERSION = 1;
97 static const int TIXML2_MINOR_VERSION = 0;
98 static const int TIXML2_PATCH_VERSION = 8;
99 
100 namespace tinyxml2
101 {
102 class XMLDocument;
103 class XMLElement;
104 class XMLAttribute;
105 class XMLComment;
106 class XMLNode;
107 class XMLText;
108 class XMLDeclaration;
109 class XMLUnknown;
110 
111 class XMLPrinter;
112 
113 /*
114  A class that wraps strings. Normally stores the start and end
115  pointers into the XML file itself, and will apply normalization
116  and entity translation if actually read. Can also store (and memory
117  manage) a traditional char[]
118 */
119 class StrPair
120 {
121 public:
122  enum {
126 
133  };
134 
135  StrPair() : flags( 0 ), start( 0 ), end( 0 ) {}
136  ~StrPair();
137 
138  void Set( char* _start, char* _end, int _flags ) {
139  Reset();
140  this->start = _start; this->end = _end; this->flags = _flags | NEEDS_FLUSH;
141  }
142  const char* GetStr();
143  bool Empty() const { return start == end; }
144 
145  void SetInternedStr( const char* str ) { Reset(); this->start = const_cast<char*>(str); }
146  void SetStr( const char* str, int flags=0 );
147 
148  char* ParseText( char* in, const char* endTag, int strFlags );
149  char* ParseName( char* in );
150 
151 
152 private:
153  void Reset();
154  void CollapseWhitespace();
155 
156  enum {
157  NEEDS_FLUSH = 0x100,
158  NEEDS_DELETE = 0x200
159  };
160 
161  // After parsing, if *end != 0, it can be set to zero.
162  int flags;
163  char* start;
164  char* end;
165 };
166 
167 
168 /*
169  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
170  Has a small initial memory pool, so that low or no usage will not
171  cause a call to new/delete
172 */
173 template <class T, int INIT>
174 class DynArray
175 {
176 public:
178  {
179  mem = pool;
180  allocated = INIT;
181  size = 0;
182  }
184  {
185  if ( mem != pool ) {
186  delete [] mem;
187  }
188  }
189  void Push( T t )
190  {
191  EnsureCapacity( size+1 );
192  mem[size++] = t;
193  }
194 
195  T* PushArr( int count )
196  {
197  EnsureCapacity( size+count );
198  T* ret = &mem[size];
199  size += count;
200  return ret;
201  }
202  T Pop() {
203  return mem[--size];
204  }
205  void PopArr( int count )
206  {
207  TIXMLASSERT( size >= count );
208  size -= count;
209  }
210 
211  bool Empty() const { return size == 0; }
212  T& operator[](int i) { TIXMLASSERT( i>= 0 && i < size ); return mem[i]; }
213  const T& operator[](int i) const { TIXMLASSERT( i>= 0 && i < size ); return mem[i]; }
214  int Size() const { return size; }
215  int Capacity() const { return allocated; }
216  const T* Mem() const { return mem; }
217  T* Mem() { return mem; }
218 
219 
220 private:
221  void EnsureCapacity( int cap ) {
222  if ( cap > allocated ) {
223  int newAllocated = cap * 2;
224  T* newMem = new T[newAllocated];
225  memcpy( newMem, mem, sizeof(T)*size ); // warning: not using constructors, only works for PODs
226  if ( mem != pool ) delete [] mem;
227  mem = newMem;
228  allocated = newAllocated;
229  }
230  }
231 
232  T* mem;
233  T pool[INIT];
234  int allocated; // objects allocated
235  int size; // number objects in use
236 };
237 
238 
239 /*
240  Parent virtual class of a pool for fast allocation
241  and deallocation of objects.
242 */
243 class MemPool
244 {
245 public:
246  MemPool() {}
247  virtual ~MemPool() {}
248 
249  virtual int ItemSize() const = 0;
250  virtual void* Alloc() = 0;
251  virtual void Free( void* ) = 0;
252 };
253 
254 
255 /*
256  Template child class to create pools of the correct type.
257 */
258 template< int SIZE >
259 class MemPoolT : public MemPool
260 {
261 public:
264  // Delete the blocks.
265  for( int i=0; i<blockPtrs.Size(); ++i ) {
266  delete blockPtrs[i];
267  }
268  }
269 
270  virtual int ItemSize() const { return SIZE; }
271  int CurrentAllocs() const { return currentAllocs; }
272 
273  virtual void* Alloc() {
274  if ( !root ) {
275  // Need a new block.
276  Block* block = new Block();
277  blockPtrs.Push( block );
278 
279  for( int i=0; i<COUNT-1; ++i ) {
280  block->chunk[i].next = &block->chunk[i+1];
281  }
282  block->chunk[COUNT-1].next = 0;
283  root = block->chunk;
284  }
285  void* result = root;
286  root = root->next;
287 
288  ++currentAllocs;
290  nAllocs++;
291  return result;
292  }
293  virtual void Free( void* mem ) {
294  if ( !mem ) return;
295  --currentAllocs;
296  Chunk* chunk = (Chunk*)mem;
297 #ifdef DEBUG
298  memset( chunk, 0xfe, sizeof(Chunk) );
299 #endif
300  chunk->next = root;
301  root = chunk;
302  }
303  void Trace( const char* name ) {
304  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
305  name, maxAllocs, maxAllocs*SIZE/1024, currentAllocs, SIZE, nAllocs, blockPtrs.Size() );
306  }
307 
308 private:
309  enum { COUNT = 1024/SIZE };
310  union Chunk {
312  char mem[SIZE];
313  };
314  struct Block {
316  };
318  Chunk* root;
319 
321  int nAllocs;
323 };
324 
325 
326 
347 {
348 public:
349  virtual ~XMLVisitor() {}
350 
352  virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { return true; }
354  virtual bool VisitExit( const XMLDocument& /*doc*/ ) { return true; }
355 
357  virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { return true; }
359  virtual bool VisitExit( const XMLElement& /*element*/ ) { return true; }
360 
362  virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { return true; }
364  virtual bool Visit( const XMLText& /*text*/ ) { return true; }
366  virtual bool Visit( const XMLComment& /*comment*/ ) { return true; }
368  virtual bool Visit( const XMLUnknown& /*unknown*/ ) { return true; }
369 };
370 
371 
372 /*
373  Utility functionality.
374 */
375 class XMLUtil
376 {
377 public:
378  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
379  // correct, but simple, and usually works.
380  static const char* SkipWhiteSpace( const char* p ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) { ++p; } return p; }
381  static char* SkipWhiteSpace( char* p ) { while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) { ++p; } return p; }
382  static bool IsWhiteSpace( char p ) { return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) ); }
383 
384  inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
385  int n = 0;
386  if ( p == q ) {
387  return true;
388  }
389  while( *p && *q && *p == *q && n<nChar ) {
390  ++p; ++q; ++n;
391  }
392  if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
393  return true;
394  }
395  return false;
396  }
397  inline static int IsUTF8Continuation( const char p ) { return p & 0x80; }
398  inline static int IsAlphaNum( unsigned char anyByte ) { return ( anyByte < 128 ) ? isalnum( anyByte ) : 1; }
399  inline static int IsAlpha( unsigned char anyByte ) { return ( anyByte < 128 ) ? isalpha( anyByte ) : 1; }
400 
401  static const char* ReadBOM( const char* p, bool* hasBOM );
402  // p is the starting location,
403  // the UTF-8 value of the entity will be placed in value, and length filled in.
404  static const char* GetCharacterRef( const char* p, char* value, int* length );
405  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
406 
407  // converts primitive types to strings
408  static void ToStr( int v, char* buffer, int bufferSize );
409  static void ToStr( unsigned v, char* buffer, int bufferSize );
410  static void ToStr( bool v, char* buffer, int bufferSize );
411  static void ToStr( float v, char* buffer, int bufferSize );
412  static void ToStr( double v, char* buffer, int bufferSize );
413 
414  // converts strings to primitive types
415  static bool ToInt( const char* str, int* value );
416  static bool ToUnsigned( const char* str, unsigned* value );
417  static bool ToBool( const char* str, bool* value );
418  static bool ToFloat( const char* str, float* value );
419  static bool ToDouble( const char* str, double* value );
420 };
421 
422 
448 class XMLNode
449 {
450  friend class XMLDocument;
451  friend class XMLElement;
452 public:
453 
455  const XMLDocument* GetDocument() const { return document; }
458 
459  virtual XMLElement* ToElement() { return 0; }
460  virtual XMLText* ToText() { return 0; }
461  virtual XMLComment* ToComment() { return 0; }
462  virtual XMLDocument* ToDocument() { return 0; }
463  virtual XMLDeclaration* ToDeclaration() { return 0; }
464  virtual XMLUnknown* ToUnknown() { return 0; }
465 
466  virtual const XMLElement* ToElement() const { return 0; }
467  virtual const XMLText* ToText() const { return 0; }
468  virtual const XMLComment* ToComment() const { return 0; }
469  virtual const XMLDocument* ToDocument() const { return 0; }
470  virtual const XMLDeclaration* ToDeclaration() const { return 0; }
471  virtual const XMLUnknown* ToUnknown() const { return 0; }
472 
482  const char* Value() const { return value.GetStr(); }
486  void SetValue( const char* val, bool staticMem=false );
487 
489  const XMLNode* Parent() const { return parent; }
490  XMLNode* Parent() { return parent; }
491 
493  bool NoChildren() const { return !firstChild; }
494 
496  const XMLNode* FirstChild() const { return firstChild; }
501  const XMLElement* FirstChildElement( const char* value=0 ) const;
502  XMLElement* FirstChildElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( _value )); }
503 
505  const XMLNode* LastChild() const { return lastChild; }
506  XMLNode* LastChild() { return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() ); }
507 
511  const XMLElement* LastChildElement( const char* value=0 ) const;
512  XMLElement* LastChildElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(_value) ); }
513 
515  const XMLNode* PreviousSibling() const { return prev; }
516  XMLNode* PreviousSibling() { return prev; }
517 
519  const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
520  XMLElement* PreviousSiblingElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( _value ) ); }
521 
523  const XMLNode* NextSibling() const { return next; }
524  XMLNode* NextSibling() { return next; }
525 
527  const XMLElement* NextSiblingElement( const char* value=0 ) const;
528  XMLElement* NextSiblingElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( _value ) ); }
529 
533  XMLNode* InsertEndChild( XMLNode* addThis );
534 
535  XMLNode* LinkEndChild( XMLNode* addThis ) { return InsertEndChild( addThis ); }
539  XMLNode* InsertFirstChild( XMLNode* addThis );
543  XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
544 
548  void DeleteChildren();
549 
553  void DeleteChild( XMLNode* node );
554 
564  virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
565 
572  virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
573 
596  virtual bool Accept( XMLVisitor* visitor ) const = 0;
597 
598  // internal
599  virtual char* ParseDeep( char*, StrPair* );
600 
601 protected:
602  XMLNode( XMLDocument* );
603  virtual ~XMLNode();
604  XMLNode( const XMLNode& ); // not supported
605  XMLNode& operator=( const XMLNode& ); // not supported
606 
609  mutable StrPair value;
610 
613 
616 
617 private:
619  void Unlink( XMLNode* child );
620 };
621 
622 
635 class XMLText : public XMLNode
636 {
637  friend class XMLBase;
638  friend class XMLDocument;
639 public:
640  virtual bool Accept( XMLVisitor* visitor ) const;
641 
642  virtual XMLText* ToText() { return this; }
643  virtual const XMLText* ToText() const { return this; }
644 
646  void SetCData( bool _isCData ) { this->isCData = _isCData; }
648  bool CData() const { return isCData; }
649 
650  char* ParseDeep( char*, StrPair* endTag );
651  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
652  virtual bool ShallowEqual( const XMLNode* compare ) const;
653 
654 
655 protected:
656  XMLText( XMLDocument* doc ) : XMLNode( doc ), isCData( false ) {}
657  virtual ~XMLText() {}
658  XMLText( const XMLText& ); // not supported
659  XMLText& operator=( const XMLText& ); // not supported
660 
661 private:
662  bool isCData;
663 };
664 
665 
667 class XMLComment : public XMLNode
668 {
669  friend class XMLDocument;
670 public:
671  virtual XMLComment* ToComment() { return this; }
672  virtual const XMLComment* ToComment() const { return this; }
673 
674  virtual bool Accept( XMLVisitor* visitor ) const;
675 
676  char* ParseDeep( char*, StrPair* endTag );
677  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
678  virtual bool ShallowEqual( const XMLNode* compare ) const;
679 
680 protected:
681  XMLComment( XMLDocument* doc );
682  virtual ~XMLComment();
683  XMLComment( const XMLComment& ); // not supported
684  XMLComment& operator=( const XMLComment& ); // not supported
685 
686 private:
687 };
688 
689 
701 class XMLDeclaration : public XMLNode
702 {
703  friend class XMLDocument;
704 public:
705  virtual XMLDeclaration* ToDeclaration() { return this; }
706  virtual const XMLDeclaration* ToDeclaration() const { return this; }
707 
708  virtual bool Accept( XMLVisitor* visitor ) const;
709 
710  char* ParseDeep( char*, StrPair* endTag );
711  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
712  virtual bool ShallowEqual( const XMLNode* compare ) const;
713 
714 protected:
715  XMLDeclaration( XMLDocument* doc );
716  virtual ~XMLDeclaration();
717  XMLDeclaration( const XMLDeclaration& ); // not supported
718  XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
719 };
720 
721 
729 class XMLUnknown : public XMLNode
730 {
731  friend class XMLDocument;
732 public:
733  virtual XMLUnknown* ToUnknown() { return this; }
734  virtual const XMLUnknown* ToUnknown() const { return this; }
735 
736  virtual bool Accept( XMLVisitor* visitor ) const;
737 
738  char* ParseDeep( char*, StrPair* endTag );
739  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
740  virtual bool ShallowEqual( const XMLNode* compare ) const;
741 
742 protected:
743  XMLUnknown( XMLDocument* doc );
744  virtual ~XMLUnknown();
745  XMLUnknown( const XMLUnknown& ); // not supported
746  XMLUnknown& operator=( const XMLUnknown& ); // not supported
747 };
748 
749 
750 enum {
753 
756 
772 
775 };
776 
777 
785 {
786  friend class XMLElement;
787 public:
788  const char* Name() const { return name.GetStr(); }
789  const char* Value() const { return value.GetStr(); }
790  const XMLAttribute* Next() const { return next; }
791 
796  int IntValue() const { int i=0; QueryIntValue( &i ); return i; }
798  unsigned UnsignedValue() const { unsigned i=0; QueryUnsignedValue( &i ); return i; }
800  bool BoolValue() const { bool b=false; QueryBoolValue( &b ); return b; }
802  double DoubleValue() const { double d=0; QueryDoubleValue( &d ); return d; }
804  float FloatValue() const { float f=0; QueryFloatValue( &f ); return f; }
805 
810  int QueryIntValue( int* value ) const;
812  int QueryUnsignedValue( unsigned int* value ) const;
814  int QueryBoolValue( bool* value ) const;
816  int QueryDoubleValue( double* value ) const;
818  int QueryFloatValue( float* value ) const;
819 
821  void SetAttribute( const char* value );
823  void SetAttribute( int value );
825  void SetAttribute( unsigned value );
827  void SetAttribute( bool value );
829  void SetAttribute( double value );
831  void SetAttribute( float value );
832 
833 private:
834  enum { BUF_SIZE = 200 };
835 
836  XMLAttribute() : next( 0 ) {}
837  virtual ~XMLAttribute() {}
838  XMLAttribute( const XMLAttribute& ); // not supported
839  void operator=( const XMLAttribute& ); // not supported
840  void SetName( const char* name );
841 
842  char* ParseDeep( char* p, bool processEntities );
843 
844  mutable StrPair name;
845  mutable StrPair value;
848 };
849 
850 
855 class XMLElement : public XMLNode
856 {
857  friend class XMLBase;
858  friend class XMLDocument;
859 public:
861  const char* Name() const { return Value(); }
863  void SetName( const char* str, bool staticMem=false ) { SetValue( str, staticMem ); }
864 
865  virtual XMLElement* ToElement() { return this; }
866  virtual const XMLElement* ToElement() const { return this; }
867  virtual bool Accept( XMLVisitor* visitor ) const;
868 
892  const char* Attribute( const char* name, const char* value=0 ) const;
893 
899  int IntAttribute( const char* name ) const { int i=0; QueryIntAttribute( name, &i ); return i; }
901  unsigned UnsignedAttribute( const char* name ) const{ unsigned i=0; QueryUnsignedAttribute( name, &i ); return i; }
903  bool BoolAttribute( const char* name ) const { bool b=false; QueryBoolAttribute( name, &b ); return b; }
905  double DoubleAttribute( const char* name ) const { double d=0; QueryDoubleAttribute( name, &d ); return d; }
907  float FloatAttribute( const char* name ) const { float f=0; QueryFloatAttribute( name, &f ); return f; }
908 
922  int QueryIntAttribute( const char* name, int* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryIntValue( _value ); }
924  int QueryUnsignedAttribute( const char* name, unsigned int* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryUnsignedValue( _value ); }
926  int QueryBoolAttribute( const char* name, bool* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryBoolValue( _value ); }
928  int QueryDoubleAttribute( const char* name, double* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryDoubleValue( _value ); }
930  int QueryFloatAttribute( const char* name, float* _value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryFloatValue( _value ); }
931 
933  void SetAttribute( const char* name, const char* _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
935  void SetAttribute( const char* name, int _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
937  void SetAttribute( const char* name, unsigned _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
939  void SetAttribute( const char* name, bool _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
941  void SetAttribute( const char* name, double _value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( _value ); }
942 
946  void DeleteAttribute( const char* name );
947 
949  const XMLAttribute* FirstAttribute() const { return rootAttribute; }
951  const XMLAttribute* FindAttribute( const char* name ) const;
952 
981  const char* GetText() const;
982 
1009  int QueryIntText( int* _value ) const;
1011  int QueryUnsignedText( unsigned* _value ) const;
1013  int QueryBoolText( bool* _value ) const;
1015  int QueryDoubleText( double* _value ) const;
1017  int QueryFloatText( float* _value ) const;
1018 
1019  // internal:
1020  enum {
1021  OPEN, // <foo>
1022  CLOSED, // <foo/>
1023  CLOSING // </foo>
1024  };
1025  int ClosingType() const { return closingType; }
1026  char* ParseDeep( char* p, StrPair* endTag );
1027  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1028  virtual bool ShallowEqual( const XMLNode* compare ) const;
1029 
1030 private:
1031  XMLElement( XMLDocument* doc );
1032  virtual ~XMLElement();
1033  XMLElement( const XMLElement& ); // not supported
1034  void operator=( const XMLElement& ); // not supported
1035 
1036  XMLAttribute* FindAttribute( const char* name );
1037  XMLAttribute* FindOrCreateAttribute( const char* name );
1038  //void LinkAttribute( XMLAttribute* attrib );
1039  char* ParseAttributes( char* p );
1040 
1042  // The attribute list is ordered; there is no 'lastAttribute'
1043  // because the list needs to be scanned for dupes before adding
1044  // a new attribute.
1046 };
1047 
1048 
1052 };
1053 
1054 
1060 class XMLDocument : public XMLNode
1061 {
1062  friend class XMLElement;
1063 public:
1066  ~XMLDocument();
1067 
1068  virtual XMLDocument* ToDocument() { return this; }
1069  virtual const XMLDocument* ToDocument() const { return this; }
1070 
1081  int Parse( const char* xml, size_t nBytes=(size_t)(-1) );
1082 
1088  int LoadFile( const char* filename );
1089 
1097  int LoadFile( FILE* );
1098 
1104  int SaveFile( const char* filename, bool compact = false );
1105 
1113  int SaveFile( FILE* fp, bool compact = false );
1114 
1115  bool ProcessEntities() const { return processEntities; }
1117 
1121  bool HasBOM() const { return writeBOM; }
1124  void SetBOM( bool useBOM ) { writeBOM = useBOM; }
1125 
1130  const XMLElement* RootElement() const { return FirstChildElement(); }
1131 
1146  void Print( XMLPrinter* streamer=0 );
1147  virtual bool Accept( XMLVisitor* visitor ) const;
1148 
1154  XMLElement* NewElement( const char* name );
1160  XMLComment* NewComment( const char* comment );
1166  XMLText* NewText( const char* text );
1178  XMLDeclaration* NewDeclaration( const char* text=0 );
1184  XMLUnknown* NewUnknown( const char* text );
1185 
1190  void DeleteNode( XMLNode* node ) { node->parent->DeleteChild( node ); }
1191 
1192  void SetError( int error, const char* str1, const char* str2 );
1193 
1195  bool Error() const { return errorID != XML_NO_ERROR; }
1197  int ErrorID() const { return errorID; }
1199  const char* GetErrorStr1() const { return errorStr1; }
1201  const char* GetErrorStr2() const { return errorStr2; }
1203  void PrintError() const;
1204 
1205  // internal
1206  char* Identify( char* p, XMLNode** node );
1207 
1208  virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { return 0; }
1209  virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { return false; }
1210 
1211 private:
1212  XMLDocument( const XMLDocument& ); // not supported
1213  void operator=( const XMLDocument& ); // not supported
1214  void InitDocument();
1215 
1216  bool writeBOM;
1218  int errorID;
1220  const char* errorStr1;
1221  const char* errorStr2;
1222  char* charBuffer;
1223 
1228 };
1229 
1230 
1287 {
1288 public:
1290  XMLHandle( XMLNode* _node ) { node = _node; }
1292  XMLHandle( XMLNode& _node ) { node = &_node; }
1294  XMLHandle( const XMLHandle& ref ) { node = ref.node; }
1296  XMLHandle& operator=( const XMLHandle& ref ) { node = ref.node; return *this; }
1297 
1299  XMLHandle FirstChild() { return XMLHandle( node ? node->FirstChild() : 0 ); }
1301  XMLHandle FirstChildElement( const char* value=0 ) { return XMLHandle( node ? node->FirstChildElement( value ) : 0 ); }
1303  XMLHandle LastChild() { return XMLHandle( node ? node->LastChild() : 0 ); }
1305  XMLHandle LastChildElement( const char* _value=0 ) { return XMLHandle( node ? node->LastChildElement( _value ) : 0 ); }
1309  XMLHandle PreviousSiblingElement( const char* _value=0 ) { return XMLHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); }
1313  XMLHandle NextSiblingElement( const char* _value=0 ) { return XMLHandle( node ? node->NextSiblingElement( _value ) : 0 ); }
1314 
1316  XMLNode* ToNode() { return node; }
1318  XMLElement* ToElement() { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1320  XMLText* ToText() { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1322  XMLUnknown* ToUnknown() { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1324  XMLDeclaration* ToDeclaration() { return ( ( node && node->ToDeclaration() ) ? node->ToDeclaration() : 0 ); }
1325 
1326 private:
1328 };
1329 
1330 
1336 {
1337 public:
1338  XMLConstHandle( const XMLNode* _node ) { node = _node; }
1339  XMLConstHandle( const XMLNode& _node ) { node = &_node; }
1340  XMLConstHandle( const XMLConstHandle& ref ) { node = ref.node; }
1341 
1342  XMLConstHandle& operator=( const XMLConstHandle& ref ) { node = ref.node; return *this; }
1343 
1344  const XMLConstHandle FirstChild() const { return XMLConstHandle( node ? node->FirstChild() : 0 ); }
1345  const XMLConstHandle FirstChildElement( const char* value=0 ) const { return XMLConstHandle( node ? node->FirstChildElement( value ) : 0 ); }
1346  const XMLConstHandle LastChild() const { return XMLConstHandle( node ? node->LastChild() : 0 ); }
1347  const XMLConstHandle LastChildElement( const char* _value=0 ) const { return XMLConstHandle( node ? node->LastChildElement( _value ) : 0 ); }
1349  const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const { return XMLConstHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); }
1350  const XMLConstHandle NextSibling() const { return XMLConstHandle( node ? node->NextSibling() : 0 ); }
1351  const XMLConstHandle NextSiblingElement( const char* _value=0 ) const { return XMLConstHandle( node ? node->NextSiblingElement( _value ) : 0 ); }
1352 
1353 
1354  const XMLNode* ToNode() const { return node; }
1355  const XMLElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1356  const XMLText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1357  const XMLUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
1358  const XMLDeclaration* ToDeclaration() const { return ( ( node && node->ToDeclaration() ) ? node->ToDeclaration() : 0 ); }
1359 
1360 private:
1361  const XMLNode* node;
1362 };
1363 
1364 
1407 class XMLPrinter : public XMLVisitor
1408 {
1409 public:
1416  XMLPrinter( FILE* file=0, bool compact = false );
1418 
1420  void PushHeader( bool writeBOM, bool writeDeclaration );
1424  void OpenElement( const char* name );
1426  void PushAttribute( const char* name, const char* value );
1427  void PushAttribute( const char* name, int value );
1428  void PushAttribute( const char* name, unsigned value );
1429  void PushAttribute( const char* name, bool value );
1430  void PushAttribute( const char* name, double value );
1432  void CloseElement();
1433 
1435  void PushText( const char* text, bool cdata=false );
1437  void PushText( int value );
1439  void PushText( unsigned value );
1441  void PushText( bool value );
1443  void PushText( float value );
1445  void PushText( double value );
1446 
1448  void PushComment( const char* comment );
1449 
1450  void PushDeclaration( const char* value );
1451  void PushUnknown( const char* value );
1452 
1453  virtual bool VisitEnter( const XMLDocument& /*doc*/ );
1454  virtual bool VisitExit( const XMLDocument& /*doc*/ ) { return true; }
1455 
1456  virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
1457  virtual bool VisitExit( const XMLElement& element );
1458 
1459  virtual bool Visit( const XMLText& text );
1460  virtual bool Visit( const XMLComment& comment );
1461  virtual bool Visit( const XMLDeclaration& declaration );
1462  virtual bool Visit( const XMLUnknown& unknown );
1463 
1468  const char* CStr() const { return buffer.Mem(); }
1474  int CStrSize() const { return buffer.Size(); }
1475 
1476 private:
1477  void SealElement();
1478  void PrintSpace( int depth );
1479  void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
1480  void Print( const char* format, ... );
1481 
1484  FILE* fp;
1485  int depth;
1489 
1490  enum {
1492  BUF_SIZE = 200
1493  };
1496 
1499 #ifdef _MSC_VER
1500  DynArray< char, 20 > accumulator;
1501 #endif
1502 };
1503 
1504 
1505 } // tinyxml2
1506 
1507 
1508 #endif // TINYXML2_INCLUDED
static char * SkipWhiteSpace(char *p)
Definition: tinyxml2.h:381
void PushComment(const char *comment)
Add a comment.
const char * Attribute(const char *name, const char *value=0) const
virtual ~XMLAttribute()
Definition: tinyxml2.h:837
XMLConstHandle(const XMLNode &_node)
Definition: tinyxml2.h:1339
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:734
#define TIXMLASSERT(x)
Definition: tinyxml2.h:68
XMLNode * InsertFirstChild(XMLNode *addThis)
Definition: tinyxml2_imp.h:693
virtual bool Accept(XMLVisitor *visitor) const
static bool ToFloat(const char *str, float *value)
Definition: tinyxml2_imp.h:486
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2_imp.h:970
friend class XMLBase
Definition: tinyxml2.h:857
XMLDeclaration(XMLDocument *doc)
Definition: tinyxml2_imp.h:986
int QueryUnsignedValue(unsigned int *value) const
See QueryIntAttribute.
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:1344
int QueryBoolValue(bool *value) const
See QueryIntAttribute.
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1357
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:1303
virtual int ItemSize() const =0
const T * Mem() const
Definition: tinyxml2.h:216
virtual void Free(void *)=0
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:706
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:470
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:863
const XMLElement * PreviousSiblingElement(const char *value=0) const
Get the previous (left) sibling element of this node, with an opitionally supplied name...
Definition: tinyxml2_imp.h:784
XMLHandle LastChildElement(const char *_value=0)
Get the last child element of this handle.
Definition: tinyxml2.h:1305
void SetAttribute(const char *name, unsigned _value)
Sets the named attribute to value.
Definition: tinyxml2.h:937
const XMLNode * node
Definition: tinyxml2.h:1361
void Unlink(XMLNode *child)
Definition: tinyxml2_imp.h:642
DynArray< char, 20 > buffer
Definition: tinyxml2.h:1498
MemPoolT< sizeof(XMLText) > textPool
Definition: tinyxml2.h:1226
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:642
XMLNode * firstChild
Definition: tinyxml2.h:611
const char * Value() const
The value of the attribute.
Definition: tinyxml2.h:789
int IntValue() const
Definition: tinyxml2.h:796
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:357
int QueryUnsignedAttribute(const char *name, unsigned int *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:924
XMLNode & operator=(const XMLNode &)
const char * GetStr()
Definition: tinyxml2_imp.h:195
XMLHandle FirstChildElement(const char *value=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1301
XMLText & operator=(const XMLText &)
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:359
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:515
XMLDeclaration & operator=(const XMLDeclaration &)
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:790
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
Definition: tinyxml2_imp.h:303
char * ParseDeep(char *, StrPair *endTag)
Definition: tinyxml2_imp.h:946
const XMLElement * ToElement() const
Definition: tinyxml2.h:1355
void DeleteChild(XMLNode *node)
Definition: tinyxml2_imp.h:661
void Set(char *_start, char *_end, int _flags)
Definition: tinyxml2.h:138
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:384
char * ParseDeep(char *, StrPair *endTag)
Definition: tinyxml2_imp.h:999
XMLConstHandle(const XMLNode *_node)
Definition: tinyxml2.h:1338
XMLComment & operator=(const XMLComment &)
virtual const XMLText * ToText() const
Definition: tinyxml2.h:643
virtual void Free(void *mem)
Definition: tinyxml2.h:293
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1069
void SetAttribute(const char *name, double _value)
Sets the named attribute to value.
Definition: tinyxml2.h:941
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition: tinyxml2.h:1199
void DeleteNode(XMLNode *node)
Definition: tinyxml2.h:1190
XMLNode * parent
Definition: tinyxml2.h:608
void Trace(const char *name)
Definition: tinyxml2.h:303
XMLElement(XMLDocument *doc)
virtual int ItemSize() const
Definition: tinyxml2.h:270
MemPoolT< sizeof(XMLElement) > elementPool
Definition: tinyxml2.h:1224
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1311
float FloatAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:907
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:460
char * ParseText(char *in, const char *endTag, int strFlags)
Definition: tinyxml2_imp.h:120
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1318
XMLHandle(XMLNode &_node)
Create a handle from a node.
Definition: tinyxml2.h:1292
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition: tinyxml2.h:1201
T * PushArr(int count)
Definition: tinyxml2.h:195
const char * errorStr1
Definition: tinyxml2.h:1220
static void ToStr(int v, char *buffer, int bufferSize)
Definition: tinyxml2_imp.h:415
XMLComment * NewComment(const char *comment)
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:648
int QueryIntAttribute(const char *name, int *_value) const
Definition: tinyxml2.h:922
XMLHandle NextSiblingElement(const char *_value=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:1313
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:368
const XMLNode * ToNode() const
Definition: tinyxml2.h:1354
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:462
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:1350
const XMLElement * LastChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:755
bool Empty() const
Definition: tinyxml2.h:211
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:382
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:464
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:1340
char * ParseDeep(char *p, StrPair *endTag)
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1358
XMLAttribute * rootAttribute
Definition: tinyxml2.h:1045
const XMLConstHandle NextSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1351
const XMLConstHandle PreviousSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1349
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2_imp.h:905
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2_imp.h:582
virtual const XMLText * ToText() const
Definition: tinyxml2.h:467
int QueryFloatText(float *_value) const
See QueryIntText()
int Parse(const char *xml, size_t nBytes=(size_t)(-1))
const XMLElement * RootElement() const
Definition: tinyxml2.h:1130
DynArray< Block *, 10 > blockPtrs
Definition: tinyxml2.h:317
int ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1197
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:861
int LoadFile(const char *filename)
void PushUnknown(const char *value)
XMLElement * PreviousSiblingElement(const char *_value=0)
Definition: tinyxml2.h:520
virtual ~XMLVisitor()
Definition: tinyxml2.h:349
virtual void * Alloc()=0
XMLElement * NewElement(const char *name)
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1195
int QueryFloatAttribute(const char *name, float *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:930
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:523
static bool ToDouble(const char *str, double *value)
Definition: tinyxml2_imp.h:495
T & operator[](int i)
Definition: tinyxml2.h:212
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:1342
int Size() const
Definition: tinyxml2.h:214
Whitespace whitespace
Definition: tinyxml2.h:1219
#define TIXML_SNPRINTF
Definition: tinyxml2.h:92
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
Definition: tinyxml2_imp.h:718
int QueryIntValue(int *value) const
void DeleteAttribute(const char *name)
XMLDocument * document
Definition: tinyxml2.h:607
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1208
char * ParseName(char *in)
Definition: tinyxml2_imp.h:141
void operator=(const XMLAttribute &)
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2_imp.h:959
virtual bool Accept(XMLVisitor *visitor) const
void Print(const char *format,...)
char * ParseDeep(char *, StrPair *endTag)
Definition: tinyxml2_imp.h:877
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
int QueryDoubleAttribute(const char *name, double *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:928
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:366
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:459
bool BoolValue() const
Query as a boolean. See IntAttribute()
Definition: tinyxml2.h:800
const XMLElement * NextSiblingElement(const char *value=0) const
Get the next (right) sibling element of this node, with an opitionally supplied name.
Definition: tinyxml2_imp.h:770
static int IsAlpha(unsigned char anyByte)
Definition: tinyxml2.h:399
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1124
virtual void * Alloc()
Definition: tinyxml2.h:273
XMLElement * LastChildElement(const char *_value=0)
Definition: tinyxml2.h:512
int IntAttribute(const char *name) const
Definition: tinyxml2.h:899
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:949
XMLDeclaration * NewDeclaration(const char *text=0)
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:463
int QueryBoolAttribute(const char *name, bool *_value) const
See QueryIntAttribute()
Definition: tinyxml2.h:926
void operator=(const XMLDocument &)
void SetName(const char *name)
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:362
char * ParseAttributes(char *p)
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2_imp.h:977
XMLAttribute * FindOrCreateAttribute(const char *name)
int QueryIntText(int *_value) const
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:455
virtual bool ShallowEqual(const XMLNode *compare) const
double DoubleAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:905
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
void PushDeclaration(const char *value)
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1068
char * ParseDeep(char *, StrPair *endTag)
XMLElement * RootElement()
Definition: tinyxml2.h:1129
XMLPrinter(FILE *file=0, bool compact=false)
static const char * GetCharacterRef(const char *p, char *value, int *length)
Definition: tinyxml2_imp.h:345
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:505
virtual bool Accept(XMLVisitor *visitor) const
XMLNode * InsertEndChild(XMLNode *addThis)
Definition: tinyxml2_imp.h:669
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:471
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:380
void SetError(int error, const char *str1, const char *str2)
void SetCData(bool _isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:646
void operator=(const XMLElement &)
virtual bool ShallowEqual(const XMLNode *compare) const =0
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:1348
bool Empty() const
Definition: tinyxml2.h:143
void SetStr(const char *str, int flags=0)
Definition: tinyxml2_imp.h:108
void SetAttribute(const char *name, int _value)
Sets the named attribute to value.
Definition: tinyxml2.h:935
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:671
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:469
XMLNode * LastChild()
Definition: tinyxml2.h:506
void Print(XMLPrinter *streamer=0)
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
virtual ~XMLText()
Definition: tinyxml2.h:657
XMLUnknown & operator=(const XMLUnknown &)
const XMLElement * FirstChildElement(const char *value=0) const
Definition: tinyxml2_imp.h:740
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:1322
virtual XMLNode * ShallowClone(XMLDocument *document) const
void SetAttribute(const char *name, bool _value)
Sets the named attribute to value.
Definition: tinyxml2.h:939
void SetInternedStr(const char *str)
Definition: tinyxml2.h:145
void SetValue(const char *val, bool staticMem=false)
Definition: tinyxml2_imp.h:619
const char * CStr() const
Definition: tinyxml2.h:1468
bool restrictedEntityFlag[ENTITY_RANGE]
Definition: tinyxml2.h:1495
static int IsAlphaNum(unsigned char anyByte)
Definition: tinyxml2.h:398
XMLNode * next
Definition: tinyxml2.h:615
MemPoolT< sizeof(XMLComment) > commentPool
Definition: tinyxml2.h:1227
XMLComment(XMLDocument *doc)
Definition: tinyxml2_imp.h:933
int QueryDoubleText(double *_value) const
See QueryIntText()
virtual bool Visit(const XMLText &text)
Visit a text node.
XMLNode * lastChild
Definition: tinyxml2.h:612
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:468
virtual char * ParseDeep(char *, StrPair *)
Definition: tinyxml2_imp.h:798
XMLNode * FirstChild()
Definition: tinyxml2.h:497
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:865
int ClosingType() const
Definition: tinyxml2.h:1025
bool HasBOM() const
Definition: tinyxml2.h:1121
void EnsureCapacity(int cap)
Definition: tinyxml2.h:221
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:672
void PushHeader(bool writeBOM, bool writeDeclaration)
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:1307
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:1454
const char * Value() const
Definition: tinyxml2.h:482
XMLHandle(XMLNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1290
virtual XMLNode * ShallowClone(XMLDocument *document) const
void Push(T t)
Definition: tinyxml2.h:189
const T & operator[](int i) const
Definition: tinyxml2.h:213
int SaveFile(const char *filename, bool compact=false)
virtual ~XMLNode()
Definition: tinyxml2_imp.h:609
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:364
XMLUnknown(XMLDocument *doc)
void OpenElement(const char *name)
const char * Name() const
The name of the attribute.
Definition: tinyxml2.h:788
int Capacity() const
Definition: tinyxml2.h:215
XMLHandle PreviousSiblingElement(const char *_value=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:1309
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:493
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:1324
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:1320
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:489
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:1346
XMLElement * NextSiblingElement(const char *_value=0)
Definition: tinyxml2.h:528
XMLNode * NextSibling()
Definition: tinyxml2.h:524
int CurrentAllocs() const
Definition: tinyxml2.h:271
XMLNode(XMLDocument *)
Definition: tinyxml2_imp.h:599
char * Identify(char *p, XMLNode **node)
Definition: tinyxml2_imp.h:505
XMLElement * FirstChildElement(const char *_value=0)
Definition: tinyxml2.h:502
const XMLText * ToText() const
Definition: tinyxml2.h:1356
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1299
XMLNode * PreviousSibling()
Definition: tinyxml2.h:516
int CStrSize() const
Definition: tinyxml2.h:1474
const XMLConstHandle LastChildElement(const char *_value=0) const
Definition: tinyxml2.h:1347
XMLText * NewText(const char *text)
char * ParseDeep(char *p, bool processEntities)
double DoubleValue() const
Query as a double. See IntAttribute()
Definition: tinyxml2.h:802
void SetAttribute(const char *name, const char *_value)
Sets the named attribute to value.
Definition: tinyxml2.h:933
void PopArr(int count)
Definition: tinyxml2.h:205
virtual ~MemPool()
Definition: tinyxml2.h:247
static bool ToUnsigned(const char *str, unsigned *value)
Definition: tinyxml2_imp.h:458
static bool ToBool(const char *str, bool *value)
Definition: tinyxml2_imp.h:466
static const char * ReadBOM(const char *p, bool *hasBOM)
Definition: tinyxml2_imp.h:286
DynArray< const char *, 10 > stack
Definition: tinyxml2.h:1497
MemPool * memPool
Definition: tinyxml2.h:618
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:457
MemPoolT< sizeof(XMLAttribute) > attributePool
Definition: tinyxml2.h:1225
unsigned UnsignedValue() const
Query as an unsigned integer. See IntAttribute()
Definition: tinyxml2.h:798
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:496
XMLUnknown * NewUnknown(const char *text)
const XMLConstHandle FirstChildElement(const char *value=0) const
Definition: tinyxml2.h:1345
void CloseElement()
If streaming, close the Element.
const char * errorStr2
Definition: tinyxml2.h:1221
const char * GetText() const
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:705
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1316
static int IsUTF8Continuation(const char p)
Definition: tinyxml2.h:397
float FloatValue() const
Query as a float. See IntAttribute()
Definition: tinyxml2.h:804
bool BoolAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:903
virtual XMLNode * ShallowClone(XMLDocument *document) const
int QueryFloatValue(float *value) const
See QueryIntAttribute.
virtual bool ShallowEqual(const XMLNode *compare) const
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:352
int QueryDoubleValue(double *value) const
See QueryIntAttribute.
virtual bool Accept(XMLVisitor *visitor) const
Definition: tinyxml2_imp.h:924
XMLNode * Parent()
Definition: tinyxml2.h:490
int QueryBoolText(bool *_value) const
See QueryIntText()
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:733
XMLAttribute * next
Definition: tinyxml2.h:846
friend class XMLBase
Definition: tinyxml2.h:637
XMLDocument(bool processEntities=true, Whitespace=PRESERVE_WHITESPACE)
constructor
int QueryUnsignedText(unsigned *_value) const
See QueryIntText()
void PrintString(const char *, bool restrictedEntitySet)
void PrintError() const
If there is an error, print it to stdout.
void CollapseWhitespace()
Definition: tinyxml2_imp.h:168
static bool ToInt(const char *str, int *value)
Definition: tinyxml2_imp.h:450
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1116
void PrintSpace(int depth)
XMLNode * prev
Definition: tinyxml2.h:614
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2_imp.h:917
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:656
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:354
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:901
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:866
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1294
bool entityFlag[ENTITY_RANGE]
Definition: tinyxml2.h:1494
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:535
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:466
bool ProcessEntities() const
Definition: tinyxml2.h:1115
void SetAttribute(const char *value)
Set the attribute to a string value.
void PushText(const char *text, bool cdata=false)
Add a text node.
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1209
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:461
virtual bool Accept(XMLVisitor *visitor) const =0
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:1296

Generated on Thu Jul 7 2016 11:09:45 for antioch-0.4.0 by  doxygen 1.8.8