Scheduler
tinyxml2.h
Go to the documentation of this file.
1 
10 /*
11 Original code by Lee Thomason (www.grinninglizard.com)
12 
13 This software is provided 'as-is', without any express or implied
14 warranty. In no event will the authors be held liable for any
15 damages arising from the use of this software.
16 
17 Permission is granted to anyone to use this software for any
18 purpose, including commercial applications, and to alter it and
19 redistribute it freely, subject to the following restrictions:
20 
21 1. The origin of this software must not be misrepresented; you must
22 not claim that you wrote the original software. If you use this
23 software in a product, an acknowledgment in the product documentation
24 would be appreciated but is not required.
25 
26 2. Altered source versions must be plainly marked as such, and
27 must not be misrepresented as being the original software.
28 
29 3. This notice may not be removed or altered from any source
30 distribution.
31 */
32 
33 #ifndef TINYXML2_INCLUDED
34 #define TINYXML2_INCLUDED
35 
36 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
37 # include <ctype.h>
38 # include <limits.h>
39 # include <stdio.h>
40 # include <stdlib.h>
41 # include <string.h>
42 # if defined(__PS3__)
43 # include <stddef.h>
44 # endif
45 #else
46 # include <cctype>
47 # include <climits>
48 # include <cstdio>
49 # include <cstdlib>
50 # include <cstring>
51 #endif
52 #include <stdint.h>
53 
54 /*
55  TODO: intern strings instead of allocation.
56 */
57 /*
58  gcc:
59  g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
60 
61  Formatting, Artistic Style:
62  AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
63 */
64 
65 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
66 # ifndef DEBUG
67 # define DEBUG
68 # endif
69 #endif
70 
71 #ifdef _MSC_VER
72 # pragma warning(push)
73 # pragma warning(disable: 4251)
74 #endif
75 
76 #ifdef _WIN32
77 # ifdef TINYXML2_EXPORT
78 # define TINYXML2_LIB __declspec(dllexport)
79 # elif defined(TINYXML2_IMPORT)
80 # define TINYXML2_LIB __declspec(dllimport)
81 # else
82 # define TINYXML2_LIB
83 # endif
84 #elif __GNUC__ >= 4
85 # define TINYXML2_LIB __attribute__((visibility("default")))
86 #else
87 # define TINYXML2_LIB
88 #endif
89 
90 
91 #if defined(DEBUG)
92 # if defined(_MSC_VER)
93 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
94 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
95 # elif defined (ANDROID_NDK)
96 # include <android/log.h>
97 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
98 # else
99 # include <assert.h>
100 # define TIXMLASSERT assert
101 # endif
102 #else
103 # define TIXMLASSERT( x ) {}
104 #endif
105 
106 
107 /* Versioning, past 1.0.14:
108  http://semver.org/
109 */
110 static const int TIXML2_MAJOR_VERSION = 4;
111 static const int TIXML2_MINOR_VERSION = 0;
112 static const int TIXML2_PATCH_VERSION = 1;
113 
114 namespace tinyxml2
115 {
116 class XMLDocument;
117 class XMLElement;
118 class XMLAttribute;
119 class XMLComment;
120 class XMLText;
121 class XMLDeclaration;
122 class XMLUnknown;
123 class XMLPrinter;
124 
125 /*
126  A class that wraps strings. Normally stores the start and end
127  pointers into the XML file itself, and will apply normalization
128  and entity translation if actually read. Can also store (and memory
129  manage) a traditional char[]
130 */
131 class StrPair
132 {
133 public:
134  enum {
138 
145  };
146 
147  StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
148  ~StrPair();
149 
150  void Set( char* start, char* end, int flags ) {
151  TIXMLASSERT( start );
152  TIXMLASSERT( end );
153  Reset();
154  _start = start;
155  _end = end;
156  _flags = flags | NEEDS_FLUSH;
157  }
158 
159  const char* GetStr();
160 
161  bool Empty() const {
162  return _start == _end;
163  }
164 
165  void SetInternedStr( const char* str ) {
166  Reset();
167  _start = const_cast<char*>(str);
168  }
169 
170  void SetStr( const char* str, int flags=0 );
171 
172  char* ParseText( char* in, const char* endTag, int strFlags );
173  char* ParseName( char* in );
174 
175  void TransferTo( StrPair* other );
176  void Reset();
177 
178 private:
179  void CollapseWhitespace();
180 
181  enum {
182  NEEDS_FLUSH = 0x100,
183  NEEDS_DELETE = 0x200
184  };
185 
186  int _flags;
187  char* _start;
188  char* _end;
189 
190  StrPair( const StrPair& other ); // not supported
191  void operator=( StrPair& other ); // not supported, use TransferTo()
192 };
193 
194 
195 /*
196  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
197  Has a small initial memory pool, so that low or no usage will not
198  cause a call to new/delete
199 */
200 template <class T, int INITIAL_SIZE>
201 class DynArray
202 {
203 public:
205  _mem = _pool;
206  _allocated = INITIAL_SIZE;
207  _size = 0;
208  }
209 
211  if ( _mem != _pool ) {
212  delete [] _mem;
213  }
214  }
215 
216  void Clear() {
217  _size = 0;
218  }
219 
220  void Push( T t ) {
221  TIXMLASSERT( _size < INT_MAX );
222  EnsureCapacity( _size+1 );
223  _mem[_size] = t;
224  ++_size;
225  }
226 
227  T* PushArr( int count ) {
228  TIXMLASSERT( count >= 0 );
229  TIXMLASSERT( _size <= INT_MAX - count );
230  EnsureCapacity( _size+count );
231  T* ret = &_mem[_size];
232  _size += count;
233  return ret;
234  }
235 
236  T Pop() {
237  TIXMLASSERT( _size > 0 );
238  --_size;
239  return _mem[_size];
240  }
241 
242  void PopArr( int count ) {
243  TIXMLASSERT( _size >= count );
244  _size -= count;
245  }
246 
247  bool Empty() const {
248  return _size == 0;
249  }
250 
251  T& operator[](int i) {
252  TIXMLASSERT( i>= 0 && i < _size );
253  return _mem[i];
254  }
255 
256  const T& operator[](int i) const {
257  TIXMLASSERT( i>= 0 && i < _size );
258  return _mem[i];
259  }
260 
261  const T& PeekTop() const {
262  TIXMLASSERT( _size > 0 );
263  return _mem[ _size - 1];
264  }
265 
266  int Size() const {
267  TIXMLASSERT( _size >= 0 );
268  return _size;
269  }
270 
271  int Capacity() const {
272  TIXMLASSERT( _allocated >= INITIAL_SIZE );
273  return _allocated;
274  }
275 
276  const T* Mem() const {
277  TIXMLASSERT( _mem );
278  return _mem;
279  }
280 
281  T* Mem() {
282  TIXMLASSERT( _mem );
283  return _mem;
284  }
285 
286 private:
287  DynArray( const DynArray& ); // not supported
288  void operator=( const DynArray& ); // not supported
289 
290  void EnsureCapacity( int cap ) {
291  TIXMLASSERT( cap > 0 );
292  if ( cap > _allocated ) {
293  TIXMLASSERT( cap <= INT_MAX / 2 );
294  int newAllocated = cap * 2;
295  T* newMem = new T[newAllocated];
296  memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
297  if ( _mem != _pool ) {
298  delete [] _mem;
299  }
300  _mem = newMem;
301  _allocated = newAllocated;
302  }
303  }
304 
305  T* _mem;
306  T _pool[INITIAL_SIZE];
307  int _allocated; // objects allocated
308  int _size; // number objects in use
309 };
310 
311 
312 /*
313  Parent virtual class of a pool for fast allocation
314  and deallocation of objects.
315 */
316 class MemPool
317 {
318 public:
319  MemPool() {}
320  virtual ~MemPool() {}
321 
322  virtual int ItemSize() const = 0;
323  virtual void* Alloc() = 0;
324  virtual void Free( void* ) = 0;
325  virtual void SetTracked() = 0;
326  virtual void Clear() = 0;
327 };
328 
329 
330 /*
331  Template child class to create pools of the correct type.
332 */
333 template< int ITEM_SIZE >
334 class MemPoolT : public MemPool
335 {
336 public:
337  MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
339  Clear();
340  }
341 
342  void Clear() {
343  // Delete the blocks.
344  while( !_blockPtrs.Empty()) {
345  Block* b = _blockPtrs.Pop();
346  delete b;
347  }
348  _root = 0;
349  _currentAllocs = 0;
350  _nAllocs = 0;
351  _maxAllocs = 0;
352  _nUntracked = 0;
353  }
354 
355  virtual int ItemSize() const {
356  return ITEM_SIZE;
357  }
358  int CurrentAllocs() const {
359  return _currentAllocs;
360  }
361 
362  virtual void* Alloc() {
363  if ( !_root ) {
364  // Need a new block.
365  Block* block = new Block();
366  _blockPtrs.Push( block );
367 
368  Item* blockItems = block->items;
369  for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
370  blockItems[i].next = &(blockItems[i + 1]);
371  }
372  blockItems[ITEMS_PER_BLOCK - 1].next = 0;
373  _root = blockItems;
374  }
375  Item* const result = _root;
376  TIXMLASSERT( result != 0 );
377  _root = _root->next;
378 
379  ++_currentAllocs;
380  if ( _currentAllocs > _maxAllocs ) {
381  _maxAllocs = _currentAllocs;
382  }
383  ++_nAllocs;
384  ++_nUntracked;
385  return result;
386  }
387 
388  virtual void Free( void* mem ) {
389  if ( !mem ) {
390  return;
391  }
392  --_currentAllocs;
393  Item* item = static_cast<Item*>( mem );
394 #ifdef DEBUG
395  memset( item, 0xfe, sizeof( *item ) );
396 #endif
397  item->next = _root;
398  _root = item;
399  }
400  void Trace( const char* name ) {
401  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
402  name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
403  ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
404  }
405 
406  void SetTracked() {
407  --_nUntracked;
408  }
409 
410  int Untracked() const {
411  return _nUntracked;
412  }
413 
414  // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
415  // The test file is large, 170k.
416  // Release: VS2010 gcc(no opt)
417  // 1k: 4000
418  // 2k: 4000
419  // 4k: 3900 21000
420  // 16k: 5200
421  // 32k: 4300
422  // 64k: 4000 21000
423  // Declared public because some compilers do not accept to use ITEMS_PER_BLOCK
424  // in private part if ITEMS_PER_BLOCK is private
425  enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
426 
427 private:
428  MemPoolT( const MemPoolT& ); // not supported
429  void operator=( const MemPoolT& ); // not supported
430 
431  union Item {
432  Item* next;
433  char itemData[ITEM_SIZE];
434  };
435  struct Block {
436  Item items[ITEMS_PER_BLOCK];
437  };
438  DynArray< Block*, 10 > _blockPtrs;
439  Item* _root;
440 
441  int _currentAllocs;
442  int _nAllocs;
443  int _maxAllocs;
444  int _nUntracked;
445 };
446 
447 
448 
469 {
470 public:
471  virtual ~XMLVisitor() {}
472 
474  virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
475  return true;
476  }
478  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
479  return true;
480  }
481 
483  virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
484  return true;
485  }
487  virtual bool VisitExit( const XMLElement& /*element*/ ) {
488  return true;
489  }
490 
492  virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
493  return true;
494  }
496  virtual bool Visit( const XMLText& /*text*/ ) {
497  return true;
498  }
500  virtual bool Visit( const XMLComment& /*comment*/ ) {
501  return true;
502  }
504  virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
505  return true;
506  }
507 };
508 
509 // WARNING: must match XMLDocument::_errorNames[]
510 enum XMLError {
531 
533 };
534 
535 
536 /*
537  Utility functionality.
538 */
539 class XMLUtil
540 {
541 public:
542  static const char* SkipWhiteSpace( const char* p ) {
543  TIXMLASSERT( p );
544  while( IsWhiteSpace(*p) ) {
545  ++p;
546  }
547  TIXMLASSERT( p );
548  return p;
549  }
550  static char* SkipWhiteSpace( char* p ) {
551  return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );
552  }
553 
554  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
555  // correct, but simple, and usually works.
556  static bool IsWhiteSpace( char p ) {
557  return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
558  }
559 
560  inline static bool IsNameStartChar( unsigned char ch ) {
561  if ( ch >= 128 ) {
562  // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
563  return true;
564  }
565  if ( isalpha( ch ) ) {
566  return true;
567  }
568  return ch == ':' || ch == '_';
569  }
570 
571  inline static bool IsNameChar( unsigned char ch ) {
572  return IsNameStartChar( ch )
573  || isdigit( ch )
574  || ch == '.'
575  || ch == '-';
576  }
577 
578  inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
579  if ( p == q ) {
580  return true;
581  }
582  TIXMLASSERT( p );
583  TIXMLASSERT( q );
584  TIXMLASSERT( nChar >= 0 );
585  return strncmp( p, q, nChar ) == 0;
586  }
587 
588  inline static bool IsUTF8Continuation( char p ) {
589  return ( p & 0x80 ) != 0;
590  }
591 
592  static const char* ReadBOM( const char* p, bool* hasBOM );
593  // p is the starting location,
594  // the UTF-8 value of the entity will be placed in value, and length filled in.
595  static const char* GetCharacterRef( const char* p, char* value, int* length );
596  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
597 
598  // converts primitive types to strings
599  static void ToStr( int v, char* buffer, int bufferSize );
600  static void ToStr( unsigned v, char* buffer, int bufferSize );
601  static void ToStr( bool v, char* buffer, int bufferSize );
602  static void ToStr( float v, char* buffer, int bufferSize );
603  static void ToStr( double v, char* buffer, int bufferSize );
604  static void ToStr(int64_t v, char* buffer, int bufferSize);
605 
606  // converts strings to primitive types
607  static bool ToInt( const char* str, int* value );
608  static bool ToUnsigned( const char* str, unsigned* value );
609  static bool ToBool( const char* str, bool* value );
610  static bool ToFloat( const char* str, float* value );
611  static bool ToDouble( const char* str, double* value );
612  static bool ToInt64(const char* str, int64_t* value);
613 };
614 
615 
642 {
643  friend class XMLDocument;
644  friend class XMLElement;
645 public:
646 
648  const XMLDocument* GetDocument() const {
649  TIXMLASSERT( _document );
650  return _document;
651  }
654  TIXMLASSERT( _document );
655  return _document;
656  }
657 
659  virtual XMLElement* ToElement() {
660  return 0;
661  }
663  virtual XMLText* ToText() {
664  return 0;
665  }
667  virtual XMLComment* ToComment() {
668  return 0;
669  }
671  virtual XMLDocument* ToDocument() {
672  return 0;
673  }
676  return 0;
677  }
679  virtual XMLUnknown* ToUnknown() {
680  return 0;
681  }
682 
683  virtual const XMLElement* ToElement() const {
684  return 0;
685  }
686  virtual const XMLText* ToText() const {
687  return 0;
688  }
689  virtual const XMLComment* ToComment() const {
690  return 0;
691  }
692  virtual const XMLDocument* ToDocument() const {
693  return 0;
694  }
695  virtual const XMLDeclaration* ToDeclaration() const {
696  return 0;
697  }
698  virtual const XMLUnknown* ToUnknown() const {
699  return 0;
700  }
701 
711  const char* Value() const;
712 
716  void SetValue( const char* val, bool staticMem=false );
717 
719  const XMLNode* Parent() const {
720  return _parent;
721  }
722 
724  return _parent;
725  }
726 
728  bool NoChildren() const {
729  return !_firstChild;
730  }
731 
733  const XMLNode* FirstChild() const {
734  return _firstChild;
735  }
736 
738  return _firstChild;
739  }
740 
744  const XMLElement* FirstChildElement( const char* name = 0 ) const;
745 
746  XMLElement* FirstChildElement( const char* name = 0 ) {
747  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
748  }
749 
751  const XMLNode* LastChild() const {
752  return _lastChild;
753  }
754 
756  return _lastChild;
757  }
758 
762  const XMLElement* LastChildElement( const char* name = 0 ) const;
763 
764  XMLElement* LastChildElement( const char* name = 0 ) {
765  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
766  }
767 
769  const XMLNode* PreviousSibling() const {
770  return _prev;
771  }
772 
774  return _prev;
775  }
776 
778  const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
779 
780  XMLElement* PreviousSiblingElement( const char* name = 0 ) {
781  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
782  }
783 
785  const XMLNode* NextSibling() const {
786  return _next;
787  }
788 
790  return _next;
791  }
792 
794  const XMLElement* NextSiblingElement( const char* name = 0 ) const;
795 
796  XMLElement* NextSiblingElement( const char* name = 0 ) {
797  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
798  }
799 
807  XMLNode* InsertEndChild( XMLNode* addThis );
808 
809  XMLNode* LinkEndChild( XMLNode* addThis ) {
810  return InsertEndChild( addThis );
811  }
819  XMLNode* InsertFirstChild( XMLNode* addThis );
828  XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
829 
833  void DeleteChildren();
834 
838  void DeleteChild( XMLNode* node );
839 
849  virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
850 
857  virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
858 
881  virtual bool Accept( XMLVisitor* visitor ) const = 0;
882 
888  void SetUserData(void* userData) { _userData = userData; }
889 
895  void* GetUserData() const { return _userData; }
896 
897 protected:
898  XMLNode( XMLDocument* );
899  virtual ~XMLNode();
900 
901  virtual char* ParseDeep( char*, StrPair* );
902 
905  mutable StrPair _value;
906 
909 
912 
913  void* _userData;
914 
915 private:
916  MemPool* _memPool;
917  void Unlink( XMLNode* child );
918  static void DeleteNode( XMLNode* node );
919  void InsertChildPreamble( XMLNode* insertThis ) const;
920  const XMLElement* ToElementWithName( const char* name ) const;
921 
922  XMLNode( const XMLNode& ); // not supported
923  XMLNode& operator=( const XMLNode& ); // not supported
924 };
925 
926 
940 {
941  friend class XMLDocument;
942 public:
943  virtual bool Accept( XMLVisitor* visitor ) const;
944 
945  virtual XMLText* ToText() {
946  return this;
947  }
948  virtual const XMLText* ToText() const {
949  return this;
950  }
951 
953  void SetCData( bool isCData ) {
954  _isCData = isCData;
955  }
957  bool CData() const {
958  return _isCData;
959  }
960 
961  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
962  virtual bool ShallowEqual( const XMLNode* compare ) const;
963 
964 protected:
965  XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
966  virtual ~XMLText() {}
967 
968  char* ParseDeep( char*, StrPair* endTag );
969 
970 private:
971  bool _isCData;
972 
973  XMLText( const XMLText& ); // not supported
974  XMLText& operator=( const XMLText& ); // not supported
975 };
976 
977 
980 {
981  friend class XMLDocument;
982 public:
983  virtual XMLComment* ToComment() {
984  return this;
985  }
986  virtual const XMLComment* ToComment() const {
987  return this;
988  }
989 
990  virtual bool Accept( XMLVisitor* visitor ) const;
991 
992  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
993  virtual bool ShallowEqual( const XMLNode* compare ) const;
994 
995 protected:
996  XMLComment( XMLDocument* doc );
997  virtual ~XMLComment();
998 
999  char* ParseDeep( char*, StrPair* endTag );
1000 
1001 private:
1002  XMLComment( const XMLComment& ); // not supported
1003  XMLComment& operator=( const XMLComment& ); // not supported
1004 };
1005 
1006 
1019 {
1020  friend class XMLDocument;
1021 public:
1023  return this;
1024  }
1025  virtual const XMLDeclaration* ToDeclaration() const {
1026  return this;
1027  }
1028 
1029  virtual bool Accept( XMLVisitor* visitor ) const;
1030 
1031  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1032  virtual bool ShallowEqual( const XMLNode* compare ) const;
1033 
1034 protected:
1035  XMLDeclaration( XMLDocument* doc );
1036  virtual ~XMLDeclaration();
1037 
1038  char* ParseDeep( char*, StrPair* endTag );
1039 
1040 private:
1041  XMLDeclaration( const XMLDeclaration& ); // not supported
1042  XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
1043 };
1044 
1045 
1054 {
1055  friend class XMLDocument;
1056 public:
1057  virtual XMLUnknown* ToUnknown() {
1058  return this;
1059  }
1060  virtual const XMLUnknown* ToUnknown() const {
1061  return this;
1062  }
1063 
1064  virtual bool Accept( XMLVisitor* visitor ) const;
1065 
1066  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1067  virtual bool ShallowEqual( const XMLNode* compare ) const;
1068 
1069 protected:
1070  XMLUnknown( XMLDocument* doc );
1071  virtual ~XMLUnknown();
1072 
1073  char* ParseDeep( char*, StrPair* endTag );
1074 
1075 private:
1076  XMLUnknown( const XMLUnknown& ); // not supported
1077  XMLUnknown& operator=( const XMLUnknown& ); // not supported
1078 };
1079 
1080 
1081 
1089 {
1090  friend class XMLElement;
1091 public:
1093  const char* Name() const;
1094 
1096  const char* Value() const;
1097 
1099  const XMLAttribute* Next() const {
1100  return _next;
1101  }
1102 
1107  int IntValue() const {
1108  int i = 0;
1109  QueryIntValue(&i);
1110  return i;
1111  }
1112 
1113  int64_t Int64Value() const {
1114  int64_t i = 0;
1115  QueryInt64Value(&i);
1116  return i;
1117  }
1118 
1120  unsigned UnsignedValue() const {
1121  unsigned i=0;
1122  QueryUnsignedValue( &i );
1123  return i;
1124  }
1126  bool BoolValue() const {
1127  bool b=false;
1128  QueryBoolValue( &b );
1129  return b;
1130  }
1132  double DoubleValue() const {
1133  double d=0;
1134  QueryDoubleValue( &d );
1135  return d;
1136  }
1138  float FloatValue() const {
1139  float f=0;
1140  QueryFloatValue( &f );
1141  return f;
1142  }
1143 
1148  XMLError QueryIntValue( int* value ) const;
1150  XMLError QueryUnsignedValue( unsigned int* value ) const;
1152  XMLError QueryInt64Value(int64_t* value) const;
1154  XMLError QueryBoolValue( bool* value ) const;
1156  XMLError QueryDoubleValue( double* value ) const;
1158  XMLError QueryFloatValue( float* value ) const;
1159 
1161  void SetAttribute( const char* value );
1163  void SetAttribute( int value );
1165  void SetAttribute( unsigned value );
1167  void SetAttribute(int64_t value);
1169  void SetAttribute( bool value );
1171  void SetAttribute( double value );
1173  void SetAttribute( float value );
1174 
1175 private:
1176  enum { BUF_SIZE = 200 };
1177 
1178  XMLAttribute() : _next( 0 ), _memPool( 0 ) {}
1179  virtual ~XMLAttribute() {}
1180 
1181  XMLAttribute( const XMLAttribute& ); // not supported
1182  void operator=( const XMLAttribute& ); // not supported
1183  void SetName( const char* name );
1184 
1185  char* ParseDeep( char* p, bool processEntities );
1186 
1187  mutable StrPair _name;
1188  mutable StrPair _value;
1189  XMLAttribute* _next;
1190  MemPool* _memPool;
1191 };
1192 
1193 
1199 {
1200  friend class XMLDocument;
1201 public:
1203  const char* Name() const {
1204  return Value();
1205  }
1207  void SetName( const char* str, bool staticMem=false ) {
1208  SetValue( str, staticMem );
1209  }
1210 
1211  virtual XMLElement* ToElement() {
1212  return this;
1213  }
1214  virtual const XMLElement* ToElement() const {
1215  return this;
1216  }
1217  virtual bool Accept( XMLVisitor* visitor ) const;
1218 
1242  const char* Attribute( const char* name, const char* value=0 ) const;
1243 
1250  int IntAttribute(const char* name, int defaultValue = 0) const;
1252  unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;
1254  int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
1256  bool BoolAttribute(const char* name, bool defaultValue = false) const;
1258  double DoubleAttribute(const char* name, double defaultValue = 0) const;
1260  float FloatAttribute(const char* name, float defaultValue = 0) const;
1261 
1275  XMLError QueryIntAttribute( const char* name, int* value ) const {
1276  const XMLAttribute* a = FindAttribute( name );
1277  if ( !a ) {
1278  return XML_NO_ATTRIBUTE;
1279  }
1280  return a->QueryIntValue( value );
1281  }
1282 
1284  XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
1285  const XMLAttribute* a = FindAttribute( name );
1286  if ( !a ) {
1287  return XML_NO_ATTRIBUTE;
1288  }
1289  return a->QueryUnsignedValue( value );
1290  }
1291 
1293  XMLError QueryInt64Attribute(const char* name, int64_t* value) const {
1294  const XMLAttribute* a = FindAttribute(name);
1295  if (!a) {
1296  return XML_NO_ATTRIBUTE;
1297  }
1298  return a->QueryInt64Value(value);
1299  }
1300 
1302  XMLError QueryBoolAttribute( const char* name, bool* value ) const {
1303  const XMLAttribute* a = FindAttribute( name );
1304  if ( !a ) {
1305  return XML_NO_ATTRIBUTE;
1306  }
1307  return a->QueryBoolValue( value );
1308  }
1310  XMLError QueryDoubleAttribute( const char* name, double* value ) const {
1311  const XMLAttribute* a = FindAttribute( name );
1312  if ( !a ) {
1313  return XML_NO_ATTRIBUTE;
1314  }
1315  return a->QueryDoubleValue( value );
1316  }
1318  XMLError QueryFloatAttribute( const char* name, float* value ) const {
1319  const XMLAttribute* a = FindAttribute( name );
1320  if ( !a ) {
1321  return XML_NO_ATTRIBUTE;
1322  }
1323  return a->QueryFloatValue( value );
1324  }
1325 
1326 
1344  int QueryAttribute( const char* name, int* value ) const {
1345  return QueryIntAttribute( name, value );
1346  }
1347 
1348  int QueryAttribute( const char* name, unsigned int* value ) const {
1349  return QueryUnsignedAttribute( name, value );
1350  }
1351 
1352  int QueryAttribute(const char* name, int64_t* value) const {
1353  return QueryInt64Attribute(name, value);
1354  }
1355 
1356  int QueryAttribute( const char* name, bool* value ) const {
1357  return QueryBoolAttribute( name, value );
1358  }
1359 
1360  int QueryAttribute( const char* name, double* value ) const {
1361  return QueryDoubleAttribute( name, value );
1362  }
1363 
1364  int QueryAttribute( const char* name, float* value ) const {
1365  return QueryFloatAttribute( name, value );
1366  }
1367 
1369  void SetAttribute( const char* name, const char* value ) {
1370  XMLAttribute* a = FindOrCreateAttribute( name );
1371  a->SetAttribute( value );
1372  }
1374  void SetAttribute( const char* name, int value ) {
1375  XMLAttribute* a = FindOrCreateAttribute( name );
1376  a->SetAttribute( value );
1377  }
1379  void SetAttribute( const char* name, unsigned value ) {
1380  XMLAttribute* a = FindOrCreateAttribute( name );
1381  a->SetAttribute( value );
1382  }
1383 
1385  void SetAttribute(const char* name, int64_t value) {
1386  XMLAttribute* a = FindOrCreateAttribute(name);
1387  a->SetAttribute(value);
1388  }
1389 
1391  void SetAttribute( const char* name, bool value ) {
1392  XMLAttribute* a = FindOrCreateAttribute( name );
1393  a->SetAttribute( value );
1394  }
1396  void SetAttribute( const char* name, double value ) {
1397  XMLAttribute* a = FindOrCreateAttribute( name );
1398  a->SetAttribute( value );
1399  }
1401  void SetAttribute( const char* name, float value ) {
1402  XMLAttribute* a = FindOrCreateAttribute( name );
1403  a->SetAttribute( value );
1404  }
1405 
1409  void DeleteAttribute( const char* name );
1410 
1412  const XMLAttribute* FirstAttribute() const {
1413  return _rootAttribute;
1414  }
1416  const XMLAttribute* FindAttribute( const char* name ) const;
1417 
1446  const char* GetText() const;
1447 
1482  void SetText( const char* inText );
1484  void SetText( int value );
1486  void SetText( unsigned value );
1488  void SetText(int64_t value);
1490  void SetText( bool value );
1492  void SetText( double value );
1494  void SetText( float value );
1495 
1522  XMLError QueryIntText( int* ival ) const;
1524  XMLError QueryUnsignedText( unsigned* uval ) const;
1526  XMLError QueryInt64Text(int64_t* uval) const;
1528  XMLError QueryBoolText( bool* bval ) const;
1530  XMLError QueryDoubleText( double* dval ) const;
1532  XMLError QueryFloatText( float* fval ) const;
1533 
1534  int IntText(int defaultValue = 0) const;
1535 
1537  unsigned UnsignedText(unsigned defaultValue = 0) const;
1539  int64_t Int64Text(int64_t defaultValue = 0) const;
1541  bool BoolText(bool defaultValue = false) const;
1543  double DoubleText(double defaultValue = 0) const;
1545  float FloatText(float defaultValue = 0) const;
1546 
1547  // internal:
1548  enum {
1549  OPEN, // <foo>
1550  CLOSED, // <foo/>
1551  CLOSING // </foo>
1552  };
1553  int ClosingType() const {
1554  return _closingType;
1555  }
1556  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1557  virtual bool ShallowEqual( const XMLNode* compare ) const;
1558 
1559 protected:
1560  char* ParseDeep( char* p, StrPair* endTag );
1561 
1562 private:
1563  XMLElement( XMLDocument* doc );
1564  virtual ~XMLElement();
1565  XMLElement( const XMLElement& ); // not supported
1566  void operator=( const XMLElement& ); // not supported
1567 
1568  XMLAttribute* FindAttribute( const char* name ) {
1569  return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));
1570  }
1571  XMLAttribute* FindOrCreateAttribute( const char* name );
1572  //void LinkAttribute( XMLAttribute* attrib );
1573  char* ParseAttributes( char* p );
1574  static void DeleteAttribute( XMLAttribute* attribute );
1575 
1576  enum { BUF_SIZE = 200 };
1577  int _closingType;
1578  // The attribute list is ordered; there is no 'lastAttribute'
1579  // because the list needs to be scanned for dupes before adding
1580  // a new attribute.
1581  XMLAttribute* _rootAttribute;
1582 };
1583 
1584 
1588 };
1589 
1590 
1597 {
1598  friend class XMLElement;
1599 public:
1601  XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
1602  ~XMLDocument();
1603 
1605  TIXMLASSERT( this == _document );
1606  return this;
1607  }
1608  virtual const XMLDocument* ToDocument() const {
1609  TIXMLASSERT( this == _document );
1610  return this;
1611  }
1612 
1623  XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
1624 
1630  XMLError LoadFile( const char* filename );
1631 
1643  XMLError LoadFile( FILE* );
1644 
1650  XMLError SaveFile( const char* filename, bool compact = false );
1651 
1659  XMLError SaveFile( FILE* fp, bool compact = false );
1660 
1661  bool ProcessEntities() const {
1662  return _processEntities;
1663  }
1665  return _whitespace;
1666  }
1667 
1671  bool HasBOM() const {
1672  return _writeBOM;
1673  }
1676  void SetBOM( bool useBOM ) {
1677  _writeBOM = useBOM;
1678  }
1679 
1684  return FirstChildElement();
1685  }
1686  const XMLElement* RootElement() const {
1687  return FirstChildElement();
1688  }
1689 
1704  void Print( XMLPrinter* streamer=0 ) const;
1705  virtual bool Accept( XMLVisitor* visitor ) const;
1706 
1712  XMLElement* NewElement( const char* name );
1718  XMLComment* NewComment( const char* comment );
1724  XMLText* NewText( const char* text );
1736  XMLDeclaration* NewDeclaration( const char* text=0 );
1742  XMLUnknown* NewUnknown( const char* text );
1743 
1748  void DeleteNode( XMLNode* node );
1749 
1750  void SetError( XMLError error, const char* str1, const char* str2 );
1751 
1753  bool Error() const {
1754  return _errorID != XML_SUCCESS;
1755  }
1757  XMLError ErrorID() const {
1758  return _errorID;
1759  }
1760  const char* ErrorName() const;
1761 
1763  const char* GetErrorStr1() const {
1764  return _errorStr1.GetStr();
1765  }
1767  const char* GetErrorStr2() const {
1768  return _errorStr2.GetStr();
1769  }
1771  void PrintError() const;
1772 
1774  void Clear();
1775 
1776  // internal
1777  char* Identify( char* p, XMLNode** node );
1778 
1779  virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
1780  return 0;
1781  }
1782  virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
1783  return false;
1784  }
1785 
1786 private:
1787  XMLDocument( const XMLDocument& ); // not supported
1788  void operator=( const XMLDocument& ); // not supported
1789 
1790  bool _writeBOM;
1791  bool _processEntities;
1792  XMLError _errorID;
1793  Whitespace _whitespace;
1794  mutable StrPair _errorStr1;
1795  mutable StrPair _errorStr2;
1796  char* _charBuffer;
1797 
1798  MemPoolT< sizeof(XMLElement) > _elementPool;
1799  MemPoolT< sizeof(XMLAttribute) > _attributePool;
1800  MemPoolT< sizeof(XMLText) > _textPool;
1801  MemPoolT< sizeof(XMLComment) > _commentPool;
1802 
1803  static const char* _errorNames[XML_ERROR_COUNT];
1804 
1805  void Parse();
1806 };
1807 
1808 
1865 {
1866 public:
1868  XMLHandle( XMLNode* node ) {
1869  _node = node;
1870  }
1872  XMLHandle( XMLNode& node ) {
1873  _node = &node;
1874  }
1876  XMLHandle( const XMLHandle& ref ) {
1877  _node = ref._node;
1878  }
1880  XMLHandle& operator=( const XMLHandle& ref ) {
1881  _node = ref._node;
1882  return *this;
1883  }
1884 
1887  return XMLHandle( _node ? _node->FirstChild() : 0 );
1888  }
1890  XMLHandle FirstChildElement( const char* name = 0 ) {
1891  return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
1892  }
1895  return XMLHandle( _node ? _node->LastChild() : 0 );
1896  }
1898  XMLHandle LastChildElement( const char* name = 0 ) {
1899  return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
1900  }
1903  return XMLHandle( _node ? _node->PreviousSibling() : 0 );
1904  }
1906  XMLHandle PreviousSiblingElement( const char* name = 0 ) {
1907  return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
1908  }
1911  return XMLHandle( _node ? _node->NextSibling() : 0 );
1912  }
1914  XMLHandle NextSiblingElement( const char* name = 0 ) {
1915  return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
1916  }
1917 
1920  return _node;
1921  }
1924  return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1925  }
1928  return ( ( _node == 0 ) ? 0 : _node->ToText() );
1929  }
1932  return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
1933  }
1936  return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
1937  }
1938 
1939 private:
1940  XMLNode* _node;
1941 };
1942 
1943 
1949 {
1950 public:
1951  XMLConstHandle( const XMLNode* node ) {
1952  _node = node;
1953  }
1954  XMLConstHandle( const XMLNode& node ) {
1955  _node = &node;
1956  }
1958  _node = ref._node;
1959  }
1960 
1962  _node = ref._node;
1963  return *this;
1964  }
1965 
1966  const XMLConstHandle FirstChild() const {
1967  return XMLConstHandle( _node ? _node->FirstChild() : 0 );
1968  }
1969  const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
1970  return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
1971  }
1972  const XMLConstHandle LastChild() const {
1973  return XMLConstHandle( _node ? _node->LastChild() : 0 );
1974  }
1975  const XMLConstHandle LastChildElement( const char* name = 0 ) const {
1976  return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
1977  }
1979  return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
1980  }
1981  const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
1982  return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
1983  }
1984  const XMLConstHandle NextSibling() const {
1985  return XMLConstHandle( _node ? _node->NextSibling() : 0 );
1986  }
1987  const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
1988  return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
1989  }
1990 
1991 
1992  const XMLNode* ToNode() const {
1993  return _node;
1994  }
1995  const XMLElement* ToElement() const {
1996  return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1997  }
1998  const XMLText* ToText() const {
1999  return ( ( _node == 0 ) ? 0 : _node->ToText() );
2000  }
2001  const XMLUnknown* ToUnknown() const {
2002  return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
2003  }
2005  return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
2006  }
2007 
2008 private:
2009  const XMLNode* _node;
2010 };
2011 
2012 
2056 {
2057 public:
2064  XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
2065  virtual ~XMLPrinter() {}
2066 
2068  void PushHeader( bool writeBOM, bool writeDeclaration );
2072  void OpenElement( const char* name, bool compactMode=false );
2074  void PushAttribute( const char* name, const char* value );
2075  void PushAttribute( const char* name, int value );
2076  void PushAttribute( const char* name, unsigned value );
2077  void PushAttribute(const char* name, int64_t value);
2078  void PushAttribute( const char* name, bool value );
2079  void PushAttribute( const char* name, double value );
2081  virtual void CloseElement( bool compactMode=false );
2082 
2084  void PushText( const char* text, bool cdata=false );
2086  void PushText( int value );
2088  void PushText( unsigned value );
2090  void PushText(int64_t value);
2092  void PushText( bool value );
2094  void PushText( float value );
2096  void PushText( double value );
2097 
2099  void PushComment( const char* comment );
2100 
2101  void PushDeclaration( const char* value );
2102  void PushUnknown( const char* value );
2103 
2104  virtual bool VisitEnter( const XMLDocument& /*doc*/ );
2105  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
2106  return true;
2107  }
2108 
2109  virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
2110  virtual bool VisitExit( const XMLElement& element );
2111 
2112  virtual bool Visit( const XMLText& text );
2113  virtual bool Visit( const XMLComment& comment );
2114  virtual bool Visit( const XMLDeclaration& declaration );
2115  virtual bool Visit( const XMLUnknown& unknown );
2116 
2121  const char* CStr() const {
2122  return _buffer.Mem();
2123  }
2129  int CStrSize() const {
2130  return _buffer.Size();
2131  }
2136  void ClearBuffer() {
2137  _buffer.Clear();
2138  _buffer.Push(0);
2139  }
2140 
2141 protected:
2142  virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
2143 
2147  virtual void PrintSpace( int depth );
2148  void Print( const char* format, ... );
2149 
2150  void SealElementIfJustOpened();
2153 
2154 private:
2155  void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
2156 
2157  bool _firstElement;
2158  FILE* _fp;
2159  int _depth;
2160  int _textDepth;
2161  bool _processEntities;
2162  bool _compactMode;
2163 
2164  enum {
2165  ENTITY_RANGE = 64,
2166  BUF_SIZE = 200
2167  };
2168  bool _entityFlag[ENTITY_RANGE];
2169  bool _restrictedEntityFlag[ENTITY_RANGE];
2170 
2171  DynArray< char, 20 > _buffer;
2172 };
2173 
2174 
2175 } // tinyxml2
2176 
2177 #if defined(_MSC_VER)
2178 # pragma warning(pop)
2179 #endif
2180 
2181 #endif // TINYXML2_INCLUDED
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1211
int QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1344
int QueryAttribute(const char *name, bool *value) const
Definition: tinyxml2.h:1356
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:2004
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1126
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1385
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1753
virtual ~XMLText()
Definition: tinyxml2.h:966
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:1966
void Push(T t)
Definition: tinyxml2.h:220
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:1972
XMLError QueryIntValue(int *value) const
Definition: tinyxml2.cpp:1336
const XMLText * ToText() const
Definition: tinyxml2.h:1998
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1284
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:695
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:671
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1868
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:689
virtual ~MemPool()
Definition: tinyxml2.h:320
XMLElement * PreviousSiblingElement(const char *name=0)
Definition: tinyxml2.h:780
int CurrentAllocs() const
Definition: tinyxml2.h:358
T * PushArr(int count)
Definition: tinyxml2.h:227
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1372
const T & operator[](int i) const
Definition: tinyxml2.h:256
XMLElement * LastChildElement(const char *name=0)
Definition: tinyxml2.h:764
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:542
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1379
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:667
XMLNode * FirstChild()
Definition: tinyxml2.h:737
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:1961
const T * Mem() const
Definition: tinyxml2.h:276
virtual const XMLText * ToText() const
Definition: tinyxml2.h:686
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1354
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:483
XMLNode * _lastChild
Definition: tinyxml2.h:908
virtual ~XMLVisitor()
Definition: tinyxml2.h:471
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:957
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:150
int ClosingType() const
Definition: tinyxml2.h:1553
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:571
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:556
void TransferTo(StrPair *other)
Definition: tinyxml2.cpp:153
XMLNode * _next
Definition: tinyxml2.h:911
const XMLElement * RootElement() const
Definition: tinyxml2.h:1686
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1057
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:496
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:733
XMLNode * _firstChild
Definition: tinyxml2.h:907
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1782
static char * SkipWhiteSpace(char *p)
Definition: tinyxml2.h:550
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1132
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:1951
XMLNode * PreviousSibling()
Definition: tinyxml2.h:773
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:478
char * ParseName(char *in)
Definition: tinyxml2.cpp:223
const T & PeekTop() const
Definition: tinyxml2.h:261
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:1954
int QueryAttribute(const char *name, double *value) const
Definition: tinyxml2.h:1360
void SetAttribute(const char *value)
Set the attribute to a string value.
Definition: tinyxml2.cpp:1390
virtual const XMLText * ToText() const
Definition: tinyxml2.h:948
void * _userData
Definition: tinyxml2.h:913
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1318
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:698
XMLNode * _parent
Definition: tinyxml2.h:904
const XMLNode * ToNode() const
Definition: tinyxml2.h:1992
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:1978
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:945
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:500
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:1894
XMLNode * Parent()
Definition: tinyxml2.h:723
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1779
int Capacity() const
Definition: tinyxml2.h:271
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1369
int Untracked() const
Definition: tinyxml2.h:410
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition: tinyxml2.h:1767
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1890
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:2001
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:1880
bool Empty() const
Definition: tinyxml2.h:247
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:1984
const double ch
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1676
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1381
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1293
bool ProcessEntities() const
Definition: tinyxml2.h:1661
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1757
XMLElement * RootElement()
Definition: tinyxml2.h:1683
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:1914
static bool IsUTF8Continuation(char p)
Definition: tinyxml2.h:588
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:719
virtual ~XMLPrinter()
Definition: tinyxml2.h:2065
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1099
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1310
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1207
string filename
Definition: aging.py:5
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1396
int IntValue() const
Definition: tinyxml2.h:1107
int QueryAttribute(const char *name, float *value) const
Definition: tinyxml2.h:1364
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
Definition: tinyxml2.h:1981
StrPair _value
Definition: tinyxml2.h:905
void * GetUserData() const
Definition: tinyxml2.h:895
#define TINYXML2_LIB
Definition: tinyxml2.h:87
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:1898
const char * GetStr()
Definition: tinyxml2.cpp:272
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2105
void SetStr(const char *str, int flags=0)
Definition: tinyxml2.cpp:188
int Size() const
Definition: tinyxml2.h:266
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:1872
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:953
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:653
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:648
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1022
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:679
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:578
int64_t Int64Value() const
Definition: tinyxml2.h:1113
virtual void * Alloc()
Definition: tinyxml2.h:362
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:487
int QueryAttribute(const char *name, int64_t *value) const
Definition: tinyxml2.h:1352
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1214
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:504
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:1957
XMLElement * NextSiblingElement(const char *name=0)
Definition: tinyxml2.h:796
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:769
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1025
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:809
XMLElement * FirstChildElement(const char *name=0)
Definition: tinyxml2.h:746
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1391
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1401
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition: tinyxml2.h:1763
const XMLConstHandle FirstChildElement(const char *name=0) const
Definition: tinyxml2.h:1969
#define TIXMLASSERT(x)
Definition: tinyxml2.h:103
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:2152
XMLNode * NextSibling()
Definition: tinyxml2.h:789
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1275
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1919
void SetUserData(void *userData)
Definition: tinyxml2.h:888
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1910
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1120
void PopArr(int count)
Definition: tinyxml2.h:242
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1345
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:965
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:560
const XMLElement * ToElement() const
Definition: tinyxml2.h:1995
XMLDocument * _document
Definition: tinyxml2.h:903
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:663
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1374
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1302
bool HasBOM() const
Definition: tinyxml2.h:1671
virtual void Free(void *mem)
Definition: tinyxml2.h:388
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:1927
int QueryAttribute(const char *name, unsigned int *value) const
Definition: tinyxml2.h:1348
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:751
T & operator[](int i)
Definition: tinyxml2.h:251
const XMLConstHandle LastChildElement(const char *name=0) const
Definition: tinyxml2.h:1975
XMLNode * LastChild()
Definition: tinyxml2.h:755
const XMLConstHandle NextSiblingElement(const char *name=0) const
Definition: tinyxml2.h:1987
virtual bool CompactMode(const XMLElement &)
Definition: tinyxml2.h:2142
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:1902
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:1935
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:728
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:692
int CStrSize() const
Definition: tinyxml2.h:2129
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1412
virtual int ItemSize() const
Definition: tinyxml2.h:355
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:1931
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1886
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1060
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1923
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:1906
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:492
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:474
XMLNode * _prev
Definition: tinyxml2.h:910
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:683
char * ParseText(char *in, const char *endTag, int strFlags)
Definition: tinyxml2.cpp:201
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1363
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1604
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1664
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1138
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:675
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:659
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:983
void Trace(const char *name)
Definition: tinyxml2.h:400
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:986
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:785
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1876
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1608
bool Empty() const
Definition: tinyxml2.h:161
const char * CStr() const
Definition: tinyxml2.h:2121
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1203
void SetInternedStr(const char *str)
Definition: tinyxml2.h:165