Twitch SDK (Internal)
tinyxml2.h
Go to the documentation of this file.
1 /*
2 Original code by Lee Thomason (www.grinninglizard.com)
3 
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any
6 damages arising from the use of this software.
7 
8 Permission is granted to anyone to use this software for any
9 purpose, including commercial applications, and to alter it and
10 redistribute it freely, subject to the following restrictions:
11 
12 1. The origin of this software must not be misrepresented; you must
13 not claim that you wrote the original software. If you use this
14 software in a product, an acknowledgment in the product documentation
15 would be appreciated but is not required.
16 
17 2. Altered source versions must be plainly marked as such, and
18 must not be misrepresented as being the original software.
19 
20 3. This notice may not be removed or altered from any source
21 distribution.
22 */
23 
24 #ifndef TINYXML2_INCLUDED
25 #define TINYXML2_INCLUDED
26 
27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
28 # include <ctype.h>
29 # include <limits.h>
30 # include <stdio.h>
31 # include <stdlib.h>
32 # include <string.h>
33 # if defined(__PS3__)
34 # include <stddef.h>
35 # endif
36 #else
37 # include <cctype>
38 # include <climits>
39 # include <cstdio>
40 # include <cstdlib>
41 # include <cstring>
42 #endif
43 #include <stdint.h>
44 
45 /*
46  TODO: intern strings instead of allocation.
47 */
48 /*
49  gcc:
50  g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
51 
52  Formatting, Artistic Style:
53  AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
54 */
55 
56 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
57 # ifndef DEBUG
58 # define DEBUG
59 # endif
60 #endif
61 
62 #ifdef _MSC_VER
63 # pragma warning(push)
64 # pragma warning(disable: 4251)
65 #endif
66 
67 #ifdef _WIN32
68 # ifdef TINYXML2_EXPORT
69 # define TINYXML2_LIB __declspec(dllexport)
70 # elif defined(TINYXML2_IMPORT)
71 # define TINYXML2_LIB __declspec(dllimport)
72 # else
73 # define TINYXML2_LIB
74 # endif
75 #else
76 # define TINYXML2_LIB
77 #endif
78 
79 
80 #if defined(DEBUG)
81 # if defined(_MSC_VER)
82 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
83 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
84 # elif defined (ANDROID_NDK)
85 # include <android/log.h>
86 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
87 # else
88 # include <assert.h>
89 # define TIXMLASSERT assert
90 # endif
91 #else
92 # define TIXMLASSERT( x ) {}
93 #endif
94 
95 
96 /* Versioning, past 1.0.14:
97  http://semver.org/
98 */
99 static const int TIXML2_MAJOR_VERSION = 4;
100 static const int TIXML2_MINOR_VERSION = 0;
101 static const int TIXML2_PATCH_VERSION = 1;
102 
103 namespace ttv
104 {
105 namespace xml
106 {
107 class XMLDocument;
108 class XMLElement;
109 class XMLAttribute;
110 class XMLComment;
111 class XMLText;
112 class XMLDeclaration;
113 class XMLUnknown;
114 class XMLPrinter;
115 
116 /*
117  A class that wraps strings. Normally stores the start and end
118  pointers into the XML file itself, and will apply normalization
119  and entity translation if actually read. Can also store (and memory
120  manage) a traditional char[]
121 */
122 class StrPair
123 {
124 public:
125  enum {
129 
136  };
137 
138  StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
139  ~StrPair();
140 
141  void Set( char* start, char* end, int flags ) {
142  Reset();
143  _start = start;
144  _end = end;
145  _flags = flags | NEEDS_FLUSH;
146  }
147 
148  const char* GetStr();
149 
150  bool Empty() const {
151  return _start == _end;
152  }
153 
154  void SetInternedStr( const char* str ) {
155  Reset();
156  _start = const_cast<char*>(str);
157  }
158 
159  void SetStr( const char* str, int flags=0 );
160 
161  char* ParseText( char* in, const char* endTag, int strFlags );
162  char* ParseName( char* in );
163 
164  void TransferTo( StrPair* other );
165 
166 private:
167  void Reset();
168  void CollapseWhitespace();
169 
170  enum {
171  NEEDS_FLUSH = 0x100,
172  NEEDS_DELETE = 0x200
173  };
174 
175  int _flags;
176  char* _start;
177  char* _end;
178 
179  StrPair( const StrPair& other ); // not supported
180  void operator=( StrPair& other ); // not supported, use TransferTo()
181 };
182 
183 
184 /*
185  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
186  Has a small initial memory pool, so that low or no usage will not
187  cause a call to new/delete
188 */
189 template <class T, int INITIAL_SIZE>
190 class DynArray
191 {
192 public:
194  _mem = _pool;
195  _allocated = INITIAL_SIZE;
196  _size = 0;
197  }
198 
200  if ( _mem != _pool ) {
201  delete [] _mem;
202  }
203  }
204 
205  void Clear() {
206  _size = 0;
207  }
208 
209  void Push( T t ) {
210  TIXMLASSERT( _size < INT_MAX );
211  EnsureCapacity( _size+1 );
212  _mem[_size++] = t;
213  }
214 
215  T* PushArr( int count ) {
216  TIXMLASSERT( count >= 0 );
217  TIXMLASSERT( _size <= INT_MAX - count );
218  EnsureCapacity( _size+count );
219  T* ret = &_mem[_size];
220  _size += count;
221  return ret;
222  }
223 
224  T Pop() {
225  TIXMLASSERT( _size > 0 );
226  return _mem[--_size];
227  }
228 
229  void PopArr( int count ) {
230  TIXMLASSERT( _size >= count );
231  _size -= count;
232  }
233 
234  bool Empty() const {
235  return _size == 0;
236  }
237 
238  T& operator[](int i) {
239  TIXMLASSERT( i>= 0 && i < _size );
240  return _mem[i];
241  }
242 
243  const T& operator[](int i) const {
244  TIXMLASSERT( i>= 0 && i < _size );
245  return _mem[i];
246  }
247 
248  const T& PeekTop() const {
249  TIXMLASSERT( _size > 0 );
250  return _mem[ _size - 1];
251  }
252 
253  int Size() const {
254  TIXMLASSERT( _size >= 0 );
255  return _size;
256  }
257 
258  int Capacity() const {
259  TIXMLASSERT( _allocated >= INITIAL_SIZE );
260  return _allocated;
261  }
262 
263  const T* Mem() const {
264  TIXMLASSERT( _mem );
265  return _mem;
266  }
267 
268  T* Mem() {
269  TIXMLASSERT( _mem );
270  return _mem;
271  }
272 
273 private:
274  DynArray( const DynArray& ); // not supported
275  void operator=( const DynArray& ); // not supported
276 
277  void EnsureCapacity( int cap ) {
278  TIXMLASSERT( cap > 0 );
279  if ( cap > _allocated ) {
280  TIXMLASSERT( cap <= INT_MAX / 2 );
281  int newAllocated = cap * 2;
282  T* newMem = new T[newAllocated];
283  memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
284  if ( _mem != _pool ) {
285  delete [] _mem;
286  }
287  _mem = newMem;
288  _allocated = newAllocated;
289  }
290  }
291 
292  T* _mem;
293  T _pool[INITIAL_SIZE];
294  int _allocated; // objects allocated
295  int _size; // number objects in use
296 };
297 
298 
299 /*
300  Parent virtual class of a pool for fast allocation
301  and deallocation of objects.
302 */
303 class MemPool
304 {
305 public:
306  MemPool() {}
307  virtual ~MemPool() {}
308 
309  virtual int ItemSize() const = 0;
310  virtual void* Alloc() = 0;
311  virtual void Free( void* ) = 0;
312  virtual void SetTracked() = 0;
313  virtual void Clear() = 0;
314 };
315 
316 
317 /*
318  Template child class to create pools of the correct type.
319 */
320 template< int SIZE >
321 class MemPoolT : public MemPool
322 {
323 public:
324  MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
326  Clear();
327  }
328 
329  void Clear() {
330  // Delete the blocks.
331  while( !_blockPtrs.Empty()) {
332  Block* b = _blockPtrs.Pop();
333  delete b;
334  }
335  _root = 0;
336  _currentAllocs = 0;
337  _nAllocs = 0;
338  _maxAllocs = 0;
339  _nUntracked = 0;
340  }
341 
342  virtual int ItemSize() const {
343  return SIZE;
344  }
345  int CurrentAllocs() const {
346  return _currentAllocs;
347  }
348 
349  virtual void* Alloc() {
350  if ( !_root ) {
351  // Need a new block.
352  Block* block = new Block();
353  _blockPtrs.Push( block );
354 
355  for( int i=0; i<COUNT-1; ++i ) {
356  block->chunk[i].next = &block->chunk[i+1];
357  }
358  block->chunk[COUNT-1].next = 0;
359  _root = block->chunk;
360  }
361  void* result = _root;
362  _root = _root->next;
363 
364  ++_currentAllocs;
365  if ( _currentAllocs > _maxAllocs ) {
366  _maxAllocs = _currentAllocs;
367  }
368  _nAllocs++;
369  _nUntracked++;
370  return result;
371  }
372 
373  virtual void Free( void* mem ) {
374  if ( !mem ) {
375  return;
376  }
377  --_currentAllocs;
378  Chunk* chunk = static_cast<Chunk*>( mem );
379 #ifdef DEBUG
380  memset( chunk, 0xfe, sizeof(Chunk) );
381 #endif
382  chunk->next = _root;
383  _root = chunk;
384  }
385  void Trace( const char* name ) {
386  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
387  name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
388  }
389 
390  void SetTracked() {
391  _nUntracked--;
392  }
393 
394  int Untracked() const {
395  return _nUntracked;
396  }
397 
398  // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
399  // The test file is large, 170k.
400  // Release: VS2010 gcc(no opt)
401  // 1k: 4000
402  // 2k: 4000
403  // 4k: 3900 21000
404  // 16k: 5200
405  // 32k: 4300
406  // 64k: 4000 21000
407  enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
408 
409 private:
410  MemPoolT( const MemPoolT& ); // not supported
411  void operator=( const MemPoolT& ); // not supported
412 
413  union Chunk {
415  char mem[SIZE];
416  };
417  struct Block {
418  Chunk chunk[COUNT];
419  };
421  Chunk* _root;
422 
424  int _nAllocs;
427 };
428 
429 
430 
451 {
452 public:
453  virtual ~XMLVisitor() {}
454 
456  virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
457  return true;
458  }
460  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
461  return true;
462  }
463 
465  virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
466  return true;
467  }
469  virtual bool VisitExit( const XMLElement& /*element*/ ) {
470  return true;
471  }
472 
474  virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
475  return true;
476  }
478  virtual bool Visit( const XMLText& /*text*/ ) {
479  return true;
480  }
482  virtual bool Visit( const XMLComment& /*comment*/ ) {
483  return true;
484  }
486  virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
487  return true;
488  }
489 };
490 
491 // WARNING: must match XMLDocument::_errorNames[]
492 enum XMLError {
513 
515 };
516 
517 
518 /*
519  Utility functionality.
520 */
521 class XMLUtil
522 {
523 public:
524  static const char* SkipWhiteSpace( const char* p ) {
525  TIXMLASSERT( p );
526  while( IsWhiteSpace(*p) ) {
527  ++p;
528  }
529  TIXMLASSERT( p );
530  return p;
531  }
532  static char* SkipWhiteSpace( char* p ) {
533  return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );
534  }
535 
536  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
537  // correct, but simple, and usually works.
538  static bool IsWhiteSpace( char p ) {
539  return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
540  }
541 
542  inline static bool IsNameStartChar( unsigned char ch ) {
543  if ( ch >= 128 ) {
544  // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
545  return true;
546  }
547  if ( isalpha( ch ) ) {
548  return true;
549  }
550  return ch == ':' || ch == '_';
551  }
552 
553  inline static bool IsNameChar( unsigned char ch ) {
554  return IsNameStartChar( ch )
555  || isdigit( ch )
556  || ch == '.'
557  || ch == '-';
558  }
559 
560  inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
561  if ( p == q ) {
562  return true;
563  }
564  return strncmp( p, q, nChar ) == 0;
565  }
566 
567  inline static bool IsUTF8Continuation( char p ) {
568  return ( p & 0x80 ) != 0;
569  }
570 
571  static const char* ReadBOM( const char* p, bool* hasBOM );
572  // p is the starting location,
573  // the UTF-8 value of the entity will be placed in value, and length filled in.
574  static const char* GetCharacterRef( const char* p, char* value, int* length );
575  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
576 
577  // converts primitive types to strings
578  static void ToStr( int v, char* buffer, int bufferSize );
579  static void ToStr( unsigned v, char* buffer, int bufferSize );
580  static void ToStr( bool v, char* buffer, int bufferSize );
581  static void ToStr( float v, char* buffer, int bufferSize );
582  static void ToStr( double v, char* buffer, int bufferSize );
583  static void ToStr(int64_t v, char* buffer, int bufferSize);
584 
585  // converts strings to primitive types
586  static bool ToInt( const char* str, int* value );
587  static bool ToUnsigned( const char* str, unsigned* value );
588  static bool ToBool( const char* str, bool* value );
589  static bool ToFloat( const char* str, float* value );
590  static bool ToDouble( const char* str, double* value );
591  static bool ToInt64(const char* str, int64_t* value);
592 };
593 
594 
621 {
622  friend class XMLDocument;
623  friend class XMLElement;
624 public:
625 
627  const XMLDocument* GetDocument() const {
628  TIXMLASSERT( _document );
629  return _document;
630  }
633  TIXMLASSERT( _document );
634  return _document;
635  }
636 
638  virtual XMLElement* ToElement() {
639  return 0;
640  }
642  virtual XMLText* ToText() {
643  return 0;
644  }
646  virtual XMLComment* ToComment() {
647  return 0;
648  }
650  virtual XMLDocument* ToDocument() {
651  return 0;
652  }
655  return 0;
656  }
658  virtual XMLUnknown* ToUnknown() {
659  return 0;
660  }
661 
662  virtual const XMLElement* ToElement() const {
663  return 0;
664  }
665  virtual const XMLText* ToText() const {
666  return 0;
667  }
668  virtual const XMLComment* ToComment() const {
669  return 0;
670  }
671  virtual const XMLDocument* ToDocument() const {
672  return 0;
673  }
674  virtual const XMLDeclaration* ToDeclaration() const {
675  return 0;
676  }
677  virtual const XMLUnknown* ToUnknown() const {
678  return 0;
679  }
680 
690  const char* Value() const;
691 
695  void SetValue( const char* val, bool staticMem=false );
696 
698  const XMLNode* Parent() const {
699  return _parent;
700  }
701 
703  return _parent;
704  }
705 
707  bool NoChildren() const {
708  return !_firstChild;
709  }
710 
712  const XMLNode* FirstChild() const {
713  return _firstChild;
714  }
715 
717  return _firstChild;
718  }
719 
723  const XMLElement* FirstChildElement( const char* name = 0 ) const;
724 
725  XMLElement* FirstChildElement( const char* name = 0 ) {
726  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
727  }
728 
730  const XMLNode* LastChild() const {
731  return _lastChild;
732  }
733 
735  return _lastChild;
736  }
737 
741  const XMLElement* LastChildElement( const char* name = 0 ) const;
742 
743  XMLElement* LastChildElement( const char* name = 0 ) {
744  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
745  }
746 
748  const XMLNode* PreviousSibling() const {
749  return _prev;
750  }
751 
753  return _prev;
754  }
755 
757  const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
758 
759  XMLElement* PreviousSiblingElement( const char* name = 0 ) {
760  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
761  }
762 
764  const XMLNode* NextSibling() const {
765  return _next;
766  }
767 
769  return _next;
770  }
771 
773  const XMLElement* NextSiblingElement( const char* name = 0 ) const;
774 
775  XMLElement* NextSiblingElement( const char* name = 0 ) {
776  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
777  }
778 
786  XMLNode* InsertEndChild( XMLNode* addThis );
787 
788  XMLNode* LinkEndChild( XMLNode* addThis ) {
789  return InsertEndChild( addThis );
790  }
798  XMLNode* InsertFirstChild( XMLNode* addThis );
807  XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
808 
812  void DeleteChildren();
813 
817  void DeleteChild( XMLNode* node );
818 
828  virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
829 
836  virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
837 
860  virtual bool Accept( XMLVisitor* visitor ) const = 0;
861 
867  void SetUserData(void* userData) { _userData = userData; }
868 
874  void* GetUserData() const { return _userData; }
875 
876 protected:
877  XMLNode( XMLDocument* );
878  virtual ~XMLNode();
879 
880  virtual char* ParseDeep( char*, StrPair* );
881 
884  mutable StrPair _value;
885 
888 
891 
892  void* _userData;
893 
894 private:
896  void Unlink( XMLNode* child );
897  static void DeleteNode( XMLNode* node );
898  void InsertChildPreamble( XMLNode* insertThis ) const;
899 
900  XMLNode( const XMLNode& ); // not supported
901  XMLNode& operator=( const XMLNode& ); // not supported
902 };
903 
904 
918 {
919  friend class XMLDocument;
920 public:
921  virtual bool Accept( XMLVisitor* visitor ) const;
922 
923  virtual XMLText* ToText() {
924  return this;
925  }
926  virtual const XMLText* ToText() const {
927  return this;
928  }
929 
931  void SetCData( bool isCData ) {
932  _isCData = isCData;
933  }
935  bool CData() const {
936  return _isCData;
937  }
938 
939  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
940  virtual bool ShallowEqual( const XMLNode* compare ) const;
941 
942 protected:
943  XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
944  virtual ~XMLText() {}
945 
946  char* ParseDeep( char*, StrPair* endTag );
947 
948 private:
949  bool _isCData;
950 
951  XMLText( const XMLText& ); // not supported
952  XMLText& operator=( const XMLText& ); // not supported
953 };
954 
955 
958 {
959  friend class XMLDocument;
960 public:
961  virtual XMLComment* ToComment() {
962  return this;
963  }
964  virtual const XMLComment* ToComment() const {
965  return this;
966  }
967 
968  virtual bool Accept( XMLVisitor* visitor ) const;
969 
970  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
971  virtual bool ShallowEqual( const XMLNode* compare ) const;
972 
973 protected:
974  XMLComment( XMLDocument* doc );
975  virtual ~XMLComment();
976 
977  char* ParseDeep( char*, StrPair* endTag );
978 
979 private:
980  XMLComment( const XMLComment& ); // not supported
981  XMLComment& operator=( const XMLComment& ); // not supported
982 };
983 
984 
997 {
998  friend class XMLDocument;
999 public:
1001  return this;
1002  }
1003  virtual const XMLDeclaration* ToDeclaration() const {
1004  return this;
1005  }
1006 
1007  virtual bool Accept( XMLVisitor* visitor ) const;
1008 
1009  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1010  virtual bool ShallowEqual( const XMLNode* compare ) const;
1011 
1012 protected:
1013  XMLDeclaration( XMLDocument* doc );
1014  virtual ~XMLDeclaration();
1015 
1016  char* ParseDeep( char*, StrPair* endTag );
1017 
1018 private:
1019  XMLDeclaration( const XMLDeclaration& ); // not supported
1020  XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
1021 };
1022 
1023 
1032 {
1033  friend class XMLDocument;
1034 public:
1035  virtual XMLUnknown* ToUnknown() {
1036  return this;
1037  }
1038  virtual const XMLUnknown* ToUnknown() const {
1039  return this;
1040  }
1041 
1042  virtual bool Accept( XMLVisitor* visitor ) const;
1043 
1044  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1045  virtual bool ShallowEqual( const XMLNode* compare ) const;
1046 
1047 protected:
1048  XMLUnknown( XMLDocument* doc );
1049  virtual ~XMLUnknown();
1050 
1051  char* ParseDeep( char*, StrPair* endTag );
1052 
1053 private:
1054  XMLUnknown( const XMLUnknown& ); // not supported
1055  XMLUnknown& operator=( const XMLUnknown& ); // not supported
1056 };
1057 
1058 
1059 
1067 {
1068  friend class XMLElement;
1069 public:
1071  const char* Name() const;
1072 
1074  const char* Value() const;
1075 
1077  const XMLAttribute* Next() const {
1078  return _next;
1079  }
1080 
1085  int IntValue() const {
1086  int i = 0;
1087  QueryIntValue(&i);
1088  return i;
1089  }
1090 
1091  int64_t Int64Value() const {
1092  int64_t i = 0;
1093  QueryInt64Value(&i);
1094  return i;
1095  }
1096 
1098  unsigned UnsignedValue() const {
1099  unsigned i=0;
1100  QueryUnsignedValue( &i );
1101  return i;
1102  }
1104  bool BoolValue() const {
1105  bool b=false;
1106  QueryBoolValue( &b );
1107  return b;
1108  }
1110  double DoubleValue() const {
1111  double d=0;
1112  QueryDoubleValue( &d );
1113  return d;
1114  }
1116  float FloatValue() const {
1117  float f=0;
1118  QueryFloatValue( &f );
1119  return f;
1120  }
1121 
1126  XMLError QueryIntValue( int* value ) const;
1128  XMLError QueryUnsignedValue( unsigned int* value ) const;
1130  XMLError QueryInt64Value(int64_t* value) const;
1132  XMLError QueryBoolValue( bool* value ) const;
1134  XMLError QueryDoubleValue( double* value ) const;
1136  XMLError QueryFloatValue( float* value ) const;
1137 
1139  void SetAttribute( const char* value );
1141  void SetAttribute( int value );
1143  void SetAttribute( unsigned value );
1145  void SetAttribute(int64_t value);
1147  void SetAttribute( bool value );
1149  void SetAttribute( double value );
1151  void SetAttribute( float value );
1152 
1153 private:
1154  enum { BUF_SIZE = 200 };
1155 
1156  XMLAttribute() : _next( 0 ), _memPool( 0 ) {}
1157  virtual ~XMLAttribute() {}
1158 
1159  XMLAttribute( const XMLAttribute& ); // not supported
1160  void operator=( const XMLAttribute& ); // not supported
1161  void SetName( const char* name );
1162 
1163  char* ParseDeep( char* p, bool processEntities );
1164 
1165  mutable StrPair _name;
1166  mutable StrPair _value;
1169 };
1170 
1171 
1177 {
1178  friend class XMLDocument;
1179 public:
1181  const char* Name() const {
1182  return Value();
1183  }
1185  void SetName( const char* str, bool staticMem=false ) {
1186  SetValue( str, staticMem );
1187  }
1188 
1189  virtual XMLElement* ToElement() {
1190  return this;
1191  }
1192  virtual const XMLElement* ToElement() const {
1193  return this;
1194  }
1195  virtual bool Accept( XMLVisitor* visitor ) const;
1196 
1220  const char* Attribute( const char* name, const char* value=0 ) const;
1221 
1227  int IntAttribute( const char* name ) const {
1228  int i=0;
1229  QueryIntAttribute( name, &i );
1230  return i;
1231  }
1232 
1234  unsigned UnsignedAttribute( const char* name ) const {
1235  unsigned i=0;
1236  QueryUnsignedAttribute( name, &i );
1237  return i;
1238  }
1239 
1241  int64_t Int64Attribute(const char* name) const {
1242  int64_t i = 0;
1243  QueryInt64Attribute(name, &i);
1244  return i;
1245  }
1246 
1248  bool BoolAttribute( const char* name ) const {
1249  bool b=false;
1250  QueryBoolAttribute( name, &b );
1251  return b;
1252  }
1254  double DoubleAttribute( const char* name ) const {
1255  double d=0;
1256  QueryDoubleAttribute( name, &d );
1257  return d;
1258  }
1260  float FloatAttribute( const char* name ) const {
1261  float f=0;
1262  QueryFloatAttribute( name, &f );
1263  return f;
1264  }
1265 
1279  XMLError QueryIntAttribute( const char* name, int* value ) const {
1280  const XMLAttribute* a = FindAttribute( name );
1281  if ( !a ) {
1282  return XML_NO_ATTRIBUTE;
1283  }
1284  return a->QueryIntValue( value );
1285  }
1286 
1288  XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
1289  const XMLAttribute* a = FindAttribute( name );
1290  if ( !a ) {
1291  return XML_NO_ATTRIBUTE;
1292  }
1293  return a->QueryUnsignedValue( value );
1294  }
1295 
1297  XMLError QueryInt64Attribute(const char* name, int64_t* value) const {
1298  const XMLAttribute* a = FindAttribute(name);
1299  if (!a) {
1300  return XML_NO_ATTRIBUTE;
1301  }
1302  return a->QueryInt64Value(value);
1303  }
1304 
1306  XMLError QueryBoolAttribute( const char* name, bool* value ) const {
1307  const XMLAttribute* a = FindAttribute( name );
1308  if ( !a ) {
1309  return XML_NO_ATTRIBUTE;
1310  }
1311  return a->QueryBoolValue( value );
1312  }
1314  XMLError QueryDoubleAttribute( const char* name, double* value ) const {
1315  const XMLAttribute* a = FindAttribute( name );
1316  if ( !a ) {
1317  return XML_NO_ATTRIBUTE;
1318  }
1319  return a->QueryDoubleValue( value );
1320  }
1322  XMLError QueryFloatAttribute( const char* name, float* value ) const {
1323  const XMLAttribute* a = FindAttribute( name );
1324  if ( !a ) {
1325  return XML_NO_ATTRIBUTE;
1326  }
1327  return a->QueryFloatValue( value );
1328  }
1329 
1330 
1348  int QueryAttribute( const char* name, int* value ) const {
1349  return QueryIntAttribute( name, value );
1350  }
1351 
1352  int QueryAttribute( const char* name, unsigned int* value ) const {
1353  return QueryUnsignedAttribute( name, value );
1354  }
1355 
1356  int QueryAttribute(const char* name, int64_t* value) const {
1357  return QueryInt64Attribute(name, value);
1358  }
1359 
1360  int QueryAttribute( const char* name, bool* value ) const {
1361  return QueryBoolAttribute( name, value );
1362  }
1363 
1364  int QueryAttribute( const char* name, double* value ) const {
1365  return QueryDoubleAttribute( name, value );
1366  }
1367 
1368  int QueryAttribute( const char* name, float* value ) const {
1369  return QueryFloatAttribute( name, value );
1370  }
1371 
1373  void SetAttribute( const char* name, const char* value ) {
1374  XMLAttribute* a = FindOrCreateAttribute( name );
1375  a->SetAttribute( value );
1376  }
1378  void SetAttribute( const char* name, int value ) {
1379  XMLAttribute* a = FindOrCreateAttribute( name );
1380  a->SetAttribute( value );
1381  }
1383  void SetAttribute( const char* name, unsigned value ) {
1384  XMLAttribute* a = FindOrCreateAttribute( name );
1385  a->SetAttribute( value );
1386  }
1387 
1389  void SetAttribute(const char* name, int64_t value) {
1390  XMLAttribute* a = FindOrCreateAttribute(name);
1391  a->SetAttribute(value);
1392  }
1393 
1395  void SetAttribute( const char* name, bool value ) {
1396  XMLAttribute* a = FindOrCreateAttribute( name );
1397  a->SetAttribute( value );
1398  }
1400  void SetAttribute( const char* name, double value ) {
1401  XMLAttribute* a = FindOrCreateAttribute( name );
1402  a->SetAttribute( value );
1403  }
1405  void SetAttribute( const char* name, float value ) {
1406  XMLAttribute* a = FindOrCreateAttribute( name );
1407  a->SetAttribute( value );
1408  }
1409 
1413  void DeleteAttribute( const char* name );
1414 
1416  const XMLAttribute* FirstAttribute() const {
1417  return _rootAttribute;
1418  }
1420  const XMLAttribute* FindAttribute( const char* name ) const;
1421 
1450  const char* GetText() const;
1451 
1486  void SetText( const char* inText );
1488  void SetText( int value );
1490  void SetText( unsigned value );
1492  void SetText(int64_t value);
1494  void SetText( bool value );
1496  void SetText( double value );
1498  void SetText( float value );
1499 
1526  XMLError QueryIntText( int* ival ) const;
1528  XMLError QueryUnsignedText( unsigned* uval ) const;
1530  XMLError QueryInt64Text(int64_t* uval) const;
1532  XMLError QueryBoolText( bool* bval ) const;
1534  XMLError QueryDoubleText( double* dval ) const;
1536  XMLError QueryFloatText( float* fval ) const;
1537 
1538  // internal:
1539  enum {
1540  OPEN, // <foo>
1541  CLOSED, // <foo/>
1542  CLOSING // </foo>
1543  };
1544  int ClosingType() const {
1545  return _closingType;
1546  }
1547  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1548  virtual bool ShallowEqual( const XMLNode* compare ) const;
1549 
1550 protected:
1551  char* ParseDeep( char* p, StrPair* endTag );
1552 
1553 private:
1554  XMLElement( XMLDocument* doc );
1555  virtual ~XMLElement();
1556  XMLElement( const XMLElement& ); // not supported
1557  void operator=( const XMLElement& ); // not supported
1558 
1559  XMLAttribute* FindAttribute( const char* name ) {
1560  return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));
1561  }
1562  XMLAttribute* FindOrCreateAttribute( const char* name );
1563  //void LinkAttribute( XMLAttribute* attrib );
1564  char* ParseAttributes( char* p );
1565  static void DeleteAttribute( XMLAttribute* attribute );
1566 
1567  enum { BUF_SIZE = 200 };
1569  // The attribute list is ordered; there is no 'lastAttribute'
1570  // because the list needs to be scanned for dupes before adding
1571  // a new attribute.
1573 };
1574 
1575 
1579 };
1580 
1581 
1588 {
1589  friend class XMLElement;
1590 public:
1592  XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
1593  ~XMLDocument();
1594 
1596  TIXMLASSERT( this == _document );
1597  return this;
1598  }
1599  virtual const XMLDocument* ToDocument() const {
1600  TIXMLASSERT( this == _document );
1601  return this;
1602  }
1603 
1614  XMLError Parse( const char* xml, size_t nBytes=SIZE_MAX );
1615 
1621  XMLError LoadFile( const char* filename );
1622 
1634  XMLError LoadFile( FILE* );
1635 
1641  XMLError SaveFile( const char* filename, bool compact = false );
1642 
1650  XMLError SaveFile( FILE* fp, bool compact = false );
1651 
1652  bool ProcessEntities() const {
1653  return _processEntities;
1654  }
1656  return _whitespace;
1657  }
1658 
1662  bool HasBOM() const {
1663  return _writeBOM;
1664  }
1667  void SetBOM( bool useBOM ) {
1668  _writeBOM = useBOM;
1669  }
1670 
1675  return FirstChildElement();
1676  }
1677  const XMLElement* RootElement() const {
1678  return FirstChildElement();
1679  }
1680 
1695  void Print( XMLPrinter* streamer=0 ) const;
1696  virtual bool Accept( XMLVisitor* visitor ) const;
1697 
1703  XMLElement* NewElement( const char* name );
1709  XMLComment* NewComment( const char* comment );
1715  XMLText* NewText( const char* text );
1727  XMLDeclaration* NewDeclaration( const char* text=0 );
1733  XMLUnknown* NewUnknown( const char* text );
1734 
1739  void DeleteNode( XMLNode* node );
1740 
1741  void SetError( XMLError error, const char* str1, const char* str2 );
1742 
1744  bool Error() const {
1745  return _errorID != XML_SUCCESS;
1746  }
1748  XMLError ErrorID() const {
1749  return _errorID;
1750  }
1751  const char* ErrorName() const;
1752 
1754  const char* GetErrorStr1() const {
1755  return _errorStr1;
1756  }
1758  const char* GetErrorStr2() const {
1759  return _errorStr2;
1760  }
1762  void PrintError() const;
1763 
1765  void Clear();
1766 
1767  // internal
1768  char* Identify( char* p, XMLNode** node );
1769 
1770  virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
1771  return 0;
1772  }
1773  virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
1774  return false;
1775  }
1776 
1777 private:
1778  XMLDocument( const XMLDocument& ); // not supported
1779  void operator=( const XMLDocument& ); // not supported
1780 
1785  const char* _errorStr1;
1786  const char* _errorStr2;
1788 
1793 
1794  static const char* _errorNames[XML_ERROR_COUNT];
1795 
1796  void Parse();
1797 };
1798 
1799 
1856 {
1857 public:
1859  XMLHandle( XMLNode* node ) {
1860  _node = node;
1861  }
1863  XMLHandle( XMLNode& node ) {
1864  _node = &node;
1865  }
1867  XMLHandle( const XMLHandle& ref ) {
1868  _node = ref._node;
1869  }
1871  XMLHandle& operator=( const XMLHandle& ref ) {
1872  _node = ref._node;
1873  return *this;
1874  }
1875 
1878  return XMLHandle( _node ? _node->FirstChild() : 0 );
1879  }
1881  XMLHandle FirstChildElement( const char* name = 0 ) {
1882  return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
1883  }
1886  return XMLHandle( _node ? _node->LastChild() : 0 );
1887  }
1889  XMLHandle LastChildElement( const char* name = 0 ) {
1890  return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
1891  }
1894  return XMLHandle( _node ? _node->PreviousSibling() : 0 );
1895  }
1897  XMLHandle PreviousSiblingElement( const char* name = 0 ) {
1898  return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
1899  }
1902  return XMLHandle( _node ? _node->NextSibling() : 0 );
1903  }
1905  XMLHandle NextSiblingElement( const char* name = 0 ) {
1906  return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
1907  }
1908 
1911  return _node;
1912  }
1915  return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1916  }
1919  return ( ( _node == 0 ) ? 0 : _node->ToText() );
1920  }
1923  return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
1924  }
1927  return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
1928  }
1929 
1930 private:
1932 };
1933 
1934 
1940 {
1941 public:
1942  XMLConstHandle( const XMLNode* node ) {
1943  _node = node;
1944  }
1945  XMLConstHandle( const XMLNode& node ) {
1946  _node = &node;
1947  }
1949  _node = ref._node;
1950  }
1951 
1953  _node = ref._node;
1954  return *this;
1955  }
1956 
1957  const XMLConstHandle FirstChild() const {
1958  return XMLConstHandle( _node ? _node->FirstChild() : 0 );
1959  }
1960  const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
1961  return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
1962  }
1963  const XMLConstHandle LastChild() const {
1964  return XMLConstHandle( _node ? _node->LastChild() : 0 );
1965  }
1966  const XMLConstHandle LastChildElement( const char* name = 0 ) const {
1967  return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
1968  }
1970  return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
1971  }
1972  const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
1973  return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
1974  }
1975  const XMLConstHandle NextSibling() const {
1976  return XMLConstHandle( _node ? _node->NextSibling() : 0 );
1977  }
1978  const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
1979  return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
1980  }
1981 
1982 
1983  const XMLNode* ToNode() const {
1984  return _node;
1985  }
1986  const XMLElement* ToElement() const {
1987  return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1988  }
1989  const XMLText* ToText() const {
1990  return ( ( _node == 0 ) ? 0 : _node->ToText() );
1991  }
1992  const XMLUnknown* ToUnknown() const {
1993  return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
1994  }
1996  return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
1997  }
1998 
1999 private:
2000  const XMLNode* _node;
2001 };
2002 
2003 
2047 {
2048 public:
2055  XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
2056  virtual ~XMLPrinter() {}
2057 
2059  void PushHeader( bool writeBOM, bool writeDeclaration );
2063  void OpenElement( const char* name, bool compactMode=false );
2065  void PushAttribute( const char* name, const char* value );
2066  void PushAttribute( const char* name, int value );
2067  void PushAttribute( const char* name, unsigned value );
2068  void PushAttribute(const char* name, int64_t value);
2069  void PushAttribute( const char* name, bool value );
2070  void PushAttribute( const char* name, double value );
2072  virtual void CloseElement( bool compactMode=false );
2073 
2075  void PushText( const char* text, bool cdata=false );
2077  void PushText( int value );
2079  void PushText( unsigned value );
2081  void PushText(int64_t value);
2083  void PushText( bool value );
2085  void PushText( float value );
2087  void PushText( double value );
2088 
2090  void PushComment( const char* comment );
2091 
2092  void PushDeclaration( const char* value );
2093  void PushUnknown( const char* value );
2094 
2095  virtual bool VisitEnter( const XMLDocument& /*doc*/ );
2096  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
2097  return true;
2098  }
2099 
2100  virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
2101  virtual bool VisitExit( const XMLElement& element );
2102 
2103  virtual bool Visit( const XMLText& text );
2104  virtual bool Visit( const XMLComment& comment );
2105  virtual bool Visit( const XMLDeclaration& declaration );
2106  virtual bool Visit( const XMLUnknown& unknown );
2107 
2112  const char* CStr() const {
2113  return _buffer.Mem();
2114  }
2120  int CStrSize() const {
2121  return _buffer.Size();
2122  }
2127  void ClearBuffer() {
2128  _buffer.Clear();
2129  _buffer.Push(0);
2130  }
2131 
2132 protected:
2133  virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
2134 
2138  virtual void PrintSpace( int depth );
2139  void Print( const char* format, ... );
2140 
2141  void SealElementIfJustOpened();
2144 
2145 private:
2146  void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
2147 
2149  FILE* _fp;
2150  int _depth;
2154 
2155  enum {
2156  ENTITY_RANGE = 64,
2157  BUF_SIZE = 200
2158  };
2159  bool _entityFlag[ENTITY_RANGE];
2160  bool _restrictedEntityFlag[ENTITY_RANGE];
2161 
2163 };
2164 
2165 
2166 } // xml
2167 } // ttv
2168 
2169 #if defined(_MSC_VER)
2170 # pragma warning(pop)
2171 #endif
2172 
2173 #endif // TINYXML2_INCLUDED
FILE * _fp
Definition: tinyxml2.h:2149
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:1893
void Push(T t)
Definition: tinyxml2.h:209
T * _mem
Definition: tinyxml2.h:292
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1389
char * _charBuffer
Definition: tinyxml2.h:1787
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:748
Definition: tinyxml2.h:450
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:712
int _nAllocs
Definition: tinyxml2.h:424
XMLNode * _prev
Definition: tinyxml2.h:889
int _currentAllocs
Definition: tinyxml2.h:423
StrPair()
Definition: tinyxml2.h:138
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1859
T * PushArr(int count)
Definition: tinyxml2.h:215
Definition: tinyxml2.h:171
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
StrPair _name
Definition: tinyxml2.h:1165
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:764
static const int TIXML2_PATCH_VERSION
Definition: tinyxml2.h:101
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1773
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:1889
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:674
XMLAttribute * _rootAttribute
Definition: tinyxml2.h:1572
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:931
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:923
Definition: tinyxml2.h:514
virtual void * Alloc()
Definition: tinyxml2.h:349
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:482
Definition: tinyxml2.h:511
void TransferTo(StrPair *other)
int64_t Int64Attribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1241
int _maxAllocs
Definition: tinyxml2.h:425
const XMLText * ToText() const
Definition: tinyxml2.h:1989
XMLElement * LastChildElement(const char *name=0)
Definition: tinyxml2.h:743
Definition: tinyxml2.h:1176
Whitespace _whitespace
Definition: tinyxml2.h:1784
XMLNode * Parent()
Definition: tinyxml2.h:702
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:1922
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1383
Definition: tinyxml2.h:1577
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:788
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:1952
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1405
int QueryAttribute(const char *name, float *value) const
Definition: tinyxml2.h:1368
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:1905
Definition: tinyxml2.h:1031
void SetStr(const char *str, int flags=0)
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1744
virtual ~XMLVisitor()
Definition: tinyxml2.h:453
Definition: tinyxml2.h:957
Chunk * _root
Definition: tinyxml2.h:421
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1185
Definition: tinyxml2.h:494
bool _writeBOM
Definition: tinyxml2.h:1781
T Pop()
Definition: tinyxml2.h:224
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:524
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1877
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1395
int QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1348
void SetAttribute(const char *value)
Set the attribute to a string value.
static bool IsUTF8Continuation(char p)
Definition: tinyxml2.h:567
Definition: tinyxml2.h:509
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1992
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1038
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:935
MemPoolT< sizeof(XMLText) > _textPool
Definition: tinyxml2.h:1791
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:943
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1077
void operator=(StrPair &other)
XMLDocument * _document
Definition: tinyxml2.h:882
char * ParseName(char *in)
void Trace(const char *name)
Definition: tinyxml2.h:385
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:632
Definition: tinyxml2.h:1855
Definition: tinyxml2.h:303
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2096
Definition: tinyxml2.h:132
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:707
XMLElement * FirstChildElement(const char *name=0)
Definition: tinyxml2.h:725
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:650
bool _compactMode
Definition: tinyxml2.h:2153
XMLNode * _node
Definition: tinyxml2.h:1931
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:1897
XMLAttribute()
Definition: tinyxml2.h:1156
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:1969
Definition: tinyxml2.h:505
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1098
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:1963
bool HasBOM() const
Definition: tinyxml2.h:1662
T & operator[](int i)
Definition: tinyxml2.h:238
Definition: tinyxml2.h:498
void SetUserData(void *userData)
Definition: tinyxml2.h:867
const XMLNode * _node
Definition: tinyxml2.h:2000
virtual void Free(void *mem)
Definition: tinyxml2.h:373
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1306
StrPair _value
Definition: tinyxml2.h:1166
Definition: tinyxml2.h:508
DynArray< char, 20 > _buffer
Definition: tinyxml2.h:2162
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1192
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1416
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1314
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1373
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:662
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1322
Definition: tinyxml2.h:620
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:668
Definition: tinyxml2.h:502
MemPoolT< sizeof(XMLComment) > _commentPool
Definition: tinyxml2.h:1792
static const int TIXML2_MINOR_VERSION
Definition: tinyxml2.h:100
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:474
int Untracked() const
Definition: tinyxml2.h:394
Definition: tinyxml2.h:499
double DoubleAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1254
const char * _errorStr2
Definition: tinyxml2.h:1786
DynArray()
Definition: tinyxml2.h:193
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1667
Definition: tinyxml2.h:135
void SetInternedStr(const char *str)
Definition: tinyxml2.h:154
char * _end
Definition: tinyxml2.h:177
XMLAttribute * _next
Definition: tinyxml2.h:1167
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:646
void SetTracked()
Definition: tinyxml2.h:390
bool ProcessEntities() const
Definition: tinyxml2.h:1652
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:677
float FloatAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1260
Definition: tinyxml2.h:172
Definition: tinyxml2.h:1540
Definition: tinyxml2.h:130
Definition: tinyxml2.h:500
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:730
MemPool * _memPool
Definition: tinyxml2.h:1168
bool _firstElement
Definition: tinyxml2.h:2148
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1234
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:560
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1110
char * ParseText(char *in, const char *endTag, int strFlags)
Definition: tinyxml2.h:190
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:478
void Clear()
Definition: tinyxml2.h:205
int QueryAttribute(const char *name, bool *value) const
Definition: tinyxml2.h:1360
Definition: tinyxml2.h:417
Definition: tinyxml2.h:1541
const XMLConstHandle FirstChildElement(const char *name=0) const
Definition: tinyxml2.h:1960
const char * _errorStr1
Definition: tinyxml2.h:1785
const T & operator[](int i) const
Definition: tinyxml2.h:243
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1035
Definition: tinyxml2.h:493
Definition: tinyxml2.h:503
~DynArray()
Definition: tinyxml2.h:199
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:671
const XMLNode * ToNode() const
Definition: tinyxml2.h:1983
XMLError _errorID
Definition: tinyxml2.h:1783
static const int TIXML2_MAJOR_VERSION
Definition: tinyxml2.h:99
const XMLElement * ToElement() const
Definition: tinyxml2.h:1986
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:658
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:465
virtual ~MemPool()
Definition: tinyxml2.h:307
virtual ~XMLPrinter()
Definition: tinyxml2.h:2056
virtual int ItemSize() const
Definition: tinyxml2.h:342
virtual const XMLText * ToText() const
Definition: tinyxml2.h:665
XMLNode * _parent
Definition: tinyxml2.h:883
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1995
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1901
bool _isCData
Definition: tinyxml2.h:949
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:1975
int CurrentAllocs() const
Definition: tinyxml2.h:345
bool BoolAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1248
#define TINYXML2_LIB
Definition: tinyxml2.h:76
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1378
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:141
XMLNode * PreviousSibling()
Definition: tinyxml2.h:752
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1000
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1181
Definition: tinyxml2.h:917
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:961
int IntValue() const
Definition: tinyxml2.h:1085
bool _processEntities
Definition: tinyxml2.h:1782
int _closingType
Definition: tinyxml2.h:1568
Definition: tinyxml2.h:1066
void ClearBuffer()
Definition: tinyxml2.h:2127
int ClosingType() const
Definition: tinyxml2.h:1544
Definition: tinyxml2.h:495
MemPoolT< sizeof(XMLAttribute) > _attributePool
Definition: tinyxml2.h:1790
XMLElement * RootElement()
Definition: tinyxml2.h:1674
XMLNode * LastChild()
Definition: tinyxml2.h:734
void Clear()
Definition: tinyxml2.h:329
const T * Mem() const
Definition: tinyxml2.h:263
virtual const XMLText * ToText() const
Definition: tinyxml2.h:926
Definition: tinyxml2.h:413
StrPair _value
Definition: tinyxml2.h:884
void PopArr(int count)
Definition: tinyxml2.h:229
int64_t Int64Value() const
Definition: tinyxml2.h:1091
int QueryAttribute(const char *name, double *value) const
Definition: tinyxml2.h:1364
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1881
int _nUntracked
Definition: tinyxml2.h:426
XMLElement * NextSiblingElement(const char *name=0)
Definition: tinyxml2.h:775
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:1918
Definition: tinyxml2.h:321
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:627
Definition: tinyxml2.h:122
Chunk * next
Definition: tinyxml2.h:414
T * Mem()
Definition: tinyxml2.h:268
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:638
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:456
char * _start
Definition: tinyxml2.h:176
bool _processEntities
Definition: tinyxml2.h:2152
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:542
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:642
int IntAttribute(const char *name) const
Definition: tinyxml2.h:1227
XMLElement * PreviousSiblingElement(const char *name=0)
Definition: tinyxml2.h:759
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1116
virtual bool CompactMode(const XMLElement &)
Definition: tinyxml2.h:2133
XMLNode * _lastChild
Definition: tinyxml2.h:887
XMLNode * FirstChild()
Definition: tinyxml2.h:716
int CStrSize() const
Definition: tinyxml2.h:2120
bool Empty() const
Definition: tinyxml2.h:234
Definition: tinyxml2.h:1587
virtual ~XMLAttribute()
Definition: tinyxml2.h:1157
const XMLConstHandle NextSiblingElement(const char *name=0) const
Definition: tinyxml2.h:1978
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1599
static char * SkipWhiteSpace(char *p)
Definition: tinyxml2.h:532
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1914
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1288
Definition: tinyxml2.h:1939
int Capacity() const
Definition: tinyxml2.h:258
Definition: tinyxml2.h:521
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1748
Definition: tinyxml2.h:1578
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:1885
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:420
int Size() const
Definition: tinyxml2.h:253
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:460
XMLError QueryIntValue(int *value) const
const T & PeekTop() const
Definition: tinyxml2.h:248
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:654
#define TIXMLASSERT(x)
Definition: tinyxml2.h:92
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:964
int QueryAttribute(const char *name, unsigned int *value) const
Definition: tinyxml2.h:1352
const XMLElement * RootElement() const
Definition: tinyxml2.h:1677
int QueryAttribute(const char *name, int64_t *value) const
Definition: tinyxml2.h:1356
const XMLConstHandle LastChildElement(const char *name=0) const
Definition: tinyxml2.h:1966
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1655
int _allocated
Definition: tinyxml2.h:294
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:2143
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:486
void CollapseWhitespace()
XMLNode * _firstChild
Definition: tinyxml2.h:886
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1910
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1279
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:553
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:1945
Definition: tinyxml2.h:496
MemPool()
Definition: tinyxml2.h:306
Definition: tinyxml2.h:996
MemPoolT< sizeof(XMLElement) > _elementPool
Definition: tinyxml2.h:1789
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1104
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1770
Definition: tinyxml2.h:506
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:538
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:698
XMLNode * _next
Definition: tinyxml2.h:890
bool Empty() const
Definition: tinyxml2.h:150
XMLError
Definition: tinyxml2.h:492
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:1926
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1400
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:1948
MemPool * _memPool
Definition: tinyxml2.h:895
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition: tinyxml2.h:1754
const char * GetStr()
MemPoolT()
Definition: tinyxml2.h:324
Definition: tinyxml2.h:2046
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:1871
Definition: tinyxml2.h:512
int _textDepth
Definition: tinyxml2.h:2151
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1595
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1003
bool _elementJustOpened
Definition: tinyxml2.h:2142
const char * CStr() const
Definition: tinyxml2.h:2112
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:469
virtual ~XMLText()
Definition: tinyxml2.h:944
Definition: tinyxml2.h:504
Definition: tinyxml2.h:507
int _depth
Definition: tinyxml2.h:2150
void * _userData
Definition: tinyxml2.h:892
XMLNode * NextSibling()
Definition: tinyxml2.h:768
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
Definition: tinyxml2.h:1972
Definition: tinyxml2.h:510
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1189
Definition: tinyxml2.h:501
XMLAttribute * FindAttribute(const char *name)
Definition: tinyxml2.h:1559
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:1863
Whitespace
Definition: tinyxml2.h:1576
int _size
Definition: tinyxml2.h:295
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1867
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:1942
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition: tinyxml2.h:1758
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1297
~MemPoolT()
Definition: tinyxml2.h:325
int _flags
Definition: tinyxml2.h:175
Definition: tinyxml2.h:133
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:1957
void * GetUserData() const
Definition: tinyxml2.h:874
void EnsureCapacity(int cap)
Definition: tinyxml2.h:277