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 -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
51 
52  Formatting, Artistic Style:
53  AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor
54  tinyxml2.cpp tinyxml2.h
55 */
56 
57 #if defined(_DEBUG) || defined(__DEBUG__)
58 # ifndef TINYXML2_DEBUG
59 # define TINYXML2_DEBUG
60 # endif
61 #endif
62 
63 #ifdef _MSC_VER
64 # pragma warning(push)
65 # pragma warning(disable : 4251)
66 #endif
67 
68 #ifdef _WIN32
69 # ifdef TINYXML2_EXPORT
70 # define TINYXML2_LIB __declspec(dllexport)
71 # elif defined(TINYXML2_IMPORT)
72 # define TINYXML2_LIB __declspec(dllimport)
73 # else
74 # define TINYXML2_LIB
75 # endif
76 #elif __GNUC__ >= 4
77 # define TINYXML2_LIB __attribute__((visibility("default")))
78 #else
79 # define TINYXML2_LIB
80 #endif
81 
82 
83 #if !defined(TIXMLASSERT)
84 # if defined(TINYXML2_DEBUG)
85 # if defined(_MSC_VER)
86 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
87 # define TIXMLASSERT(x) \
88  if (!((void)0, (x))) \
89  { \
90  __debugbreak(); \
91  }
92 # elif defined(ANDROID_NDK)
93 # include <android/log.h>
94 # define TIXMLASSERT(x) \
95  if (!(x)) \
96  { \
97  __android_log_assert("assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__); \
98  }
99 # else
100 # include <assert.h>
101 # define TIXMLASSERT assert
102 # endif
103 # else
104 # define TIXMLASSERT(x) \
105  { \
106  }
107 # endif
108 #endif
109 
110 /* Versioning, past 1.0.14:
111  http://semver.org/
112 */
113 static const int TIXML2_MAJOR_VERSION = 9;
114 static const int TIXML2_MINOR_VERSION = 0;
115 static const int TIXML2_PATCH_VERSION = 0;
116 
117 #define TINYXML2_MAJOR_VERSION 9
118 #define TINYXML2_MINOR_VERSION 0
119 #define TINYXML2_PATCH_VERSION 0
120 
121 // A fixed element depth limit is problematic. There needs to be a
122 // limit to avoid a stack overflow. However, that limit varies per
123 // system, and the capacity of the stack. On the other hand, it's a trivial
124 // attack that can result from ill, malicious, or even correctly formed XML,
125 // so there needs to be a limit in place.
126 static const int TINYXML2_MAX_ELEMENT_DEPTH = 100;
127 
128 namespace tinyxml2 {
129 class XMLDocument;
130 class XMLElement;
131 class XMLAttribute;
132 class XMLComment;
133 class XMLText;
134 class XMLDeclaration;
135 class XMLUnknown;
136 class XMLPrinter;
137 
138 /*
139  A class that wraps strings. Normally stores the start and end
140  pointers into the XML file itself, and will apply normalization
141  and entity translation if actually read. Can also store (and memory
142  manage) a traditional char[]
143 
144  Isn't clear why TINYXML2_LIB is needed; but seems to fix #719
145 */
147 {
148 public:
149  enum Mode
150  {
151  NEEDS_ENTITY_PROCESSING = 0x01,
152  NEEDS_NEWLINE_NORMALIZATION = 0x02,
153  NEEDS_WHITESPACE_COLLAPSING = 0x04,
154 
155  TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
156  TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
157  ATTRIBUTE_NAME = 0,
158  ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
159  ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
160  COMMENT = NEEDS_NEWLINE_NORMALIZATION
161  };
162 
164  : _flags(0)
165  , _start(0)
166  , _end(0)
167  {
168  }
169  ~StrPair();
170 
171  void Set(char* start, char* end, int flags)
172  {
173  TIXMLASSERT(start);
174  TIXMLASSERT(end);
175  Reset();
176  _start = start;
177  _end = end;
178  _flags = flags | NEEDS_FLUSH;
179  }
180 
181  const char* GetStr();
182 
183  bool Empty() const { return _start == _end; }
184 
185  void SetInternedStr(const char* str)
186  {
187  Reset();
188  _start = const_cast<char*>(str);
189  }
190 
191  void SetStr(const char* str, int flags = 0);
192 
193  char* ParseText(char* in, const char* endTag, int strFlags, int* curLineNumPtr);
194  char* ParseName(char* in);
195 
196  void TransferTo(StrPair* other);
197  void Reset();
198 
199 private:
200  void CollapseWhitespace();
201 
202  enum
203  {
204  NEEDS_FLUSH = 0x100,
205  NEEDS_DELETE = 0x200
206  };
207 
208  int _flags;
209  char* _start;
210  char* _end;
211 
212  StrPair(const StrPair& other); // not supported
213  void operator=(const StrPair& other); // not supported, use TransferTo()
214 };
215 
216 
217 /*
218  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
219  Has a small initial memory pool, so that low or no usage will not
220  cause a call to new/delete
221 */
222 template <class T, int INITIAL_SIZE>
223 class DynArray
224 {
225 public:
227  : _mem(_pool)
228  , _allocated(INITIAL_SIZE)
229  , _size(0)
230  {
231  }
232 
234  {
235  if (_mem != _pool)
236  {
237  delete[] _mem;
238  }
239  }
240 
241  void Clear() { _size = 0; }
242 
243  void Push(T t)
244  {
245  TIXMLASSERT(_size < INT_MAX);
246  EnsureCapacity(_size + 1);
247  _mem[_size] = t;
248  ++_size;
249  }
250 
251  T* PushArr(int count)
252  {
253  TIXMLASSERT(count >= 0);
254  TIXMLASSERT(_size <= INT_MAX - count);
255  EnsureCapacity(_size + count);
256  T* ret = &_mem[_size];
257  _size += count;
258  return ret;
259  }
260 
261  T Pop()
262  {
263  TIXMLASSERT(_size > 0);
264  --_size;
265  return _mem[_size];
266  }
267 
268  void PopArr(int count)
269  {
270  TIXMLASSERT(_size >= count);
271  _size -= count;
272  }
273 
274  bool Empty() const { return _size == 0; }
275 
276  T& operator[](int i)
277  {
278  TIXMLASSERT(i >= 0 && i < _size);
279  return _mem[i];
280  }
281 
282  const T& operator[](int i) const
283  {
284  TIXMLASSERT(i >= 0 && i < _size);
285  return _mem[i];
286  }
287 
288  const T& PeekTop() const
289  {
290  TIXMLASSERT(_size > 0);
291  return _mem[_size - 1];
292  }
293 
294  int Size() const
295  {
296  TIXMLASSERT(_size >= 0);
297  return _size;
298  }
299 
300  int Capacity() const
301  {
302  TIXMLASSERT(_allocated >= INITIAL_SIZE);
303  return _allocated;
304  }
305 
306  void SwapRemove(int i)
307  {
308  TIXMLASSERT(i >= 0 && i < _size);
309  TIXMLASSERT(_size > 0);
310  _mem[i] = _mem[_size - 1];
311  --_size;
312  }
313 
314  const T* Mem() const
315  {
316  TIXMLASSERT(_mem);
317  return _mem;
318  }
319 
320  T* Mem()
321  {
322  TIXMLASSERT(_mem);
323  return _mem;
324  }
325 
326 private:
327  DynArray(const DynArray&); // not supported
328  void operator=(const DynArray&); // not supported
329 
330  void EnsureCapacity(int cap)
331  {
332  TIXMLASSERT(cap > 0);
333  if (cap > _allocated)
334  {
335  TIXMLASSERT(cap <= INT_MAX / 2);
336  const int newAllocated = cap * 2;
337  T* newMem = new T[newAllocated];
338  TIXMLASSERT(newAllocated >= _size);
339  memcpy(
340  newMem, _mem, sizeof(T) * _size); // warning: not using constructors, only works for PODs
341  if (_mem != _pool)
342  {
343  delete[] _mem;
344  }
345  _mem = newMem;
346  _allocated = newAllocated;
347  }
348  }
349 
350  T* _mem;
351  T _pool[INITIAL_SIZE];
352  int _allocated; // objects allocated
353  int _size; // number objects in use
354 };
355 
356 
357 /*
358  Parent virtual class of a pool for fast allocation
359  and deallocation of objects.
360 */
361 class MemPool
362 {
363 public:
364  MemPool() {}
365  virtual ~MemPool() {}
366 
367  virtual int ItemSize() const = 0;
368  virtual void* Alloc() = 0;
369  virtual void Free(void*) = 0;
370  virtual void SetTracked() = 0;
371 };
372 
373 
374 /*
375  Template child class to create pools of the correct type.
376 */
377 template <int ITEM_SIZE>
378 class MemPoolT : public MemPool
379 {
380 public:
382  : _blockPtrs()
383  , _root(0)
384  , _currentAllocs(0)
385  , _nAllocs(0)
386  , _maxAllocs(0)
387  , _nUntracked(0)
388  {
389  }
391 
392  void Clear()
393  {
394  // Delete the blocks.
395  while (!_blockPtrs.Empty())
396  {
397  Block* lastBlock = _blockPtrs.Pop();
398  delete lastBlock;
399  }
400  _root = 0;
401  _currentAllocs = 0;
402  _nAllocs = 0;
403  _maxAllocs = 0;
404  _nUntracked = 0;
405  }
406 
407  virtual int ItemSize() const { return ITEM_SIZE; }
408  int CurrentAllocs() const { return _currentAllocs; }
409 
410  virtual void* Alloc()
411  {
412  if (!_root)
413  {
414  // Need a new block.
415  Block* block = new Block();
416  _blockPtrs.Push(block);
417 
418  Item* blockItems = block->items;
419  for (int i = 0; i < ITEMS_PER_BLOCK - 1; ++i)
420  {
421  blockItems[i].next = &(blockItems[i + 1]);
422  }
423  blockItems[ITEMS_PER_BLOCK - 1].next = 0;
424  _root = blockItems;
425  }
426  Item* const result = _root;
427  TIXMLASSERT(result != 0);
428  _root = _root->next;
429 
430  ++_currentAllocs;
432  {
434  }
435  ++_nAllocs;
436  ++_nUntracked;
437  return result;
438  }
439 
440  virtual void Free(void* mem)
441  {
442  if (!mem)
443  {
444  return;
445  }
446  --_currentAllocs;
447  Item* item = static_cast<Item*>(mem);
448 #ifdef TINYXML2_DEBUG
449  memset(item, 0xfe, sizeof(*item));
450 #endif
451  item->next = _root;
452  _root = item;
453  }
454  void Trace(const char* name)
455  {
456  printf("Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
457  name,
458  _maxAllocs,
459  _maxAllocs * ITEM_SIZE / 1024,
461  ITEM_SIZE,
462  _nAllocs,
463  _blockPtrs.Size());
464  }
465 
466  void SetTracked() { --_nUntracked; }
467 
468  int Untracked() const { return _nUntracked; }
469 
470  // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
471  // The test file is large, 170k.
472  // Release: VS2010 gcc(no opt)
473  // 1k: 4000
474  // 2k: 4000
475  // 4k: 3900 21000
476  // 16k: 5200
477  // 32k: 4300
478  // 64k: 4000 21000
479  // Declared public because some compilers do not accept to use ITEMS_PER_BLOCK
480  // in private part if ITEMS_PER_BLOCK is private
481  enum
482  {
483  ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE
484  };
485 
486 private:
487  MemPoolT(const MemPoolT&); // not supported
488  void operator=(const MemPoolT&); // not supported
489 
490  union Item
491  {
493  char itemData[ITEM_SIZE];
494  };
495  struct Block
496  {
498  };
500  Item* _root;
501 
503  int _nAllocs;
506 };
507 
508 
529 {
530 public:
531  virtual ~XMLVisitor() {}
532 
534  virtual bool VisitEnter(const XMLDocument& /*doc*/) { return true; }
536  virtual bool VisitExit(const XMLDocument& /*doc*/) { return true; }
537 
539  virtual bool VisitEnter(const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/)
540  {
541  return true;
542  }
544  virtual bool VisitExit(const XMLElement& /*element*/) { return true; }
545 
547  virtual bool Visit(const XMLDeclaration& /*declaration*/) { return true; }
549  virtual bool Visit(const XMLText& /*text*/) { return true; }
551  virtual bool Visit(const XMLComment& /*comment*/) { return true; }
553  virtual bool Visit(const XMLUnknown& /*unknown*/) { return true; }
554 };
555 
556 // WARNING: must match XMLDocument::_errorNames[]
558 {
578 
580 };
581 
582 
583 /*
584  Utility functionality.
585 */
587 {
588 public:
589  static const char* SkipWhiteSpace(const char* p, int* curLineNumPtr)
590  {
591  TIXMLASSERT(p);
592 
593  while (IsWhiteSpace(*p))
594  {
595  if (curLineNumPtr && *p == '\n')
596  {
597  ++(*curLineNumPtr);
598  }
599  ++p;
600  }
601  TIXMLASSERT(p);
602  return p;
603  }
604  static char* SkipWhiteSpace(char* const p, int* curLineNumPtr)
605  {
606  return const_cast<char*>(SkipWhiteSpace(const_cast<const char*>(p), curLineNumPtr));
607  }
608 
609  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
610  // correct, but simple, and usually works.
611  static bool IsWhiteSpace(char p)
612  {
613  return !IsUTF8Continuation(p) && isspace(static_cast<unsigned char>(p));
614  }
615 
616  inline static bool IsNameStartChar(unsigned char ch)
617  {
618  if (ch >= 128)
619  {
620  // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
621  return true;
622  }
623  if (isalpha(ch))
624  {
625  return true;
626  }
627  return ch == ':' || ch == '_';
628  }
629 
630  inline static bool IsNameChar(unsigned char ch)
631  {
632  return IsNameStartChar(ch) || isdigit(ch) || ch == '.' || ch == '-';
633  }
634 
635  inline static bool IsPrefixHex(const char* p)
636  {
637  p = SkipWhiteSpace(p, 0);
638  return p && *p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X');
639  }
640 
641  inline static bool StringEqual(const char* p, const char* q, int nChar = INT_MAX)
642  {
643  if (p == q)
644  {
645  return true;
646  }
647  TIXMLASSERT(p);
648  TIXMLASSERT(q);
649  TIXMLASSERT(nChar >= 0);
650  return strncmp(p, q, nChar) == 0;
651  }
652 
653  inline static bool IsUTF8Continuation(const char p) { return (p & 0x80) != 0; }
654 
655  static const char* ReadBOM(const char* p, bool* hasBOM);
656  // p is the starting location,
657  // the UTF-8 value of the entity will be placed in value, and length filled in.
658  static const char* GetCharacterRef(const char* p, char* value, int* length);
659  static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length);
660 
661  // converts primitive types to strings
662  static void ToStr(int v, char* buffer, int bufferSize);
663  static void ToStr(unsigned v, char* buffer, int bufferSize);
664  static void ToStr(bool v, char* buffer, int bufferSize);
665  static void ToStr(float v, char* buffer, int bufferSize);
666  static void ToStr(double v, char* buffer, int bufferSize);
667  static void ToStr(int64_t v, char* buffer, int bufferSize);
668  static void ToStr(uint64_t v, char* buffer, int bufferSize);
669 
670  // converts strings to primitive types
671  static bool ToInt(const char* str, int* value);
672  static bool ToUnsigned(const char* str, unsigned* value);
673  static bool ToBool(const char* str, bool* value);
674  static bool ToFloat(const char* str, float* value);
675  static bool ToDouble(const char* str, double* value);
676  static bool ToInt64(const char* str, int64_t* value);
677  static bool ToUnsigned64(const char* str, uint64_t* value);
678  // Changes what is serialized for a boolean value.
679  // Default to "true" and "false". Shouldn't be changed
680  // unless you have a special testing or compatibility need.
681  // Be careful: static, global, & not thread safe.
682  // Be sure to set static const memory as parameters.
683  static void SetBoolSerialization(const char* writeTrue, const char* writeFalse);
684 
685 private:
686  static const char* writeBoolTrue;
687  static const char* writeBoolFalse;
688 };
689 
690 
717 {
718  friend class XMLDocument;
719  friend class XMLElement;
720 
721 public:
723  const XMLDocument* GetDocument() const
724  {
725  TIXMLASSERT(_document);
726  return _document;
727  }
730  {
731  TIXMLASSERT(_document);
732  return _document;
733  }
734 
736  virtual XMLElement* ToElement() { return 0; }
738  virtual XMLText* ToText() { return 0; }
740  virtual XMLComment* ToComment() { return 0; }
742  virtual XMLDocument* ToDocument() { return 0; }
744  virtual XMLDeclaration* ToDeclaration() { return 0; }
746  virtual XMLUnknown* ToUnknown() { return 0; }
747 
748  virtual const XMLElement* ToElement() const { return 0; }
749  virtual const XMLText* ToText() const { return 0; }
750  virtual const XMLComment* ToComment() const { return 0; }
751  virtual const XMLDocument* ToDocument() const { return 0; }
752  virtual const XMLDeclaration* ToDeclaration() const { return 0; }
753  virtual const XMLUnknown* ToUnknown() const { return 0; }
754 
764  const char* Value() const;
765 
769  void SetValue(const char* val, bool staticMem = false);
770 
772  int GetLineNum() const { return _parseLineNum; }
773 
775  const XMLNode* Parent() const { return _parent; }
776 
777  XMLNode* Parent() { return _parent; }
778 
780  bool NoChildren() const { return !_firstChild; }
781 
783  const XMLNode* FirstChild() const { return _firstChild; }
784 
785  XMLNode* FirstChild() { return _firstChild; }
786 
790  const XMLElement* FirstChildElement(const char* name = 0) const;
791 
792  XMLElement* FirstChildElement(const char* name = 0)
793  {
794  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement(name));
795  }
796 
798  const XMLNode* LastChild() const { return _lastChild; }
799 
800  XMLNode* LastChild() { return _lastChild; }
801 
805  const XMLElement* LastChildElement(const char* name = 0) const;
806 
807  XMLElement* LastChildElement(const char* name = 0)
808  {
809  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name));
810  }
811 
813  const XMLNode* PreviousSibling() const { return _prev; }
814 
815  XMLNode* PreviousSibling() { return _prev; }
816 
818  const XMLElement* PreviousSiblingElement(const char* name = 0) const;
819 
820  XMLElement* PreviousSiblingElement(const char* name = 0)
821  {
822  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement(name));
823  }
824 
826  const XMLNode* NextSibling() const { return _next; }
827 
828  XMLNode* NextSibling() { return _next; }
829 
831  const XMLElement* NextSiblingElement(const char* name = 0) const;
832 
833  XMLElement* NextSiblingElement(const char* name = 0)
834  {
835  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement(name));
836  }
837 
845  XMLNode* InsertEndChild(XMLNode* addThis);
846 
847  XMLNode* LinkEndChild(XMLNode* addThis) { return InsertEndChild(addThis); }
855  XMLNode* InsertFirstChild(XMLNode* addThis);
864  XMLNode* InsertAfterChild(XMLNode* afterThis, XMLNode* addThis);
865 
869  void DeleteChildren();
870 
874  void DeleteChild(XMLNode* node);
875 
885  virtual XMLNode* ShallowClone(XMLDocument* document) const = 0;
886 
900  XMLNode* DeepClone(XMLDocument* target) const;
901 
908  virtual bool ShallowEqual(const XMLNode* compare) const = 0;
909 
932  virtual bool Accept(XMLVisitor* visitor) const = 0;
933 
939  void SetUserData(void* userData) { _userData = userData; }
940 
946  void* GetUserData() const { return _userData; }
947 
948 protected:
949  explicit XMLNode(XMLDocument*);
950  virtual ~XMLNode();
951 
952  virtual char* ParseDeep(char* p, StrPair* parentEndTag, int* curLineNumPtr);
953 
956  mutable StrPair _value;
958 
961 
964 
965  void* _userData;
966 
967 private:
969  void Unlink(XMLNode* child);
970  static void DeleteNode(XMLNode* node);
971  void InsertChildPreamble(XMLNode* insertThis) const;
972  const XMLElement* ToElementWithName(const char* name) const;
973 
974  XMLNode(const XMLNode&); // not supported
975  XMLNode& operator=(const XMLNode&); // not supported
976 };
977 
978 
992 {
993  friend class XMLDocument;
994 
995 public:
996  virtual bool Accept(XMLVisitor* visitor) const;
997 
998  virtual XMLText* ToText() { return this; }
999  virtual const XMLText* ToText() const { return this; }
1000 
1002  void SetCData(bool isCData) { _isCData = isCData; }
1004  bool CData() const { return _isCData; }
1005 
1006  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1007  virtual bool ShallowEqual(const XMLNode* compare) const;
1008 
1009 protected:
1010  explicit XMLText(XMLDocument* doc)
1011  : XMLNode(doc)
1012  , _isCData(false)
1013  {
1014  }
1015  virtual ~XMLText() {}
1016 
1017  char* ParseDeep(char* p, StrPair* parentEndTag, int* curLineNumPtr);
1018 
1019 private:
1020  bool _isCData;
1021 
1022  XMLText(const XMLText&); // not supported
1023  XMLText& operator=(const XMLText&); // not supported
1024 };
1025 
1026 
1029 {
1030  friend class XMLDocument;
1031 
1032 public:
1033  virtual XMLComment* ToComment() { return this; }
1034  virtual const XMLComment* ToComment() const { return this; }
1035 
1036  virtual bool Accept(XMLVisitor* visitor) const;
1037 
1038  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1039  virtual bool ShallowEqual(const XMLNode* compare) const;
1040 
1041 protected:
1042  explicit XMLComment(XMLDocument* doc);
1043  virtual ~XMLComment();
1044 
1045  char* ParseDeep(char* p, StrPair* parentEndTag, int* curLineNumPtr);
1046 
1047 private:
1048  XMLComment(const XMLComment&); // not supported
1049  XMLComment& operator=(const XMLComment&); // not supported
1050 };
1051 
1052 
1065 {
1066  friend class XMLDocument;
1067 
1068 public:
1069  virtual XMLDeclaration* ToDeclaration() { return this; }
1070  virtual const XMLDeclaration* ToDeclaration() const { return this; }
1071 
1072  virtual bool Accept(XMLVisitor* visitor) const;
1073 
1074  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1075  virtual bool ShallowEqual(const XMLNode* compare) const;
1076 
1077 protected:
1078  explicit XMLDeclaration(XMLDocument* doc);
1079  virtual ~XMLDeclaration();
1080 
1081  char* ParseDeep(char* p, StrPair* parentEndTag, int* curLineNumPtr);
1082 
1083 private:
1084  XMLDeclaration(const XMLDeclaration&); // not supported
1085  XMLDeclaration& operator=(const XMLDeclaration&); // not supported
1086 };
1087 
1088 
1097 {
1098  friend class XMLDocument;
1099 
1100 public:
1101  virtual XMLUnknown* ToUnknown() { return this; }
1102  virtual const XMLUnknown* ToUnknown() const { return this; }
1103 
1104  virtual bool Accept(XMLVisitor* visitor) const;
1105 
1106  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1107  virtual bool ShallowEqual(const XMLNode* compare) const;
1108 
1109 protected:
1110  explicit XMLUnknown(XMLDocument* doc);
1111  virtual ~XMLUnknown();
1112 
1113  char* ParseDeep(char* p, StrPair* parentEndTag, int* curLineNumPtr);
1114 
1115 private:
1116  XMLUnknown(const XMLUnknown&); // not supported
1117  XMLUnknown& operator=(const XMLUnknown&); // not supported
1118 };
1119 
1120 
1128 {
1129  friend class XMLElement;
1130 
1131 public:
1133  const char* Name() const;
1134 
1136  const char* Value() const;
1137 
1139  int GetLineNum() const { return _parseLineNum; }
1140 
1142  const XMLAttribute* Next() const { return _next; }
1143 
1148  int IntValue() const
1149  {
1150  int i = 0;
1151  QueryIntValue(&i);
1152  return i;
1153  }
1154 
1155  int64_t Int64Value() const
1156  {
1157  int64_t i = 0;
1158  QueryInt64Value(&i);
1159  return i;
1160  }
1161 
1162  uint64_t Unsigned64Value() const
1163  {
1164  uint64_t i = 0;
1165  QueryUnsigned64Value(&i);
1166  return i;
1167  }
1168 
1170  unsigned UnsignedValue() const
1171  {
1172  unsigned i = 0;
1173  QueryUnsignedValue(&i);
1174  return i;
1175  }
1177  bool BoolValue() const
1178  {
1179  bool b = false;
1180  QueryBoolValue(&b);
1181  return b;
1182  }
1184  double DoubleValue() const
1185  {
1186  double d = 0;
1187  QueryDoubleValue(&d);
1188  return d;
1189  }
1191  float FloatValue() const
1192  {
1193  float f = 0;
1194  QueryFloatValue(&f);
1195  return f;
1196  }
1197 
1202  XMLError QueryIntValue(int* value) const;
1204  XMLError QueryUnsignedValue(unsigned int* value) const;
1206  XMLError QueryInt64Value(int64_t* value) const;
1208  XMLError QueryUnsigned64Value(uint64_t* value) const;
1210  XMLError QueryBoolValue(bool* value) const;
1212  XMLError QueryDoubleValue(double* value) const;
1214  XMLError QueryFloatValue(float* value) const;
1215 
1217  void SetAttribute(const char* value);
1219  void SetAttribute(int value);
1221  void SetAttribute(unsigned value);
1223  void SetAttribute(int64_t value);
1225  void SetAttribute(uint64_t value);
1227  void SetAttribute(bool value);
1229  void SetAttribute(double value);
1231  void SetAttribute(float value);
1232 
1233 private:
1234  enum
1235  {
1236  BUF_SIZE = 200
1237  };
1238 
1240  : _name()
1241  , _value()
1242  , _parseLineNum(0)
1243  , _next(0)
1244  , _memPool(0)
1245  {
1246  }
1247  virtual ~XMLAttribute() {}
1248 
1249  XMLAttribute(const XMLAttribute&); // not supported
1250  void operator=(const XMLAttribute&); // not supported
1251  void SetName(const char* name);
1252 
1253  char* ParseDeep(char* p, bool processEntities, int* curLineNumPtr);
1254 
1255  mutable StrPair _name;
1256  mutable StrPair _value;
1260 };
1261 
1262 
1268 {
1269  friend class XMLDocument;
1270 
1271 public:
1273  const char* Name() const { return Value(); }
1275  void SetName(const char* str, bool staticMem = false) { SetValue(str, staticMem); }
1276 
1277  virtual XMLElement* ToElement() { return this; }
1278  virtual const XMLElement* ToElement() const { return this; }
1279  virtual bool Accept(XMLVisitor* visitor) const;
1280 
1304  const char* Attribute(const char* name, const char* value = 0) const;
1305 
1312  int IntAttribute(const char* name, int defaultValue = 0) const;
1314  unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;
1316  int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
1318  uint64_t Unsigned64Attribute(const char* name, uint64_t defaultValue = 0) const;
1320  bool BoolAttribute(const char* name, bool defaultValue = false) const;
1322  double DoubleAttribute(const char* name, double defaultValue = 0) const;
1324  float FloatAttribute(const char* name, float defaultValue = 0) const;
1325 
1339  XMLError QueryIntAttribute(const char* name, int* value) const
1340  {
1341  const XMLAttribute* a = FindAttribute(name);
1342  if (!a)
1343  {
1344  return XML_NO_ATTRIBUTE;
1345  }
1346  return a->QueryIntValue(value);
1347  }
1348 
1350  XMLError QueryUnsignedAttribute(const char* name, unsigned int* value) const
1351  {
1352  const XMLAttribute* a = FindAttribute(name);
1353  if (!a)
1354  {
1355  return XML_NO_ATTRIBUTE;
1356  }
1357  return a->QueryUnsignedValue(value);
1358  }
1359 
1361  XMLError QueryInt64Attribute(const char* name, int64_t* value) const
1362  {
1363  const XMLAttribute* a = FindAttribute(name);
1364  if (!a)
1365  {
1366  return XML_NO_ATTRIBUTE;
1367  }
1368  return a->QueryInt64Value(value);
1369  }
1370 
1372  XMLError QueryUnsigned64Attribute(const char* name, uint64_t* value) const
1373  {
1374  const XMLAttribute* a = FindAttribute(name);
1375  if (!a)
1376  {
1377  return XML_NO_ATTRIBUTE;
1378  }
1379  return a->QueryUnsigned64Value(value);
1380  }
1381 
1383  XMLError QueryBoolAttribute(const char* name, bool* value) const
1384  {
1385  const XMLAttribute* a = FindAttribute(name);
1386  if (!a)
1387  {
1388  return XML_NO_ATTRIBUTE;
1389  }
1390  return a->QueryBoolValue(value);
1391  }
1393  XMLError QueryDoubleAttribute(const char* name, double* value) const
1394  {
1395  const XMLAttribute* a = FindAttribute(name);
1396  if (!a)
1397  {
1398  return XML_NO_ATTRIBUTE;
1399  }
1400  return a->QueryDoubleValue(value);
1401  }
1403  XMLError QueryFloatAttribute(const char* name, float* value) const
1404  {
1405  const XMLAttribute* a = FindAttribute(name);
1406  if (!a)
1407  {
1408  return XML_NO_ATTRIBUTE;
1409  }
1410  return a->QueryFloatValue(value);
1411  }
1412 
1414  XMLError QueryStringAttribute(const char* name, const char** value) const
1415  {
1416  const XMLAttribute* a = FindAttribute(name);
1417  if (!a)
1418  {
1419  return XML_NO_ATTRIBUTE;
1420  }
1421  *value = a->Value();
1422  return XML_SUCCESS;
1423  }
1424 
1425 
1443  XMLError QueryAttribute(const char* name, int* value) const
1444  {
1445  return QueryIntAttribute(name, value);
1446  }
1447 
1448  XMLError QueryAttribute(const char* name, unsigned int* value) const
1449  {
1450  return QueryUnsignedAttribute(name, value);
1451  }
1452 
1453  XMLError QueryAttribute(const char* name, int64_t* value) const
1454  {
1455  return QueryInt64Attribute(name, value);
1456  }
1457 
1458  XMLError QueryAttribute(const char* name, uint64_t* value) const
1459  {
1460  return QueryUnsigned64Attribute(name, value);
1461  }
1462 
1463  XMLError QueryAttribute(const char* name, bool* value) const
1464  {
1465  return QueryBoolAttribute(name, value);
1466  }
1467 
1468  XMLError QueryAttribute(const char* name, double* value) const
1469  {
1470  return QueryDoubleAttribute(name, value);
1471  }
1472 
1473  XMLError QueryAttribute(const char* name, float* value) const
1474  {
1475  return QueryFloatAttribute(name, value);
1476  }
1477 
1478  XMLError QueryAttribute(const char* name, const char** value) const
1479  {
1480  return QueryStringAttribute(name, value);
1481  }
1482 
1484  void SetAttribute(const char* name, const char* value)
1485  {
1486  XMLAttribute* a = FindOrCreateAttribute(name);
1487  a->SetAttribute(value);
1488  }
1490  void SetAttribute(const char* name, int value)
1491  {
1492  XMLAttribute* a = FindOrCreateAttribute(name);
1493  a->SetAttribute(value);
1494  }
1496  void SetAttribute(const char* name, unsigned value)
1497  {
1498  XMLAttribute* a = FindOrCreateAttribute(name);
1499  a->SetAttribute(value);
1500  }
1501 
1503  void SetAttribute(const char* name, int64_t value)
1504  {
1505  XMLAttribute* a = FindOrCreateAttribute(name);
1506  a->SetAttribute(value);
1507  }
1508 
1510  void SetAttribute(const char* name, uint64_t value)
1511  {
1512  XMLAttribute* a = FindOrCreateAttribute(name);
1513  a->SetAttribute(value);
1514  }
1515 
1517  void SetAttribute(const char* name, bool value)
1518  {
1519  XMLAttribute* a = FindOrCreateAttribute(name);
1520  a->SetAttribute(value);
1521  }
1523  void SetAttribute(const char* name, double value)
1524  {
1525  XMLAttribute* a = FindOrCreateAttribute(name);
1526  a->SetAttribute(value);
1527  }
1529  void SetAttribute(const char* name, float value)
1530  {
1531  XMLAttribute* a = FindOrCreateAttribute(name);
1532  a->SetAttribute(value);
1533  }
1534 
1538  void DeleteAttribute(const char* name);
1539 
1541  const XMLAttribute* FirstAttribute() const { return _rootAttribute; }
1543  const XMLAttribute* FindAttribute(const char* name) const;
1544 
1573  const char* GetText() const;
1574 
1609  void SetText(const char* inText);
1612  void SetText(int value);
1615  void SetText(unsigned value);
1618  void SetText(int64_t value);
1621  void SetText(uint64_t value);
1624  void SetText(bool value);
1627  void SetText(double value);
1630  void SetText(float value);
1631 
1658  XMLError QueryIntText(int* ival) const;
1660  XMLError QueryUnsignedText(unsigned* uval) const;
1662  XMLError QueryInt64Text(int64_t* uval) const;
1664  XMLError QueryUnsigned64Text(uint64_t* uval) const;
1666  XMLError QueryBoolText(bool* bval) const;
1668  XMLError QueryDoubleText(double* dval) const;
1670  XMLError QueryFloatText(float* fval) const;
1671 
1672  int IntText(int defaultValue = 0) const;
1673 
1675  unsigned UnsignedText(unsigned defaultValue = 0) const;
1677  int64_t Int64Text(int64_t defaultValue = 0) const;
1679  uint64_t Unsigned64Text(uint64_t defaultValue = 0) const;
1681  bool BoolText(bool defaultValue = false) const;
1683  double DoubleText(double defaultValue = 0) const;
1685  float FloatText(float defaultValue = 0) const;
1686 
1691  XMLElement* InsertNewChildElement(const char* name);
1693  XMLComment* InsertNewComment(const char* comment);
1695  XMLText* InsertNewText(const char* text);
1697  XMLDeclaration* InsertNewDeclaration(const char* text);
1699  XMLUnknown* InsertNewUnknown(const char* text);
1700 
1701 
1702  // internal:
1704  {
1705  OPEN, // <foo>
1706  CLOSED, // <foo/>
1707  CLOSING // </foo>
1708  };
1709  ElementClosingType ClosingType() const { return _closingType; }
1710  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1711  virtual bool ShallowEqual(const XMLNode* compare) const;
1712 
1713 protected:
1714  char* ParseDeep(char* p, StrPair* parentEndTag, int* curLineNumPtr);
1715 
1716 private:
1717  XMLElement(XMLDocument* doc);
1718  virtual ~XMLElement();
1719  XMLElement(const XMLElement&); // not supported
1720  void operator=(const XMLElement&); // not supported
1721 
1722  XMLAttribute* FindOrCreateAttribute(const char* name);
1723  char* ParseAttributes(char* p, int* curLineNumPtr);
1724  static void DeleteAttribute(XMLAttribute* attribute);
1725  XMLAttribute* CreateAttribute();
1726 
1727  enum
1728  {
1729  BUF_SIZE = 200
1730  };
1732  // The attribute list is ordered; there is no 'lastAttribute'
1733  // because the list needs to be scanned for dupes before adding
1734  // a new attribute.
1736 };
1737 
1738 
1740 {
1743 };
1744 
1745 
1752 {
1753  friend class XMLElement;
1754  // Gives access to SetError and Push/PopDepth, but over-access for everything else.
1755  // Wishing C++ had "internal" scope.
1756  friend class XMLNode;
1757  friend class XMLText;
1758  friend class XMLComment;
1759  friend class XMLDeclaration;
1760  friend class XMLUnknown;
1761 
1762 public:
1764  XMLDocument(bool processEntities = true, Whitespace whitespaceMode = PRESERVE_WHITESPACE);
1765  ~XMLDocument();
1766 
1768  {
1769  TIXMLASSERT(this == _document);
1770  return this;
1771  }
1772  virtual const XMLDocument* ToDocument() const
1773  {
1774  TIXMLASSERT(this == _document);
1775  return this;
1776  }
1777 
1788  XMLError Parse(const char* xml, size_t nBytes = static_cast<size_t>(-1));
1789 
1795  XMLError LoadFile(const char* filename);
1796 
1808  XMLError LoadFile(FILE*);
1809 
1815  XMLError SaveFile(const char* filename, bool compact = false);
1816 
1824  XMLError SaveFile(FILE* fp, bool compact = false);
1825 
1826  bool ProcessEntities() const { return _processEntities; }
1827  Whitespace WhitespaceMode() const { return _whitespaceMode; }
1828 
1832  bool HasBOM() const { return _writeBOM; }
1835  void SetBOM(bool useBOM) { _writeBOM = useBOM; }
1836 
1840  XMLElement* RootElement() { return FirstChildElement(); }
1841  const XMLElement* RootElement() const { return FirstChildElement(); }
1842 
1857  void Print(XMLPrinter* streamer = 0) const;
1858  virtual bool Accept(XMLVisitor* visitor) const;
1859 
1865  XMLElement* NewElement(const char* name);
1871  XMLComment* NewComment(const char* comment);
1877  XMLText* NewText(const char* text);
1889  XMLDeclaration* NewDeclaration(const char* text = 0);
1895  XMLUnknown* NewUnknown(const char* text);
1896 
1901  void DeleteNode(XMLNode* node);
1902 
1904  void ClearError();
1905 
1907  bool Error() const { return _errorID != XML_SUCCESS; }
1909  XMLError ErrorID() const { return _errorID; }
1910  const char* ErrorName() const;
1911  static const char* ErrorIDToName(XMLError errorID);
1912 
1916  const char* ErrorStr() const;
1917 
1919  void PrintError() const;
1920 
1922  int ErrorLineNum() const { return _errorLineNum; }
1923 
1925  void Clear();
1926 
1934  void DeepCopy(XMLDocument* target) const;
1935 
1936  // internal
1937  char* Identify(char* p, XMLNode** node);
1938 
1939  // internal
1940  void MarkInUse(const XMLNode* const);
1941 
1942  virtual XMLNode* ShallowClone(XMLDocument* /*document*/) const { return 0; }
1943  virtual bool ShallowEqual(const XMLNode* /*compare*/) const { return false; }
1944 
1945 private:
1946  XMLDocument(const XMLDocument&); // not supported
1947  void operator=(const XMLDocument&); // not supported
1948 
1958  // Memory tracking does add some overhead.
1959  // However, the code assumes that you don't
1960  // have a bunch of unlinked nodes around.
1961  // Therefore it takes less memory to track
1962  // in the document vs. a linked list in the XMLNode,
1963  // and the performance is the same.
1965 
1966  MemPoolT<sizeof(XMLElement)> _elementPool;
1967  MemPoolT<sizeof(XMLAttribute)> _attributePool;
1968  MemPoolT<sizeof(XMLText)> _textPool;
1969  MemPoolT<sizeof(XMLComment)> _commentPool;
1970 
1971  static const char* _errorNames[XML_ERROR_COUNT];
1972 
1973  void Parse();
1974 
1975  void SetError(XMLError error, int lineNum, const char* format, ...);
1976 
1977  // Something of an obvious security hole, once it was discovered.
1978  // Either an ill-formed XML or an excessively deep one can overflow
1979  // the stack. Track stack depth, and error out if needed.
1981  {
1982  public:
1983  explicit DepthTracker(XMLDocument* document)
1984  {
1985  this->_document = document;
1986  document->PushDepth();
1987  }
1988  ~DepthTracker() { _document->PopDepth(); }
1989 
1990  private:
1992  };
1993  void PushDepth();
1994  void PopDepth();
1995 
1996  template <class NodeType, int PoolElementSize>
1997  NodeType* CreateUnlinkedNode(MemPoolT<PoolElementSize>& pool);
1998 };
1999 
2000 template <class NodeType, int PoolElementSize>
2002 {
2003  TIXMLASSERT(sizeof(NodeType) == PoolElementSize);
2004  TIXMLASSERT(sizeof(NodeType) == pool.ItemSize());
2005  NodeType* returnNode = new (pool.Alloc()) NodeType(this);
2006  TIXMLASSERT(returnNode);
2007  returnNode->_memPool = &pool;
2008 
2009  _unlinked.Push(returnNode);
2010  return returnNode;
2011 }
2012 
2069 {
2070 public:
2072  explicit XMLHandle(XMLNode* node)
2073  : _node(node)
2074  {
2075  }
2077  explicit XMLHandle(XMLNode& node)
2078  : _node(&node)
2079  {
2080  }
2082  XMLHandle(const XMLHandle& ref)
2083  : _node(ref._node)
2084  {
2085  }
2088  {
2089  _node = ref._node;
2090  return *this;
2091  }
2092 
2094  XMLHandle FirstChild() { return XMLHandle(_node ? _node->FirstChild() : 0); }
2096  XMLHandle FirstChildElement(const char* name = 0)
2097  {
2098  return XMLHandle(_node ? _node->FirstChildElement(name) : 0);
2099  }
2101  XMLHandle LastChild() { return XMLHandle(_node ? _node->LastChild() : 0); }
2103  XMLHandle LastChildElement(const char* name = 0)
2104  {
2105  return XMLHandle(_node ? _node->LastChildElement(name) : 0);
2106  }
2108  XMLHandle PreviousSibling() { return XMLHandle(_node ? _node->PreviousSibling() : 0); }
2110  XMLHandle PreviousSiblingElement(const char* name = 0)
2111  {
2112  return XMLHandle(_node ? _node->PreviousSiblingElement(name) : 0);
2113  }
2115  XMLHandle NextSibling() { return XMLHandle(_node ? _node->NextSibling() : 0); }
2117  XMLHandle NextSiblingElement(const char* name = 0)
2118  {
2119  return XMLHandle(_node ? _node->NextSiblingElement(name) : 0);
2120  }
2121 
2123  XMLNode* ToNode() { return _node; }
2125  XMLElement* ToElement() { return (_node ? _node->ToElement() : 0); }
2127  XMLText* ToText() { return (_node ? _node->ToText() : 0); }
2129  XMLUnknown* ToUnknown() { return (_node ? _node->ToUnknown() : 0); }
2131  XMLDeclaration* ToDeclaration() { return (_node ? _node->ToDeclaration() : 0); }
2132 
2133 private:
2135 };
2136 
2137 
2143 {
2144 public:
2145  explicit XMLConstHandle(const XMLNode* node)
2146  : _node(node)
2147  {
2148  }
2149  explicit XMLConstHandle(const XMLNode& node)
2150  : _node(&node)
2151  {
2152  }
2154  : _node(ref._node)
2155  {
2156  }
2157 
2159  {
2160  _node = ref._node;
2161  return *this;
2162  }
2163 
2165  {
2166  return XMLConstHandle(_node ? _node->FirstChild() : 0);
2167  }
2168  const XMLConstHandle FirstChildElement(const char* name = 0) const
2169  {
2170  return XMLConstHandle(_node ? _node->FirstChildElement(name) : 0);
2171  }
2172  const XMLConstHandle LastChild() const { return XMLConstHandle(_node ? _node->LastChild() : 0); }
2173  const XMLConstHandle LastChildElement(const char* name = 0) const
2174  {
2175  return XMLConstHandle(_node ? _node->LastChildElement(name) : 0);
2176  }
2178  {
2179  return XMLConstHandle(_node ? _node->PreviousSibling() : 0);
2180  }
2181  const XMLConstHandle PreviousSiblingElement(const char* name = 0) const
2182  {
2183  return XMLConstHandle(_node ? _node->PreviousSiblingElement(name) : 0);
2184  }
2186  {
2187  return XMLConstHandle(_node ? _node->NextSibling() : 0);
2188  }
2189  const XMLConstHandle NextSiblingElement(const char* name = 0) const
2190  {
2191  return XMLConstHandle(_node ? _node->NextSiblingElement(name) : 0);
2192  }
2193 
2194 
2195  const XMLNode* ToNode() const { return _node; }
2196  const XMLElement* ToElement() const { return (_node ? _node->ToElement() : 0); }
2197  const XMLText* ToText() const { return (_node ? _node->ToText() : 0); }
2198  const XMLUnknown* ToUnknown() const { return (_node ? _node->ToUnknown() : 0); }
2199  const XMLDeclaration* ToDeclaration() const { return (_node ? _node->ToDeclaration() : 0); }
2200 
2201 private:
2202  const XMLNode* _node;
2203 };
2204 
2205 
2249 {
2250 public:
2257  XMLPrinter(FILE* file = 0, bool compact = false, int depth = 0);
2258  virtual ~XMLPrinter() {}
2259 
2261  void PushHeader(bool writeBOM, bool writeDeclaration);
2265  void OpenElement(const char* name, bool compactMode = false);
2267  void PushAttribute(const char* name, const char* value);
2268  void PushAttribute(const char* name, int value);
2269  void PushAttribute(const char* name, unsigned value);
2270  void PushAttribute(const char* name, int64_t value);
2271  void PushAttribute(const char* name, uint64_t value);
2272  void PushAttribute(const char* name, bool value);
2273  void PushAttribute(const char* name, double value);
2275  virtual void CloseElement(bool compactMode = false);
2276 
2278  void PushText(const char* text, bool cdata = false);
2280  void PushText(int value);
2282  void PushText(unsigned value);
2284  void PushText(int64_t value);
2286  void PushText(uint64_t value);
2288  void PushText(bool value);
2290  void PushText(float value);
2292  void PushText(double value);
2293 
2295  void PushComment(const char* comment);
2296 
2297  void PushDeclaration(const char* value);
2298  void PushUnknown(const char* value);
2299 
2300  virtual bool VisitEnter(const XMLDocument& /*doc*/);
2301  virtual bool VisitExit(const XMLDocument& /*doc*/) { return true; }
2302 
2303  virtual bool VisitEnter(const XMLElement& element, const XMLAttribute* attribute);
2304  virtual bool VisitExit(const XMLElement& element);
2305 
2306  virtual bool Visit(const XMLText& text);
2307  virtual bool Visit(const XMLComment& comment);
2308  virtual bool Visit(const XMLDeclaration& declaration);
2309  virtual bool Visit(const XMLUnknown& unknown);
2310 
2315  const char* CStr() const { return _buffer.Mem(); }
2321  int CStrSize() const { return _buffer.Size(); }
2326  void ClearBuffer(bool resetToFirstElement = true)
2327  {
2328  _buffer.Clear();
2329  _buffer.Push(0);
2330  _firstElement = resetToFirstElement;
2331  }
2332 
2333 protected:
2334  virtual bool CompactMode(const XMLElement&) { return _compactMode; }
2335 
2339  virtual void PrintSpace(int depth);
2340  virtual void Print(const char* format, ...);
2341  virtual void Write(const char* data, size_t size);
2342  virtual void Putc(char ch);
2343 
2344  inline void Write(const char* data) { Write(data, strlen(data)); }
2345 
2346  void SealElementIfJustOpened();
2349 
2350 private:
2355  void PrepareForNewNode(bool compactMode);
2356  void PrintString(const char*, bool restrictedEntitySet); // prints out, after detecting entities.
2357 
2359  FILE* _fp;
2360  int _depth;
2364 
2365  enum
2366  {
2367  ENTITY_RANGE = 64,
2368  BUF_SIZE = 200
2369  };
2370  bool _entityFlag[ENTITY_RANGE];
2371  bool _restrictedEntityFlag[ENTITY_RANGE];
2372 
2374 
2375  // Prohibit cloning, intentionally not implemented
2376  XMLPrinter(const XMLPrinter&);
2377  XMLPrinter& operator=(const XMLPrinter&);
2378 };
2379 
2380 
2381 } // namespace tinyxml2
2382 
2383 #if defined(_MSC_VER)
2384 # pragma warning(pop)
2385 #endif
2386 
2387 #endif // TINYXML2_INCLUDED
tinyxml2::DynArray::operator=
void operator=(const DynArray &)
tinyxml2::MemPool::SetTracked
virtual void SetTracked()=0
tinyxml2::XMLDocument::ToDocument
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1772
tinyxml2::XMLDocument::HasBOM
bool HasBOM() const
Definition: tinyxml2.h:1832
tinyxml2::XMLAttribute::UnsignedValue
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1170
tinyxml2::XMLConstHandle::ToText
const XMLText * ToText() const
Definition: tinyxml2.h:2197
tinyxml2::XMLNode::ToText
virtual const XMLText * ToText() const
Definition: tinyxml2.h:749
tinyxml2::XMLDocument::DepthTracker::_document
XMLDocument * _document
Definition: tinyxml2.h:1991
tinyxml2::XMLElement::QueryUnsigned64Attribute
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1372
tinyxml2::MemPoolT::Item
Definition: tinyxml2.h:490
tinyxml2::XMLDocument::Error
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1907
tinyxml2::StrPair::_start
char * _start
Definition: tinyxml2.h:209
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:551
tinyxml2::XML_NO_TEXT_NODE
@ XML_NO_TEXT_NODE
Definition: tinyxml2.h:576
tinyxml2::XMLUtil
Definition: tinyxml2.h:586
tinyxml2::XMLAttribute::Value
const char * Value() const
The value of the attribute.
Definition: tinyxml2.cpp:1551
tinyxml2::StrPair::Empty
bool Empty() const
Definition: tinyxml2.h:183
tinyxml2::XMLDocument::ErrorLineNum
int ErrorLineNum() const
Return the line where the error occurred, or zero if unknown.
Definition: tinyxml2.h:1922
tinyxml2::MemPoolT::Block::items
Item items[ITEMS_PER_BLOCK]
Definition: tinyxml2.h:497
tinyxml2::DynArray::Mem
T * Mem()
Definition: tinyxml2.h:320
tinyxml2::XMLText::CData
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:1004
tinyxml2::XMLNode::_lastChild
XMLNode * _lastChild
Definition: tinyxml2.h:960
tinyxml2::XMLNode::ToDeclaration
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:744
tinyxml2::XMLElement::ToElement
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1277
tinyxml2::DynArray::~DynArray
~DynArray()
Definition: tinyxml2.h:233
tinyxml2::COLLAPSE_WHITESPACE
@ COLLAPSE_WHITESPACE
Definition: tinyxml2.h:1742
tinyxml2::XMLElement::_rootAttribute
XMLAttribute * _rootAttribute
Definition: tinyxml2.h:1735
tinyxml2::XMLNode::NextSibling
XMLNode * NextSibling()
Definition: tinyxml2.h:828
tinyxml2::XMLConstHandle::ToNode
const XMLNode * ToNode() const
Definition: tinyxml2.h:2195
tinyxml2::XMLDocument::_charBuffer
char * _charBuffer
Definition: tinyxml2.h:1955
tinyxml2::MemPoolT::_currentAllocs
int _currentAllocs
Definition: tinyxml2.h:502
tinyxml2::XMLAttribute::SetAttribute
void SetAttribute(const char *value)
Set the attribute to a string value.
Definition: tinyxml2.cpp:1667
tinyxml2::XMLHandle::XMLHandle
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:2082
tinyxml2::XMLComment
Definition: tinyxml2.h:1028
tinyxml2::XMLVisitor::VisitExit
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:536
tinyxml2::XMLAttribute::_next
XMLAttribute * _next
Definition: tinyxml2.h:1258
tinyxml2::MemPool
Definition: tinyxml2.h:361
tinyxml2::DynArray::DynArray
DynArray()
Definition: tinyxml2.h:226
tinyxml2::XMLUtil::SkipWhiteSpace
static char * SkipWhiteSpace(char *const p, int *curLineNumPtr)
Definition: tinyxml2.h:604
tinyxml2::XMLNode::_memPool
MemPool * _memPool
Definition: tinyxml2.h:968
tinyxml2::MemPoolT::Trace
void Trace(const char *name)
Definition: tinyxml2.h:454
tinyxml2::XMLHandle::PreviousSiblingElement
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:2110
tinyxml2::XML_ERROR_PARSING_UNKNOWN
@ XML_ERROR_PARSING_UNKNOWN
Definition: tinyxml2.h:571
tinyxml2::MemPoolT::Free
virtual void Free(void *mem)
Definition: tinyxml2.h:440
tinyxml2::XMLError
XMLError
Definition: tinyxml2.h:557
tinyxml2::XMLElement::QueryBoolAttribute
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1383
tinyxml2::XMLVisitor::~XMLVisitor
virtual ~XMLVisitor()
Definition: tinyxml2.h:531
tinyxml2::XMLNode::_parent
XMLNode * _parent
Definition: tinyxml2.h:955
TIXMLASSERT
#define TIXMLASSERT(x)
Definition: tinyxml2.h:104
tinyxml2::DynArray::_size
int _size
Definition: tinyxml2.h:353
tinyxml2::XMLNode::NoChildren
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:780
tinyxml2::MemPoolT::~MemPoolT
~MemPoolT()
Definition: tinyxml2.h:390
tinyxml2::XMLElement::QueryStringAttribute
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1414
tinyxml2::XMLElement::SetName
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1275
tinyxml2::XML_ERROR_FILE_NOT_FOUND
@ XML_ERROR_FILE_NOT_FOUND
Definition: tinyxml2.h:562
tinyxml2::XMLDocument::ShallowClone
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1942
tinyxml2::XMLPrinter::_stack
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:2348
tinyxml2::StrPair::Mode
Mode
Definition: tinyxml2.h:149
tinyxml2::XMLNode::ToElement
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:748
tinyxml2::XMLDocument::_writeBOM
bool _writeBOM
Definition: tinyxml2.h:1949
tinyxml2::XMLDocument::_errorID
XMLError _errorID
Definition: tinyxml2.h:1951
tinyxml2::XMLPrinter
Definition: tinyxml2.h:2248
tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED
@ XML_ERROR_FILE_COULD_NOT_BE_OPENED
Definition: tinyxml2.h:563
tinyxml2::XML_WRONG_ATTRIBUTE_TYPE
@ XML_WRONG_ATTRIBUTE_TYPE
Definition: tinyxml2.h:561
tinyxml2::XMLDocument::CreateUnlinkedNode
NodeType * CreateUnlinkedNode(MemPoolT< PoolElementSize > &pool)
Definition: tinyxml2.h:2001
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1484
tinyxml2::DynArray::Mem
const T * Mem() const
Definition: tinyxml2.h:314
tinyxml2::MemPool::ItemSize
virtual int ItemSize() const =0
tinyxml2::XMLHandle
Definition: tinyxml2.h:2068
tinyxml2::DynArray::PeekTop
const T & PeekTop() const
Definition: tinyxml2.h:288
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:553
TIXML2_MAJOR_VERSION
static const int TIXML2_MAJOR_VERSION
Definition: tinyxml2.h:113
tinyxml2::XMLAttribute::DoubleValue
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1184
tinyxml2::XML_ERROR_PARSING_DECLARATION
@ XML_ERROR_PARSING_DECLARATION
Definition: tinyxml2.h:570
tinyxml2::XML_ERROR_FILE_READ_ERROR
@ XML_ERROR_FILE_READ_ERROR
Definition: tinyxml2.h:564
tinyxml2::XMLNode::_prev
XMLNode * _prev
Definition: tinyxml2.h:962
tinyxml2::XMLUnknown::ToUnknown
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1102
tinyxml2::XML_ERROR_PARSING_ELEMENT
@ XML_ERROR_PARSING_ELEMENT
Definition: tinyxml2.h:565
tinyxml2::XMLDocument::ErrorID
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1909
tinyxml2::StrPair::_flags
int _flags
Definition: tinyxml2.h:208
tinyxml2::XMLHandle::XMLHandle
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:2077
tinyxml2::XMLVisitor::VisitEnter
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:539
tinyxml2::DynArray::PopArr
void PopArr(int count)
Definition: tinyxml2.h:268
tinyxml2::XMLVisitor
Definition: tinyxml2.h:528
tinyxml2::XMLNode::FirstChildElement
XMLElement * FirstChildElement(const char *name=0)
Definition: tinyxml2.h:792
tinyxml2::XMLElement::QueryInt64Attribute
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1361
tinyxml2::XMLPrinter::_firstElement
bool _firstElement
Definition: tinyxml2.h:2358
tinyxml2::XMLConstHandle::ToDeclaration
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:2199
tinyxml2::XML_ERROR_PARSING_TEXT
@ XML_ERROR_PARSING_TEXT
Definition: tinyxml2.h:567
tinyxml2::DynArray::_mem
T * _mem
Definition: tinyxml2.h:350
tinyxml2::XMLHandle::_node
XMLNode * _node
Definition: tinyxml2.h:2134
tinyxml2::XMLDocument::WhitespaceMode
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1827
tinyxml2::XMLPrinter::VisitExit
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2301
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1523
TIXML2_MINOR_VERSION
static const int TIXML2_MINOR_VERSION
Definition: tinyxml2.h:114
tinyxml2::XMLPrinter::_textDepth
int _textDepth
Definition: tinyxml2.h:2361
tinyxml2::XMLUnknown::ToUnknown
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1101
tinyxml2::XMLNode::ToComment
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:750
tinyxml2::XMLVisitor::VisitExit
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:544
tinyxml2::XMLNode::NextSibling
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:826
TINYXML2_MAX_ELEMENT_DEPTH
static const int TINYXML2_MAX_ELEMENT_DEPTH
Definition: tinyxml2.h:126
TINYXML2_LIB
#define TINYXML2_LIB
Definition: tinyxml2.h:79
tinyxml2::XMLConstHandle::ToElement
const XMLElement * ToElement() const
Definition: tinyxml2.h:2196
tinyxml2::XMLText::~XMLText
virtual ~XMLText()
Definition: tinyxml2.h:1015
tinyxml2::XMLDocument::_whitespaceMode
Whitespace _whitespaceMode
Definition: tinyxml2.h:1952
tinyxml2::XMLNode::GetDocument
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:723
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, const char **value) const
Definition: tinyxml2.h:1478
tinyxml2::XML_ERROR_PARSING_COMMENT
@ XML_ERROR_PARSING_COMMENT
Definition: tinyxml2.h:569
tinyxml2::XMLHandle::operator=
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:2087
tinyxml2::StrPair::Set
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:171
tinyxml2::XMLConstHandle::XMLConstHandle
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:2145
tinyxml2::XMLAttribute
Definition: tinyxml2.h:1127
tinyxml2::XMLHandle::ToElement
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:2125
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, uint64_t *value) const
Definition: tinyxml2.h:1458
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1517
tinyxml2::XMLConstHandle::NextSibling
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:2185
tinyxml2::XMLDocument::ProcessEntities
bool ProcessEntities() const
Definition: tinyxml2.h:1826
tinyxml2::XMLDocument::RootElement
const XMLElement * RootElement() const
Definition: tinyxml2.h:1841
tinyxml2::XMLPrinter::CStr
const char * CStr() const
Definition: tinyxml2.h:2315
tinyxml2::XMLText
Definition: tinyxml2.h:991
tinyxml2::Whitespace
Whitespace
Definition: tinyxml2.h:1739
tinyxml2::XMLElement::_closingType
ElementClosingType _closingType
Definition: tinyxml2.h:1731
tinyxml2::XMLConstHandle::LastChildElement
const XMLConstHandle LastChildElement(const char *name=0) const
Definition: tinyxml2.h:2173
tinyxml2::XMLUtil::writeBoolTrue
static const char * writeBoolTrue
Definition: tinyxml2.h:686
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1510
tinyxml2::XMLNode::ToUnknown
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:746
tinyxml2::XMLElement::FirstAttribute
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1541
tinyxml2::MemPoolT::_maxAllocs
int _maxAllocs
Definition: tinyxml2.h:504
tinyxml2::XMLAttribute::QueryUnsignedValue
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1607
tinyxml2::XMLAttribute::QueryInt64Value
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1617
tinyxml2::XMLPrinter::_buffer
DynArray< char, 20 > _buffer
Definition: tinyxml2.h:2373
tinyxml2::XMLUtil::IsNameStartChar
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:616
tinyxml2::XML_SUCCESS
@ XML_SUCCESS
Definition: tinyxml2.h:559
tinyxml2::XMLPrinter::CStrSize
int CStrSize() const
Definition: tinyxml2.h:2321
tinyxml2::XMLAttribute::QueryDoubleValue
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1657
tinyxml2::XMLComment::ToComment
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:1033
tinyxml2::XMLAttribute::_value
StrPair _value
Definition: tinyxml2.h:1256
tinyxml2::XMLNode::FirstChild
XMLNode * FirstChild()
Definition: tinyxml2.h:785
tinyxml2::XMLPrinter::_compactMode
bool _compactMode
Definition: tinyxml2.h:2363
tinyxml2::XMLAttribute::QueryBoolValue
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1637
tinyxml2::XMLPrinter::_fp
FILE * _fp
Definition: tinyxml2.h:2359
tinyxml2::XMLDocument::_unlinked
DynArray< XMLNode *, 10 > _unlinked
Definition: tinyxml2.h:1964
tinyxml2::XMLNode::FirstChild
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:783
tinyxml2::DynArray::Pop
T Pop()
Definition: tinyxml2.h:261
tinyxml2::XMLUtil::writeBoolFalse
static const char * writeBoolFalse
Definition: tinyxml2.h:687
tinyxml2::XMLDocument::DepthTracker::DepthTracker
DepthTracker(XMLDocument *document)
Definition: tinyxml2.h:1983
tinyxml2::XMLNode::GetLineNum
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
Definition: tinyxml2.h:772
tinyxml2::XMLText::_isCData
bool _isCData
Definition: tinyxml2.h:1020
tinyxml2::DynArray::Size
int Size() const
Definition: tinyxml2.h:294
tinyxml2::XMLNode::_firstChild
XMLNode * _firstChild
Definition: tinyxml2.h:959
tinyxml2::XMLComment::ToComment
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:1034
tinyxml2::StrPair::SetInternedStr
void SetInternedStr(const char *str)
Definition: tinyxml2.h:185
tinyxml2::XMLNode::LinkEndChild
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:847
tinyxml2::XMLText::XMLText
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:1010
tinyxml2::XMLDeclaration
Definition: tinyxml2.h:1064
tinyxml2::XMLAttribute::_name
StrPair _name
Definition: tinyxml2.h:1255
tinyxml2::DynArray::Empty
bool Empty() const
Definition: tinyxml2.h:274
tinyxml2::XMLDocument::_parseCurLineNum
int _parseCurLineNum
Definition: tinyxml2.h:1956
tinyxml2::XMLConstHandle::FirstChild
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:2164
tinyxml2::XMLUnknown
Definition: tinyxml2.h:1096
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1496
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, double *value) const
Definition: tinyxml2.h:1468
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, unsigned int *value) const
Definition: tinyxml2.h:1448
tinyxml2::XMLText::SetCData
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:1002
tinyxml2::XMLConstHandle::ToUnknown
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:2198
tinyxml2::MemPoolT::_nUntracked
int _nUntracked
Definition: tinyxml2.h:505
tinyxml2::XMLHandle::ToText
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:2127
tinyxml2::XMLElement::ElementClosingType
ElementClosingType
Definition: tinyxml2.h:1703
tinyxml2::XMLElement
Definition: tinyxml2.h:1267
tinyxml2::MemPoolT::CurrentAllocs
int CurrentAllocs() const
Definition: tinyxml2.h:408
tinyxml2::XMLHandle::LastChild
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:2101
tinyxml2::XMLElement::ClosingType
ElementClosingType ClosingType() const
Definition: tinyxml2.h:1709
tinyxml2::XMLNode::ToDocument
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:751
tinyxml2::XMLDocument::ToDocument
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1767
tinyxml2::XMLNode::Parent
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:775
tinyxml2::XMLAttribute::_parseLineNum
int _parseLineNum
Definition: tinyxml2.h:1257
tinyxml2::XMLNode::_value
StrPair _value
Definition: tinyxml2.h:956
tinyxml2::XML_ERROR_PARSING_CDATA
@ XML_ERROR_PARSING_CDATA
Definition: tinyxml2.h:568
tinyxml2::MemPoolT::_blockPtrs
DynArray< Block *, 10 > _blockPtrs
Definition: tinyxml2.h:499
tinyxml2::XMLPrinter::CompactMode
virtual bool CompactMode(const XMLElement &)
Definition: tinyxml2.h:2334
tinyxml2::XMLDocument::RootElement
XMLElement * RootElement()
Definition: tinyxml2.h:1840
tinyxml2::XMLAttribute::QueryFloatValue
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1647
tinyxml2::XMLNode::SetUserData
void SetUserData(void *userData)
Definition: tinyxml2.h:939
tinyxml2::XMLElement::QueryDoubleAttribute
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1393
tinyxml2::MemPoolT
Definition: tinyxml2.h:378
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1529
tinyxml2::DynArray::Clear
void Clear()
Definition: tinyxml2.h:241
tinyxml2::XMLPrinter::_processEntities
bool _processEntities
Definition: tinyxml2.h:2362
tinyxml2::XMLNode::ToElement
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:736
tinyxml2::MemPool::~MemPool
virtual ~MemPool()
Definition: tinyxml2.h:365
tinyxml2::DynArray::PushArr
T * PushArr(int count)
Definition: tinyxml2.h:251
tinyxml2::XMLElement::CLOSED
@ CLOSED
Definition: tinyxml2.h:1706
tinyxml2::XMLUtil::IsUTF8Continuation
static bool IsUTF8Continuation(const char p)
Definition: tinyxml2.h:653
tinyxml2::XMLNode::GetUserData
void * GetUserData() const
Definition: tinyxml2.h:946
tinyxml2::XMLHandle::XMLHandle
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:2072
tinyxml2::MemPoolT::Alloc
virtual void * Alloc()
Definition: tinyxml2.h:410
tinyxml2::XMLUtil::IsPrefixHex
static bool IsPrefixHex(const char *p)
Definition: tinyxml2.h:635
tinyxml2::MemPoolT::ItemSize
virtual int ItemSize() const
Definition: tinyxml2.h:407
tinyxml2::XMLPrinter::ClearBuffer
void ClearBuffer(bool resetToFirstElement=true)
Definition: tinyxml2.h:2326
tinyxml2::XMLNode::_parseLineNum
int _parseLineNum
Definition: tinyxml2.h:957
tinyxml2::XMLElement::ToElement
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1278
tinyxml2::XMLConstHandle::LastChild
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:2172
tinyxml2::XMLElement::QueryUnsignedAttribute
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1350
tinyxml2::MemPool::MemPool
MemPool()
Definition: tinyxml2.h:364
tinyxml2::XML_ERROR_PARSING_ATTRIBUTE
@ XML_ERROR_PARSING_ATTRIBUTE
Definition: tinyxml2.h:566
tinyxml2::DynArray::operator[]
T & operator[](int i)
Definition: tinyxml2.h:276
tinyxml2::MemPoolT::SetTracked
void SetTracked()
Definition: tinyxml2.h:466
tinyxml2::XMLPrinter::~XMLPrinter
virtual ~XMLPrinter()
Definition: tinyxml2.h:2258
tinyxml2::MemPoolT::MemPoolT
MemPoolT()
Definition: tinyxml2.h:381
tinyxml2::XMLNode::LastChild
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:798
tinyxml2::XMLHandle::ToDeclaration
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:2131
tinyxml2::XMLAttribute::QueryUnsigned64Value
XMLError QueryUnsigned64Value(uint64_t *value) const
See QueryIntValue.
Definition: tinyxml2.cpp:1627
tinyxml2::XMLHandle::FirstChildElement
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:2096
tinyxml2::DynArray::operator[]
const T & operator[](int i) const
Definition: tinyxml2.h:282
tinyxml2::XMLConstHandle::NextSiblingElement
const XMLConstHandle NextSiblingElement(const char *name=0) const
Definition: tinyxml2.h:2189
tinyxml2::XMLDocument::_errorLineNum
int _errorLineNum
Definition: tinyxml2.h:1954
tinyxml2::PRESERVE_WHITESPACE
@ PRESERVE_WHITESPACE
Definition: tinyxml2.h:1741
tinyxml2::XMLNode::_next
XMLNode * _next
Definition: tinyxml2.h:963
tinyxml2::StrPair::StrPair
StrPair()
Definition: tinyxml2.h:163
tinyxml2::XMLNode::_userData
void * _userData
Definition: tinyxml2.h:965
tinyxml2::XMLHandle::PreviousSibling
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:2108
tinyxml2::XMLAttribute::BoolValue
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1177
tinyxml2::XMLNode
Definition: tinyxml2.h:716
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:549
tinyxml2::MemPool::Free
virtual void Free(void *)=0
tinyxml2::XMLConstHandle::_node
const XMLNode * _node
Definition: tinyxml2.h:2202
tinyxml2::XMLConstHandle::operator=
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:2158
tinyxml2::XMLNode::PreviousSiblingElement
XMLElement * PreviousSiblingElement(const char *name=0)
Definition: tinyxml2.h:820
tinyxml2::XMLDocument::DepthTracker::~DepthTracker
~DepthTracker()
Definition: tinyxml2.h:1988
tinyxml2::XMLAttribute::_memPool
MemPool * _memPool
Definition: tinyxml2.h:1259
tinyxml2::XMLDeclaration::ToDeclaration
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1070
tinyxml2::XMLNode::NextSiblingElement
XMLElement * NextSiblingElement(const char *name=0)
Definition: tinyxml2.h:833
tinyxml2::XMLHandle::ToNode
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:2123
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1490
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, float *value) const
Definition: tinyxml2.h:1473
tinyxml2::MemPoolT::_nAllocs
int _nAllocs
Definition: tinyxml2.h:503
tinyxml2::DynArray::Push
void Push(T t)
Definition: tinyxml2.h:243
tinyxml2::XMLUtil::IsWhiteSpace
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:611
tinyxml2::XMLConstHandle::PreviousSiblingElement
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
Definition: tinyxml2.h:2181
tinyxml2::XMLDeclaration::ToDeclaration
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1069
tinyxml2::XMLNode::LastChildElement
XMLElement * LastChildElement(const char *name=0)
Definition: tinyxml2.h:807
tinyxml2::XMLPrinter::Write
void Write(const char *data)
Definition: tinyxml2.h:2344
tinyxml2::MemPoolT::Item::next
Item * next
Definition: tinyxml2.h:492
tinyxml2::XMLNode::ToText
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:738
tinyxml2::XMLDocument::SetBOM
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1835
tinyxml2::XMLConstHandle::XMLConstHandle
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:2153
tinyxml2::XMLElement::QueryIntAttribute
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1339
tinyxml2::XMLUtil::StringEqual
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:641
tinyxml2::DynArray::SwapRemove
void SwapRemove(int i)
Definition: tinyxml2.h:306
tinyxml2::DynArray::_pool
T _pool[INITIAL_SIZE]
Definition: tinyxml2.h:351
tinyxml2::XML_CAN_NOT_CONVERT_TEXT
@ XML_CAN_NOT_CONVERT_TEXT
Definition: tinyxml2.h:575
tinyxml2::XMLHandle::ToUnknown
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:2129
tinyxml2::XMLDocument
Definition: tinyxml2.h:1751
tinyxml2::XMLAttribute::XMLAttribute
XMLAttribute()
Definition: tinyxml2.h:1239
tinyxml2::DynArray::EnsureCapacity
void EnsureCapacity(int cap)
Definition: tinyxml2.h:330
tinyxml2::XMLAttribute::GetLineNum
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition: tinyxml2.h:1139
tinyxml2::XMLNode::Parent
XMLNode * Parent()
Definition: tinyxml2.h:777
tinyxml2::XML_ELEMENT_DEPTH_EXCEEDED
@ XML_ELEMENT_DEPTH_EXCEEDED
Definition: tinyxml2.h:577
tinyxml2
Definition: tinyxml2.h:128
tinyxml2::XMLAttribute::~XMLAttribute
virtual ~XMLAttribute()
Definition: tinyxml2.h:1247
tinyxml2::XMLText::ToText
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:998
tinyxml2::XMLNode::ToComment
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:740
tinyxml2::MemPool::Alloc
virtual void * Alloc()=0
tinyxml2::XMLVisitor::VisitEnter
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:534
tinyxml2::XMLAttribute::FloatValue
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1191
tinyxml2::XMLAttribute::Int64Value
int64_t Int64Value() const
Definition: tinyxml2.h:1155
tinyxml2::XMLAttribute::Unsigned64Value
uint64_t Unsigned64Value() const
Definition: tinyxml2.h:1162
tinyxml2::XMLNode::_document
XMLDocument * _document
Definition: tinyxml2.h:954
tinyxml2::XMLAttribute::IntValue
int IntValue() const
Definition: tinyxml2.h:1148
tinyxml2::MemPoolT::Untracked
int Untracked() const
Definition: tinyxml2.h:468
tinyxml2::MemPoolT::ITEMS_PER_BLOCK
@ ITEMS_PER_BLOCK
Definition: tinyxml2.h:483
tinyxml2::XMLText::ToText
virtual const XMLText * ToText() const
Definition: tinyxml2.h:999
tinyxml2::XMLDocument::_processEntities
bool _processEntities
Definition: tinyxml2.h:1950
tinyxml2::XMLNode::ToDocument
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:742
tinyxml2::XMLHandle::NextSiblingElement
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:2117
tinyxml2::XMLUtil::SkipWhiteSpace
static const char * SkipWhiteSpace(const char *p, int *curLineNumPtr)
Definition: tinyxml2.h:589
tinyxml2::XMLElement::SetAttribute
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1503
tinyxml2::DynArray
Definition: tinyxml2.h:223
tinyxml2::XML_ERROR_MISMATCHED_ELEMENT
@ XML_ERROR_MISMATCHED_ELEMENT
Definition: tinyxml2.h:573
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1443
tinyxml2::XMLUtil::IsNameChar
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:630
tinyxml2::XMLDocument::_errorStr
StrPair _errorStr
Definition: tinyxml2.h:1953
tinyxml2::MemPoolT::operator=
void operator=(const MemPoolT &)
tinyxml2::XMLConstHandle::FirstChildElement
const XMLConstHandle FirstChildElement(const char *name=0) const
Definition: tinyxml2.h:2168
tinyxml2::MemPoolT::Item::itemData
char itemData[ITEM_SIZE]
Definition: tinyxml2.h:493
tinyxml2::XML_ERROR_COUNT
@ XML_ERROR_COUNT
Definition: tinyxml2.h:579
tinyxml2::XMLDocument::PushDepth
void PushDepth()
Definition: tinyxml2.cpp:2777
tinyxml2::XMLNode::PreviousSibling
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:813
tinyxml2::XMLDocument::ShallowEqual
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1943
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, bool *value) const
Definition: tinyxml2.h:1463
tinyxml2::XML_NO_ATTRIBUTE
@ XML_NO_ATTRIBUTE
Definition: tinyxml2.h:560
tinyxml2::MemPoolT::Clear
void Clear()
Definition: tinyxml2.h:392
tinyxml2::XMLNode::ToUnknown
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:753
TIXML2_PATCH_VERSION
static const int TIXML2_PATCH_VERSION
Definition: tinyxml2.h:115
tinyxml2::XMLVisitor::Visit
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:547
tinyxml2::XMLNode::ToDeclaration
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:752
tinyxml2::XMLNode::GetDocument
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:729
tinyxml2::XMLElement::QueryAttribute
XMLError QueryAttribute(const char *name, int64_t *value) const
Definition: tinyxml2.h:1453
tinyxml2::XMLDocument::_parsingDepth
int _parsingDepth
Definition: tinyxml2.h:1957
tinyxml2::XMLElement::QueryFloatAttribute
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1403
tinyxml2::XML_ERROR_PARSING
@ XML_ERROR_PARSING
Definition: tinyxml2.h:574
tinyxml2::XMLNode::PreviousSibling
XMLNode * PreviousSibling()
Definition: tinyxml2.h:815
tinyxml2::MemPoolT::Block
Definition: tinyxml2.h:495
tinyxml2::DynArray::_allocated
int _allocated
Definition: tinyxml2.h:352
tinyxml2::XMLConstHandle::XMLConstHandle
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:2149
tinyxml2::XML_ERROR_EMPTY_DOCUMENT
@ XML_ERROR_EMPTY_DOCUMENT
Definition: tinyxml2.h:572
tinyxml2::XMLPrinter::_depth
int _depth
Definition: tinyxml2.h:2360
tinyxml2::XMLHandle::NextSibling
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:2115
tinyxml2::XMLDocument::DepthTracker
Definition: tinyxml2.h:1980
tinyxml2::XMLConstHandle
Definition: tinyxml2.h:2142
tinyxml2::MemPoolT::_root
Item * _root
Definition: tinyxml2.h:500
tinyxml2::DynArray::Capacity
int Capacity() const
Definition: tinyxml2.h:300
tinyxml2::XMLHandle::FirstChild
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:2094
tinyxml2::StrPair::_end
char * _end
Definition: tinyxml2.h:210
tinyxml2::XMLHandle::LastChildElement
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:2103
tinyxml2::XMLAttribute::QueryIntValue
XMLError QueryIntValue(int *value) const
Definition: tinyxml2.cpp:1597
tinyxml2::XMLAttribute::Next
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1142
tinyxml2::XMLElement::OPEN
@ OPEN
Definition: tinyxml2.h:1705
tinyxml2::XMLPrinter::_elementJustOpened
bool _elementJustOpened
Definition: tinyxml2.h:2347
tinyxml2::XMLNode::LastChild
XMLNode * LastChild()
Definition: tinyxml2.h:800
tinyxml2::XMLConstHandle::PreviousSibling
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:2177
tinyxml2::StrPair
Definition: tinyxml2.h:146
tinyxml2::XMLElement::Name
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1273


sick_safevisionary_base
Author(s):
autogenerated on Sat Oct 21 2023 02:24:26