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