ECOGEN 4.0
Evolutive, Compressible, Open, Genuine, Easy, N-phase
Loading...
Searching...
No Matches
tinyxml2.h
Go to the documentation of this file.
1/*
2Original code by Lee Thomason (www.grinninglizard.com)
3This software is provided 'as-is', without any express or implied
4warranty. In no event will the authors be held liable for any
5damages arising from the use of this software.
6Permission is granted to anyone to use this software for any
7purpose, including commercial applications, and to alter it and
8redistribute it freely, subject to the following restrictions:
9// Official webSite: https://code-mphi.github.io/ECOGEN/
101. The origin of this software must not be misrepresented; you must
11not claim that you wrote the original software. If you use this
12software in a product, an acknowledgment in the product documentation
13would be appreciated but is not required.
142. Altered source versions must be plainly marked as such, and
15must not be misrepresented as being the original software.
163. This notice may not be removed or altered from any source
17distribution.
18*/
19
20#ifndef TINYXML2_INCLUDED
21#define TINYXML2_INCLUDED
22
23#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
24# include <ctype.h>
25# include <limits.h>
26# include <stdio.h>
27# include <stdlib.h>
28# include <string.h>
29# include <stdarg.h>
30#else
31# include <cctype>
32# include <climits>
33# include <cstdio>
34# include <cstdlib>
35# include <cstring>
36# include <cstdarg>
37#endif
38
39/*
40TODO: intern strings instead of allocation.
41*/
42/*
43gcc:
44g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
45Formatting, Artistic Style:
46AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
47*/
48
49#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
50# ifndef DEBUG
51# define DEBUG
52# endif
53#endif
54
55#ifdef _MSC_VER
56# pragma warning(push)
57# pragma warning(disable: 4251)
58#endif
59
60#ifdef _WIN32
61# ifdef TINYXML2_EXPORT
62# define TINYXML2_LIB __declspec(dllexport)
63# elif defined(TINYXML2_IMPORT)
64# define TINYXML2_LIB __declspec(dllimport)
65# else
66# define TINYXML2_LIB
67# endif
68#else
69# define TINYXML2_LIB
70#endif
71
72
73#if defined(DEBUG)
74# if defined(_MSC_VER)
75# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
76# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
77# elif defined (ANDROID_NDK)
78# include <android/log.h>
79# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
80# else
81# include <assert.h>
82# define TIXMLASSERT assert
83# endif
84# else
85# define TIXMLASSERT( x ) {}
86#endif
87
88
89#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
90// Microsoft visual studio, version 2005 and higher.
91/*int _snprintf_s(
92char *buffer,
93size_t sizeOfBuffer,
94size_t count,
95const char *format [,
96argument] ...
97);*/
98inline int TIXML_SNPRINTF(char* buffer, size_t size, const char* format, ...)
99{
100 va_list va;
101 va_start(va, format);
102 int result = vsnprintf_s(buffer, size, _TRUNCATE, format, va);
103 va_end(va);
104 return result;
105}
106#define TIXML_SSCANF sscanf_s
107#elif defined WINCE
108#define TIXML_SNPRINTF _snprintf
109#define TIXML_SSCANF sscanf
110#else
111// GCC version 3 and higher
112//#warning( "Using sn* functions." )
113#define TIXML_SNPRINTF snprintf
114#define TIXML_SSCANF sscanf
115#endif
116
117/* Versioning, past 1.0.14:
118http://semver.org/
119*/
120static const int TIXML2_MAJOR_VERSION = 3;
121static const int TIXML2_MINOR_VERSION = 0;
122static const int TIXML2_PATCH_VERSION = 0;
123
124namespace tinyxml2
125{
126 class XMLDocument;
127 class XMLElement;
128 class XMLAttribute;
129 class XMLComment;
130 class XMLText;
131 class XMLDeclaration;
132 class XMLUnknown;
133 class XMLPrinter;
134
135 /*
136 A class that wraps strings. Normally stores the start and end
137 pointers into the XML file itself, and will apply normalization
138 and entity translation if actually read. Can also store (and memory
139 manage) a traditional char[]
140 */
142 {
143 public:
144 enum {
148
155 };
156
157 StrPair() : _flags(0), _start(0), _end(0) {}
158 ~StrPair();
159
160 void Set(char* start, char* end, int flags) {
161 Reset();
162 _start = start;
163 _end = end;
164 _flags = flags | NEEDS_FLUSH;
165 }
166
167 const char* GetStr();
168
169 bool Empty() const {
170 return _start == _end;
171 }
172
173 void SetInternedStr(const char* str) {
174 Reset();
175 _start = const_cast<char*>(str);
176 }
177
178 void SetStr(const char* str, int flags = 0);
179
180 char* ParseText(char* in, const char* endTag, int strFlags);
181 char* ParseName(char* in);
182
183 void TransferTo(StrPair* other);
184
185 private:
186 void Reset();
187 void CollapseWhitespace();
188
189 enum {
190 NEEDS_FLUSH = 0x100,
191 NEEDS_DELETE = 0x200
192 };
193
194 // After parsing, if *_end != 0, it can be set to zero.
196 char* _start;
197 char* _end;
198
199 StrPair(const StrPair& other); // not supported
200 void operator=(StrPair& other); // not supported, use TransferTo()
201 };
202
203
204 /*
205 A dynamic array of Plain Old Data. Doesn't support constructors, etc.
206 Has a small initial memory pool, so that low or no usage will not
207 cause a call to new/delete
208 */
209 template <class T, int INIT>
211 {
212 public:
214 _mem = _pool;
215 _allocated = INIT;
216 _size = 0;
217 }
218
220 if (_mem != _pool) {
221 delete[] _mem;
222 }
223 }
224
225 void Clear() {
226 _size = 0;
227 }
228
229 void Push(T t) {
230 TIXMLASSERT(_size < INT_MAX);
232 _mem[_size++] = t;
233 }
234
235 T* PushArr(int count) {
236 TIXMLASSERT(count >= 0);
237 TIXMLASSERT(_size <= INT_MAX - count);
238 EnsureCapacity(_size + count);
239 T* ret = &_mem[_size];
240 _size += count;
241 return ret;
242 }
243
244 T Pop() {
245 TIXMLASSERT(_size > 0);
246 return _mem[--_size];
247 }
248
249 void PopArr(int count) {
250 TIXMLASSERT(_size >= count);
251 _size -= count;
252 }
253
254 bool Empty() const {
255 return _size == 0;
256 }
257
258 T& operator[](int i) {
259 TIXMLASSERT(i >= 0 && i < _size);
260 return _mem[i];
261 }
262
263 const T& operator[](int i) const {
264 TIXMLASSERT(i >= 0 && i < _size);
265 return _mem[i];
266 }
267
268 const T& PeekTop() const {
269 TIXMLASSERT(_size > 0);
270 return _mem[_size - 1];
271 }
272
273 int Size() const {
274 TIXMLASSERT(_size >= 0);
275 return _size;
276 }
277
278 int Capacity() const {
279 return _allocated;
280 }
281
282 const T* Mem() const {
283 return _mem;
284 }
285
286 T* Mem() {
287 return _mem;
288 }
289
290 private:
291 DynArray(const DynArray&); // not supported
292 void operator=(const DynArray&); // not supported
293
294 void EnsureCapacity(int cap) {
295 TIXMLASSERT(cap > 0);
296 if (cap > _allocated) {
297 TIXMLASSERT(cap <= INT_MAX / 2);
298 int newAllocated = cap * 2;
299 T* newMem = new T[newAllocated];
300 memcpy(newMem, _mem, sizeof(T)*_size); // warning: not using constructors, only works for PODs
301 if (_mem != _pool) {
302 delete[] _mem;
303 }
304 _mem = newMem;
305 _allocated = newAllocated;
306 }
307 }
308
310 T _pool[INIT];
311 int _allocated; // objects allocated
312 int _size; // number objects in use
313 };
314
315
316 /*
317 Parent virtual class of a pool for fast allocation
318 and deallocation of objects.
319 */
321 {
322 public:
324 virtual ~MemPool() {}
325
326 virtual int ItemSize() const = 0;
327 virtual void* Alloc() = 0;
328 virtual void Free(void*) = 0;
329 virtual void SetTracked() = 0;
330 virtual void Clear() = 0;
331 };
332
333
334 /*
335 Template child class to create pools of the correct type.
336 */
337 template< int SIZE >
338 class MemPoolT : public MemPool
339 {
340 public:
343 Clear();
344 }
345
346 void Clear() {
347 // Delete the blocks.
348 while (!_blockPtrs.Empty()) {
349 Block* b = _blockPtrs.Pop();
350 delete b;
351 }
352 _root = 0;
353 _currentAllocs = 0;
354 _nAllocs = 0;
355 _maxAllocs = 0;
356 _nUntracked = 0;
357 }
358
359 virtual int ItemSize() const {
360 return SIZE;
361 }
362 int CurrentAllocs() const {
363 return _currentAllocs;
364 }
365
366 virtual void* Alloc() {
367 if (!_root) {
368 // Need a new block.
369 Block* block = new Block();
370 _blockPtrs.Push(block);
371
372 for (int i = 0; i<COUNT - 1; ++i) {
373 block->chunk[i].next = &block->chunk[i + 1];
374 }
375 block->chunk[COUNT - 1].next = 0;
376 _root = block->chunk;
377 }
378 void* result = _root;
379 _root = _root->next;
380
384 }
385 _nAllocs++;
386 _nUntracked++;
387 return result;
388 }
389
390 virtual void Free(void* mem) {
391 if (!mem) {
392 return;
393 }
395 Chunk* chunk = static_cast<Chunk*>(mem);
396#ifdef DEBUG
397 memset(chunk, 0xfe, sizeof(Chunk));
398#endif
399 chunk->next = _root;
400 _root = chunk;
401 }
402 void Trace(const char* name) {
403 printf("Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
405 }
406
407 void SetTracked() {
408 _nUntracked--;
409 }
410
411 int Untracked() const {
412 return _nUntracked;
413 }
414
415 // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
416 // The test file is large, 170k.
417 // Release: VS2010 gcc(no opt)
418 // 1k: 4000
419 // 2k: 4000
420 // 4k: 3900 21000
421 // 16k: 5200
422 // 32k: 4300
423 // 64k: 4000 21000
424 enum { COUNT = (4 * 1024) / SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
425
426 private:
427 MemPoolT(const MemPoolT&); // not supported
428 void operator=(const MemPoolT&); // not supported
429
430 union Chunk {
432 char mem[SIZE];
433 };
434 struct Block {
436 };
439
444 };
445
446
447
463 {
464 public:
465 virtual ~XMLVisitor() {}
466
468 virtual bool VisitEnter(const XMLDocument& /*doc*/) {
469 return true;
470 }
472 virtual bool VisitExit(const XMLDocument& /*doc*/) {
473 return true;
474 }
475
477 virtual bool VisitEnter(const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/) {
478 return true;
479 }
481 virtual bool VisitExit(const XMLElement& /*element*/) {
482 return true;
483 }
484
486 virtual bool Visit(const XMLDeclaration& /*declaration*/) {
487 return true;
488 }
490 virtual bool Visit(const XMLText& /*text*/) {
491 return true;
492 }
494 virtual bool Visit(const XMLComment& /*comment*/) {
495 return true;
496 }
498 virtual bool Visit(const XMLUnknown& /*unknown*/) {
499 return true;
500 }
501 };
502
503 // WARNING: must match XMLDocument::_errorNames[]
529
530
531 /*
532 Utility functionality.
533 */
535 {
536 public:
537 static const char* SkipWhiteSpace(const char* p) {
538 TIXMLASSERT(p);
539 while (IsWhiteSpace(*p)) {
540 ++p;
541 }
542 TIXMLASSERT(p);
543 return p;
544 }
545 static char* SkipWhiteSpace(char* p) {
546 return const_cast<char*>(SkipWhiteSpace(const_cast<const char*>(p)));
547 }
548
549 // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
550 // correct, but simple, and usually works.
551 static bool IsWhiteSpace(char p) {
552 return !IsUTF8Continuation(p) && isspace(static_cast<unsigned char>(p));
553 }
554
555 inline static bool IsNameStartChar(unsigned char ch) {
556 if (ch >= 128) {
557 // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
558 return true;
559 }
560 if (isalpha(ch)) {
561 return true;
562 }
563 return ch == ':' || ch == '_';
564 }
565
566 inline static bool IsNameChar(unsigned char ch) {
567 return IsNameStartChar(ch)
568 || isdigit(ch)
569 || ch == '.'
570 || ch == '-';
571 }
572
573 inline static bool StringEqual(const char* p, const char* q, int nChar = INT_MAX) {
574 if (p == q) {
575 return true;
576 }
577 int n = 0;
578 while (*p && *q && *p == *q && n<nChar) {
579 ++p;
580 ++q;
581 ++n;
582 }
583 if ((n == nChar) || (*p == 0 && *q == 0)) {
584 return true;
585 }
586 return false;
587 }
588
589 inline static bool IsUTF8Continuation(const char p) {
590 return (p & 0x80) != 0;
591 }
592
593 static const char* ReadBOM(const char* p, bool* hasBOM);
594 // p is the starting location,
595 // the UTF-8 value of the entity will be placed in value, and length filled in.
596 static const char* GetCharacterRef(const char* p, char* value, int* length);
597 static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length);
598
599 // converts primitive types to strings
600 static void ToStr(int v, char* buffer, int bufferSize);
601 static void ToStr(unsigned v, char* buffer, int bufferSize);
602 static void ToStr(bool v, char* buffer, int bufferSize);
603 static void ToStr(float v, char* buffer, int bufferSize);
604 static void ToStr(double v, char* buffer, int bufferSize);
605
606 // converts strings to primitive types
607 static bool ToInt(const char* str, int* value);
608 static bool ToUnsigned(const char* str, unsigned* value);
609 static bool ToBool(const char* str, bool* value);
610 static bool ToFloat(const char* str, float* value);
611 static bool ToDouble(const char* str, double* value);
612 };
613
614
637 {
638 friend class XMLDocument;
639 friend class XMLElement;
640 public:
641
643 const XMLDocument* GetDocument() const {
644 return _document;
645 }
648 return _document;
649 }
650
653 return 0;
654 }
656 virtual XMLText* ToText() {
657 return 0;
658 }
661 return 0;
662 }
665 return 0;
666 }
669 return 0;
670 }
673 return 0;
674 }
675
676 virtual const XMLElement* ToElement() const {
677 return 0;
678 }
679 virtual const XMLText* ToText() const {
680 return 0;
681 }
682 virtual const XMLComment* ToComment() const {
683 return 0;
684 }
685 virtual const XMLDocument* ToDocument() const {
686 return 0;
687 }
688 virtual const XMLDeclaration* ToDeclaration() const {
689 return 0;
690 }
691 virtual const XMLUnknown* ToUnknown() const {
692 return 0;
693 }
694
704 const char* Value() const;
705
709 void SetValue(const char* val, bool staticMem = false);
710
712 const XMLNode* Parent() const {
713 return _parent;
714 }
715
717 return _parent;
718 }
719
721 bool NoChildren() const {
722 return !_firstChild;
723 }
724
726 const XMLNode* FirstChild() const {
727 return _firstChild;
728 }
729
731 return _firstChild;
732 }
733
737 const XMLElement* FirstChildElement(const char* value = 0) const;
738
739 XMLElement* FirstChildElement(const char* value = 0) {
740 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement(value));
741 }
742
744 const XMLNode* LastChild() const {
745 return _lastChild;
746 }
747
749 return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild());
750 }
751
755 const XMLElement* LastChildElement(const char* value = 0) const;
756
757 XMLElement* LastChildElement(const char* value = 0) {
758 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value));
759 }
760
762 const XMLNode* PreviousSibling() const {
763 return _prev;
764 }
765
767 return _prev;
768 }
769
771 const XMLElement* PreviousSiblingElement(const char* value = 0) const;
772
773 XMLElement* PreviousSiblingElement(const char* value = 0) {
774 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement(value));
775 }
776
778 const XMLNode* NextSibling() const {
779 return _next;
780 }
781
783 return _next;
784 }
785
787 const XMLElement* NextSiblingElement(const char* value = 0) const;
788
789 XMLElement* NextSiblingElement(const char* value = 0) {
790 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement(value));
791 }
792
800 XMLNode* InsertEndChild(XMLNode* addThis);
801
803 return InsertEndChild(addThis);
804 }
812 XMLNode* InsertFirstChild(XMLNode* addThis);
821 XMLNode* InsertAfterChild(XMLNode* afterThis, XMLNode* addThis);
822
826 void DeleteChildren();
827
831 void DeleteChild(XMLNode* node);
832
841 virtual XMLNode* ShallowClone(XMLDocument* document) const = 0;
842
848 virtual bool ShallowEqual(const XMLNode* compare) const = 0;
849
867 virtual bool Accept(XMLVisitor* visitor) const = 0;
868
869 // internal
870 virtual char* ParseDeep(char*, StrPair*);
871
872 protected:
874 virtual ~XMLNode();
875
879
882
885
886 private:
888 void Unlink(XMLNode* child);
889 static void DeleteNode(XMLNode* node);
890 void InsertChildPreamble(XMLNode* insertThis) const;
891
892 XMLNode(const XMLNode&); // not supported
893 XMLNode& operator=(const XMLNode&); // not supported
894 };
895
896
908 {
909 friend class XMLBase;
910 friend class XMLDocument;
911 public:
912 virtual bool Accept(XMLVisitor* visitor) const;
913
914 virtual XMLText* ToText() {
915 return this;
916 }
917 virtual const XMLText* ToText() const {
918 return this;
919 }
920
922 void SetCData(bool isCData) {
923 _isCData = isCData;
924 }
926 bool CData() const {
927 return _isCData;
928 }
929
930 char* ParseDeep(char*, StrPair* endTag);
931 virtual XMLNode* ShallowClone(XMLDocument* document) const;
932 virtual bool ShallowEqual(const XMLNode* compare) const;
933
934 protected:
935 XMLText(XMLDocument* doc) : XMLNode(doc), _isCData(false) {}
936 virtual ~XMLText() {}
937
938 private:
940
941 XMLText(const XMLText&); // not supported
942 XMLText& operator=(const XMLText&); // not supported
943 };
944
945
948 {
949 friend class XMLDocument;
950 public:
952 return this;
953 }
954 virtual const XMLComment* ToComment() const {
955 return this;
956 }
957
958 virtual bool Accept(XMLVisitor* visitor) const;
959
960 char* ParseDeep(char*, StrPair* endTag);
961 virtual XMLNode* ShallowClone(XMLDocument* document) const;
962 virtual bool ShallowEqual(const XMLNode* compare) const;
963
964 protected:
966 virtual ~XMLComment();
967
968 private:
969 XMLComment(const XMLComment&); // not supported
970 XMLComment& operator=(const XMLComment&); // not supported
971 };
972
973
984 {
985 friend class XMLDocument;
986 public:
988 return this;
989 }
990 virtual const XMLDeclaration* ToDeclaration() const {
991 return this;
992 }
993
994 virtual bool Accept(XMLVisitor* visitor) const;
995
996 char* ParseDeep(char*, StrPair* endTag);
997 virtual XMLNode* ShallowClone(XMLDocument* document) const;
998 virtual bool ShallowEqual(const XMLNode* compare) const;
999
1000 protected:
1002 virtual ~XMLDeclaration();
1003
1004 private:
1005 XMLDeclaration(const XMLDeclaration&); // not supported
1006 XMLDeclaration& operator=(const XMLDeclaration&); // not supported
1007 };
1008
1009
1017 {
1018 friend class XMLDocument;
1019 public:
1021 return this;
1022 }
1023 virtual const XMLUnknown* ToUnknown() const {
1024 return this;
1025 }
1026
1027 virtual bool Accept(XMLVisitor* visitor) const;
1028
1029 char* ParseDeep(char*, StrPair* endTag);
1030 virtual XMLNode* ShallowClone(XMLDocument* document) const;
1031 virtual bool ShallowEqual(const XMLNode* compare) const;
1032
1033 protected:
1034 XMLUnknown(XMLDocument* doc);
1035 virtual ~XMLUnknown();
1036
1037 private:
1038 XMLUnknown(const XMLUnknown&); // not supported
1039 XMLUnknown& operator=(const XMLUnknown&); // not supported
1040 };
1041
1042
1043
1050 {
1051 friend class XMLElement;
1052 public:
1054 const char* Name() const;
1055
1057 const char* Value() const;
1058
1060 const XMLAttribute* Next() const {
1061 return _next;
1062 }
1063
1068 int IntValue() const {
1069 int i = 0;
1070 QueryIntValue(&i);
1071 return i;
1072 }
1074 unsigned UnsignedValue() const {
1075 unsigned i = 0;
1076 QueryUnsignedValue(&i);
1077 return i;
1078 }
1080 bool BoolValue() const {
1081 bool b = false;
1082 QueryBoolValue(&b);
1083 return b;
1084 }
1086 double DoubleValue() const {
1087 double d = 0;
1088 QueryDoubleValue(&d);
1089 return d;
1090 }
1092 float FloatValue() const {
1093 float f = 0;
1094 QueryFloatValue(&f);
1095 return f;
1096 }
1097
1102 XMLError QueryIntValue(int* value) const;
1104 XMLError QueryUnsignedValue(unsigned int* value) const;
1106 XMLError QueryBoolValue(bool* value) const;
1108 XMLError QueryDoubleValue(double* value) const;
1110 XMLError QueryFloatValue(float* value) const;
1111
1113 void SetAttribute(const char* value);
1115 void SetAttribute(int value);
1117 void SetAttribute(unsigned value);
1119 void SetAttribute(bool value);
1121 void SetAttribute(double value);
1123 void SetAttribute(float value);
1124
1125 private:
1126 enum { BUF_SIZE = 200 };
1127
1128 XMLAttribute() : _next(0), _memPool(0) {}
1129 virtual ~XMLAttribute() {}
1130
1131 XMLAttribute(const XMLAttribute&); // not supported
1132 void operator=(const XMLAttribute&); // not supported
1133 void SetName(const char* name);
1134
1135 char* ParseDeep(char* p, bool processEntities);
1136
1141 };
1142
1143
1149 {
1150 friend class XMLBase;
1151 friend class XMLDocument;
1152 public:
1154 const char* Name() const {
1155 return Value();
1156 }
1158 void SetName(const char* str, bool staticMem = false) {
1159 SetValue(str, staticMem);
1160 }
1161
1163 return this;
1164 }
1165 virtual const XMLElement* ToElement() const {
1166 return this;
1167 }
1168 virtual bool Accept(XMLVisitor* visitor) const;
1169
1189 const char* Attribute(const char* name, const char* value = 0) const;
1190
1196 int IntAttribute(const char* name) const {
1197 int i = 0;
1198 QueryIntAttribute(name, &i);
1199 return i;
1200 }
1202 unsigned UnsignedAttribute(const char* name) const {
1203 unsigned i = 0;
1204 QueryUnsignedAttribute(name, &i);
1205 return i;
1206 }
1208 bool BoolAttribute(const char* name) const {
1209 bool b = false;
1210 QueryBoolAttribute(name, &b);
1211 return b;
1212 }
1214 double DoubleAttribute(const char* name) const {
1215 double d = 0;
1216 QueryDoubleAttribute(name, &d);
1217 return d;
1218 }
1220 float FloatAttribute(const char* name) const {
1221 float f = 0;
1222 QueryFloatAttribute(name, &f);
1223 return f;
1224 }
1225
1238 XMLError QueryIntAttribute(const char* name, int* value) const {
1239 const XMLAttribute* a = FindAttribute(name);
1240 if (!a) {
1241 return XML_NO_ATTRIBUTE;
1242 }
1243 return a->QueryIntValue(value);
1244 }
1246 XMLError QueryUnsignedAttribute(const char* name, unsigned int* value) const {
1247 const XMLAttribute* a = FindAttribute(name);
1248 if (!a) {
1249 return XML_NO_ATTRIBUTE;
1250 }
1251 return a->QueryUnsignedValue(value);
1252 }
1254 XMLError QueryBoolAttribute(const char* name, bool* value) const {
1255 const XMLAttribute* a = FindAttribute(name);
1256 if (!a) {
1257 return XML_NO_ATTRIBUTE;
1258 }
1259 return a->QueryBoolValue(value);
1260 }
1262 XMLError QueryDoubleAttribute(const char* name, double* value) const {
1263 const XMLAttribute* a = FindAttribute(name);
1264 if (!a) {
1265 return XML_NO_ATTRIBUTE;
1266 }
1267 return a->QueryDoubleValue(value);
1268 }
1270 XMLError QueryFloatAttribute(const char* name, float* value) const {
1271 const XMLAttribute* a = FindAttribute(name);
1272 if (!a) {
1273 return XML_NO_ATTRIBUTE;
1274 }
1275 return a->QueryFloatValue(value);
1276 }
1277
1278
1295 int QueryAttribute(const char* name, int* value) const {
1296 return QueryIntAttribute(name, value);
1297 }
1298
1299 int QueryAttribute(const char* name, unsigned int* value) const {
1300 return QueryUnsignedAttribute(name, value);
1301 }
1302
1303 int QueryAttribute(const char* name, bool* value) const {
1304 return QueryBoolAttribute(name, value);
1305 }
1306
1307 int QueryAttribute(const char* name, double* value) const {
1308 return QueryDoubleAttribute(name, value);
1309 }
1310
1311 int QueryAttribute(const char* name, float* value) const {
1312 return QueryFloatAttribute(name, value);
1313 }
1314
1316 void SetAttribute(const char* name, const char* value) {
1317 XMLAttribute* a = FindOrCreateAttribute(name);
1318 a->SetAttribute(value);
1319 }
1321 void SetAttribute(const char* name, int value) {
1322 XMLAttribute* a = FindOrCreateAttribute(name);
1323 a->SetAttribute(value);
1324 }
1326 void SetAttribute(const char* name, unsigned value) {
1327 XMLAttribute* a = FindOrCreateAttribute(name);
1328 a->SetAttribute(value);
1329 }
1331 void SetAttribute(const char* name, bool value) {
1332 XMLAttribute* a = FindOrCreateAttribute(name);
1333 a->SetAttribute(value);
1334 }
1336 void SetAttribute(const char* name, double value) {
1337 XMLAttribute* a = FindOrCreateAttribute(name);
1338 a->SetAttribute(value);
1339 }
1341 void SetAttribute(const char* name, float value) {
1342 XMLAttribute* a = FindOrCreateAttribute(name);
1343 a->SetAttribute(value);
1344 }
1345
1349 void DeleteAttribute(const char* name);
1350
1353 return _rootAttribute;
1354 }
1356 const XMLAttribute* FindAttribute(const char* name) const;
1357
1381 const char* GetText() const;
1382
1413 void SetText(const char* inText);
1415 void SetText(int value);
1417 void SetText(unsigned value);
1419 void SetText(bool value);
1421 void SetText(double value);
1423 void SetText(float value);
1424
1447 XMLError QueryIntText(int* ival) const;
1449 XMLError QueryUnsignedText(unsigned* uval) const;
1451 XMLError QueryBoolText(bool* bval) const;
1453 XMLError QueryDoubleText(double* dval) const;
1455 XMLError QueryFloatText(float* fval) const;
1456
1457 // internal:
1458 enum {
1459 OPEN, // <foo>
1460 CLOSED, // <foo/>
1461 CLOSING // </foo>
1463 int ClosingType() const {
1464 return _closingType;
1465 }
1466 char* ParseDeep(char* p, StrPair* endTag);
1467 virtual XMLNode* ShallowClone(XMLDocument* document) const;
1468 virtual bool ShallowEqual(const XMLNode* compare) const;
1469
1470 private:
1471 XMLElement(XMLDocument* doc);
1472 virtual ~XMLElement();
1473 XMLElement(const XMLElement&); // not supported
1474 void operator=(const XMLElement&); // not supported
1475
1476 XMLAttribute* FindAttribute(const char* name) {
1477 return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute(name));
1478 }
1479 XMLAttribute* FindOrCreateAttribute(const char* name);
1480 //void LinkAttribute( XMLAttribute* attrib );
1481 char* ParseAttributes(char* p);
1482 static void DeleteAttribute(XMLAttribute* attribute);
1483
1484 enum { BUF_SIZE = 200 };
1486 // The attribute list is ordered; there is no 'lastAttribute'
1487 // because the list needs to be scanned for dupes before adding
1488 // a new attribute.
1490 };
1491
1492
1497
1498
1505 {
1506 friend class XMLElement;
1507 public:
1509 XMLDocument(bool processEntities = true, Whitespace = PRESERVE_WHITESPACE);
1510 ~XMLDocument();
1511
1513 return this;
1514 }
1515 virtual const XMLDocument* ToDocument() const {
1516 return this;
1517 }
1518
1528 XMLError Parse(const char* xml, size_t nBytes = (size_t)(-1));
1529
1535 XMLError LoadFile(const char* filename);
1536
1547 XMLError LoadFile(FILE*);
1548
1554 XMLError SaveFile(const char* filename, bool compact = false);
1555
1562 XMLError SaveFile(FILE* fp, bool compact = false);
1563
1564 bool ProcessEntities() const {
1565 return _processEntities;
1566 }
1568 return _whitespace;
1569 }
1570
1574 bool HasBOM() const {
1575 return _writeBOM;
1576 }
1579 void SetBOM(bool useBOM) {
1580 _writeBOM = useBOM;
1581 }
1582
1587 return FirstChildElement();
1588 }
1589 const XMLElement* RootElement() const {
1590 return FirstChildElement();
1591 }
1592
1606 void Print(XMLPrinter* streamer = 0) const;
1607 virtual bool Accept(XMLVisitor* visitor) const;
1608
1614 XMLElement* NewElement(const char* name);
1620 XMLComment* NewComment(const char* comment);
1626 XMLText* NewText(const char* text);
1637 XMLDeclaration* NewDeclaration(const char* text = 0);
1643 XMLUnknown* NewUnknown(const char* text);
1644
1649 void DeleteNode(XMLNode* node);
1650
1651 void SetError(XMLError error, const char* str1, const char* str2);
1652
1654 bool Error() const {
1655 return _errorID != XML_NO_ERROR;
1656 }
1659 return _errorID;
1660 }
1661 const char* ErrorName() const;
1662
1664 const char* GetErrorStr1() const {
1665 return _errorStr1;
1666 }
1668 const char* GetErrorStr2() const {
1669 return _errorStr2;
1670 }
1672 void PrintError() const;
1673
1675 void Clear();
1676
1677 // internal
1678 char* Identify(char* p, XMLNode** node);
1679
1680 virtual XMLNode* ShallowClone(XMLDocument* /*document*/) const {
1681 return 0;
1682 }
1683 virtual bool ShallowEqual(const XMLNode* /*compare*/) const {
1684 return false;
1685 }
1686
1687 private:
1688 XMLDocument(const XMLDocument&); // not supported
1689 void operator=(const XMLDocument&); // not supported
1690
1695 const char* _errorStr1;
1696 const char* _errorStr2;
1698
1699 MemPoolT< sizeof(XMLElement) > _elementPool;
1700 MemPoolT< sizeof(XMLAttribute) > _attributePool;
1701 MemPoolT< sizeof(XMLText) > _textPool;
1702 MemPoolT< sizeof(XMLComment) > _commentPool;
1703
1704 static const char* _errorNames[XML_ERROR_COUNT];
1705
1706 void Parse();
1707 };
1708
1709
1758 {
1759 public:
1762 _node = node;
1763 }
1766 _node = &node;
1767 }
1769 XMLHandle(const XMLHandle& ref) {
1770 _node = ref._node;
1771 }
1774 _node = ref._node;
1775 return *this;
1776 }
1777
1780 return XMLHandle(_node ? _node->FirstChild() : 0);
1781 }
1783 XMLHandle FirstChildElement(const char* value = 0) {
1784 return XMLHandle(_node ? _node->FirstChildElement(value) : 0);
1785 }
1788 return XMLHandle(_node ? _node->LastChild() : 0);
1789 }
1791 XMLHandle LastChildElement(const char* _value = 0) {
1792 return XMLHandle(_node ? _node->LastChildElement(_value) : 0);
1793 }
1796 return XMLHandle(_node ? _node->PreviousSibling() : 0);
1797 }
1799 XMLHandle PreviousSiblingElement(const char* _value = 0) {
1800 return XMLHandle(_node ? _node->PreviousSiblingElement(_value) : 0);
1801 }
1804 return XMLHandle(_node ? _node->NextSibling() : 0);
1805 }
1807 XMLHandle NextSiblingElement(const char* _value = 0) {
1808 return XMLHandle(_node ? _node->NextSiblingElement(_value) : 0);
1809 }
1810
1813 return _node;
1814 }
1817 return ((_node == 0) ? 0 : _node->ToElement());
1818 }
1821 return ((_node == 0) ? 0 : _node->ToText());
1822 }
1825 return ((_node == 0) ? 0 : _node->ToUnknown());
1826 }
1829 return ((_node == 0) ? 0 : _node->ToDeclaration());
1830 }
1831
1832 private:
1834 };
1835
1836
1842 {
1843 public:
1845 _node = node;
1846 }
1848 _node = &node;
1849 }
1851 _node = ref._node;
1852 }
1853
1855 _node = ref._node;
1856 return *this;
1857 }
1858
1860 return XMLConstHandle(_node ? _node->FirstChild() : 0);
1861 }
1862 const XMLConstHandle FirstChildElement(const char* value = 0) const {
1863 return XMLConstHandle(_node ? _node->FirstChildElement(value) : 0);
1864 }
1866 return XMLConstHandle(_node ? _node->LastChild() : 0);
1867 }
1868 const XMLConstHandle LastChildElement(const char* _value = 0) const {
1869 return XMLConstHandle(_node ? _node->LastChildElement(_value) : 0);
1870 }
1872 return XMLConstHandle(_node ? _node->PreviousSibling() : 0);
1873 }
1874 const XMLConstHandle PreviousSiblingElement(const char* _value = 0) const {
1875 return XMLConstHandle(_node ? _node->PreviousSiblingElement(_value) : 0);
1876 }
1878 return XMLConstHandle(_node ? _node->NextSibling() : 0);
1879 }
1880 const XMLConstHandle NextSiblingElement(const char* _value = 0) const {
1881 return XMLConstHandle(_node ? _node->NextSiblingElement(_value) : 0);
1882 }
1883
1884
1885 const XMLNode* ToNode() const {
1886 return _node;
1887 }
1888 const XMLElement* ToElement() const {
1889 return ((_node == 0) ? 0 : _node->ToElement());
1890 }
1891 const XMLText* ToText() const {
1892 return ((_node == 0) ? 0 : _node->ToText());
1893 }
1894 const XMLUnknown* ToUnknown() const {
1895 return ((_node == 0) ? 0 : _node->ToUnknown());
1896 }
1898 return ((_node == 0) ? 0 : _node->ToDeclaration());
1899 }
1900
1901 private:
1903 };
1904
1905
1940 {
1941 public:
1948 XMLPrinter(FILE* file = 0, bool compact = false, int depth = 0);
1949 virtual ~XMLPrinter() {}
1950
1952 void PushHeader(bool writeBOM, bool writeDeclaration);
1956 void OpenElement(const char* name, bool compactMode = false);
1958 void PushAttribute(const char* name, const char* value);
1959 void PushAttribute(const char* name, int value);
1960 void PushAttribute(const char* name, unsigned value);
1961 void PushAttribute(const char* name, bool value);
1962 void PushAttribute(const char* name, double value);
1964 virtual void CloseElement(bool compactMode = false);
1965
1967 void PushText(const char* text, bool cdata = false);
1969 void PushText(int value);
1971 void PushText(unsigned value);
1973 void PushText(bool value);
1975 void PushText(float value);
1977 void PushText(double value);
1978
1980 void PushComment(const char* comment);
1981
1982 void PushDeclaration(const char* value);
1983 void PushUnknown(const char* value);
1984
1985 virtual bool VisitEnter(const XMLDocument& /*doc*/);
1986 virtual bool VisitExit(const XMLDocument& /*doc*/) {
1987 return true;
1988 }
1989
1990 virtual bool VisitEnter(const XMLElement& element, const XMLAttribute* attribute);
1991 virtual bool VisitExit(const XMLElement& element);
1992
1993 virtual bool Visit(const XMLText& text);
1994 virtual bool Visit(const XMLComment& comment);
1995 virtual bool Visit(const XMLDeclaration& declaration);
1996 virtual bool Visit(const XMLUnknown& unknown);
1997
2002 const char* CStr() const {
2003 return _buffer.Mem();
2004 }
2010 int CStrSize() const {
2011 return _buffer.Size();
2012 }
2018 _buffer.Clear();
2019 _buffer.Push(0);
2020 }
2021
2022 protected:
2023 virtual bool CompactMode(const XMLElement&) { return _compactMode; }
2024
2028 virtual void PrintSpace(int depth);
2029 void Print(const char* format, ...);
2030
2031 void SealElementIfJustOpened();
2034
2035 private:
2036 void PrintString(const char*, bool restrictedEntitySet); // prints out, after detecting entities.
2037
2039 FILE* _fp;
2044
2045 enum {
2046 ENTITY_RANGE = 64,
2047 BUF_SIZE = 200
2049 bool _entityFlag[ENTITY_RANGE];
2050 bool _restrictedEntityFlag[ENTITY_RANGE];
2051
2053 };
2054
2055
2056} // tinyxml2
2057
2058#if defined(_MSC_VER)
2059# pragma warning(pop)
2060#endif
2061
2062#endif // TINYXML2_INCLUDED
@ p
Definition Tools.h:60
@ SIZE
Definition Tools.h:60
Definition tinyxml2.h:211
T Pop()
Definition tinyxml2.h:244
T * _mem
Definition tinyxml2.h:309
T & operator[](int i)
Definition tinyxml2.h:258
void Push(T t)
Definition tinyxml2.h:229
T * Mem()
Definition tinyxml2.h:286
T * PushArr(int count)
Definition tinyxml2.h:235
void EnsureCapacity(int cap)
Definition tinyxml2.h:294
int Size() const
Definition tinyxml2.h:273
int Capacity() const
Definition tinyxml2.h:278
const T * Mem() const
Definition tinyxml2.h:282
int _size
Definition tinyxml2.h:312
const T & operator[](int i) const
Definition tinyxml2.h:263
const T & PeekTop() const
Definition tinyxml2.h:268
int _allocated
Definition tinyxml2.h:311
void Clear()
Definition tinyxml2.h:225
void PopArr(int count)
Definition tinyxml2.h:249
T _pool[INIT]
Definition tinyxml2.h:310
~DynArray()
Definition tinyxml2.h:219
void operator=(const DynArray &)
DynArray(const DynArray &)
DynArray()
Definition tinyxml2.h:213
bool Empty() const
Definition tinyxml2.h:254
Definition tinyxml2.h:339
@ COUNT
Definition tinyxml2.h:424
void Trace(const char *name)
Definition tinyxml2.h:402
virtual int ItemSize() const
Definition tinyxml2.h:359
int _nAllocs
Definition tinyxml2.h:441
int Untracked() const
Definition tinyxml2.h:411
void Clear()
Definition tinyxml2.h:346
virtual void Free(void *mem)
Definition tinyxml2.h:390
void operator=(const MemPoolT &)
void SetTracked()
Definition tinyxml2.h:407
MemPoolT()
Definition tinyxml2.h:341
int _maxAllocs
Definition tinyxml2.h:442
int _nUntracked
Definition tinyxml2.h:443
int CurrentAllocs() const
Definition tinyxml2.h:362
virtual void * Alloc()
Definition tinyxml2.h:366
~MemPoolT()
Definition tinyxml2.h:342
int _currentAllocs
Definition tinyxml2.h:440
Chunk * _root
Definition tinyxml2.h:438
MemPoolT(const MemPoolT &)
DynArray< Block *, 10 > _blockPtrs
Definition tinyxml2.h:437
Definition tinyxml2.h:321
virtual int ItemSize() const =0
virtual void * Alloc()=0
virtual void Free(void *)=0
virtual void Clear()=0
MemPool()
Definition tinyxml2.h:323
virtual void SetTracked()=0
virtual ~MemPool()
Definition tinyxml2.h:324
Definition tinyxml2.h:142
@ COMMENT
Definition tinyxml2.h:154
@ ATTRIBUTE_VALUE_LEAVE_ENTITIES
Definition tinyxml2.h:153
@ NEEDS_ENTITY_PROCESSING
Definition tinyxml2.h:145
@ ATTRIBUTE_VALUE
Definition tinyxml2.h:152
@ NEEDS_NEWLINE_NORMALIZATION
Definition tinyxml2.h:146
@ TEXT_ELEMENT_LEAVE_ENTITIES
Definition tinyxml2.h:150
@ ATTRIBUTE_NAME
Definition tinyxml2.h:151
@ TEXT_ELEMENT
Definition tinyxml2.h:149
@ COLLAPSE_WHITESPACE
Definition tinyxml2.h:147
void operator=(StrPair &other)
void SetStr(const char *str, int flags=0)
Definition tinyxml2.cpp:107
void SetInternedStr(const char *str)
Definition tinyxml2.h:173
void TransferTo(StrPair *other)
Definition tinyxml2.cpp:73
@ NEEDS_FLUSH
Definition tinyxml2.h:190
@ NEEDS_DELETE
Definition tinyxml2.h:191
void Set(char *start, char *end, int flags)
Definition tinyxml2.h:160
~StrPair()
Definition tinyxml2.cpp:67
StrPair()
Definition tinyxml2.h:157
void Reset()
Definition tinyxml2.cpp:96
char * _end
Definition tinyxml2.h:197
char * ParseName(char *in)
Definition tinyxml2.cpp:138
StrPair(const StrPair &other)
bool Empty() const
Definition tinyxml2.h:169
char * _start
Definition tinyxml2.h:196
const char * GetStr()
Definition tinyxml2.cpp:187
char * ParseText(char *in, const char *endTag, int strFlags)
Definition tinyxml2.cpp:118
void CollapseWhitespace()
Definition tinyxml2.cpp:158
int _flags
Definition tinyxml2.h:195
Definition tinyxml2.h:1050
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
Definition tinyxml2.cpp:1223
virtual ~XMLAttribute()
Definition tinyxml2.h:1129
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition tinyxml2.h:1074
float FloatValue() const
Query as a float. See IntValue()
Definition tinyxml2.h:1092
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
Definition tinyxml2.cpp:1232
void operator=(const XMLAttribute &)
XMLAttribute * _next
Definition tinyxml2.h:1139
void SetAttribute(const char *value)
Set the attribute to a string value.
Definition tinyxml2.cpp:1241
XMLAttribute(const XMLAttribute &)
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
Definition tinyxml2.cpp:1205
double DoubleValue() const
Query as a double. See IntValue()
Definition tinyxml2.h:1086
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
Definition tinyxml2.cpp:1214
XMLError QueryIntValue(int *value) const
Definition tinyxml2.cpp:1196
StrPair _name
Definition tinyxml2.h:1137
bool BoolValue() const
Query as a boolean. See IntValue()
Definition tinyxml2.h:1080
const XMLAttribute * Next() const
The next attribute in the list.
Definition tinyxml2.h:1060
StrPair _value
Definition tinyxml2.h:1138
MemPool * _memPool
Definition tinyxml2.h:1140
int IntValue() const
Definition tinyxml2.h:1068
XMLAttribute()
Definition tinyxml2.h:1128
Definition tinyxml2.h:948
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition tinyxml2.h:951
XMLComment & operator=(const XMLComment &)
XMLComment(const XMLComment &)
virtual const XMLComment * ToComment() const
Definition tinyxml2.h:954
Definition tinyxml2.h:1842
XMLConstHandle(const XMLNode *node)
Definition tinyxml2.h:1844
const XMLText * ToText() const
Definition tinyxml2.h:1891
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition tinyxml2.h:1854
const XMLElement * ToElement() const
Definition tinyxml2.h:1888
XMLConstHandle(const XMLConstHandle &ref)
Definition tinyxml2.h:1850
const XMLUnknown * ToUnknown() const
Definition tinyxml2.h:1894
const XMLDeclaration * ToDeclaration() const
Definition tinyxml2.h:1897
const XMLConstHandle NextSiblingElement(const char *_value=0) const
Definition tinyxml2.h:1880
XMLConstHandle(const XMLNode &node)
Definition tinyxml2.h:1847
const XMLConstHandle FirstChildElement(const char *value=0) const
Definition tinyxml2.h:1862
const XMLConstHandle LastChild() const
Definition tinyxml2.h:1865
const XMLNode * ToNode() const
Definition tinyxml2.h:1885
const XMLConstHandle PreviousSibling() const
Definition tinyxml2.h:1871
const XMLConstHandle PreviousSiblingElement(const char *_value=0) const
Definition tinyxml2.h:1874
const XMLNode * _node
Definition tinyxml2.h:1902
const XMLConstHandle LastChildElement(const char *_value=0) const
Definition tinyxml2.h:1868
const XMLConstHandle NextSibling() const
Definition tinyxml2.h:1877
const XMLConstHandle FirstChild() const
Definition tinyxml2.h:1859
Definition tinyxml2.h:984
XMLDeclaration & operator=(const XMLDeclaration &)
XMLDeclaration(const XMLDeclaration &)
virtual const XMLDeclaration * ToDeclaration() const
Definition tinyxml2.h:990
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition tinyxml2.h:987
Definition tinyxml2.h:1505
XMLElement * RootElement()
Definition tinyxml2.h:1586
void SetBOM(bool useBOM)
Definition tinyxml2.h:1579
bool _writeBOM
Definition tinyxml2.h:1691
bool HasBOM() const
Definition tinyxml2.h:1574
bool Error() const
Return true if there was an error parsing the document.
Definition tinyxml2.h:1654
const char * _errorStr1
Definition tinyxml2.h:1695
const XMLElement * RootElement() const
Definition tinyxml2.h:1589
Whitespace _whitespace
Definition tinyxml2.h:1694
bool ProcessEntities() const
Definition tinyxml2.h:1564
XMLError _errorID
Definition tinyxml2.h:1693
const char * _errorStr2
Definition tinyxml2.h:1696
virtual bool ShallowEqual(const XMLNode *) const
Definition tinyxml2.h:1683
char * _charBuffer
Definition tinyxml2.h:1697
Whitespace WhitespaceMode() const
Definition tinyxml2.h:1567
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition tinyxml2.h:1512
const char * GetErrorStr1() const
Return a possibly helpful diagnostic location or string.
Definition tinyxml2.h:1664
bool _processEntities
Definition tinyxml2.h:1692
void operator=(const XMLDocument &)
virtual const XMLDocument * ToDocument() const
Definition tinyxml2.h:1515
const char * GetErrorStr2() const
Return a possibly helpful secondary diagnostic location or string.
Definition tinyxml2.h:1668
XMLDocument(const XMLDocument &)
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition tinyxml2.h:1680
XMLError ErrorID() const
Return the errorID.
Definition tinyxml2.h:1658
Definition tinyxml2.h:1149
int QueryAttribute(const char *name, int *value) const
Definition tinyxml2.h:1295
@ OPEN
Definition tinyxml2.h:1459
@ CLOSED
Definition tinyxml2.h:1460
bool BoolAttribute(const char *name) const
See IntAttribute()
Definition tinyxml2.h:1208
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition tinyxml2.h:1316
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1254
int QueryAttribute(const char *name, unsigned int *value) const
Definition tinyxml2.h:1299
XMLElement(const XMLElement &)
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition tinyxml2.h:1336
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1246
unsigned UnsignedAttribute(const char *name) const
See IntAttribute()
Definition tinyxml2.h:1202
int QueryAttribute(const char *name, float *value) const
Definition tinyxml2.h:1311
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition tinyxml2.h:1352
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition tinyxml2.h:1341
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1262
float FloatAttribute(const char *name) const
See IntAttribute()
Definition tinyxml2.h:1220
XMLAttribute * FindAttribute(const char *name)
Definition tinyxml2.h:1476
int QueryAttribute(const char *name, double *value) const
Definition tinyxml2.h:1307
double DoubleAttribute(const char *name) const
See IntAttribute()
Definition tinyxml2.h:1214
XMLError QueryIntAttribute(const char *name, int *value) const
Definition tinyxml2.h:1238
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition tinyxml2.h:1158
virtual const XMLElement * ToElement() const
Definition tinyxml2.h:1165
int QueryAttribute(const char *name, bool *value) const
Definition tinyxml2.h:1303
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition tinyxml2.h:1331
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition tinyxml2.h:1321
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition tinyxml2.h:1162
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition tinyxml2.h:1154
int ClosingType() const
Definition tinyxml2.h:1463
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1270
int IntAttribute(const char *name) const
Definition tinyxml2.h:1196
XMLAttribute * _rootAttribute
Definition tinyxml2.h:1489
int _closingType
Definition tinyxml2.h:1485
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition tinyxml2.h:1326
void operator=(const XMLElement &)
Definition tinyxml2.h:1758
XMLHandle PreviousSiblingElement(const char *_value=0)
Get the previous sibling element of this handle.
Definition tinyxml2.h:1799
XMLHandle LastChildElement(const char *_value=0)
Get the last child element of this handle.
Definition tinyxml2.h:1791
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition tinyxml2.h:1795
XMLHandle NextSiblingElement(const char *_value=0)
Get the next sibling element of this handle.
Definition tinyxml2.h:1807
XMLHandle FirstChild()
Get the first child of this handle.
Definition tinyxml2.h:1779
XMLNode * _node
Definition tinyxml2.h:1833
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition tinyxml2.h:1812
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition tinyxml2.h:1828
XMLHandle FirstChildElement(const char *value=0)
Get the first child element of this handle.
Definition tinyxml2.h:1783
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition tinyxml2.h:1761
XMLHandle LastChild()
Get the last child of this handle.
Definition tinyxml2.h:1787
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition tinyxml2.h:1773
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition tinyxml2.h:1765
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition tinyxml2.h:1803
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition tinyxml2.h:1816
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition tinyxml2.h:1820
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition tinyxml2.h:1824
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition tinyxml2.h:1769
Definition tinyxml2.h:637
virtual const XMLText * ToText() const
Definition tinyxml2.h:679
XMLNode * NextSibling()
Definition tinyxml2.h:782
XMLNode * _lastChild
Definition tinyxml2.h:881
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition tinyxml2.h:656
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition tinyxml2.h:668
XMLNode * _parent
Definition tinyxml2.h:877
XMLElement * NextSiblingElement(const char *value=0)
Definition tinyxml2.h:789
XMLNode * _next
Definition tinyxml2.h:884
XMLNode * FirstChild()
Definition tinyxml2.h:730
StrPair _value
Definition tinyxml2.h:878
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition tinyxml2.h:647
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition tinyxml2.h:712
MemPool * _memPool
Definition tinyxml2.h:887
XMLNode * LastChild()
Definition tinyxml2.h:748
XMLNode & operator=(const XMLNode &)
XMLNode * PreviousSibling()
Definition tinyxml2.h:766
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition tinyxml2.h:660
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition tinyxml2.h:664
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition tinyxml2.h:744
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition tinyxml2.h:643
virtual const XMLElement * ToElement() const
Definition tinyxml2.h:676
XMLNode(const XMLNode &)
virtual bool ShallowEqual(const XMLNode *compare) const =0
virtual bool Accept(XMLVisitor *visitor) const =0
XMLDocument * _document
Definition tinyxml2.h:876
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition tinyxml2.h:762
virtual const XMLDeclaration * ToDeclaration() const
Definition tinyxml2.h:688
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition tinyxml2.h:652
XMLNode * _prev
Definition tinyxml2.h:883
XMLNode * _firstChild
Definition tinyxml2.h:880
XMLElement * PreviousSiblingElement(const char *value=0)
Definition tinyxml2.h:773
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition tinyxml2.h:672
virtual const XMLUnknown * ToUnknown() const
Definition tinyxml2.h:691
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition tinyxml2.h:726
bool NoChildren() const
Returns true if this node has no children.
Definition tinyxml2.h:721
virtual const XMLDocument * ToDocument() const
Definition tinyxml2.h:685
XMLNode * Parent()
Definition tinyxml2.h:716
XMLNode * LinkEndChild(XMLNode *addThis)
Definition tinyxml2.h:802
virtual const XMLComment * ToComment() const
Definition tinyxml2.h:682
XMLElement * LastChildElement(const char *value=0)
Definition tinyxml2.h:757
XMLElement * FirstChildElement(const char *value=0)
Definition tinyxml2.h:739
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition tinyxml2.h:778
Definition tinyxml2.h:1940
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:1986
int _depth
Definition tinyxml2.h:2040
DynArray< char, 20 > _buffer
Definition tinyxml2.h:2052
void ClearBuffer()
Definition tinyxml2.h:2017
int CStrSize() const
Definition tinyxml2.h:2010
virtual bool CompactMode(const XMLElement &)
Definition tinyxml2.h:2023
int _textDepth
Definition tinyxml2.h:2041
bool _processEntities
Definition tinyxml2.h:2042
FILE * _fp
Definition tinyxml2.h:2039
bool _compactMode
Definition tinyxml2.h:2043
DynArray< const char *, 10 > _stack
Definition tinyxml2.h:2033
bool _firstElement
Definition tinyxml2.h:2038
const char * CStr() const
Definition tinyxml2.h:2002
bool _elementJustOpened
Definition tinyxml2.h:2032
virtual ~XMLPrinter()
Definition tinyxml2.h:1949
Definition tinyxml2.h:908
XMLText(const XMLText &)
virtual const XMLText * ToText() const
Definition tinyxml2.h:917
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition tinyxml2.h:914
bool _isCData
Definition tinyxml2.h:939
XMLText & operator=(const XMLText &)
bool CData() const
Returns true if this is a CDATA text element.
Definition tinyxml2.h:926
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition tinyxml2.h:922
XMLText(XMLDocument *doc)
Definition tinyxml2.h:935
virtual ~XMLText()
Definition tinyxml2.h:936
Definition tinyxml2.h:1017
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition tinyxml2.h:1020
XMLUnknown(const XMLUnknown &)
virtual const XMLUnknown * ToUnknown() const
Definition tinyxml2.h:1023
XMLUnknown & operator=(const XMLUnknown &)
Definition tinyxml2.h:535
static bool IsNameChar(unsigned char ch)
Definition tinyxml2.h:566
static const char * SkipWhiteSpace(const char *p)
Definition tinyxml2.h:537
static bool ToUnsigned(const char *str, unsigned *value)
Definition tinyxml2.cpp:493
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
Definition tinyxml2.cpp:307
static bool IsWhiteSpace(char p)
Definition tinyxml2.h:551
static bool ToFloat(const char *str, float *value)
Definition tinyxml2.cpp:520
static void ToStr(int v, char *buffer, int bufferSize)
Definition tinyxml2.cpp:452
static const char * GetCharacterRef(const char *p, char *value, int *length)
Definition tinyxml2.cpp:356
static char * SkipWhiteSpace(char *p)
Definition tinyxml2.h:545
static bool IsUTF8Continuation(const char p)
Definition tinyxml2.h:589
static bool IsNameStartChar(unsigned char ch)
Definition tinyxml2.h:555
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition tinyxml2.h:573
static bool ToInt(const char *str, int *value)
Definition tinyxml2.cpp:485
static bool ToDouble(const char *str, double *value)
Definition tinyxml2.cpp:528
static bool ToBool(const char *str, bool *value)
Definition tinyxml2.cpp:501
static const char * ReadBOM(const char *p, bool *hasBOM)
Definition tinyxml2.cpp:289
Definition tinyxml2.h:463
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition tinyxml2.h:498
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:472
virtual ~XMLVisitor()
Definition tinyxml2.h:465
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition tinyxml2.h:481
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:468
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition tinyxml2.h:494
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition tinyxml2.h:486
virtual bool Visit(const XMLText &)
Visit a text node.
Definition tinyxml2.h:490
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition tinyxml2.h:477
Definition tinyxml2.cpp:49
XMLError
Definition tinyxml2.h:504
@ XML_ERROR_MISMATCHED_ELEMENT
Definition tinyxml2.h:522
@ XML_ERROR_EMPTY_DOCUMENT
Definition tinyxml2.h:521
@ XML_SUCCESS
Definition tinyxml2.h:505
@ XML_ERROR_ELEMENT_MISMATCH
Definition tinyxml2.h:512
@ XML_ERROR_PARSING_ATTRIBUTE
Definition tinyxml2.h:514
@ XML_ERROR_FILE_NOT_FOUND
Definition tinyxml2.h:509
@ XML_ERROR_IDENTIFYING_TAG
Definition tinyxml2.h:515
@ XML_ERROR_PARSING_TEXT
Definition tinyxml2.h:516
@ XML_ERROR_PARSING_COMMENT
Definition tinyxml2.h:518
@ XML_NO_TEXT_NODE
Definition tinyxml2.h:525
@ XML_ERROR_FILE_READ_ERROR
Definition tinyxml2.h:511
@ XML_ERROR_PARSING_UNKNOWN
Definition tinyxml2.h:520
@ XML_ERROR_PARSING_CDATA
Definition tinyxml2.h:517
@ XML_ERROR_COUNT
Definition tinyxml2.h:527
@ XML_NO_ATTRIBUTE
Definition tinyxml2.h:507
@ XML_NO_ERROR
Definition tinyxml2.h:506
@ XML_ERROR_PARSING_DECLARATION
Definition tinyxml2.h:519
@ XML_WRONG_ATTRIBUTE_TYPE
Definition tinyxml2.h:508
@ XML_ERROR_PARSING
Definition tinyxml2.h:523
@ XML_ERROR_PARSING_ELEMENT
Definition tinyxml2.h:513
@ XML_ERROR_FILE_COULD_NOT_BE_OPENED
Definition tinyxml2.h:510
@ XML_CAN_NOT_CONVERT_TEXT
Definition tinyxml2.h:524
Whitespace
Definition tinyxml2.h:1493
@ PRESERVE_WHITESPACE
Definition tinyxml2.h:1494
@ COLLAPSE_WHITESPACE
Definition tinyxml2.h:1495
Definition tinyxml2.h:434
Chunk chunk[COUNT]
Definition tinyxml2.h:435
#define TIXMLASSERT(x)
Definition tinyxml2.h:85
static const int TIXML2_PATCH_VERSION
Definition tinyxml2.h:122
static const int TIXML2_MAJOR_VERSION
Definition tinyxml2.h:120
#define TINYXML2_LIB
Definition tinyxml2.h:69
static const int TIXML2_MINOR_VERSION
Definition tinyxml2.h:121
#define TIXML_SNPRINTF
Definition tinyxml2.h:113
Definition tinyxml2.h:430
char mem[SIZE]
Definition tinyxml2.h:432
Chunk * next
Definition tinyxml2.h:431