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 #else
34 # include <cctype>
35 # include <climits>
36 # include <cstdio>
37 # include <cstdlib>
38 # include <cstring>
39 #endif
40 
41 /*
42  TODO: intern strings instead of allocation.
43 */
44 /*
45  gcc:
46  g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
47 
48  Formatting, Artistic Style:
49  AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
50 */
51 
52 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
53 # ifndef DEBUG
54 # define DEBUG
55 # endif
56 #endif
57 
58 #ifdef _MSC_VER
59 # pragma warning(push)
60 # pragma warning(disable: 4251)
61 #endif
62 
63 #ifdef _WIN32
64 # ifdef TINYXML2_EXPORT
65 # define TINYXML2_LIB __declspec(dllexport)
66 # elif defined(TINYXML2_IMPORT)
67 # define TINYXML2_LIB __declspec(dllimport)
68 # else
69 # define TINYXML2_LIB
70 # endif
71 #else
72 # define TINYXML2_LIB
73 #endif
74 
75 
76 #if defined(DEBUG)
77 # if defined(_MSC_VER)
78 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
79 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
80 # elif defined (ANDROID_NDK)
81 # include <android/log.h>
82 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
83 # else
84 # include <assert.h>
85 # define TIXMLASSERT assert
86 # endif
87 # else
88 # define TIXMLASSERT( x ) {}
89 #endif
90 
91 
92 /* Versioning, past 1.0.14:
93  http://semver.org/
94 */
95 static const int TIXML2_MAJOR_VERSION = 3;
96 static const int TIXML2_MINOR_VERSION = 0;
97 static const int TIXML2_PATCH_VERSION = 0;
98 
99 namespace tinyxml2
100 {
101 class XMLDocument;
102 class XMLElement;
103 class XMLAttribute;
104 class XMLComment;
105 class XMLText;
106 class XMLDeclaration;
107 class XMLUnknown;
108 class XMLPrinter;
109 
110 /*
111  A class that wraps strings. Normally stores the start and end
112  pointers into the XML file itself, and will apply normalization
113  and entity translation if actually read. Can also store (and memory
114  manage) a traditional char[]
115 */
116 class StrPair
117 {
118 public:
119  enum {
123 
130  };
131 
132  StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
133  ~StrPair();
134 
135  void Set( char* start, char* end, int flags ) {
136  Reset();
137  _start = start;
138  _end = end;
139  _flags = flags | NEEDS_FLUSH;
140  }
141 
142  const char* GetStr();
143 
144  bool Empty() const {
145  return _start == _end;
146  }
147 
148  void SetInternedStr( const char* str ) {
149  Reset();
150  _start = const_cast<char*>(str);
151  }
152 
153  void SetStr( const char* str, int flags=0 );
154 
155  char* ParseText( char* in, const char* endTag, int strFlags );
156  char* ParseName( char* in );
157 
158  void TransferTo( StrPair* other );
159 
160 private:
161  void Reset();
162  void CollapseWhitespace();
163 
164  enum {
165  NEEDS_FLUSH = 0x100,
166  NEEDS_DELETE = 0x200
167  };
168 
169  // After parsing, if *_end != 0, it can be set to zero.
170  int _flags;
171  char* _start;
172  char* _end;
173 
174  StrPair( const StrPair& other ); // not supported
175  void operator=( StrPair& other ); // not supported, use TransferTo()
176 };
177 
178 
179 /*
180  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
181  Has a small initial memory pool, so that low or no usage will not
182  cause a call to new/delete
183 */
184 template <class T, int INITIAL_SIZE>
185 class DynArray
186 {
187 public:
189  _mem = _pool;
190  _allocated = INITIAL_SIZE;
191  _size = 0;
192  }
193 
195  if ( _mem != _pool ) {
196  delete [] _mem;
197  }
198  }
199 
200  void Clear() {
201  _size = 0;
202  }
203 
204  void Push( T t ) {
205  TIXMLASSERT( _size < INT_MAX );
206  EnsureCapacity( _size+1 );
207  _mem[_size++] = t;
208  }
209 
210  T* PushArr( int count ) {
211  TIXMLASSERT( count >= 0 );
212  TIXMLASSERT( _size <= INT_MAX - count );
213  EnsureCapacity( _size+count );
214  T* ret = &_mem[_size];
215  _size += count;
216  return ret;
217  }
218 
219  T Pop() {
220  TIXMLASSERT( _size > 0 );
221  return _mem[--_size];
222  }
223 
224  void PopArr( int count ) {
225  TIXMLASSERT( _size >= count );
226  _size -= count;
227  }
228 
229  bool Empty() const {
230  return _size == 0;
231  }
232 
233  T& operator[](int i) {
234  TIXMLASSERT( i>= 0 && i < _size );
235  return _mem[i];
236  }
237 
238  const T& operator[](int i) const {
239  TIXMLASSERT( i>= 0 && i < _size );
240  return _mem[i];
241  }
242 
243  const T& PeekTop() const {
244  TIXMLASSERT( _size > 0 );
245  return _mem[ _size - 1];
246  }
247 
248  int Size() const {
249  TIXMLASSERT( _size >= 0 );
250  return _size;
251  }
252 
253  int Capacity() const {
254  TIXMLASSERT( _allocated >= INITIAL_SIZE );
255  return _allocated;
256  }
257 
258  const T* Mem() const {
259  TIXMLASSERT( _mem );
260  return _mem;
261  }
262 
263  T* Mem() {
264  TIXMLASSERT( _mem );
265  return _mem;
266  }
267 
268 private:
269  DynArray( const DynArray& ); // not supported
270  void operator=( const DynArray& ); // not supported
271 
272  void EnsureCapacity( int cap ) {
273  TIXMLASSERT( cap > 0 );
274  if ( cap > _allocated ) {
275  TIXMLASSERT( cap <= INT_MAX / 2 );
276  int newAllocated = cap * 2;
277  T* newMem = new T[newAllocated];
278  memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
279  if ( _mem != _pool ) {
280  delete [] _mem;
281  }
282  _mem = newMem;
283  _allocated = newAllocated;
284  }
285  }
286 
287  T* _mem;
288  T _pool[INITIAL_SIZE];
289  int _allocated; // objects allocated
290  int _size; // number objects in use
291 };
292 
293 
294 /*
295  Parent virtual class of a pool for fast allocation
296  and deallocation of objects.
297 */
298 class MemPool
299 {
300 public:
301  MemPool() {}
302  virtual ~MemPool() {}
303 
304  virtual int ItemSize() const = 0;
305  virtual void* Alloc() = 0;
306  virtual void Free( void* ) = 0;
307  virtual void SetTracked() = 0;
308  virtual void Clear() = 0;
309 };
310 
311 
312 /*
313  Template child class to create pools of the correct type.
314 */
315 template< int SIZE >
316 class MemPoolT : public MemPool
317 {
318 public:
319  MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
321  Clear();
322  }
323 
324  void Clear() {
325  // Delete the blocks.
326  while( !_blockPtrs.Empty()) {
327  Block* b = _blockPtrs.Pop();
328  delete b;
329  }
330  _root = 0;
331  _currentAllocs = 0;
332  _nAllocs = 0;
333  _maxAllocs = 0;
334  _nUntracked = 0;
335  }
336 
337  virtual int ItemSize() const {
338  return SIZE;
339  }
340  int CurrentAllocs() const {
341  return _currentAllocs;
342  }
343 
344  virtual void* Alloc() {
345  if ( !_root ) {
346  // Need a new block.
347  Block* block = new Block();
348  _blockPtrs.Push( block );
349 
350  for( int i=0; i<COUNT-1; ++i ) {
351  block->chunk[i].next = &block->chunk[i+1];
352  }
353  block->chunk[COUNT-1].next = 0;
354  _root = block->chunk;
355  }
356  void* result = _root;
357  _root = _root->next;
358 
359  ++_currentAllocs;
360  if ( _currentAllocs > _maxAllocs ) {
361  _maxAllocs = _currentAllocs;
362  }
363  _nAllocs++;
364  _nUntracked++;
365  return result;
366  }
367 
368  virtual void Free( void* mem ) {
369  if ( !mem ) {
370  return;
371  }
372  --_currentAllocs;
373  Chunk* chunk = static_cast<Chunk*>( mem );
374 #ifdef DEBUG
375  memset( chunk, 0xfe, sizeof(Chunk) );
376 #endif
377  chunk->next = _root;
378  _root = chunk;
379  }
380  void Trace( const char* name ) {
381  printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
382  name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
383  }
384 
385  void SetTracked() {
386  _nUntracked--;
387  }
388 
389  int Untracked() const {
390  return _nUntracked;
391  }
392 
393  // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
394  // The test file is large, 170k.
395  // Release: VS2010 gcc(no opt)
396  // 1k: 4000
397  // 2k: 4000
398  // 4k: 3900 21000
399  // 16k: 5200
400  // 32k: 4300
401  // 64k: 4000 21000
402  enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
403 
404 private:
405  MemPoolT( const MemPoolT& ); // not supported
406  void operator=( const MemPoolT& ); // not supported
407 
408  union Chunk {
410  char mem[SIZE];
411  };
412  struct Block {
413  Chunk chunk[COUNT];
414  };
416  Chunk* _root;
417 
419  int _nAllocs;
422 };
423 
424 
425 
446 {
447 public:
448  virtual ~XMLVisitor() {}
449 
451  virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
452  return true;
453  }
455  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
456  return true;
457  }
458 
460  virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
461  return true;
462  }
464  virtual bool VisitExit( const XMLElement& /*element*/ ) {
465  return true;
466  }
467 
469  virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
470  return true;
471  }
473  virtual bool Visit( const XMLText& /*text*/ ) {
474  return true;
475  }
477  virtual bool Visit( const XMLComment& /*comment*/ ) {
478  return true;
479  }
481  virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
482  return true;
483  }
484 };
485 
486 // WARNING: must match XMLDocument::_errorNames[]
487 enum XMLError {
509 
511 };
512 
513 
514 /*
515  Utility functionality.
516 */
517 class XMLUtil
518 {
519 public:
520  static const char* SkipWhiteSpace( const char* p ) {
521  TIXMLASSERT( p );
522  while( IsWhiteSpace(*p) ) {
523  ++p;
524  }
525  TIXMLASSERT( p );
526  return p;
527  }
528  static char* SkipWhiteSpace( char* p ) {
529  return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );
530  }
531 
532  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
533  // correct, but simple, and usually works.
534  static bool IsWhiteSpace( char p ) {
535  return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
536  }
537 
538  inline static bool IsNameStartChar( unsigned char ch ) {
539  if ( ch >= 128 ) {
540  // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
541  return true;
542  }
543  if ( isalpha( ch ) ) {
544  return true;
545  }
546  return ch == ':' || ch == '_';
547  }
548 
549  inline static bool IsNameChar( unsigned char ch ) {
550  return IsNameStartChar( ch )
551  || isdigit( ch )
552  || ch == '.'
553  || ch == '-';
554  }
555 
556  inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
557  if ( p == q ) {
558  return true;
559  }
560  int n = 0;
561  while( *p && *q && *p == *q && n<nChar ) {
562  ++p;
563  ++q;
564  ++n;
565  }
566  if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
567  return true;
568  }
569  return false;
570  }
571 
572  inline static bool IsUTF8Continuation( char p ) {
573  return ( p & 0x80 ) != 0;
574  }
575 
576  static const char* ReadBOM( const char* p, bool* hasBOM );
577  // p is the starting location,
578  // the UTF-8 value of the entity will be placed in value, and length filled in.
579  static const char* GetCharacterRef( const char* p, char* value, int* length );
580  static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
581 
582  // converts primitive types to strings
583  static void ToStr( int v, char* buffer, int bufferSize );
584  static void ToStr( unsigned v, char* buffer, int bufferSize );
585  static void ToStr( bool v, char* buffer, int bufferSize );
586  static void ToStr( float v, char* buffer, int bufferSize );
587  static void ToStr( double v, char* buffer, int bufferSize );
588 
589  // converts strings to primitive types
590  static bool ToInt( const char* str, int* value );
591  static bool ToUnsigned( const char* str, unsigned* value );
592  static bool ToBool( const char* str, bool* value );
593  static bool ToFloat( const char* str, float* value );
594  static bool ToDouble( const char* str, double* value );
595 };
596 
597 
624 {
625  friend class XMLDocument;
626  friend class XMLElement;
627 public:
628 
630  const XMLDocument* GetDocument() const {
631  TIXMLASSERT( _document );
632  return _document;
633  }
636  TIXMLASSERT( _document );
637  return _document;
638  }
639 
641  virtual XMLElement* ToElement() {
642  return 0;
643  }
645  virtual XMLText* ToText() {
646  return 0;
647  }
649  virtual XMLComment* ToComment() {
650  return 0;
651  }
653  virtual XMLDocument* ToDocument() {
654  return 0;
655  }
658  return 0;
659  }
661  virtual XMLUnknown* ToUnknown() {
662  return 0;
663  }
664 
665  virtual const XMLElement* ToElement() const {
666  return 0;
667  }
668  virtual const XMLText* ToText() const {
669  return 0;
670  }
671  virtual const XMLComment* ToComment() const {
672  return 0;
673  }
674  virtual const XMLDocument* ToDocument() const {
675  return 0;
676  }
677  virtual const XMLDeclaration* ToDeclaration() const {
678  return 0;
679  }
680  virtual const XMLUnknown* ToUnknown() const {
681  return 0;
682  }
683 
693  const char* Value() const;
694 
698  void SetValue( const char* val, bool staticMem=false );
699 
701  const XMLNode* Parent() const {
702  return _parent;
703  }
704 
706  return _parent;
707  }
708 
710  bool NoChildren() const {
711  return !_firstChild;
712  }
713 
715  const XMLNode* FirstChild() const {
716  return _firstChild;
717  }
718 
720  return _firstChild;
721  }
722 
726  const XMLElement* FirstChildElement( const char* name = 0 ) const;
727 
728  XMLElement* FirstChildElement( const char* name = 0 ) {
729  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
730  }
731 
733  const XMLNode* LastChild() const {
734  return _lastChild;
735  }
736 
738  return _lastChild;
739  }
740 
744  const XMLElement* LastChildElement( const char* name = 0 ) const;
745 
746  XMLElement* LastChildElement( const char* name = 0 ) {
747  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
748  }
749 
751  const XMLNode* PreviousSibling() const {
752  return _prev;
753  }
754 
756  return _prev;
757  }
758 
760  const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
761 
762  XMLElement* PreviousSiblingElement( const char* name = 0 ) {
763  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
764  }
765 
767  const XMLNode* NextSibling() const {
768  return _next;
769  }
770 
772  return _next;
773  }
774 
776  const XMLElement* NextSiblingElement( const char* name = 0 ) const;
777 
778  XMLElement* NextSiblingElement( const char* name = 0 ) {
779  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
780  }
781 
789  XMLNode* InsertEndChild( XMLNode* addThis );
790 
791  XMLNode* LinkEndChild( XMLNode* addThis ) {
792  return InsertEndChild( addThis );
793  }
801  XMLNode* InsertFirstChild( XMLNode* addThis );
810  XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
811 
815  void DeleteChildren();
816 
820  void DeleteChild( XMLNode* node );
821 
831  virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
832 
839  virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
840 
863  virtual bool Accept( XMLVisitor* visitor ) const = 0;
864 
865 protected:
866  XMLNode( XMLDocument* );
867  virtual ~XMLNode();
868 
869  virtual char* ParseDeep( char*, StrPair* );
870 
873  mutable StrPair _value;
874 
877 
880 
881 private:
883  void Unlink( XMLNode* child );
884  static void DeleteNode( XMLNode* node );
885  void InsertChildPreamble( XMLNode* insertThis ) const;
886 
887  XMLNode( const XMLNode& ); // not supported
888  XMLNode& operator=( const XMLNode& ); // not supported
889 };
890 
891 
905 {
906  friend class XMLBase;
907  friend class XMLDocument;
908 public:
909  virtual bool Accept( XMLVisitor* visitor ) const;
910 
911  virtual XMLText* ToText() {
912  return this;
913  }
914  virtual const XMLText* ToText() const {
915  return this;
916  }
917 
919  void SetCData( bool isCData ) {
920  _isCData = isCData;
921  }
923  bool CData() const {
924  return _isCData;
925  }
926 
927  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
928  virtual bool ShallowEqual( const XMLNode* compare ) const;
929 
930 protected:
931  XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
932  virtual ~XMLText() {}
933 
934  char* ParseDeep( char*, StrPair* endTag );
935 
936 private:
937  bool _isCData;
938 
939  XMLText( const XMLText& ); // not supported
940  XMLText& operator=( const XMLText& ); // not supported
941 };
942 
943 
946 {
947  friend class XMLDocument;
948 public:
949  virtual XMLComment* ToComment() {
950  return this;
951  }
952  virtual const XMLComment* ToComment() const {
953  return this;
954  }
955 
956  virtual bool Accept( XMLVisitor* visitor ) const;
957 
958  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
959  virtual bool ShallowEqual( const XMLNode* compare ) const;
960 
961 protected:
962  XMLComment( XMLDocument* doc );
963  virtual ~XMLComment();
964 
965  char* ParseDeep( char*, StrPair* endTag );
966 
967 private:
968  XMLComment( const XMLComment& ); // not supported
969  XMLComment& operator=( const XMLComment& ); // not supported
970 };
971 
972 
985 {
986  friend class XMLDocument;
987 public:
989  return this;
990  }
991  virtual const XMLDeclaration* ToDeclaration() const {
992  return this;
993  }
994 
995  virtual bool Accept( XMLVisitor* visitor ) const;
996 
997  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
998  virtual bool ShallowEqual( const XMLNode* compare ) const;
999 
1000 protected:
1001  XMLDeclaration( XMLDocument* doc );
1002  virtual ~XMLDeclaration();
1003 
1004  char* ParseDeep( char*, StrPair* endTag );
1005 
1006 private:
1007  XMLDeclaration( const XMLDeclaration& ); // not supported
1008  XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
1009 };
1010 
1011 
1020 {
1021  friend class XMLDocument;
1022 public:
1023  virtual XMLUnknown* ToUnknown() {
1024  return this;
1025  }
1026  virtual const XMLUnknown* ToUnknown() const {
1027  return this;
1028  }
1029 
1030  virtual bool Accept( XMLVisitor* visitor ) const;
1031 
1032  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1033  virtual bool ShallowEqual( const XMLNode* compare ) const;
1034 
1035 protected:
1036  XMLUnknown( XMLDocument* doc );
1037  virtual ~XMLUnknown();
1038 
1039  char* ParseDeep( char*, StrPair* endTag );
1040 
1041 private:
1042  XMLUnknown( const XMLUnknown& ); // not supported
1043  XMLUnknown& operator=( const XMLUnknown& ); // not supported
1044 };
1045 
1046 
1047 
1055 {
1056  friend class XMLElement;
1057 public:
1059  const char* Name() const;
1060 
1062  const char* Value() const;
1063 
1065  const XMLAttribute* Next() const {
1066  return _next;
1067  }
1068 
1073  int IntValue() const {
1074  int i=0;
1075  QueryIntValue( &i );
1076  return i;
1077  }
1079  unsigned UnsignedValue() const {
1080  unsigned i=0;
1081  QueryUnsignedValue( &i );
1082  return i;
1083  }
1085  bool BoolValue() const {
1086  bool b=false;
1087  QueryBoolValue( &b );
1088  return b;
1089  }
1091  double DoubleValue() const {
1092  double d=0;
1093  QueryDoubleValue( &d );
1094  return d;
1095  }
1097  float FloatValue() const {
1098  float f=0;
1099  QueryFloatValue( &f );
1100  return f;
1101  }
1102 
1107  XMLError QueryIntValue( int* value ) const;
1109  XMLError QueryUnsignedValue( unsigned int* value ) const;
1111  XMLError QueryBoolValue( bool* value ) const;
1113  XMLError QueryDoubleValue( double* value ) const;
1115  XMLError QueryFloatValue( float* value ) const;
1116 
1118  void SetAttribute( const char* value );
1120  void SetAttribute( int value );
1122  void SetAttribute( unsigned value );
1124  void SetAttribute( bool value );
1126  void SetAttribute( double value );
1128  void SetAttribute( float value );
1129 
1130 private:
1131  enum { BUF_SIZE = 200 };
1132 
1133  XMLAttribute() : _next( 0 ), _memPool( 0 ) {}
1134  virtual ~XMLAttribute() {}
1135 
1136  XMLAttribute( const XMLAttribute& ); // not supported
1137  void operator=( const XMLAttribute& ); // not supported
1138  void SetName( const char* name );
1139 
1140  char* ParseDeep( char* p, bool processEntities );
1141 
1142  mutable StrPair _name;
1143  mutable StrPair _value;
1146 };
1147 
1148 
1154 {
1155  friend class XMLBase;
1156  friend class XMLDocument;
1157 public:
1159  const char* Name() const {
1160  return Value();
1161  }
1163  void SetName( const char* str, bool staticMem=false ) {
1164  SetValue( str, staticMem );
1165  }
1166 
1167  virtual XMLElement* ToElement() {
1168  return this;
1169  }
1170  virtual const XMLElement* ToElement() const {
1171  return this;
1172  }
1173  virtual bool Accept( XMLVisitor* visitor ) const;
1174 
1198  const char* Attribute( const char* name, const char* value=0 ) const;
1199 
1205  int IntAttribute( const char* name ) const {
1206  int i=0;
1207  QueryIntAttribute( name, &i );
1208  return i;
1209  }
1211  unsigned UnsignedAttribute( const char* name ) const {
1212  unsigned i=0;
1213  QueryUnsignedAttribute( name, &i );
1214  return i;
1215  }
1217  bool BoolAttribute( const char* name ) const {
1218  bool b=false;
1219  QueryBoolAttribute( name, &b );
1220  return b;
1221  }
1223  double DoubleAttribute( const char* name ) const {
1224  double d=0;
1225  QueryDoubleAttribute( name, &d );
1226  return d;
1227  }
1229  float FloatAttribute( const char* name ) const {
1230  float f=0;
1231  QueryFloatAttribute( name, &f );
1232  return f;
1233  }
1234 
1248  XMLError QueryIntAttribute( const char* name, int* value ) const {
1249  const XMLAttribute* a = FindAttribute( name );
1250  if ( !a ) {
1251  return XML_NO_ATTRIBUTE;
1252  }
1253  return a->QueryIntValue( value );
1254  }
1256  XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
1257  const XMLAttribute* a = FindAttribute( name );
1258  if ( !a ) {
1259  return XML_NO_ATTRIBUTE;
1260  }
1261  return a->QueryUnsignedValue( value );
1262  }
1264  XMLError QueryBoolAttribute( const char* name, bool* value ) const {
1265  const XMLAttribute* a = FindAttribute( name );
1266  if ( !a ) {
1267  return XML_NO_ATTRIBUTE;
1268  }
1269  return a->QueryBoolValue( value );
1270  }
1272  XMLError QueryDoubleAttribute( const char* name, double* value ) const {
1273  const XMLAttribute* a = FindAttribute( name );
1274  if ( !a ) {
1275  return XML_NO_ATTRIBUTE;
1276  }
1277  return a->QueryDoubleValue( value );
1278  }
1280  XMLError QueryFloatAttribute( const char* name, float* value ) const {
1281  const XMLAttribute* a = FindAttribute( name );
1282  if ( !a ) {
1283  return XML_NO_ATTRIBUTE;
1284  }
1285  return a->QueryFloatValue( value );
1286  }
1287 
1288 
1306  int QueryAttribute( const char* name, int* value ) const {
1307  return QueryIntAttribute( name, value );
1308  }
1309 
1310  int QueryAttribute( const char* name, unsigned int* value ) const {
1311  return QueryUnsignedAttribute( name, value );
1312  }
1313 
1314  int QueryAttribute( const char* name, bool* value ) const {
1315  return QueryBoolAttribute( name, value );
1316  }
1317 
1318  int QueryAttribute( const char* name, double* value ) const {
1319  return QueryDoubleAttribute( name, value );
1320  }
1321 
1322  int QueryAttribute( const char* name, float* value ) const {
1323  return QueryFloatAttribute( name, value );
1324  }
1325 
1327  void SetAttribute( const char* name, const char* value ) {
1328  XMLAttribute* a = FindOrCreateAttribute( name );
1329  a->SetAttribute( value );
1330  }
1332  void SetAttribute( const char* name, int value ) {
1333  XMLAttribute* a = FindOrCreateAttribute( name );
1334  a->SetAttribute( value );
1335  }
1337  void SetAttribute( const char* name, unsigned value ) {
1338  XMLAttribute* a = FindOrCreateAttribute( name );
1339  a->SetAttribute( value );
1340  }
1342  void SetAttribute( const char* name, bool value ) {
1343  XMLAttribute* a = FindOrCreateAttribute( name );
1344  a->SetAttribute( value );
1345  }
1347  void SetAttribute( const char* name, double value ) {
1348  XMLAttribute* a = FindOrCreateAttribute( name );
1349  a->SetAttribute( value );
1350  }
1352  void SetAttribute( const char* name, float value ) {
1353  XMLAttribute* a = FindOrCreateAttribute( name );
1354  a->SetAttribute( value );
1355  }
1356 
1360  void DeleteAttribute( const char* name );
1361 
1363  const XMLAttribute* FirstAttribute() const {
1364  return _rootAttribute;
1365  }
1367  const XMLAttribute* FindAttribute( const char* name ) const;
1368 
1397  const char* GetText() const;
1398 
1433  void SetText( const char* inText );
1435  void SetText( int value );
1437  void SetText( unsigned value );
1439  void SetText( bool value );
1441  void SetText( double value );
1443  void SetText( float value );
1444 
1471  XMLError QueryIntText( int* ival ) const;
1473  XMLError QueryUnsignedText( unsigned* uval ) const;
1475  XMLError QueryBoolText( bool* bval ) const;
1477  XMLError QueryDoubleText( double* dval ) const;
1479  XMLError QueryFloatText( float* fval ) const;
1480 
1481  // internal:
1482  enum {
1483  OPEN, // <foo>
1484  CLOSED, // <foo/>
1485  CLOSING // </foo>
1486  };
1487  int ClosingType() const {
1488  return _closingType;
1489  }
1490  virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1491  virtual bool ShallowEqual( const XMLNode* compare ) const;
1492 
1493 protected:
1494  char* ParseDeep( char* p, StrPair* endTag );
1495 
1496 private:
1497  XMLElement( XMLDocument* doc );
1498  virtual ~XMLElement();
1499  XMLElement( const XMLElement& ); // not supported
1500  void operator=( const XMLElement& ); // not supported
1501 
1502  XMLAttribute* FindAttribute( const char* name ) {
1503  return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));
1504  }
1505  XMLAttribute* FindOrCreateAttribute( const char* name );
1506  //void LinkAttribute( XMLAttribute* attrib );
1507  char* ParseAttributes( char* p );
1508  static void DeleteAttribute( XMLAttribute* attribute );
1509 
1510  enum { BUF_SIZE = 200 };
1512  // The attribute list is ordered; there is no 'lastAttribute'
1513  // because the list needs to be scanned for dupes before adding
1514  // a new attribute.
1516 };
1517 
1518 
1522 };
1523 
1524 
1531 {
1532  friend class XMLElement;
1533 public:
1535  XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
1536  ~XMLDocument();
1537 
1539  TIXMLASSERT( this == _document );
1540  return this;
1541  }
1542  virtual const XMLDocument* ToDocument() const {
1543  TIXMLASSERT( this == _document );
1544  return this;
1545  }
1546 
1557  XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
1558 
1564  XMLError LoadFile( const char* filename );
1565 
1577  XMLError LoadFile( FILE* );
1578 
1584  XMLError SaveFile( const char* filename, bool compact = false );
1585 
1593  XMLError SaveFile( FILE* fp, bool compact = false );
1594 
1595  bool ProcessEntities() const {
1596  return _processEntities;
1597  }
1599  return _whitespace;
1600  }
1601 
1605  bool HasBOM() const {
1606  return _writeBOM;
1607  }
1610  void SetBOM( bool useBOM ) {
1611  _writeBOM = useBOM;
1612  }
1613 
1618  return FirstChildElement();
1619  }
1620  const XMLElement* RootElement() const {
1621  return FirstChildElement();
1622  }
1623 
1638  void Print( XMLPrinter* streamer=0 ) const;
1639  virtual bool Accept( XMLVisitor* visitor ) const;
1640 
1646  XMLElement* NewElement( const char* name );
1652  XMLComment* NewComment( const char* comment );
1658  XMLText* NewText( const char* text );
1670  XMLDeclaration* NewDeclaration( const char* text=0 );
1676  XMLUnknown* NewUnknown( const char* text );
1677 
1682  void DeleteNode( XMLNode* node );
1683 
1684  void SetError( XMLError error, const char* str1, const char* str2 );
1685 
1687  bool Error() const {
1688  return _errorID != XML_NO_ERROR;
1689  }
1691  XMLError ErrorID() const {
1692  return _errorID;
1693  }
1694  const char* ErrorName() const;
1695 
1697  const char* GetErrorStr1() const {
1698  return _errorStr1;
1699  }
1701  const char* GetErrorStr2() const {
1702  return _errorStr2;
1703  }
1705  void PrintError() const;
1706 
1708  void Clear();
1709 
1710  // internal
1711  char* Identify( char* p, XMLNode** node );
1712 
1713  virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
1714  return 0;
1715  }
1716  virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
1717  return false;
1718  }
1719 
1720 private:
1721  XMLDocument( const XMLDocument& ); // not supported
1722  void operator=( const XMLDocument& ); // not supported
1723 
1728  const char* _errorStr1;
1729  const char* _errorStr2;
1731 
1736 
1737  static const char* _errorNames[XML_ERROR_COUNT];
1738 
1739  void Parse();
1740 };
1741 
1742 
1799 {
1800 public:
1802  XMLHandle( XMLNode* node ) {
1803  _node = node;
1804  }
1806  XMLHandle( XMLNode& node ) {
1807  _node = &node;
1808  }
1810  XMLHandle( const XMLHandle& ref ) {
1811  _node = ref._node;
1812  }
1814  XMLHandle& operator=( const XMLHandle& ref ) {
1815  _node = ref._node;
1816  return *this;
1817  }
1818 
1821  return XMLHandle( _node ? _node->FirstChild() : 0 );
1822  }
1824  XMLHandle FirstChildElement( const char* name = 0 ) {
1825  return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
1826  }
1829  return XMLHandle( _node ? _node->LastChild() : 0 );
1830  }
1832  XMLHandle LastChildElement( const char* name = 0 ) {
1833  return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
1834  }
1837  return XMLHandle( _node ? _node->PreviousSibling() : 0 );
1838  }
1840  XMLHandle PreviousSiblingElement( const char* name = 0 ) {
1841  return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
1842  }
1845  return XMLHandle( _node ? _node->NextSibling() : 0 );
1846  }
1848  XMLHandle NextSiblingElement( const char* name = 0 ) {
1849  return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
1850  }
1851 
1854  return _node;
1855  }
1858  return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1859  }
1862  return ( ( _node == 0 ) ? 0 : _node->ToText() );
1863  }
1866  return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
1867  }
1870  return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
1871  }
1872 
1873 private:
1875 };
1876 
1877 
1883 {
1884 public:
1885  XMLConstHandle( const XMLNode* node ) {
1886  _node = node;
1887  }
1888  XMLConstHandle( const XMLNode& node ) {
1889  _node = &node;
1890  }
1892  _node = ref._node;
1893  }
1894 
1896  _node = ref._node;
1897  return *this;
1898  }
1899 
1900  const XMLConstHandle FirstChild() const {
1901  return XMLConstHandle( _node ? _node->FirstChild() : 0 );
1902  }
1903  const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
1904  return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
1905  }
1906  const XMLConstHandle LastChild() const {
1907  return XMLConstHandle( _node ? _node->LastChild() : 0 );
1908  }
1909  const XMLConstHandle LastChildElement( const char* name = 0 ) const {
1910  return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
1911  }
1913  return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
1914  }
1915  const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
1916  return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
1917  }
1918  const XMLConstHandle NextSibling() const {
1919  return XMLConstHandle( _node ? _node->NextSibling() : 0 );
1920  }
1921  const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
1922  return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
1923  }
1924 
1925 
1926  const XMLNode* ToNode() const {
1927  return _node;
1928  }
1929  const XMLElement* ToElement() const {
1930  return ( ( _node == 0 ) ? 0 : _node->ToElement() );
1931  }
1932  const XMLText* ToText() const {
1933  return ( ( _node == 0 ) ? 0 : _node->ToText() );
1934  }
1935  const XMLUnknown* ToUnknown() const {
1936  return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
1937  }
1939  return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
1940  }
1941 
1942 private:
1943  const XMLNode* _node;
1944 };
1945 
1946 
1990 {
1991 public:
1998  XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
1999  virtual ~XMLPrinter() {}
2000 
2002  void PushHeader( bool writeBOM, bool writeDeclaration );
2006  void OpenElement( const char* name, bool compactMode=false );
2008  void PushAttribute( const char* name, const char* value );
2009  void PushAttribute( const char* name, int value );
2010  void PushAttribute( const char* name, unsigned value );
2011  void PushAttribute( const char* name, bool value );
2012  void PushAttribute( const char* name, double value );
2014  virtual void CloseElement( bool compactMode=false );
2015 
2017  void PushText( const char* text, bool cdata=false );
2019  void PushText( int value );
2021  void PushText( unsigned value );
2023  void PushText( bool value );
2025  void PushText( float value );
2027  void PushText( double value );
2028 
2030  void PushComment( const char* comment );
2031 
2032  void PushDeclaration( const char* value );
2033  void PushUnknown( const char* value );
2034 
2035  virtual bool VisitEnter( const XMLDocument& /*doc*/ );
2036  virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
2037  return true;
2038  }
2039 
2040  virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
2041  virtual bool VisitExit( const XMLElement& element );
2042 
2043  virtual bool Visit( const XMLText& text );
2044  virtual bool Visit( const XMLComment& comment );
2045  virtual bool Visit( const XMLDeclaration& declaration );
2046  virtual bool Visit( const XMLUnknown& unknown );
2047 
2052  const char* CStr() const {
2053  return _buffer.Mem();
2054  }
2060  int CStrSize() const {
2061  return _buffer.Size();
2062  }
2067  void ClearBuffer() {
2068  _buffer.Clear();
2069  _buffer.Push(0);
2070  }
2071 
2072 protected:
2073  virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
2074 
2078  virtual void PrintSpace( int depth );
2079  void Print( const char* format, ... );
2080 
2081  void SealElementIfJustOpened();
2084 
2085 private:
2086  void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
2087 
2089  FILE* _fp;
2090  int _depth;
2094 
2095  enum {
2096  ENTITY_RANGE = 64,
2097  BUF_SIZE = 200
2098  };
2099  bool _entityFlag[ENTITY_RANGE];
2100  bool _restrictedEntityFlag[ENTITY_RANGE];
2101 
2103 };
2104 
2105 
2106 } // tinyxml2
2107 
2108 #if defined(_MSC_VER)
2109 # pragma warning(pop)
2110 #endif
2111 
2112 #endif // TINYXML2_INCLUDED
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1167
double DoubleAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1223
d
Whitespace _whitespace
Definition: tinyxml2.h:1727
int QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1306
int QueryAttribute(const char *name, bool *value) const
Definition: tinyxml2.h:1314
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1938
void CollapseWhitespace()
Definition: tinyxml2.cpp:230
const char * _errorStr1
Definition: tinyxml2.h:1728
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1085
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1687
virtual ~XMLText()
Definition: tinyxml2.h:932
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:1900
filename
void Push(T t)
Definition: tinyxml2.h:204
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:1906
XMLError QueryIntValue(int *value) const
Definition: tinyxml2.cpp:1284
const XMLText * ToText() const
Definition: tinyxml2.h:1932
virtual void Free(void *mem)
Definition: tinyxml2.h:368
static const int TIXML2_PATCH_VERSION
Definition: tinyxml2.h:97
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1256
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:677
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:653
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1802
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:671
virtual void * Alloc()
Definition: tinyxml2.h:344
const XMLNode * _node
Definition: tinyxml2.h:1943
virtual ~MemPool()
Definition: tinyxml2.h:302
XMLElement * PreviousSiblingElement(const char *name=0)
Definition: tinyxml2.h:762
T * PushArr(int count)
Definition: tinyxml2.h:210
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1311
const T & operator[](int i) const
Definition: tinyxml2.h:238
f
XMLElement * LastChildElement(const char *name=0)
Definition: tinyxml2.h:746
XMLAttribute * _rootAttribute
Definition: tinyxml2.h:1515
MemPoolT< sizeof(XMLAttribute) > _attributePool
Definition: tinyxml2.h:1733
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:520
int CurrentAllocs() const
Definition: tinyxml2.h:340
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1337
virtual ~XMLAttribute()
Definition: tinyxml2.h:1134
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:649
XMLNode * FirstChild()
Definition: tinyxml2.h:719
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:1895
const T * Mem() const
Definition: tinyxml2.h:258
virtual const XMLText * ToText() const
Definition: tinyxml2.h:668
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:460
XMLNode * _lastChild
Definition: tinyxml2.h:876
virtual ~XMLVisitor()
Definition: tinyxml2.h:448
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:923
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:135
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:415
int ClosingType() const
Definition: tinyxml2.h:1487
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:549
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:534
void TransferTo(StrPair *other)
Definition: tinyxml2.cpp:144
XMLNode * _next
Definition: tinyxml2.h:879
const XMLElement * RootElement() const
Definition: tinyxml2.h:1620
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1023
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:473
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:715
XMLNode * _firstChild
Definition: tinyxml2.h:875
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1716
static char * SkipWhiteSpace(char *p)
Definition: tinyxml2.h:528
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1091
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:1885
XMLNode * PreviousSibling()
Definition: tinyxml2.h:755
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:455
char * ParseName(char *in)
Definition: tinyxml2.cpp:210
const T & PeekTop() const
Definition: tinyxml2.h:243
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:1888
int QueryAttribute(const char *name, double *value) const
Definition: tinyxml2.h:1318
void SetAttribute(const char *value)
Set the attribute to a string value.
Definition: tinyxml2.cpp:1329
virtual const XMLText * ToText() const
Definition: tinyxml2.h:914
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1280
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:680
XMLNode * _parent
Definition: tinyxml2.h:872
const XMLNode * ToNode() const
Definition: tinyxml2.h:1926
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:1912
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:911
MemPool * _memPool
Definition: tinyxml2.h:882
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:477
int IntAttribute(const char *name) const
Definition: tinyxml2.h:1205
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:1828
XMLNode * Parent()
Definition: tinyxml2.h:705
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1713
int Capacity() const
Definition: tinyxml2.h:253
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1327
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition: tinyxml2.h:1701
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1824
static const int TIXML2_MINOR_VERSION
Definition: tinyxml2.h:96
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1935
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:1814
bool Empty() const
Definition: tinyxml2.h:229
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:1918
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1610
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1320
bool ProcessEntities() const
Definition: tinyxml2.h:1595
DynArray< char, 20 > _buffer
Definition: tinyxml2.h:2102
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1691
XMLElement * RootElement()
Definition: tinyxml2.h:1617
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:1848
static bool IsUTF8Continuation(char p)
Definition: tinyxml2.h:572
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:701
virtual ~XMLPrinter()
Definition: tinyxml2.h:1999
XMLAttribute * _next
Definition: tinyxml2.h:1144
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1065
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1272
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1163
virtual int ItemSize() const
Definition: tinyxml2.h:337
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1347
int IntValue() const
Definition: tinyxml2.h:1073
int QueryAttribute(const char *name, float *value) const
Definition: tinyxml2.h:1322
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
Definition: tinyxml2.h:1915
static const int TIXML2_MAJOR_VERSION
Definition: tinyxml2.h:95
StrPair _value
Definition: tinyxml2.h:873
MemPoolT< sizeof(XMLComment) > _commentPool
Definition: tinyxml2.h:1735
#define TINYXML2_LIB
Definition: tinyxml2.h:72
bool BoolAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1217
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:1832
void EnsureCapacity(int cap)
Definition: tinyxml2.h:272
const char * GetStr()
Definition: tinyxml2.cpp:259
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2036
void SetStr(const char *str, int flags=0)
Definition: tinyxml2.cpp:178
int Size() const
Definition: tinyxml2.h:248
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:1806
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:919
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:635
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:630
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:988
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:661
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:556
int Untracked() const
Definition: tinyxml2.h:389
const char * _errorStr2
Definition: tinyxml2.h:1729
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1211
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:464
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1170
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:481
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:1891
XMLElement * NextSiblingElement(const char *name=0)
Definition: tinyxml2.h:778
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:751
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:991
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:791
XMLAttribute * FindAttribute(const char *name)
Definition: tinyxml2.h:1502
XMLElement * FirstChildElement(const char *name=0)
Definition: tinyxml2.h:728
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1342
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1352
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition: tinyxml2.h:1697
const XMLConstHandle FirstChildElement(const char *name=0) const
Definition: tinyxml2.h:1903
#define TIXMLASSERT(x)
Definition: tinyxml2.h:88
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:2083
XMLNode * NextSibling()
Definition: tinyxml2.h:771
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1248
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1853
void Trace(const char *name)
Definition: tinyxml2.h:380
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1844
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1079
void PopArr(int count)
Definition: tinyxml2.h:224
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1293
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:931
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:538
const XMLElement * ToElement() const
Definition: tinyxml2.h:1929
XMLDocument * _document
Definition: tinyxml2.h:871
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:645
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1332
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1264
bool HasBOM() const
Definition: tinyxml2.h:1605
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:1861
void operator=(StrPair &other)
int QueryAttribute(const char *name, unsigned int *value) const
Definition: tinyxml2.h:1310
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:733
T & operator[](int i)
Definition: tinyxml2.h:233
const XMLConstHandle LastChildElement(const char *name=0) const
Definition: tinyxml2.h:1909
XMLNode * LastChild()
Definition: tinyxml2.h:737
const XMLConstHandle NextSiblingElement(const char *name=0) const
Definition: tinyxml2.h:1921
virtual bool CompactMode(const XMLElement &)
Definition: tinyxml2.h:2073
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:1836
MemPoolT< sizeof(XMLText) > _textPool
Definition: tinyxml2.h:1734
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:1869
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:710
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:674
int CStrSize() const
Definition: tinyxml2.h:2060
MemPoolT< sizeof(XMLElement) > _elementPool
Definition: tinyxml2.h:1732
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1363
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:1865
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1820
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1026
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1857
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:1840
float FloatAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1229
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:469
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:451
XMLNode * _prev
Definition: tinyxml2.h:878
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:665
char * ParseText(char *in, const char *endTag, int strFlags)
Definition: tinyxml2.cpp:190
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1302
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1538
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1598
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1097
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:657
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:641
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:949
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:952
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:767
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1810
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1542
bool Empty() const
Definition: tinyxml2.h:144
const char * CStr() const
Definition: tinyxml2.h:2052
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1159
void SetInternedStr(const char *str)
Definition: tinyxml2.h:148


denso_robot_core
Author(s): DENSO WAVE INCORPORATED
autogenerated on Mon Jun 10 2019 13:12:27