AWS SDK for C++  0.12.9
AWS SDK for C++
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 This file has been modified from its original version by Amazon:
25  (1) Memory management operations use aws memory management api
26  (2) Import-export preproccesor logic tweaked for better integration into core library
27  (3) Wrapped everything in Amazon namespace to prevent static linking issues if the user includes a version of this code through another dependency
28 */
29 #ifndef TINYXML2_INCLUDED
30 #define TINYXML2_INCLUDED
31 
32 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
33 # include <ctype.h>
34 # include <limits.h>
35 # include <stdio.h>
36 # include <stdlib.h>
37 # include <string.h>
38 # include <stdarg.h>
39 #else
40 # include <cctype>
41 # include <climits>
42 # include <cstdio>
43 # include <cstdlib>
44 # include <cstring>
45 # include <cstdarg>
46 #endif
47 
49 
50 /*
51 TODO: intern strings instead of allocation.
52 */
53 /*
54 gcc:
55 g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
56 
57 Formatting, Artistic Style:
58 AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
59 */
60 
61 #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
62 # ifndef DEBUG
63 # define DEBUG
64 # endif
65 #endif
66 
67 #ifdef _MSC_VER
68 # pragma warning(push)
69 # pragma warning(disable: 4251)
70 #endif
71 
72 #ifdef _WIN32
73  #ifdef USE_IMPORT_EXPORT
74  #ifdef AWS_CORE_EXPORTS
75  #define TINYXML2_LIB __declspec(dllexport)
76  #else
77  #define TINYXML2_LIB __declspec(dllimport)
78  #endif // AWS_CORE_EXPORTS
79  #endif // USE_IMPORT_EXPORT
80 #endif
81 
82 #ifndef TINYXML2_LIB
83  #define TINYXML2_LIB
84 #endif // TINYXML2_LIB
85 
86 
87 #if defined(DEBUG)
88 # if defined(_MSC_VER)
89 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
90 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
91 # elif defined (ANDROID_NDK)
92 # include <android/log.h>
93 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
94 # else
95 # include <assert.h>
96 # define TIXMLASSERT assert
97 # endif
98 # else
99 # define TIXMLASSERT( x ) {}
100 #endif
101 
102 
103 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
104 // Microsoft visual studio, version 2005 and higher.
105 /*int _snprintf_s(
106 char *buffer,
107 size_t sizeOfBuffer,
108 size_t count,
109 const char *format [,
110 argument] ...
111 );*/
112 inline int TIXML_SNPRINTF(char* buffer, size_t size, const char* format, ...)
113 {
114  va_list va;
115  va_start(va, format);
116  int result = vsnprintf_s(buffer, size, _TRUNCATE, format, va);
117  va_end(va);
118  return result;
119 }
120 #define TIXML_SSCANF sscanf_s
121 #elif defined WINCE
122 #define TIXML_SNPRINTF _snprintf
123 #define TIXML_SSCANF sscanf
124 #else
125 // GCC version 3 and higher
126 //#warning( "Using sn* functions." )
127 #define TIXML_SNPRINTF snprintf
128 #define TIXML_SSCANF sscanf
129 #endif
130 
131 /* Versioning, past 1.0.14:
132 http://semver.org/
133 */
134 static const int TIXML2_MAJOR_VERSION = 2;
135 static const int TIXML2_MINOR_VERSION = 2;
136 static const int TIXML2_PATCH_VERSION = 0;
137 
138 namespace Aws
139 {
140 namespace External
141 {
142 namespace tinyxml2
143 {
144  class XMLDocument;
145  class XMLElement;
146  class XMLAttribute;
147  class XMLComment;
148  class XMLText;
149  class XMLDeclaration;
150  class XMLUnknown;
151  class XMLPrinter;
152 
153  static const char* ALLOCATION_TAG = "AWS::TinyXML";
154 
155  /*
156  A class that wraps strings. Normally stores the start and end
157  pointers into the XML file itself, and will apply normalization
158  and entity translation if actually read. Can also store (and memory
159  manage) a traditional char[]
160  */
162  {
163  public:
164  enum {
165  NEEDS_ENTITY_PROCESSING = 0x01,
166  NEEDS_NEWLINE_NORMALIZATION = 0x02,
168 
169  TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
170  TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
171  ATTRIBUTE_NAME = 0,
172  ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
173  ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
174  COMMENT = NEEDS_NEWLINE_NORMALIZATION
175  };
176 
177  StrPair() : _flags(0), _start(0), _end(0) {}
178  ~StrPair();
179 
180  void Set(char* start, char* end, int flags) {
181  Reset();
182  _start = start;
183  _end = end;
184  _flags = flags | NEEDS_FLUSH;
185  }
186 
187  const char* GetStr();
188 
189  bool Empty() const {
190  return _start == _end;
191  }
192 
193  void SetInternedStr(const char* str) {
194  Reset();
195  _start = const_cast<char*>(str);
196  }
197 
198  void SetStr(const char* str, int flags = 0);
199 
200  char* ParseText(char* in, const char* endTag, int strFlags);
201  char* ParseName(char* in);
202 
203  void TransferTo(StrPair* other);
204 
205  private:
206  void Reset();
207  void CollapseWhitespace();
208 
209  enum {
210  NEEDS_FLUSH = 0x100,
211  NEEDS_DELETE = 0x200
212  };
213 
214  // After parsing, if *_end != 0, it can be set to zero.
215  int _flags;
216  char* _start;
217  char* _end;
218 
219  StrPair(const StrPair& other); // not supported
220  void operator=(StrPair& other); // not supported, use TransferTo()
221  };
222 
223 
224  /*
225  A dynamic array of Plain Old Data. Doesn't support constructors, etc.
226  Has a small initial memory pool, so that low or no usage will not
227  cause a call to new/delete
228  */
229  template <class T, int INIT>
230  class DynArray
231  {
232  public:
234  _mem = _pool;
235  _allocated = INIT;
236  _size = 0;
237  }
238 
240  if (_mem != _pool) {
241  Aws::DeleteArray<T>(_mem);
242  }
243  }
244 
245  void Clear() {
246  _size = 0;
247  }
248 
249  void Push(T t) {
250  TIXMLASSERT(_size < INT_MAX);
251  EnsureCapacity(_size + 1);
252  _mem[_size++] = t;
253  }
254 
255  T* PushArr(int count) {
256  TIXMLASSERT(count >= 0);
257  TIXMLASSERT(_size <= INT_MAX - count);
258  EnsureCapacity(_size + count);
259  T* ret = &_mem[_size];
260  _size += count;
261  return ret;
262  }
263 
264  T Pop() {
265  TIXMLASSERT(_size > 0);
266  return _mem[--_size];
267  }
268 
269  void PopArr(int count) {
270  TIXMLASSERT(_size >= count);
271  _size -= count;
272  }
273 
274  bool Empty() const {
275  return _size == 0;
276  }
277 
278  T& operator[](int i) {
279  TIXMLASSERT(i >= 0 && i < _size);
280  return _mem[i];
281  }
282 
283  const T& operator[](int i) const {
284  TIXMLASSERT(i >= 0 && i < _size);
285  return _mem[i];
286  }
287 
288  const T& PeekTop() const {
289  TIXMLASSERT(_size > 0);
290  return _mem[_size - 1];
291  }
292 
293  int Size() const {
294  TIXMLASSERT(_size >= 0);
295  return _size;
296  }
297 
298  int Capacity() const {
299  return _allocated;
300  }
301 
302  const T* Mem() const {
303  return _mem;
304  }
305 
306  T* Mem() {
307  return _mem;
308  }
309 
310  private:
311  DynArray(const DynArray&); // not supported
312  void operator=(const DynArray&); // not supported
313 
314  void EnsureCapacity(int cap) {
315  TIXMLASSERT(cap > 0);
316  if (cap > _allocated) {
317  TIXMLASSERT(cap <= INT_MAX / 2);
318  int newAllocated = cap * 2;
319  T* newMem = Aws::NewArray<T>(newAllocated, ALLOCATION_TAG);
320  memcpy(newMem, _mem, sizeof(T)*_size); // warning: not using constructors, only works for PODs
321  if (_mem != _pool) {
322  Aws::DeleteArray<T>(_mem);
323  }
324  _mem = newMem;
325  _allocated = newAllocated;
326  }
327  }
328 
329  T* _mem;
330  T _pool[INIT];
331  int _allocated; // objects allocated
332  int _size; // number objects in use
333  };
334 
335 
336  /*
337  Parent virtual class of a pool for fast allocation
338  and deallocation of objects.
339  */
340  class MemPool
341  {
342  public:
343  MemPool() {}
344  virtual ~MemPool() {}
345 
346  virtual int ItemSize() const = 0;
347  virtual void* Alloc() = 0;
348  virtual void Free(void*) = 0;
349  virtual void SetTracked() = 0;
350  virtual void Clear() = 0;
351  };
352 
353 
354  /*
355  Template child class to create pools of the correct type.
356  */
357  template< int SIZE >
358  class MemPoolT : public MemPool
359  {
360  public:
361  MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
363  Clear();
364  }
365 
366  void Clear() {
367  // Delete the blocks.
368  while (!_blockPtrs.Empty()) {
369  Block* b = _blockPtrs.Pop();
370  Aws::Delete(b);
371  }
372  _root = 0;
373  _currentAllocs = 0;
374  _nAllocs = 0;
375  _maxAllocs = 0;
376  _nUntracked = 0;
377  }
378 
379  virtual int ItemSize() const {
380  return SIZE;
381  }
382  int CurrentAllocs() const {
383  return _currentAllocs;
384  }
385 
386  virtual void* Alloc() {
387  if (!_root) {
388  // Need a new block.
389  Block* block = Aws::New<Block>(ALLOCATION_TAG);
390  _blockPtrs.Push(block);
391 
392  for (int i = 0; i<COUNT - 1; ++i) {
393  block->chunk[i].next = &block->chunk[i + 1];
394  }
395  block->chunk[COUNT - 1].next = 0;
396  _root = block->chunk;
397  }
398  void* result = _root;
399  _root = _root->next;
400 
401  ++_currentAllocs;
402  if (_currentAllocs > _maxAllocs) {
403  _maxAllocs = _currentAllocs;
404  }
405  _nAllocs++;
406  _nUntracked++;
407  return result;
408  }
409 
410  virtual void Free(void* mem) {
411  if (!mem) {
412  return;
413  }
414  --_currentAllocs;
415  Chunk* chunk = static_cast<Chunk*>(mem);
416 #ifdef DEBUG
417  memset(chunk, 0xfe, sizeof(Chunk));
418 #endif
419  chunk->next = _root;
420  _root = chunk;
421  }
422  void Trace(const char* name) {
423  printf("Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
424  name, _maxAllocs, _maxAllocs*SIZE / 1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size());
425  }
426 
427  void SetTracked() {
428  _nUntracked--;
429  }
430 
431  int Untracked() const {
432  return _nUntracked;
433  }
434 
435  // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
436  // The test file is large, 170k.
437  // Release: VS2010 gcc(no opt)
438  // 1k: 4000
439  // 2k: 4000
440  // 4k: 3900 21000
441  // 16k: 5200
442  // 32k: 4300
443  // 64k: 4000 21000
444  enum { COUNT = (4 * 1024) / SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
445 
446  private:
447  MemPoolT(const MemPoolT&); // not supported
448  void operator=(const MemPoolT&); // not supported
449 
450  union Chunk {
451  Chunk* next;
452  char mem[SIZE];
453  };
454  struct Block {
455  Chunk chunk[COUNT];
456  };
457  DynArray< Block*, 10 > _blockPtrs;
458  Chunk* _root;
459 
460  int _currentAllocs;
461  int _nAllocs;
462  int _maxAllocs;
463  int _nUntracked;
464  };
465 
466 
467 
488  {
489  public:
490  virtual ~XMLVisitor() {}
491 
493  virtual bool VisitEnter(const XMLDocument& /*doc*/) {
494  return true;
495  }
497  virtual bool VisitExit(const XMLDocument& /*doc*/) {
498  return true;
499  }
500 
502  virtual bool VisitEnter(const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/) {
503  return true;
504  }
506  virtual bool VisitExit(const XMLElement& /*element*/) {
507  return true;
508  }
509 
511  virtual bool Visit(const XMLDeclaration& /*declaration*/) {
512  return true;
513  }
515  virtual bool Visit(const XMLText& /*text*/) {
516  return true;
517  }
519  virtual bool Visit(const XMLComment& /*comment*/) {
520  return true;
521  }
523  virtual bool Visit(const XMLUnknown& /*unknown*/) {
524  return true;
525  }
526  };
527 
528  // WARNING: must match XMLDocument::_errorNames[]
529  enum XMLError {
551 
553  };
554 
555 
556  /*
557  Utility functionality.
558  */
559  class XMLUtil
560  {
561  public:
562  static const char* SkipWhiteSpace(const char* p) {
563  TIXMLASSERT(p);
564  while (IsWhiteSpace(*p)) {
565  ++p;
566  }
567  TIXMLASSERT(p);
568  return p;
569  }
570  static char* SkipWhiteSpace(char* p) {
571  return const_cast<char*>(SkipWhiteSpace(const_cast<const char*>(p)));
572  }
573 
574  // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
575  // correct, but simple, and usually works.
576  static bool IsWhiteSpace(char p) {
577  return !IsUTF8Continuation(p) && isspace(static_cast<unsigned char>(p));
578  }
579 
580  inline static bool IsNameStartChar(unsigned char ch) {
581  if (ch >= 128) {
582  // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
583  return true;
584  }
585  if (isalpha(ch)) {
586  return true;
587  }
588  return ch == ':' || ch == '_';
589  }
590 
591  inline static bool IsNameChar(unsigned char ch) {
592  return IsNameStartChar(ch)
593  || isdigit(ch)
594  || ch == '.'
595  || ch == '-';
596  }
597 
598  inline static bool StringEqual(const char* p, const char* q, int nChar = INT_MAX) {
599  if (p == q) {
600  return true;
601  }
602  int n = 0;
603  while (*p && *q && *p == *q && n<nChar) {
604  ++p;
605  ++q;
606  ++n;
607  }
608  if ((n == nChar) || (*p == 0 && *q == 0)) {
609  return true;
610  }
611  return false;
612  }
613 
614  inline static bool IsUTF8Continuation(const char p) {
615  return (p & 0x80) != 0;
616  }
617 
618  static const char* ReadBOM(const char* p, bool* hasBOM);
619  // p is the starting location,
620  // the UTF-8 value of the entity will be placed in value, and length filled in.
621  static const char* GetCharacterRef(const char* p, char* value, int* length);
622  static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length);
623 
624  // converts primitive types to strings
625  static void ToStr(int v, char* buffer, int bufferSize);
626  static void ToStr(unsigned v, char* buffer, int bufferSize);
627  static void ToStr(bool v, char* buffer, int bufferSize);
628  static void ToStr(float v, char* buffer, int bufferSize);
629  static void ToStr(double v, char* buffer, int bufferSize);
630 
631  // converts strings to primitive types
632  static bool ToInt(const char* str, int* value);
633  static bool ToUnsigned(const char* str, unsigned* value);
634  static bool ToBool(const char* str, bool* value);
635  static bool ToFloat(const char* str, float* value);
636  static bool ToDouble(const char* str, double* value);
637  };
638 
639 
666  {
667  friend class XMLDocument;
668  friend class XMLElement;
669  public:
670 
672  const XMLDocument* GetDocument() const {
673  return _document;
674  }
677  return _document;
678  }
679 
681  virtual XMLElement* ToElement() {
682  return 0;
683  }
685  virtual XMLText* ToText() {
686  return 0;
687  }
689  virtual XMLComment* ToComment() {
690  return 0;
691  }
693  virtual XMLDocument* ToDocument() {
694  return 0;
695  }
698  return 0;
699  }
701  virtual XMLUnknown* ToUnknown() {
702  return 0;
703  }
704 
705  virtual const XMLElement* ToElement() const {
706  return 0;
707  }
708  virtual const XMLText* ToText() const {
709  return 0;
710  }
711  virtual const XMLComment* ToComment() const {
712  return 0;
713  }
714  virtual const XMLDocument* ToDocument() const {
715  return 0;
716  }
717  virtual const XMLDeclaration* ToDeclaration() const {
718  return 0;
719  }
720  virtual const XMLUnknown* ToUnknown() const {
721  return 0;
722  }
723 
733  const char* Value() const;
734 
738  void SetValue(const char* val, bool staticMem = false);
739 
741  const XMLNode* Parent() const {
742  return _parent;
743  }
744 
746  return _parent;
747  }
748 
750  bool NoChildren() const {
751  return !_firstChild;
752  }
753 
755  const XMLNode* FirstChild() const {
756  return _firstChild;
757  }
758 
760  return _firstChild;
761  }
762 
766  const XMLElement* FirstChildElement(const char* value = 0) const;
767 
768  XMLElement* FirstChildElement(const char* value = 0) {
769  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement(value));
770  }
771 
773  const XMLNode* LastChild() const {
774  return _lastChild;
775  }
776 
778  return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild());
779  }
780 
784  const XMLElement* LastChildElement(const char* value = 0) const;
785 
786  XMLElement* LastChildElement(const char* value = 0) {
787  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value));
788  }
789 
791  const XMLNode* PreviousSibling() const {
792  return _prev;
793  }
794 
796  return _prev;
797  }
798 
800  const XMLElement* PreviousSiblingElement(const char* value = 0) const;
801 
802  XMLElement* PreviousSiblingElement(const char* value = 0) {
803  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement(value));
804  }
805 
807  const XMLNode* NextSibling() const {
808  return _next;
809  }
810 
812  return _next;
813  }
814 
816  const XMLElement* NextSiblingElement(const char* value = 0) const;
817 
818  XMLElement* NextSiblingElement(const char* value = 0) {
819  return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement(value));
820  }
821 
829  XMLNode* InsertEndChild(XMLNode* addThis);
830 
832  return InsertEndChild(addThis);
833  }
841  XMLNode* InsertFirstChild(XMLNode* addThis);
850  XMLNode* InsertAfterChild(XMLNode* afterThis, XMLNode* addThis);
851 
855  void DeleteChildren();
856 
860  void DeleteChild(XMLNode* node);
861 
871  virtual XMLNode* ShallowClone(XMLDocument* document) const = 0;
872 
879  virtual bool ShallowEqual(const XMLNode* compare) const = 0;
880 
903  virtual bool Accept(XMLVisitor* visitor) const = 0;
904 
905  // internal
906  virtual char* ParseDeep(char*, StrPair*);
907 
908  protected:
910  virtual ~XMLNode();
911 
914  mutable StrPair _value;
915 
918 
921 
922  private:
923  MemPool* _memPool;
924  void Unlink(XMLNode* child);
925  static void DeleteNode(XMLNode* node);
926  void InsertChildPreamble(XMLNode* insertThis) const;
927 
928  XMLNode(const XMLNode&); // not supported
929  XMLNode& operator=(const XMLNode&); // not supported
930  };
931 
932 
945  class TINYXML2_LIB XMLText : public XMLNode
946  {
947  friend class XMLBase;
948  friend class XMLDocument;
949  public:
950  virtual bool Accept(XMLVisitor* visitor) const;
951 
952  virtual XMLText* ToText() {
953  return this;
954  }
955  virtual const XMLText* ToText() const {
956  return this;
957  }
958 
960  void SetCData(bool isCData) {
961  _isCData = isCData;
962  }
964  bool CData() const {
965  return _isCData;
966  }
967 
968  char* ParseDeep(char*, StrPair* endTag);
969  virtual XMLNode* ShallowClone(XMLDocument* document) const;
970  virtual bool ShallowEqual(const XMLNode* compare) const;
971 
972  protected:
973  XMLText(XMLDocument* doc) : XMLNode(doc), _isCData(false) {}
974  virtual ~XMLText() {}
975 
976  private:
977  bool _isCData;
978 
979  XMLText(const XMLText&); // not supported
980  XMLText& operator=(const XMLText&); // not supported
981  };
982 
983 
986  {
987  friend class XMLDocument;
988  public:
989  virtual XMLComment* ToComment() {
990  return this;
991  }
992  virtual const XMLComment* ToComment() const {
993  return this;
994  }
995 
996  virtual bool Accept(XMLVisitor* visitor) const;
997 
998  char* ParseDeep(char*, StrPair* endTag);
999  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1000  virtual bool ShallowEqual(const XMLNode* compare) const;
1001 
1002  protected:
1003  XMLComment(XMLDocument* doc);
1004  virtual ~XMLComment();
1005 
1006  private:
1007  XMLComment(const XMLComment&); // not supported
1008  XMLComment& operator=(const XMLComment&); // not supported
1009  };
1010 
1011 
1024  {
1025  friend class XMLDocument;
1026  public:
1028  return this;
1029  }
1030  virtual const XMLDeclaration* ToDeclaration() const {
1031  return this;
1032  }
1033 
1034  virtual bool Accept(XMLVisitor* visitor) const;
1035 
1036  char* ParseDeep(char*, StrPair* endTag);
1037  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1038  virtual bool ShallowEqual(const XMLNode* compare) const;
1039 
1040  protected:
1042  virtual ~XMLDeclaration();
1043 
1044  private:
1045  XMLDeclaration(const XMLDeclaration&); // not supported
1046  XMLDeclaration& operator=(const XMLDeclaration&); // not supported
1047  };
1048 
1049 
1058  {
1059  friend class XMLDocument;
1060  public:
1061  virtual XMLUnknown* ToUnknown() {
1062  return this;
1063  }
1064  virtual const XMLUnknown* ToUnknown() const {
1065  return this;
1066  }
1067 
1068  virtual bool Accept(XMLVisitor* visitor) const;
1069 
1070  char* ParseDeep(char*, StrPair* endTag);
1071  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1072  virtual bool ShallowEqual(const XMLNode* compare) const;
1073 
1074  protected:
1075  XMLUnknown(XMLDocument* doc);
1076  virtual ~XMLUnknown();
1077 
1078  private:
1079  XMLUnknown(const XMLUnknown&); // not supported
1080  XMLUnknown& operator=(const XMLUnknown&); // not supported
1081  };
1082 
1083 
1084 
1092  {
1093  friend class XMLElement;
1094  public:
1096  const char* Name() const;
1097 
1099  const char* Value() const;
1100 
1102  const XMLAttribute* Next() const {
1103  return _next;
1104  }
1105 
1110  int IntValue() const {
1111  int i = 0;
1112  QueryIntValue(&i);
1113  return i;
1114  }
1116  unsigned UnsignedValue() const {
1117  unsigned i = 0;
1118  QueryUnsignedValue(&i);
1119  return i;
1120  }
1122  bool BoolValue() const {
1123  bool b = false;
1124  QueryBoolValue(&b);
1125  return b;
1126  }
1128  double DoubleValue() const {
1129  double d = 0;
1130  QueryDoubleValue(&d);
1131  return d;
1132  }
1134  float FloatValue() const {
1135  float f = 0;
1136  QueryFloatValue(&f);
1137  return f;
1138  }
1139 
1144  XMLError QueryIntValue(int* value) const;
1146  XMLError QueryUnsignedValue(unsigned int* value) const;
1148  XMLError QueryBoolValue(bool* value) const;
1150  XMLError QueryDoubleValue(double* value) const;
1152  XMLError QueryFloatValue(float* value) const;
1153 
1155  void SetAttribute(const char* value);
1157  void SetAttribute(int value);
1159  void SetAttribute(unsigned value);
1161  void SetAttribute(bool value);
1163  void SetAttribute(double value);
1165  void SetAttribute(float value);
1166 
1167  private:
1168  enum { BUF_SIZE = 200 };
1169 
1170  XMLAttribute() : _next(0), _memPool(0) {}
1171  virtual ~XMLAttribute() {}
1172 
1173  XMLAttribute(const XMLAttribute&); // not supported
1174  void operator=(const XMLAttribute&); // not supported
1175  void SetName(const char* name);
1176 
1177  char* ParseDeep(char* p, bool processEntities);
1178 
1179  mutable StrPair _name;
1180  mutable StrPair _value;
1181  XMLAttribute* _next;
1182  MemPool* _memPool;
1183  };
1184 
1185 
1191  {
1192  friend class XMLBase;
1193  friend class XMLDocument;
1194  public:
1196  const char* Name() const {
1197  return Value();
1198  }
1200  void SetName(const char* str, bool staticMem = false) {
1201  SetValue(str, staticMem);
1202  }
1203 
1204  virtual XMLElement* ToElement() {
1205  return this;
1206  }
1207  virtual const XMLElement* ToElement() const {
1208  return this;
1209  }
1210  virtual bool Accept(XMLVisitor* visitor) const;
1211 
1235  const char* Attribute(const char* name, const char* value = 0) const;
1236 
1242  int IntAttribute(const char* name) const {
1243  int i = 0;
1244  QueryIntAttribute(name, &i);
1245  return i;
1246  }
1248  unsigned UnsignedAttribute(const char* name) const {
1249  unsigned i = 0;
1250  QueryUnsignedAttribute(name, &i);
1251  return i;
1252  }
1254  bool BoolAttribute(const char* name) const {
1255  bool b = false;
1256  QueryBoolAttribute(name, &b);
1257  return b;
1258  }
1260  double DoubleAttribute(const char* name) const {
1261  double d = 0;
1262  QueryDoubleAttribute(name, &d);
1263  return d;
1264  }
1266  float FloatAttribute(const char* name) const {
1267  float f = 0;
1268  QueryFloatAttribute(name, &f);
1269  return f;
1270  }
1271 
1285  XMLError QueryIntAttribute(const char* name, int* value) const {
1286  const XMLAttribute* a = FindAttribute(name);
1287  if (!a) {
1288  return XML_NO_ATTRIBUTE;
1289  }
1290  return a->QueryIntValue(value);
1291  }
1293  XMLError QueryUnsignedAttribute(const char* name, unsigned int* value) const {
1294  const XMLAttribute* a = FindAttribute(name);
1295  if (!a) {
1296  return XML_NO_ATTRIBUTE;
1297  }
1298  return a->QueryUnsignedValue(value);
1299  }
1301  XMLError QueryBoolAttribute(const char* name, bool* value) const {
1302  const XMLAttribute* a = FindAttribute(name);
1303  if (!a) {
1304  return XML_NO_ATTRIBUTE;
1305  }
1306  return a->QueryBoolValue(value);
1307  }
1309  XMLError QueryDoubleAttribute(const char* name, double* value) const {
1310  const XMLAttribute* a = FindAttribute(name);
1311  if (!a) {
1312  return XML_NO_ATTRIBUTE;
1313  }
1314  return a->QueryDoubleValue(value);
1315  }
1317  XMLError QueryFloatAttribute(const char* name, float* value) const {
1318  const XMLAttribute* a = FindAttribute(name);
1319  if (!a) {
1320  return XML_NO_ATTRIBUTE;
1321  }
1322  return a->QueryFloatValue(value);
1323  }
1324 
1325 
1343  int QueryAttribute(const char* name, int* value) const {
1344  return QueryIntAttribute(name, value);
1345  }
1346 
1347  int QueryAttribute(const char* name, unsigned int* value) const {
1348  return QueryUnsignedAttribute(name, value);
1349  }
1350 
1351  int QueryAttribute(const char* name, bool* value) const {
1352  return QueryBoolAttribute(name, value);
1353  }
1354 
1355  int QueryAttribute(const char* name, double* value) const {
1356  return QueryDoubleAttribute(name, value);
1357  }
1358 
1359  int QueryAttribute(const char* name, float* value) const {
1360  return QueryFloatAttribute(name, value);
1361  }
1362 
1364  void SetAttribute(const char* name, const char* value) {
1365  XMLAttribute* a = FindOrCreateAttribute(name);
1366  a->SetAttribute(value);
1367  }
1369  void SetAttribute(const char* name, int value) {
1370  XMLAttribute* a = FindOrCreateAttribute(name);
1371  a->SetAttribute(value);
1372  }
1374  void SetAttribute(const char* name, unsigned value) {
1375  XMLAttribute* a = FindOrCreateAttribute(name);
1376  a->SetAttribute(value);
1377  }
1379  void SetAttribute(const char* name, bool value) {
1380  XMLAttribute* a = FindOrCreateAttribute(name);
1381  a->SetAttribute(value);
1382  }
1384  void SetAttribute(const char* name, double value) {
1385  XMLAttribute* a = FindOrCreateAttribute(name);
1386  a->SetAttribute(value);
1387  }
1389  void SetAttribute(const char* name, float value) {
1390  XMLAttribute* a = FindOrCreateAttribute(name);
1391  a->SetAttribute(value);
1392  }
1393 
1397  void DeleteAttribute(const char* name);
1398 
1400  const XMLAttribute* FirstAttribute() const {
1401  return _rootAttribute;
1402  }
1404  const XMLAttribute* FindAttribute(const char* name) const;
1405 
1434  const char* GetText() const;
1435 
1470  void SetText(const char* inText);
1472  void SetText(int value);
1474  void SetText(unsigned value);
1476  void SetText(bool value);
1478  void SetText(double value);
1480  void SetText(float value);
1481 
1508  XMLError QueryIntText(int* ival) const;
1510  XMLError QueryUnsignedText(unsigned* uval) const;
1512  XMLError QueryBoolText(bool* bval) const;
1514  XMLError QueryDoubleText(double* dval) const;
1516  XMLError QueryFloatText(float* fval) const;
1517 
1518  // internal:
1519  enum {
1520  OPEN, // <foo>
1521  CLOSED, // <foo/>
1522  CLOSING // </foo>
1523  };
1524  int ClosingType() const {
1525  return _closingType;
1526  }
1527  char* ParseDeep(char* p, StrPair* endTag);
1528  virtual XMLNode* ShallowClone(XMLDocument* document) const;
1529  virtual bool ShallowEqual(const XMLNode* compare) const;
1530 
1531  private:
1532  XMLElement(XMLDocument* doc);
1533  virtual ~XMLElement();
1534  XMLElement(const XMLElement&); // not supported
1535  void operator=(const XMLElement&); // not supported
1536 
1537  XMLAttribute* FindAttribute(const char* name) {
1538  return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute(name));
1539  }
1540  XMLAttribute* FindOrCreateAttribute(const char* name);
1541  //void LinkAttribute( XMLAttribute* attrib );
1542  char* ParseAttributes(char* p);
1543  static void DeleteAttribute(XMLAttribute* attribute);
1544 
1545  enum { BUF_SIZE = 200 };
1546  int _closingType;
1547  // The attribute list is ordered; there is no 'lastAttribute'
1548  // because the list needs to be scanned for dupes before adding
1549  // a new attribute.
1550  XMLAttribute* _rootAttribute;
1551  };
1552 
1553 
1554  enum Whitespace {
1557  };
1558 
1559 
1566  {
1567  friend class XMLElement;
1568  public:
1570  XMLDocument(bool processEntities = true, Whitespace = PRESERVE_WHITESPACE);
1571  ~XMLDocument();
1572 
1574  return this;
1575  }
1576  virtual const XMLDocument* ToDocument() const {
1577  return this;
1578  }
1579 
1590  XMLError Parse(const char* xml, size_t nBytes = (size_t)(-1));
1591 
1597  XMLError LoadFile(const char* filename);
1598 
1610  XMLError LoadFile(FILE*);
1611 
1617  XMLError SaveFile(const char* filename, bool compact = false);
1618 
1626  XMLError SaveFile(FILE* fp, bool compact = false);
1627 
1628  bool ProcessEntities() const {
1629  return _processEntities;
1630  }
1632  return _whitespace;
1633  }
1634 
1638  bool HasBOM() const {
1639  return _writeBOM;
1640  }
1643  void SetBOM(bool useBOM) {
1644  _writeBOM = useBOM;
1645  }
1646 
1651  return FirstChildElement();
1652  }
1653  const XMLElement* RootElement() const {
1654  return FirstChildElement();
1655  }
1656 
1671  void Print(XMLPrinter* streamer = 0) const;
1672  virtual bool Accept(XMLVisitor* visitor) const;
1673 
1679  XMLElement* NewElement(const char* name);
1685  XMLComment* NewComment(const char* comment);
1691  XMLText* NewText(const char* text);
1703  XMLDeclaration* NewDeclaration(const char* text = 0);
1709  XMLUnknown* NewUnknown(const char* text);
1710 
1715  void DeleteNode(XMLNode* node);
1716 
1717  void SetError(XMLError error, const char* str1, const char* str2);
1718 
1720  bool Error() const {
1721  return _errorID != XML_NO_ERROR;
1722  }
1724  XMLError ErrorID() const {
1725  return _errorID;
1726  }
1727  const char* ErrorName() const;
1728 
1730  const char* GetErrorStr1() const {
1731  return _errorStr1;
1732  }
1734  const char* GetErrorStr2() const {
1735  return _errorStr2;
1736  }
1738  void PrintError() const;
1739 
1741  void Clear();
1742 
1743  // internal
1744  char* Identify(char* p, XMLNode** node);
1745 
1746  virtual XMLNode* ShallowClone(XMLDocument* /*document*/) const {
1747  return 0;
1748  }
1749  virtual bool ShallowEqual(const XMLNode* /*compare*/) const {
1750  return false;
1751  }
1752 
1753  private:
1754  XMLDocument(const XMLDocument&); // not supported
1755  void operator=(const XMLDocument&); // not supported
1756 
1757  bool _writeBOM;
1758  bool _processEntities;
1759  XMLError _errorID;
1760  Whitespace _whitespace;
1761  const char* _errorStr1;
1762  const char* _errorStr2;
1763  char* _charBuffer;
1764 
1765  MemPoolT< sizeof(XMLElement) > _elementPool;
1766  MemPoolT< sizeof(XMLAttribute) > _attributePool;
1767  MemPoolT< sizeof(XMLText) > _textPool;
1768  MemPoolT< sizeof(XMLComment) > _commentPool;
1769 
1770  static const char* _errorNames[XML_ERROR_COUNT];
1771 
1772  void Parse();
1773  };
1774 
1775 
1832  {
1833  public:
1836  _node = node;
1837  }
1840  _node = &node;
1841  }
1843  XMLHandle(const XMLHandle& ref) {
1844  _node = ref._node;
1845  }
1848  _node = ref._node;
1849  return *this;
1850  }
1851 
1854  return XMLHandle(_node ? _node->FirstChild() : 0);
1855  }
1857  XMLHandle FirstChildElement(const char* value = 0) {
1858  return XMLHandle(_node ? _node->FirstChildElement(value) : 0);
1859  }
1862  return XMLHandle(_node ? _node->LastChild() : 0);
1863  }
1865  XMLHandle LastChildElement(const char* _value = 0) {
1866  return XMLHandle(_node ? _node->LastChildElement(_value) : 0);
1867  }
1870  return XMLHandle(_node ? _node->PreviousSibling() : 0);
1871  }
1873  XMLHandle PreviousSiblingElement(const char* _value = 0) {
1874  return XMLHandle(_node ? _node->PreviousSiblingElement(_value) : 0);
1875  }
1878  return XMLHandle(_node ? _node->NextSibling() : 0);
1879  }
1881  XMLHandle NextSiblingElement(const char* _value = 0) {
1882  return XMLHandle(_node ? _node->NextSiblingElement(_value) : 0);
1883  }
1884 
1887  return _node;
1888  }
1891  return ((_node == 0) ? 0 : _node->ToElement());
1892  }
1895  return ((_node == 0) ? 0 : _node->ToText());
1896  }
1899  return ((_node == 0) ? 0 : _node->ToUnknown());
1900  }
1903  return ((_node == 0) ? 0 : _node->ToDeclaration());
1904  }
1905 
1906  private:
1907  XMLNode* _node;
1908  };
1909 
1910 
1916  {
1917  public:
1918  XMLConstHandle(const XMLNode* node) {
1919  _node = node;
1920  }
1921  XMLConstHandle(const XMLNode& node) {
1922  _node = &node;
1923  }
1925  _node = ref._node;
1926  }
1927 
1929  _node = ref._node;
1930  return *this;
1931  }
1932 
1933  const XMLConstHandle FirstChild() const {
1934  return XMLConstHandle(_node ? _node->FirstChild() : 0);
1935  }
1936  const XMLConstHandle FirstChildElement(const char* value = 0) const {
1937  return XMLConstHandle(_node ? _node->FirstChildElement(value) : 0);
1938  }
1939  const XMLConstHandle LastChild() const {
1940  return XMLConstHandle(_node ? _node->LastChild() : 0);
1941  }
1942  const XMLConstHandle LastChildElement(const char* _value = 0) const {
1943  return XMLConstHandle(_node ? _node->LastChildElement(_value) : 0);
1944  }
1946  return XMLConstHandle(_node ? _node->PreviousSibling() : 0);
1947  }
1948  const XMLConstHandle PreviousSiblingElement(const char* _value = 0) const {
1949  return XMLConstHandle(_node ? _node->PreviousSiblingElement(_value) : 0);
1950  }
1951  const XMLConstHandle NextSibling() const {
1952  return XMLConstHandle(_node ? _node->NextSibling() : 0);
1953  }
1954  const XMLConstHandle NextSiblingElement(const char* _value = 0) const {
1955  return XMLConstHandle(_node ? _node->NextSiblingElement(_value) : 0);
1956  }
1957 
1958 
1959  const XMLNode* ToNode() const {
1960  return _node;
1961  }
1962  const XMLElement* ToElement() const {
1963  return ((_node == 0) ? 0 : _node->ToElement());
1964  }
1965  const XMLText* ToText() const {
1966  return ((_node == 0) ? 0 : _node->ToText());
1967  }
1968  const XMLUnknown* ToUnknown() const {
1969  return ((_node == 0) ? 0 : _node->ToUnknown());
1970  }
1972  return ((_node == 0) ? 0 : _node->ToDeclaration());
1973  }
1974 
1975  private:
1976  const XMLNode* _node;
1977  };
1978 
1979 
2023  {
2024  public:
2031  XMLPrinter(FILE* file = 0, bool compact = false, int depth = 0);
2032  virtual ~XMLPrinter() {}
2033 
2035  void PushHeader(bool writeBOM, bool writeDeclaration);
2039  void OpenElement(const char* name, bool compactMode = false);
2041  void PushAttribute(const char* name, const char* value);
2042  void PushAttribute(const char* name, int value);
2043  void PushAttribute(const char* name, unsigned value);
2044  void PushAttribute(const char* name, bool value);
2045  void PushAttribute(const char* name, double value);
2047  virtual void CloseElement(bool compactMode = false);
2048 
2050  void PushText(const char* text, bool cdata = false);
2052  void PushText(int value);
2054  void PushText(unsigned value);
2056  void PushText(bool value);
2058  void PushText(float value);
2060  void PushText(double value);
2061 
2063  void PushComment(const char* comment);
2064 
2065  void PushDeclaration(const char* value);
2066  void PushUnknown(const char* value);
2067 
2068  virtual bool VisitEnter(const XMLDocument& /*doc*/);
2069  virtual bool VisitExit(const XMLDocument& /*doc*/) {
2070  return true;
2071  }
2072 
2073  virtual bool VisitEnter(const XMLElement& element, const XMLAttribute* attribute);
2074  virtual bool VisitExit(const XMLElement& element);
2075 
2076  virtual bool Visit(const XMLText& text);
2077  virtual bool Visit(const XMLComment& comment);
2078  virtual bool Visit(const XMLDeclaration& declaration);
2079  virtual bool Visit(const XMLUnknown& unknown);
2080 
2085  const char* CStr() const {
2086  return _buffer.Mem();
2087  }
2093  int CStrSize() const {
2094  return _buffer.Size();
2095  }
2100  void ClearBuffer() {
2101  _buffer.Clear();
2102  _buffer.Push(0);
2103  }
2104 
2105  protected:
2106  virtual bool CompactMode(const XMLElement&) { return _compactMode; }
2107 
2111  virtual void PrintSpace(int depth);
2112  void Print(const char* format, ...);
2113 
2114  void SealElementIfJustOpened();
2117 
2118  private:
2119  void PrintString(const char*, bool restrictedEntitySet); // prints out, after detecting entities.
2120 
2121  bool _firstElement;
2122  FILE* _fp;
2123  int _depth;
2124  int _textDepth;
2125  bool _processEntities;
2126  bool _compactMode;
2127 
2128  enum {
2129  ENTITY_RANGE = 64,
2130  BUF_SIZE = 200
2131  };
2132  bool _entityFlag[ENTITY_RANGE];
2133  bool _restrictedEntityFlag[ENTITY_RANGE];
2134 
2135  DynArray< char, 20 > _buffer;
2136  };
2137 
2138 
2139 } // tinyxml2
2140 } // namespace External
2141 } // namespace Aws
2142 
2143 #if defined(_MSC_VER)
2144 # pragma warning(pop)
2145 #endif
2146 
2147 #endif // TINYXML2_INCLUDED
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:773
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:714
const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1971
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition: tinyxml2.h:598
virtual const XMLText * ToText() const
Definition: tinyxml2.h:955
XMLConstHandle(const XMLNode &node)
Definition: tinyxml2.h:1921
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:1869
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:960
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:791
XMLElement * FirstChildElement(const char *value=0)
Definition: tinyxml2.h:768
DynArray< const char *, 10 > _stack
Definition: tinyxml2.h:2116
static const int TIXML2_PATCH_VERSION
Definition: tinyxml2.h:136
static const char * ALLOCATION_TAG
Definition: tinyxml2.h:153
void Delete(T *pointerToT)
Definition: AWSMemory.h:79
const XMLElement * RootElement() const
Definition: tinyxml2.h:1653
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:515
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:717
double DoubleAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1260
float FloatAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1266
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:1898
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1724
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1843
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:1886
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1122
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1749
virtual int ItemSize() const
Definition: tinyxml2.h:379
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:497
static bool IsWhiteSpace(char p)
Definition: tinyxml2.h:576
static const char * SkipWhiteSpace(const char *p)
Definition: tinyxml2.h:562
XMLConstHandle(const XMLConstHandle &ref)
Definition: tinyxml2.h:1924
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:685
XMLNode * LinkEndChild(XMLNode *addThis)
Definition: tinyxml2.h:831
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1379
XMLHandle LastChildElement(const char *_value=0)
Get the last child element of this handle.
Definition: tinyxml2.h:1865
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1374
const XMLConstHandle LastChild() const
Definition: tinyxml2.h:1939
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1064
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1134
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1301
virtual bool CompactMode(const XMLElement &)
Definition: tinyxml2.h:2106
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:1839
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:1847
const XMLConstHandle FirstChild() const
Definition: tinyxml2.h:1933
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1720
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:750
int QueryAttribute(const char *name, bool *value) const
Definition: tinyxml2.h:1351
virtual const XMLDeclaration * ToDeclaration() const
Definition: tinyxml2.h:1030
int QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1343
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:1207
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:1902
virtual const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:720
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:1894
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:697
XMLElement * NextSiblingElement(const char *value=0)
Definition: tinyxml2.h:818
static const int TIXML2_MINOR_VERSION
Definition: tinyxml2.h:135
bool BoolAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1254
virtual const XMLDocument * ToDocument() const
Definition: tinyxml2.h:1576
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:676
XMLError QueryIntValue(int *value) const
XMLElement * LastChildElement(const char *value=0)
Definition: tinyxml2.h:786
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1116
XMLText(XMLDocument *doc)
Definition: tinyxml2.h:973
const XMLConstHandle FirstChildElement(const char *value=0) const
Definition: tinyxml2.h:1936
static bool IsUTF8Continuation(const char p)
Definition: tinyxml2.h:614
const T & operator[](int i) const
Definition: tinyxml2.h:283
virtual const XMLText * ToText() const
Definition: tinyxml2.h:708
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1364
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:711
virtual const XMLElement * ToElement() const
Definition: tinyxml2.h:705
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:989
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1196
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1293
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:681
const XMLConstHandle NextSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1954
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:511
static const int TIXML2_MAJOR_VERSION
Definition: tinyxml2.h:134
void Trace(const char *name)
Definition: tinyxml2.h:422
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1309
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1285
void SetAttribute(const char *value)
Set the attribute to a string value.
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:506
XMLConstHandle(const XMLNode *node)
Definition: tinyxml2.h:1918
#define TINYXML2_LIB
Definition: tinyxml2.h:83
const XMLNode * ToNode() const
Definition: tinyxml2.h:1959
static char * SkipWhiteSpace(char *p)
Definition: tinyxml2.h:570
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:519
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:689
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1746
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1204
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition: tinyxml2.h:1734
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition: tinyxml2.h:1928
XMLHandle PreviousSiblingElement(const char *_value=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:1873
int IntAttribute(const char *name) const
Definition: tinyxml2.h:1242
void SetInternedStr(const char *str)
Definition: tinyxml2.h:193
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1384
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:1861
#define TIXML_SNPRINTF
Definition: tinyxml2.h:127
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
const T & PeekTop() const
Definition: tinyxml2.h:288
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1200
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:964
static bool IsNameChar(unsigned char ch)
Definition: tinyxml2.h:591
void Set(char *start, char *end, int flags)
Definition: tinyxml2.h:180
const XMLElement * ToElement() const
Definition: tinyxml2.h:1962
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
Definition: tinyxml2.h:1248
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:755
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:701
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition: tinyxml2.h:1730
const XMLConstHandle PreviousSibling() const
Definition: tinyxml2.h:1945
#define TIXMLASSERT(x)
Definition: tinyxml2.h:99
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:807
virtual const XMLComment * ToComment() const
Definition: tinyxml2.h:992
Whitespace WhitespaceMode() const
Definition: tinyxml2.h:1631
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1128
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:672
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:1890
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1835
AWS_CORE_API void Free(void *memoryPtr)
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:952
const XMLText * ToText() const
Definition: tinyxml2.h:1965
int QueryAttribute(const char *name, float *value) const
Definition: tinyxml2.h:1359
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2069
int QueryAttribute(const char *name, double *value) const
Definition: tinyxml2.h:1355
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:1877
int QueryAttribute(const char *name, unsigned int *value) const
Definition: tinyxml2.h:1347
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1389
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:502
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:741
virtual void Free(void *mem)
Definition: tinyxml2.h:410
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1061
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1400
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:1853
XMLElement * PreviousSiblingElement(const char *value=0)
Definition: tinyxml2.h:802
XMLHandle NextSiblingElement(const char *_value=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:1881
const XMLConstHandle LastChildElement(const char *_value=0) const
Definition: tinyxml2.h:1942
XMLHandle FirstChildElement(const char *value=0)
Get the first child element of this handle.
Definition: tinyxml2.h:1857
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1027
const XMLUnknown * ToUnknown() const
Definition: tinyxml2.h:1968
const XMLConstHandle PreviousSiblingElement(const char *_value=0) const
Definition: tinyxml2.h:1948
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1573
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1102
const char * CStr() const
Definition: tinyxml2.h:2085
const XMLConstHandle NextSibling() const
Definition: tinyxml2.h:1951
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:493
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:693
JSON (JavaScript Object Notation).
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1317
static bool IsNameStartChar(unsigned char ch)
Definition: tinyxml2.h:580
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1369
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:523