MIDAS  0.75
 All Classes Namespaces Files Functions Variables 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 
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
20 
21 3. This notice may not be removed or altered from any source
22 distribution.
23 */
24 
25 #ifndef TINYXML2_INCLUDED
26 #define TINYXML2_INCLUDED
27 
28 #if defined(ANDROID_NDK) || defined(__BORLANDC__)
29 # include <ctype.h>
30 # include <limits.h>
31 # include <stdio.h>
32 # include <stdlib.h>
33 # include <string.h>
34 # include <stdarg.h>
35 #else
36 # include <cctype>
37 # include <climits>
38 # include <cstdio>
39 # include <cstdlib>
40 # include <cstring>
41 # include <cstdarg>
42 #endif
43 
44 /*
45  TODO: intern strings instead of allocation.
46 */
47 /*
48  gcc:
49  g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
50 
51  Formatting, Artistic Style:
52  AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
53 */
54 
55 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
56 # ifndef DEBUG
57 # define DEBUG
58 # endif
59 #endif
60 
61 #ifdef _MSC_VER
62 # pragma warning(push)
63 # pragma warning(disable: 4251)
64 #endif
65 
66 #ifdef _WIN32
67 # ifdef TINYXML2_EXPORT
68 # define TINYXML2_LIB __declspec(dllexport)
69 # elif defined(TINYXML2_IMPORT)
70 # define TINYXML2_LIB __declspec(dllimport)
71 # else
72 # define TINYXML2_LIB
73 # endif
74 #else
75 # define TINYXML2_LIB
76 #endif
77 
78 
79 #if defined(DEBUG)
80 # if defined(_MSC_VER)
81 # define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
82 # elif defined (ANDROID_NDK)
83 # include <android/log.h>
84 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
85 # else
86 # include <assert.h>
87 # define TIXMLASSERT assert
88 # endif
89 # else
90 # define TIXMLASSERT( x ) {}
91 #endif
92 
93 
94 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
95 // Microsoft visual studio, version 2005 and higher.
96 /*int _snprintf_s(
97  char *buffer,
98  size_t sizeOfBuffer,
99  size_t count,
100  const char *format [,
101  argument] ...
102 );*/
103 inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
104 {
105  va_list va;
106  va_start( va, format );
107  int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
108  va_end( va );
109  return result;
110 }
111 #define TIXML_SSCANF sscanf_s
112 #else
113 // GCC version 3 and higher
114 //#warning( "Using sn* functions." )
115 #define TIXML_SNPRINTF snprintf
116 #define TIXML_SSCANF sscanf
117 #endif
118 
119 static const int TIXML2_MAJOR_VERSION = 1;
120 static const int TIXML2_MINOR_VERSION = 0;
121 static const int TIXML2_PATCH_VERSION = 11;
122 
123 namespace tinyxml2
124 {
125 class XMLDocument;
126 class XMLElement;
127 class XMLAttribute;
128 class XMLComment;
129 class XMLText;
130 class XMLDeclaration;
131 class XMLUnknown;
132 class XMLPrinter;
133 
134 /*
135  A class that wraps strings. Normally stores the start and end
136  pointers into the XML file itself, and will apply normalization
137  and entity translation if actually read. Can also store (and memory
138  manage) a traditional char[]
139 */
140 class StrPair
141 {
142 public:
143  enum {
147 
154  };
155 
156  StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
157  ~StrPair();
158 
159  void Set( char* start, char* end, int flags ) {
160  Reset();
161  _start = start;
162  _end = end;
163  _flags = flags | NEEDS_FLUSH;
164  }
165 
166  const char* GetStr();
167 
168  bool Empty() const {
169  return _start == _end;
170  }
171 
172  void SetInternedStr( const char* str ) {
173  Reset();
174  _start = const_cast<char*>(str);
175  }
176 
177  void SetStr( const char* str, int flags=0 );
178 
179  char* ParseText( char* in, const char* endTag, int strFlags );
180  char* ParseName( char* in );
181 
182 private:
183  void Reset();
184  void CollapseWhitespace();
185 
186  enum {
187  NEEDS_FLUSH = 0x100,
188  NEEDS_DELETE = 0x200
189  };
190 
191  // After parsing, if *_end != 0, it can be set to zero.
192  int _flags;
193  char* _start;
194  char* _end;
195 };
196 
197 
198 /*
199  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
200  Has a small initial memory pool, so that low or no usage will not
201  cause a call to new/delete
202 */
203 template <class T, int INIT>
204 class DynArray
205 {
206 public:
208  _mem = _pool;
209  _allocated = INIT;
210  _size = 0;
211  }
212 
214  if ( _mem != _pool ) {
215  delete [] _mem;
216  }
217  }
218 
219  void Push( T t ) {
220  EnsureCapacity( _size+1 );
221  _mem[_size++] = t;
222  }
223 
224  T* PushArr( int count ) {
225  EnsureCapacity( _size+count );
226  T* ret = &_mem[_size];
227  _size += count;
228  return ret;
229  }
230 
231  T Pop() {
232  return _mem[--_size];
233  }
234 
235  void PopArr( int count ) {
236  TIXMLASSERT( _size >= count );
237  _size -= count;
238  }
239 
240  bool Empty() const {
241  return _size == 0;
242  }
243 
244  T& operator[](int i) {
245  TIXMLASSERT( i>= 0 && i < _size );
246  return _mem[i];
247  }
248 
249  const T& operator[](int i) const {
250  TIXMLASSERT( i>= 0 && i < _size );
251  return _mem[i];
252  }
253 
254  const T& PeekTop() const {
255  TIXMLASSERT( _size > 0 );
256  return _mem[ _size - 1];
257  }
258 
259  int Size() const {
260  return _size;
261  }
262 
263  int Capacity() const {
264  return _allocated;
265  }
266 
267  const T* Mem() const {
268  return _mem;
269  }
270 
271  T* Mem() {
272  return _mem;
273  }
274 
275 private:
276  void EnsureCapacity( int cap ) {
277  if ( cap > _allocated ) {
278  int newAllocated = cap * 2;
279  T* newMem = new T[newAllocated];
280  memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
281  if ( _mem != _pool ) {
282  delete [] _mem;
283  }
284  _mem = newMem;
285  _allocated = newAllocated;
286  }
287  }
288 
289  T* _mem;
290  T _pool[INIT];
291  int _allocated; // objects allocated
292  int _size; // number objects in use
293 };
294 
295 
296 /*
297  Parent virtual class of a pool for fast allocation
298  and deallocation of objects.
299 */
300 class MemPool
301 {
302 public:
303  MemPool() {}
304  virtual ~MemPool() {}
305 
306  virtual int ItemSize() const = 0;
307  virtual void* Alloc() = 0;
308  virtual void Free( void* ) = 0;
309  virtual void SetTracked() = 0;
310 };
311 
312 
313 /*
314  Template child class to create pools of the correct type.
315 */
316 template< int SIZE >
317 class MemPoolT : public MemPool
318 {
319 public:
322  // Delete the blocks.
323  for( int i=0; i<_blockPtrs.Size(); ++i ) {
324  delete _blockPtrs[i];
325  }
326  }
327 
328  virtual int ItemSize() const {
329  return SIZE;
330  }
331  int CurrentAllocs() const {
332  return _currentAllocs;
333  }
334 
335  virtual void* Alloc() {
336  if ( !_root ) {
337  // Need a new block.
338  Block* block = new Block();
339  _blockPtrs.Push( block );
340 
341  for( int i=0; i<COUNT-1; ++i ) {
342  block->chunk[i].next = &block->chunk[i+1];
343  }
344  block->chunk[COUNT-1].next = 0;
345  _root = block->chunk;
346  }
347  void* result = _root;
348  _root = _root->next;
349 
350  ++_currentAllocs;
351  if ( _currentAllocs > _maxAllocs ) {
353  }
354  _nAllocs++;
355  _nUntracked++;
356  return result;
357  }
358  virtual void Free( void* mem ) {
359  if ( !mem ) {
360  return;
361  }
362  --_currentAllocs;
363  Chunk* chunk = (Chunk*)mem;
364 #ifdef DEBUG
365  memset( chunk, 0xfe, sizeof(Chunk) );
366 #endif
367  chunk->next = _root;
368  _root = chunk;
369  }
370  void Trace( const char* name ) {
371  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
372  name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
373  }
374 
375  void SetTracked() {
376  _nUntracked--;
377  }
378 
379  int Untracked() const {
380  return _nUntracked;
381  }
382 
383  // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
384  // The test file is large, 170k.
385  // Release: VS2010 gcc(no opt)
386  // 1k: 4000
387  // 2k: 4000
388  // 4k: 3900 21000
389  // 16k: 5200
390  // 32k: 4300
391  // 64k: 4000 21000
392  enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
393 
394 private:
395  union Chunk {
397  char mem[SIZE];
398  };
399  struct Block {
401  };
403  Chunk* _root;
404 
406  int _nAllocs;
409 };
410 
411 
412 
433 {
434 public:
435  virtual ~XMLVisitor() {}
436 
438  virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
439  return true;
440  }
442  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
443  return true;
444  }
445 
447  virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
448  return true;
449  }
451  virtual bool VisitExit( const XMLElement& /*element*/ ) {
452  return true;
453  }
454 
456  virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
457  return true;
458  }
460  virtual bool Visit( const XMLText& /*text*/ ) {
461  return true;
462  }
464  virtual bool Visit( const XMLComment& /*comment*/ ) {
465  return true;
466  }
468  virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
469  return true;
470  }
471 };
472 
473 
474 /*
475  Utility functionality.
476 */
477 class XMLUtil
478 {
479 public:
480  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
481  // correct, but simple, and usually works.
482  static const char* SkipWhiteSpace( const char* p ) {
483  while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
484  ++p;
485  }
486  return p;
487  }
488  static char* SkipWhiteSpace( char* p ) {
489  while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) {
490  ++p;
491  }
492  return p;
493  }
494  static bool IsWhiteSpace( char p ) {
495  return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
496  }
497 
498  inline static bool IsNameStartChar( unsigned char ch ) {
499  return ( ( ch < 128 ) ? isalpha( ch ) : 1 )
500  || ch == ':'
501  || ch == '_';
502  }
503 
504  inline static bool IsNameChar( unsigned char ch ) {
505  return IsNameStartChar( ch )
506  || isdigit( ch )
507  || ch == '.'
508  || ch == '-';
509  }
510 
511  inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
512  int n = 0;
513  if ( p == q ) {
514  return true;
515  }
516  while( *p && *q && *p == *q && n<nChar ) {
517  ++p;
518  ++q;
519  ++n;
520  }
521  if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
522  return true;
523  }
524  return false;
525  }
526 
527  inline static int IsUTF8Continuation( const char p ) {
528  return p & 0x80;
529  }
530 
531  static const char* ReadBOM( const char* p, bool* hasBOM );
532  // p is the starting location,
533  // the UTF-8 value of the entity will be placed in value, and length filled in.
534  static const char* GetCharacterRef( const char* p, char* value, int* length );
535  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
536 
537  // converts primitive types to strings
538  static void ToStr( int v, char* buffer, int bufferSize );
539  static void ToStr( unsigned v, char* buffer, int bufferSize );
540  static void ToStr( bool v, char* buffer, int bufferSize );
541  static void ToStr( float v, char* buffer, int bufferSize );
542  static void ToStr( double v, char* buffer, int bufferSize );
543 
544  // converts strings to primitive types
545  static bool ToLong( const char* str, long* value ); // termitovo
546  static bool ToInt( const char* str, int* value );
547  static bool ToUnsigned( const char* str, unsigned* value );
548  static bool ToBool( const char* str, bool* value );
549  static bool ToFloat( const char* str, float* value );
550  static bool ToDouble( const char* str, double* value );
551 };
552 
553 
580 {
581  friend class XMLDocument;
582  friend class XMLElement;
583 public:
584 
586  const XMLDocument* GetDocument() const {
587  return _document;
588  }
591  return _document;
592  }
593 
595  virtual XMLElement* ToElement() {
596  return 0;
597  }
599  virtual XMLText* ToText() {
600  return 0;
601  }
603  virtual XMLComment* ToComment() {
604  return 0;
605  }
607  virtual XMLDocument* ToDocument() {
608  return 0;
609  }
612  return 0;
613  }
615  virtual XMLUnknown* ToUnknown() {
616  return 0;
617  }
618 
619  virtual const XMLElement* ToElement() const {
620  return 0;
621  }
622  virtual const XMLText* ToText() const {
623  return 0;
624  }
625  virtual const XMLComment* ToComment() const {
626  return 0;
627  }
628  virtual const XMLDocument* ToDocument() const {
629  return 0;
630  }
631  virtual const XMLDeclaration* ToDeclaration() const {
632  return 0;
633  }
634  virtual const XMLUnknown* ToUnknown() const {
635  return 0;
636  }
637 
647  const char* Value() const {
648  return _value.GetStr();
649  }
650 
654  void SetValue( const char* val, bool staticMem=false );
655 
657  const XMLNode* Parent() const {
658  return _parent;
659  }
660 
662  return _parent;
663  }
664 
666  bool NoChildren() const {
667  return !_firstChild;
668  }
669 
671  const XMLNode* FirstChild() const {
672  return _firstChild;
673  }
674 
676  return _firstChild;
677  }
678 
682  const XMLElement* FirstChildElement( const char* value=0 ) const;
683 
684  XMLElement* FirstChildElement( const char* value=0 ) {
685  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value ));
686  }
687 
689  const XMLNode* LastChild() const {
690  return _lastChild;
691  }
692 
694  return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
695  }
696 
700  const XMLElement* LastChildElement( const char* value=0 ) const;
701 
702  XMLElement* LastChildElement( const char* value=0 ) {
703  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) );
704  }
705 
707  const XMLNode* PreviousSibling() const {
708  return _prev;
709  }
710 
712  return _prev;
713  }
714 
716  const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
717 
718  XMLElement* PreviousSiblingElement( const char* value=0 ) {
719  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) );
720  }
721 
723  const XMLNode* NextSibling() const {
724  return _next;
725  }
726 
728  return _next;
729  }
730 
732  const XMLElement* NextSiblingElement( const char* value=0 ) const;
733 
734  XMLElement* NextSiblingElement( const char* value=0 ) {
735  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) );
736  }
737 
741  XMLNode* InsertEndChild( XMLNode* addThis );
742 
743  XMLNode* LinkEndChild( XMLNode* addThis ) {
744  return InsertEndChild( addThis );
745  }
749  XMLNode* InsertFirstChild( XMLNode* addThis );
753  XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
754 
758  void DeleteChildren();
759 
763  void DeleteChild( XMLNode* node );
764 
774  virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
775 
782  virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
783 
806  virtual bool Accept( XMLVisitor* visitor ) const = 0;
807 
808  // internal
809  virtual char* ParseDeep( char*, StrPair* );
810 
811 protected:
812  XMLNode( XMLDocument* );
813  virtual ~XMLNode();
814  XMLNode( const XMLNode& ); // not supported
815  XMLNode& operator=( const XMLNode& ); // not supported
816 
819  mutable StrPair _value;
820 
823 
826 
827 private:
829  void Unlink( XMLNode* child );
830 };
831 
832 
846 {
847  friend class XMLBase;
848  friend class XMLDocument;
849 public:
850  virtual bool Accept( XMLVisitor* visitor ) const;
851 
852  virtual XMLText* ToText() {
853  return this;
854  }
855  virtual const XMLText* ToText() const {
856  return this;
857  }
858 
860  void SetCData( bool isCData ) {
861  _isCData = isCData;
862  }
864  bool CData() const {
865  return _isCData;
866  }
867 
868  char* ParseDeep( char*, StrPair* endTag );
869  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
870  virtual bool ShallowEqual( const XMLNode* compare ) const;
871 
872 protected:
873  XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
874  virtual ~XMLText() {}
875  XMLText( const XMLText& ); // not supported
876  XMLText& operator=( const XMLText& ); // not supported
877 
878 private:
879  bool _isCData;
880 };
881 
882 
885 {
886  friend class XMLDocument;
887 public:
888  virtual XMLComment* ToComment() {
889  return this;
890  }
891  virtual const XMLComment* ToComment() const {
892  return this;
893  }
894 
895  virtual bool Accept( XMLVisitor* visitor ) const;
896 
897  char* ParseDeep( char*, StrPair* endTag );
898  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
899  virtual bool ShallowEqual( const XMLNode* compare ) const;
900 
901 protected:
902  XMLComment( XMLDocument* doc );
903  virtual ~XMLComment();
904  XMLComment( const XMLComment& ); // not supported
905  XMLComment& operator=( const XMLComment& ); // not supported
906 
907 private:
908 };
909 
910 
923 {
924  friend class XMLDocument;
925 public:
927  return this;
928  }
929  virtual const XMLDeclaration* ToDeclaration() const {
930  return this;
931  }
932 
933  virtual bool Accept( XMLVisitor* visitor ) const;
934 
935  char* ParseDeep( char*, StrPair* endTag );
936  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
937  virtual bool ShallowEqual( const XMLNode* compare ) const;
938 
939 protected:
940  XMLDeclaration( XMLDocument* doc );
941  virtual ~XMLDeclaration();
942  XMLDeclaration( const XMLDeclaration& ); // not supported
943  XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
944 };
945 
946 
955 {
956  friend class XMLDocument;
957 public:
958  virtual XMLUnknown* ToUnknown() {
959  return this;
960  }
961  virtual const XMLUnknown* ToUnknown() const {
962  return this;
963  }
964 
965  virtual bool Accept( XMLVisitor* visitor ) const;
966 
967  char* ParseDeep( char*, StrPair* endTag );
968  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
969  virtual bool ShallowEqual( const XMLNode* compare ) const;
970 
971 protected:
972  XMLUnknown( XMLDocument* doc );
973  virtual ~XMLUnknown();
974  XMLUnknown( const XMLUnknown& ); // not supported
975  XMLUnknown& operator=( const XMLUnknown& ); // not supported
976 };
977 
978 
979 enum XMLError {
982 
985 
1001 
1004 };
1005 
1006 
1014 {
1015  friend class XMLElement;
1016 public:
1018  const char* Name() const {
1019  return _name.GetStr();
1020  }
1022  const char* Value() const {
1023  return _value.GetStr();
1024  }
1026  const XMLAttribute* Next() const {
1027  return _next;
1028  }
1029 
1034  int IntValue() const {
1035  int i=0;
1036  QueryIntValue( &i );
1037  return i;
1038  }
1040  unsigned UnsignedValue() const {
1041  unsigned i=0;
1042  QueryUnsignedValue( &i );
1043  return i;
1044  }
1046  bool BoolValue() const {
1047  bool b=false;
1048  QueryBoolValue( &b );
1049  return b;
1050  }
1052  double DoubleValue() const {
1053  double d=0;
1054  QueryDoubleValue( &d );
1055  return d;
1056  }
1058  float FloatValue() const {
1059  float f=0;
1060  QueryFloatValue( &f );
1061  return f;
1062  }
1063 
1068  XMLError QueryLongValue( long* value ) const;
1070  XMLError QueryIntValue( int* value ) const;
1072  XMLError QueryUnsignedValue( unsigned int* value ) const;
1074  XMLError QueryBoolValue( bool* value ) const;
1076  XMLError QueryDoubleValue( double* value ) const;
1078  XMLError QueryFloatValue( float* value ) const;
1079 
1081  void SetAttribute( const char* value );
1083  void SetAttribute( int value );
1085  void SetAttribute( unsigned value );
1087  void SetAttribute( bool value );
1089  void SetAttribute( double value );
1091  void SetAttribute( float value );
1092 
1093 private:
1094  enum { BUF_SIZE = 200 };
1095 
1096  XMLAttribute() : _next( 0 ), _memPool( 0 ) {}
1097  virtual ~XMLAttribute() {}
1098 
1099  XMLAttribute( const XMLAttribute& ); // not supported
1100  void operator=( const XMLAttribute& ); // not supported
1101  void SetName( const char* name );
1102 
1103  char* ParseDeep( char* p, bool processEntities );
1104 
1105  mutable StrPair _name;
1106  mutable StrPair _value;
1109 };
1110 
1111 
1117 {
1118  friend class XMLBase;
1119  friend class XMLDocument;
1120 public:
1122  const char* Name() const {
1123  return Value();
1124  }
1126  void SetName( const char* str, bool staticMem=false ) {
1127  SetValue( str, staticMem );
1128  }
1129 
1130  virtual XMLElement* ToElement() {
1131  return this;
1132  }
1133  virtual const XMLElement* ToElement() const {
1134  return this;
1135  }
1136  virtual bool Accept( XMLVisitor* visitor ) const;
1137 
1161  const char* Attribute( const char* name, const char* value=0 ) const;
1162 
1168  int IntAttribute( const char* name ) const {
1169  int i=0;
1170  QueryIntAttribute( name, &i );
1171  return i;
1172  }
1174  unsigned UnsignedAttribute( const char* name ) const {
1175  unsigned i=0;
1176  QueryUnsignedAttribute( name, &i );
1177  return i;
1178  }
1180  bool BoolAttribute( const char* name ) const {
1181  bool b=false;
1182  QueryBoolAttribute( name, &b );
1183  return b;
1184  }
1186  double DoubleAttribute( const char* name ) const {
1187  double d=0;
1188  QueryDoubleAttribute( name, &d );
1189  return d;
1190  }
1192  float FloatAttribute( const char* name ) const {
1193  float f=0;
1194  QueryFloatAttribute( name, &f );
1195  return f;
1196  }
1197 
1211  // termitovo pridana fce
1212  XMLError QueryLongAttribute( const char* name, long* value ) const {
1213  const XMLAttribute* a = FindAttribute( name );
1214  if ( !a ) {
1215  return XML_NO_ATTRIBUTE;
1216  }
1217  return a->QueryLongValue( value );
1218  }
1219  // termitovo
1220  XMLError QueryIntAttribute( const char* name, int* value ) const {
1221  const XMLAttribute* a = FindAttribute( name );
1222  if ( !a ) {
1223  return XML_NO_ATTRIBUTE;
1224  }
1225  return a->QueryIntValue( value );
1226  }
1228  XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
1229  const XMLAttribute* a = FindAttribute( name );
1230  if ( !a ) {
1231  return XML_NO_ATTRIBUTE;
1232  }
1233  return a->QueryUnsignedValue( value );
1234  }
1236  XMLError QueryBoolAttribute( const char* name, bool* value ) const {
1237  const XMLAttribute* a = FindAttribute( name );
1238  if ( !a ) {
1239  return XML_NO_ATTRIBUTE;
1240  }
1241  return a->QueryBoolValue( value );
1242  }
1244  XMLError QueryDoubleAttribute( const char* name, double* value ) const {
1245  const XMLAttribute* a = FindAttribute( name );
1246  if ( !a ) {
1247  return XML_NO_ATTRIBUTE;
1248  }
1249  return a->QueryDoubleValue( value );
1250  }
1252  XMLError QueryFloatAttribute( const char* name, float* value ) const {
1253  const XMLAttribute* a = FindAttribute( name );
1254  if ( !a ) {
1255  return XML_NO_ATTRIBUTE;
1256  }
1257  return a->QueryFloatValue( value );
1258  }
1259 
1260 
1278  int QueryAttribute( const char* name, int* value ) const {
1279  return QueryIntAttribute( name, value );
1280  }
1281 
1282  int QueryAttribute( const char* name, unsigned int* value ) const {
1283  return QueryUnsignedAttribute( name, value );
1284  }
1285 
1286  int QueryAttribute( const char* name, bool* value ) const {
1287  return QueryBoolAttribute( name, value );
1288  }
1289 
1290  int QueryAttribute( const char* name, double* value ) const {
1291  return QueryDoubleAttribute( name, value );
1292  }
1293 
1294  int QueryAttribute( const char* name, float* value ) const {
1295  return QueryFloatAttribute( name, value );
1296  }
1297 
1299  void SetAttribute( const char* name, const char* value ) {
1300  XMLAttribute* a = FindOrCreateAttribute( name );
1301  a->SetAttribute( value );
1302  }
1304  void SetAttribute( const char* name, int value ) {
1305  XMLAttribute* a = FindOrCreateAttribute( name );
1306  a->SetAttribute( value );
1307  }
1309  void SetAttribute( const char* name, unsigned value ) {
1310  XMLAttribute* a = FindOrCreateAttribute( name );
1311  a->SetAttribute( value );
1312  }
1314  void SetAttribute( const char* name, bool value ) {
1315  XMLAttribute* a = FindOrCreateAttribute( name );
1316  a->SetAttribute( value );
1317  }
1319  void SetAttribute( const char* name, double value ) {
1320  XMLAttribute* a = FindOrCreateAttribute( name );
1321  a->SetAttribute( value );
1322  }
1323 
1327  void DeleteAttribute( const char* name );
1328 
1330  const XMLAttribute* FirstAttribute() const {
1331  return _rootAttribute;
1332  }
1334  const XMLAttribute* FindAttribute( const char* name ) const;
1335 
1364  const char* GetText() const;
1365 
1392  XMLError QueryIntText( int* ival ) const;
1394  XMLError QueryUnsignedText( unsigned* uval ) const;
1396  XMLError QueryBoolText( bool* bval ) const;
1398  XMLError QueryDoubleText( double* dval ) const;
1400  XMLError QueryFloatText( float* fval ) const;
1401 
1402  // internal:
1403  enum {
1404  OPEN, // <foo>
1405  CLOSED, // <foo/>
1406  CLOSING // </foo>
1407  };
1408  int ClosingType() const {
1409  return _closingType;
1410  }
1411  char* ParseDeep( char* p, StrPair* endTag );
1412  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1413  virtual bool ShallowEqual( const XMLNode* compare ) const;
1414 
1415 private:
1416  XMLElement( XMLDocument* doc );
1417  virtual ~XMLElement();
1418  XMLElement( const XMLElement& ); // not supported
1419  void operator=( const XMLElement& ); // not supported
1420 
1421  XMLAttribute* FindAttribute( const char* name );
1422  XMLAttribute* FindOrCreateAttribute( const char* name );
1423  //void LinkAttribute( XMLAttribute* attrib );
1424  char* ParseAttributes( char* p );
1425 
1427  // The attribute list is ordered; there is no 'lastAttribute'
1428  // because the list needs to be scanned for dupes before adding
1429  // a new attribute.
1431 };
1432 
1433 
1437 };
1438 
1439 
1446 {
1447  friend class XMLElement;
1448 public:
1450  XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
1451  ~XMLDocument();
1452 
1454  return this;
1455  }
1456  virtual const XMLDocument* ToDocument() const {
1457  return this;
1458  }
1459 
1470  XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
1471 
1477  XMLError LoadFile( const char* filename );
1478 
1486  XMLError LoadFile( FILE* );
1487 
1493  XMLError SaveFile( const char* filename, bool compact = false );
1494 
1502  XMLError SaveFile( FILE* fp, bool compact = false );
1503 
1504  bool ProcessEntities() const {
1505  return _processEntities;
1506  }
1508  return _whitespace;
1509  }
1510 
1514  bool HasBOM() const {
1515  return _writeBOM;
1516  }
1519  void SetBOM( bool useBOM ) {
1520  _writeBOM = useBOM;
1521  }
1522 
1527  return FirstChildElement();
1528  }
1529  const XMLElement* RootElement() const {
1530  return FirstChildElement();
1531  }
1532 
1547  void Print( XMLPrinter* streamer=0 ) const;
1548  virtual bool Accept( XMLVisitor* visitor ) const;
1549 
1555  XMLElement* NewElement( const char* name );
1561  XMLComment* NewComment( const char* comment );
1567  XMLText* NewText( const char* text );
1579  XMLDeclaration* NewDeclaration( const char* text=0 );
1585  XMLUnknown* NewUnknown( const char* text );
1586 
1591  void DeleteNode( XMLNode* node ) {
1592  node->_parent->DeleteChild( node );
1593  }
1594 
1595  void SetError( XMLError error, const char* str1, const char* str2 );
1596 
1598  bool Error() const {
1599  return _errorID != XML_NO_ERROR;
1600  }
1602  XMLError ErrorID() const {
1603  return _errorID;
1604  }
1606  const char* GetErrorStr1() const {
1607  return _errorStr1;
1608  }
1610  const char* GetErrorStr2() const {
1611  return _errorStr2;
1612  }
1614  void PrintError() const;
1615 
1617  void Clear();
1618 
1619  // internal
1620  char* Identify( char* p, XMLNode** node );
1621 
1622  virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
1623  return 0;
1624  }
1625  virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
1626  return false;
1627  }
1628 
1629 private:
1630  XMLDocument( const XMLDocument& ); // not supported
1631  void operator=( const XMLDocument& ); // not supported
1632 
1637  const char* _errorStr1;
1638  const char* _errorStr2;
1640 
1645 };
1646 
1647 
1704 {
1705 public:
1707  XMLHandle( XMLNode* node ) {
1708  _node = node;
1709  }
1711  XMLHandle( XMLNode& node ) {
1712  _node = &node;
1713  }
1715  XMLHandle( const XMLHandle& ref ) {
1716  _node = ref._node;
1717  }
1719  XMLHandle& operator=( const XMLHandle& ref ) {
1720  _node = ref._node;
1721  return *this;
1722  }
1723 
1726  return XMLHandle( _node ? _node->FirstChild() : 0 );
1727  }
1729  XMLHandle FirstChildElement( const char* value=0 ) {
1730  return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
1731  }
1734  return XMLHandle( _node ? _node->LastChild() : 0 );
1735  }
1737  XMLHandle LastChildElement( const char* _value=0 ) {
1738  return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
1739  }
1742  return XMLHandle( _node ? _node->PreviousSibling() : 0 );
1743  }
1745  XMLHandle PreviousSiblingElement( const char* _value=0 ) {
1746  return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
1747  }
1750  return XMLHandle( _node ? _node->NextSibling() : 0 );
1751  }
1753  XMLHandle NextSiblingElement( const char* _value=0 ) {
1754  return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
1755  }
1756 
1759  return _node;
1760  }
1763  return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
1764  }
1767  return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
1768  }
1771  return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
1772  }
1775  return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
1776  }
1777 
1778 private:
1780 };
1781 
1782 
1788 {
1789 public:
1790  XMLConstHandle( const XMLNode* node ) {
1791  _node = node;
1792  }
1793  XMLConstHandle( const XMLNode& node ) {
1794  _node = &node;
1795  }
1797  _node = ref._node;
1798  }
1799 
1801  _node = ref._node;
1802  return *this;
1803  }
1804 
1805  const XMLConstHandle FirstChild() const {
1806  return XMLConstHandle( _node ? _node->FirstChild() : 0 );
1807  }
1808  const XMLConstHandle FirstChildElement( const char* value=0 ) const {
1809  return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
1810  }
1811  const XMLConstHandle LastChild() const {
1812  return XMLConstHandle( _node ? _node->LastChild() : 0 );
1813  }
1814  const XMLConstHandle LastChildElement( const char* _value=0 ) const {
1815  return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
1816  }
1818  return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
1819  }
1820  const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const {
1821  return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
1822  }
1823  const XMLConstHandle NextSibling() const {
1824  return XMLConstHandle( _node ? _node->NextSibling() : 0 );
1825  }
1826  const XMLConstHandle NextSiblingElement( const char* _value=0 ) const {
1827  return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
1828  }
1829 
1830 
1831  const XMLNode* ToNode() const {
1832  return _node;
1833  }
1834  const XMLElement* ToElement() const {
1835  return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
1836  }
1837  const XMLText* ToText() const {
1838  return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
1839  }
1840  const XMLUnknown* ToUnknown() const {
1841  return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
1842  }
1844  return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
1845  }
1846 
1847 private:
1848  const XMLNode* _node;
1849 };
1850 
1851 
1895 {
1896 public:
1903  XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
1904  virtual ~XMLPrinter() {}
1905 
1907  void PushHeader( bool writeBOM, bool writeDeclaration );
1911  void OpenElement( const char* name );
1913  void PushAttribute( const char* name, const char* value );
1914  void PushAttribute( const char* name, int value );
1915  void PushAttribute( const char* name, unsigned value );
1916  void PushAttribute( const char* name, bool value );
1917  void PushAttribute( const char* name, double value );
1919  virtual void CloseElement();
1920 
1922  void PushText( const char* text, bool cdata=false , bool specrow=false );
1924  void PushText( int value );
1926  void PushText( unsigned value );
1928  void PushText( bool value );
1930  void PushText( float value );
1932  void PushText( double value );
1933 
1935  void PushComment( const char* comment );
1936 
1937  void PushDeclaration( const char* value );
1938  void PushUnknown( const char* value );
1939 
1940  virtual bool VisitEnter( const XMLDocument& /*doc*/ );
1941  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
1942  return true;
1943  }
1944 
1945  virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
1946  virtual bool VisitExit( const XMLElement& element );
1947 
1948  virtual bool Visit( const XMLText& text );
1949  virtual bool Visit( const XMLComment& comment );
1950  virtual bool Visit( const XMLDeclaration& declaration );
1951  virtual bool Visit( const XMLUnknown& unknown );
1952 
1957  const char* CStr() const {
1958  return _buffer.Mem();
1959  }
1965  int CStrSize() const {
1966  return _buffer.Size();
1967  }
1968 
1969 protected:
1970  void SealElement();
1973 
1974 private:
1975  void PrintSpace( int depth );
1976  void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
1977  void Print( const char* format, ... );
1978 
1980  FILE* _fp;
1981  int _depth;
1985 
1986  enum {
1987  ENTITY_RANGE = 64,
1988  BUF_SIZE = 200
1989  };
1990  bool _entityFlag[ENTITY_RANGE];
1991  bool _restrictedEntityFlag[ENTITY_RANGE];
1992 
1994 #ifdef _MSC_VER
1995  DynArray< char, 20 > _accumulator;
1996 #endif
1997 };
1998 
1999 
2000 } // tinyxml2
2001 
2002 #if defined(_MSC_VER)
2003 # pragma warning(pop)
2004 #endif
2005 
2006 #endif // TINYXML2_INCLUDED
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1130
double DoubleAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1186
T & operator[](int i)
Definition: tinyxml2.h:244
Whitespace _whitespace
Definition: tinyxml2.h:1636
int QueryAttribute(const char *name, int *value) const
Given an attribute name, QueryAttribute() returns XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conve...
Definition: tinyxml2.h:1278
int QueryAttribute(const char *name, bool *value) const
Definition: tinyxml2.h:1286
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1843
void CollapseWhitespace()
Definition: tinyxml2.cpp:151
const char * _errorStr1
Definition: tinyxml2.h:1637
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1046
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1598
virtual ~XMLText()
Definition: tinyxml2.h:874
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:1805
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:1811
XMLError QueryIntValue(int *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1095
const XMLText * ToText() const
Definition: tinyxml2.h:1837
virtual void Free(void *mem)
Definition: tinyxml2.h:358
static const int TIXML2_PATCH_VERSION
Definition: tinyxml2.h:121
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1228
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:631
T * PushArr(int count)
Definition: tinyxml2.h:224
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:607
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1707
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:625
virtual void * Alloc()
Definition: tinyxml2.h:335
const XMLNode * _node
Definition: tinyxml2.h:1848
virtual ~MemPool()
Definition: tinyxml2.h:304
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1122
void PopArr(int count)
Definition: tinyxml2.h:235
XMLAttribute * _rootAttribute
Definition: tinyxml2.h:1430
MemPoolT< sizeof(XMLAttribute) > _attributePool
Definition: tinyxml2.h:1642
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:482
const T & operator[](int i) const
Definition: tinyxml2.h:249
Printing functionality.
Definition: tinyxml2.h:1894
int CurrentAllocs() const
Definition: tinyxml2.h:331
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1309
virtual ~XMLAttribute()
Definition: tinyxml2.h:1097
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:603
XMLNode * FirstChild()
Definition: tinyxml2.h:675
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:1800
virtual const XMLText * ToText() const
Definition: tinyxml2.h:622
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:447
XMLNode * _lastChild
Definition: tinyxml2.h:822
virtual ~XMLVisitor()
Definition: tinyxml2.h:435
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:864
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:159
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:402
virtual void Free(void *)=0
A variant of the XMLHandle class for working with const XMLNodes and Documents.
Definition: tinyxml2.h:1787
int ClosingType() const
Definition: tinyxml2.h:1408
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:504
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:494
XMLHandle LastChildElement(const char *_value=0)
Get the last child element of this handle.
Definition: tinyxml2.h:1737
XMLNode * _next
Definition: tinyxml2.h:825
const XMLElement * RootElement() const
Definition: tinyxml2.h:1529
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:958
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:460
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:671
XMLNode * _firstChild
Definition: tinyxml2.h:821
const char * Name() const
The name of the attribute.
Definition: tinyxml2.h:1018
virtual bool ShallowEqual(const XMLNode *) const
Test if 2 nodes are the same, but don't test children.
Definition: tinyxml2.h:1625
The element is a container class.
Definition: tinyxml2.h:1116
static char * SkipWhiteSpace(char *p)
Definition: tinyxml2.h:488
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1052
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:1790
XMLNode * PreviousSibling()
Definition: tinyxml2.h:711
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:442
char * ParseName(char *in)
Definition: tinyxml2.cpp:131
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:1793
int QueryAttribute(const char *name, double *value) const
Definition: tinyxml2.h:1290
void SetAttribute(const char *value)
Set the attribute to a string value.
Definition: tinyxml2.cpp:1140
virtual const XMLText * ToText() const
Definition: tinyxml2.h:855
int Capacity() const
Definition: tinyxml2.h:263
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1252
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:634
XMLNode * _parent
Definition: tinyxml2.h:818
const XMLNode * ToNode() const
Definition: tinyxml2.h:1831
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:1817
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:852
MemPool * _memPool
Definition: tinyxml2.h:828
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:464
int IntAttribute(const char *name) const
Given an attribute name, IntAttribute() returns the value of the attribute interpreted as an integer...
Definition: tinyxml2.h:1168
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:1733
XMLNode * Parent()
Definition: tinyxml2.h:661
const char * Value() const
The value of the attribute.
Definition: tinyxml2.h:1022
virtual XMLNode * ShallowClone(XMLDocument *) const
Make a copy of this node, but not its children.
Definition: tinyxml2.h:1622
const T & PeekTop() const
Definition: tinyxml2.h:254
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1299
A Document binds together all the functionality.
Definition: tinyxml2.h:1445
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition: tinyxml2.h:1610
static const int TIXML2_MINOR_VERSION
Definition: tinyxml2.h:120
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1840
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:1719
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:1823
void SetBOM(bool useBOM)
Sets whether to write the BOM when writing the file.
Definition: tinyxml2.h:1519
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1131
bool ProcessEntities() const
Definition: tinyxml2.h:1504
DynArray< char, 20 > _buffer
Definition: tinyxml2.h:1993
const XMLConstHandle NextSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1826
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1602
XMLElement * RootElement()
Return the root element of DOM.
Definition: tinyxml2.h:1526
Any tag that TinyXML-2 doesn't recognize is saved as an unknown.
Definition: tinyxml2.h:954
A XMLHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing...
Definition: tinyxml2.h:1703
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:657
virtual ~XMLPrinter()
Definition: tinyxml2.h:1904
XMLAttribute * _next
Definition: tinyxml2.h:1107
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1026
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1244
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1126
virtual int ItemSize() const
Definition: tinyxml2.h:328
XMLNode is a base class for every object that is in the XML Document Object Model (DOM)...
Definition: tinyxml2.h:579
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1319
int IntValue() const
IntValue interprets the attribute as an integer, and returns the value.
Definition: tinyxml2.h:1034
int QueryAttribute(const char *name, float *value) const
Definition: tinyxml2.h:1294
static const int TIXML2_MAJOR_VERSION
Definition: tinyxml2.h:119
const char * Value() const
The meaning of 'value' changes for the specific type.
Definition: tinyxml2.h:647
StrPair _value
Definition: tinyxml2.h:819
void DeleteNode(XMLNode *node)
Delete a node associated with this document.
Definition: tinyxml2.h:1591
virtual void SetTracked()=0
MemPoolT< sizeof(XMLComment) > _commentPool
Definition: tinyxml2.h:1644
virtual void * Alloc()=0
XMLHandle NextSiblingElement(const char *_value=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:1753
An attribute is a name-value pair.
Definition: tinyxml2.h:1013
#define TINYXML2_LIB
Definition: tinyxml2.h:75
bool BoolAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1180
const char * GetStr()
Definition: tinyxml2.cpp:178
const XMLConstHandle LastChildElement(const char *_value=0) const
Definition: tinyxml2.h:1814
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:1941
void SetStr(const char *str, int flags=0)
Definition: tinyxml2.cpp:100
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:1711
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:860
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:590
XMLError QueryLongAttribute(const char *name, long *value) const
Given an attribute name, QueryIntAttribute() returns XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the co...
Definition: tinyxml2.h:1212
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:586
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:926
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:615
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:511
int Untracked() const
Definition: tinyxml2.h:379
const char * _errorStr2
Definition: tinyxml2.h:1638
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1174
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:451
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1133
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:468
XML text.
Definition: tinyxml2.h:845
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:1796
#define TIXML_SNPRINTF
Definition: tinyxml2.h:115
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:707
const XMLConstHandle FirstChildElement(const char *value=0) const
Definition: tinyxml2.h:1808
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:929
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:743
In correct XML the declaration is the first entry in the file.
Definition: tinyxml2.h:922
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1314
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition: tinyxml2.h:1606
#define TIXMLASSERT(x)
Definition: tinyxml2.h:90
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:1972
XMLNode * NextSibling()
Definition: tinyxml2.h:727
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1220
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1758
void Trace(const char *name)
Definition: tinyxml2.h:370
Implements the interface to the "Visitor pattern" (see the Accept() method.) If you call the Accept()...
Definition: tinyxml2.h:432
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1749
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1040
int Size() const
Definition: tinyxml2.h:259
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1104
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:873
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:498
const XMLElement * ToElement() const
Definition: tinyxml2.h:1834
void DeleteChild(XMLNode *node)
Delete a child of this node.
Definition: tinyxml2.cpp:651
XMLDocument * _document
Definition: tinyxml2.h:817
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:599
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1304
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1236
bool HasBOM() const
Returns true if this document has a leading Byte Order Mark of UTF8.
Definition: tinyxml2.h:1514
void EnsureCapacity(int cap)
Definition: tinyxml2.h:276
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:1766
int QueryAttribute(const char *name, unsigned int *value) const
Definition: tinyxml2.h:1282
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:689
static int IsUTF8Continuation(const char p)
Definition: tinyxml2.h:527
const T * Mem() const
Definition: tinyxml2.h:267
XMLNode * LastChild()
Definition: tinyxml2.h:693
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:1741
MemPoolT< sizeof(XMLText) > _textPool
Definition: tinyxml2.h:1643
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:1774
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:666
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:628
int CStrSize() const
If in print to memory mode, return the size of the XML file in memory.
Definition: tinyxml2.h:1965
MemPoolT< sizeof(XMLElement) > _elementPool
Definition: tinyxml2.h:1641
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1330
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:1770
const XMLConstHandle PreviousSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1820
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1725
XMLElement * FirstChildElement(const char *value=0)
Definition: tinyxml2.h:684
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:961
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1762
float FloatAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1192
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:456
bool Empty() const
Definition: tinyxml2.h:240
void Push(T t)
Definition: tinyxml2.h:219
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:438
XMLNode * _prev
Definition: tinyxml2.h:824
XMLElement * NextSiblingElement(const char *value=0)
Definition: tinyxml2.h:734
XMLElement * LastChildElement(const char *value=0)
Definition: tinyxml2.h:702
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:619
char * ParseText(char *in, const char *endTag, int strFlags)
Definition: tinyxml2.cpp:111
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1113
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1453
virtual int ItemSize() const =0
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1507
An XML Comment.
Definition: tinyxml2.h:884
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1058
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:611
XMLHandle PreviousSiblingElement(const char *_value=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:1745
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:595
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:888
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:891
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:723
XMLError QueryLongValue(long *value) const
QueryIntValue interprets the attribute as an integer, and returns the value in the provided parameter...
Definition: tinyxml2.cpp:1086
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1715
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1456
XMLElement * PreviousSiblingElement(const char *value=0)
Definition: tinyxml2.h:718
bool Empty() const
Definition: tinyxml2.h:168
const char * CStr() const
If in print to memory mode, return a pointer to the XML file in memory.
Definition: tinyxml2.h:1957
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1122
XMLHandle FirstChildElement(const char *value=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1729
void SetInternedStr(const char *str)
Definition: tinyxml2.h:172