AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
tinyxml2.h
1/*
2Original code by Lee Thomason (www.grinninglizard.com)
3
4This software is provided 'as-is', without any express or implied
5warranty. In no event will the authors be held liable for any
6damages arising from the use of this software.
7
8Permission is granted to anyone to use this software for any
9purpose, including commercial applications, and to alter it and
10redistribute it freely, subject to the following restrictions:
11
121. The origin of this software must not be misrepresented; you must
13not claim that you wrote the original software. If you use this
14software in a product, an acknowledgment in the product documentation
15would be appreciated but is not required.
16
172. Altered source versions must be plainly marked as such, and
18must not be misrepresented as being the original software.
19
203. This notice may not be removed or altered from any source
21distribution.
22*/
23/*
24This file has been modified from its original version by Amazon:
25 (1) Memory management operations use aws memory management api
26 (2) Import-export preprocessor logic tweaked for better integration into core library
27 (3) Wrapped everything in Amazon namespace to prevent static linking issues if the user includes a version of this code through another dependency
28*/
29#ifndef TINYXML2_INCLUDED
30#define TINYXML2_INCLUDED
31
32#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
33# include <ctype.h>
34# include <limits.h>
35# include <stdio.h>
36# include <stdlib.h>
37# include <string.h>
38# if defined(__PS3__)
39# include <stddef.h>
40# endif
41#else
42# include <cctype>
43# include <climits>
44# include <cstdio>
45# include <cstdlib>
46# include <cstring>
47#endif
48#include <stdint.h>
49
50#include <aws/core/utils/memory/AWSMemory.h>
51
52/*
53 TODO: intern strings instead of allocation.
54*/
55/*
56 gcc:
57 g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
58
59 Formatting, Artistic Style:
60 AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
61*/
62
63#if defined( _DEBUG ) || defined (__DEBUG__)
64# ifndef DEBUG
65# define DEBUG
66# endif
67#endif
68
69#ifdef _MSC_VER
70# pragma warning(push)
71# pragma warning(disable: 4251)
72#endif
73
74#ifdef _WIN32
75 #ifdef USE_IMPORT_EXPORT
76 #ifdef AWS_CORE_EXPORTS
77 #define TINYXML2_LIB __declspec(dllexport)
78 #else
79 #define TINYXML2_LIB __declspec(dllimport)
80 #endif // AWS_CORE_EXPORTS
81 #endif // USE_IMPORT_EXPORT
82#elif __GNUC__ >= 4
83 #define TINYXML2_LIB __attribute__((visibility("default")))
84#endif // _WIN32
85
86#ifndef TINYXML2_LIB
87 #define TINYXML2_LIB
88#endif // TINYXML2_LIB
89
90#if defined(DEBUG)
91# if defined(_MSC_VER)
92# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
93# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
94# elif defined (ANDROID_NDK)
95# include <android/log.h>
96# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
97# else
98# include <assert.h>
99# define TIXMLASSERT assert
100# endif
101#else
102# define TIXMLASSERT( x ) {}
103#endif
104
105
106/* Versioning, past 1.0.14:
107 http://semver.org/
108*/
109static const int TIXML2_MAJOR_VERSION = 6;
110static const int TIXML2_MINOR_VERSION = 1;
111static const int TIXML2_PATCH_VERSION = 0;
112
113#define TINYXML2_MAJOR_VERSION 6
114#define TINYXML2_MINOR_VERSION 1
115#define TINYXML2_PATCH_VERSION 0
116
117namespace Aws
118{
119namespace External
120{
121namespace tinyxml2
122{
123class XMLDocument;
124class XMLElement;
125class XMLAttribute;
126class XMLComment;
127class XMLText;
128class XMLDeclaration;
129class XMLUnknown;
130class XMLPrinter;
131
132static const char* ALLOCATION_TAG = "AWS::TinyXML";
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*/
140class TINYXML2_LIB StrPair
141{
142public:
143 enum {
144 NEEDS_ENTITY_PROCESSING = 0x01,
145 NEEDS_NEWLINE_NORMALIZATION = 0x02,
146 NEEDS_WHITESPACE_COLLAPSING = 0x04,
147
148 TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
149 TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
150 ATTRIBUTE_NAME = 0,
151 ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
152 ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
153 COMMENT = NEEDS_NEWLINE_NORMALIZATION
154 };
155
156 StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
158
159 void Set( char* start, char* end, int flags ) {
160 TIXMLASSERT( start );
161 TIXMLASSERT( end );
162 Reset();
163 _start = start;
164 _end = end;
165 _flags = flags | NEEDS_FLUSH;
166 }
167
168 const char* GetStr();
169
170 bool Empty() const {
171 return _start == _end;
172 }
173
174 void SetInternedStr( const char* str ) {
175 Reset();
176 _start = const_cast<char*>(str);
177 }
178
179 void SetStr( const char* str, int flags=0 );
180
181 char* ParseText( char* in, const char* endTag, int strFlags, int* curLineNumPtr );
182 char* ParseName( char* in );
183
184 void TransferTo( StrPair* other );
185 void Reset();
186
187private:
188 void CollapseWhitespace();
189
190 enum {
191 NEEDS_FLUSH = 0x100,
192 NEEDS_DELETE = 0x200
193 };
194
195 int _flags;
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*/
209template <class T, int INITIAL_SIZE>
211{
212public:
214 _mem( _pool ),
215 _allocated( INITIAL_SIZE ),
216 _size( 0 )
217 {
218 }
219
221 if ( _mem != _pool ) {
222 Aws::DeleteArray<T>(_mem);
223 }
224 }
225
226 void Clear() {
227 _size = 0;
228 }
229
230 void Push( T t ) {
231 TIXMLASSERT( _size < INT_MAX );
232 EnsureCapacity( _size+1 );
233 _mem[_size] = t;
234 ++_size;
235 }
236
237 T* PushArr( int count ) {
238 TIXMLASSERT( count >= 0 );
239 TIXMLASSERT( _size <= INT_MAX - count );
240 EnsureCapacity( _size+count );
241 T* ret = &_mem[_size];
242 _size += count;
243 return ret;
244 }
245
246 T Pop() {
247 TIXMLASSERT( _size > 0 );
248 --_size;
249 return _mem[_size];
250 }
251
252 void PopArr( int count ) {
253 TIXMLASSERT( _size >= count );
254 _size -= count;
255 }
256
257 bool Empty() const {
258 return _size == 0;
259 }
260
261 T& operator[](int i) {
262 TIXMLASSERT( i>= 0 && i < _size );
263 return _mem[i];
264 }
265
266 const T& operator[](int i) const {
267 TIXMLASSERT( i>= 0 && i < _size );
268 return _mem[i];
269 }
270
271 const T& PeekTop() const {
272 TIXMLASSERT( _size > 0 );
273 return _mem[ _size - 1];
274 }
275
276 int Size() const {
277 TIXMLASSERT( _size >= 0 );
278 return _size;
279 }
280
281 int Capacity() const {
282 TIXMLASSERT( _allocated >= INITIAL_SIZE );
283 return _allocated;
284 }
285
286 void SwapRemove(int i) {
287 TIXMLASSERT(i >= 0 && i < _size);
288 TIXMLASSERT(_size > 0);
289 _mem[i] = _mem[_size - 1];
290 --_size;
291 }
292
293 const T* Mem() const {
294 TIXMLASSERT( _mem );
295 return _mem;
296 }
297
298 T* Mem() {
299 TIXMLASSERT( _mem );
300 return _mem;
301 }
302
303private:
304 DynArray( const DynArray& ); // not supported
305 void operator=( const DynArray& ); // not supported
306
307 void EnsureCapacity( int cap ) {
308 TIXMLASSERT( cap > 0 );
309 if ( cap > _allocated ) {
310 TIXMLASSERT( cap <= INT_MAX / 2 );
311 int newAllocated = cap * 2;
312 T* newMem = Aws::NewArray<T>(newAllocated, ALLOCATION_TAG);
313 TIXMLASSERT( newAllocated >= _size );
314 memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
315 if ( _mem != _pool ) {
316 Aws::DeleteArray<T>(_mem);
317 }
318 _mem = newMem;
319 _allocated = newAllocated;
320 }
321 }
322
323 T* _mem;
324 T _pool[INITIAL_SIZE];
325 int _allocated; // objects allocated
326 int _size; // number objects in use
327};
328
329
330/*
331 Parent virtual class of a pool for fast allocation
332 and deallocation of objects.
333*/
335{
336public:
338 virtual ~MemPool() {}
339
340 virtual int ItemSize() const = 0;
341 virtual void* Alloc() = 0;
342 virtual void Free( void* ) = 0;
343 virtual void SetTracked() = 0;
344 virtual void Clear() = 0;
345};
346
347
348/*
349 Template child class to create pools of the correct type.
350*/
351template< int ITEM_SIZE >
352class MemPoolT : public MemPool
353{
354public:
355 MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
357 Clear();
358 }
359
360 void Clear() {
361 // Delete the blocks.
362 while( !_blockPtrs.Empty()) {
363 Block* lastBlock = _blockPtrs.Pop();
364 Aws::Delete(lastBlock);
365 }
366 _root = 0;
367 _currentAllocs = 0;
368 _nAllocs = 0;
369 _maxAllocs = 0;
370 _nUntracked = 0;
371 }
372
373 virtual int ItemSize() const {
374 return ITEM_SIZE;
375 }
376 int CurrentAllocs() const {
377 return _currentAllocs;
378 }
379
380 virtual void* Alloc() {
381 if ( !_root ) {
382 // Need a new block.
383 Block* block = Aws::New<Block>(ALLOCATION_TAG);
384 _blockPtrs.Push( block );
385
386 Item* blockItems = block->items;
387 for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
388 blockItems[i].next = &(blockItems[i + 1]);
389 }
390 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
391 _root = blockItems;
392 }
393 Item* const result = _root;
394 TIXMLASSERT( result != 0 );
395 _root = _root->next;
396
397 ++_currentAllocs;
398 if ( _currentAllocs > _maxAllocs ) {
399 _maxAllocs = _currentAllocs;
400 }
401 ++_nAllocs;
402 ++_nUntracked;
403 return result;
404 }
405
406 virtual void Free( void* mem ) {
407 if ( !mem ) {
408 return;
409 }
410 --_currentAllocs;
411 Item* item = static_cast<Item*>( mem );
412#ifdef DEBUG
413 memset( item, 0xfe, sizeof( *item ) );
414#endif
415 item->next = _root;
416 _root = item;
417 }
418 void Trace( const char* name ) {
419 printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
420 name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
421 ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
422 }
423
424 void SetTracked() {
425 --_nUntracked;
426 }
427
428 int Untracked() const {
429 return _nUntracked;
430 }
431
432 // This number is perf sensitive. 4k seems like a good tradeoff on my machine.
433 // The test file is large, 170k.
434 // Release: VS2010 gcc(no opt)
435 // 1k: 4000
436 // 2k: 4000
437 // 4k: 3900 21000
438 // 16k: 5200
439 // 32k: 4300
440 // 64k: 4000 21000
441 // Declared public because some compilers do not accept to use ITEMS_PER_BLOCK
442 // in private part if ITEMS_PER_BLOCK is private
443 enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
444
445private:
446 MemPoolT( const MemPoolT& ); // not supported
447 void operator=( const MemPoolT& ); // not supported
448
449 union Item {
450 Item* next;
451 char itemData[ITEM_SIZE];
452 };
453 struct Block {
454 Item items[ITEMS_PER_BLOCK];
455 };
456 DynArray< Block*, 10 > _blockPtrs;
457 Item* _root;
458
459 int _currentAllocs;
460 int _nAllocs;
461 int _maxAllocs;
462 int _nUntracked;
463};
464
465
466
486class TINYXML2_LIB XMLVisitor
487{
488public:
489 virtual ~XMLVisitor() {}
490
492 virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
493 return true;
494 }
496 virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
497 return true;
498 }
499
501 virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
502 return true;
503 }
505 virtual bool VisitExit( const XMLElement& /*element*/ ) {
506 return true;
507 }
508
510 virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
511 return true;
512 }
514 virtual bool Visit( const XMLText& /*text*/ ) {
515 return true;
516 }
518 virtual bool Visit( const XMLComment& /*comment*/ ) {
519 return true;
520 }
522 virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
523 return true;
524 }
525};
526
527// WARNING: must match XMLDocument::_errorNames[]
535 UNUSED_XML_ERROR_ELEMENT_MISMATCH, // remove at next major version
538 UNUSED_XML_ERROR_IDENTIFYING_TAG, // remove at next major version
549
552
553
554/*
555 Utility functionality.
556*/
557class TINYXML2_LIB XMLUtil
558{
559public:
560 static const char* SkipWhiteSpace( const char* p, int* curLineNumPtr ) {
561 TIXMLASSERT( p );
562
563 while( IsWhiteSpace(*p) ) {
564 if (curLineNumPtr && *p == '\n') {
565 ++(*curLineNumPtr);
566 }
567 ++p;
568 }
569 TIXMLASSERT( p );
570 return p;
571 }
572 static char* SkipWhiteSpace( char* p, int* curLineNumPtr ) {
573 return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p), curLineNumPtr ) );
574 }
575
576 // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
577 // correct, but simple, and usually works.
578 static bool IsWhiteSpace( char p ) {
579 return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
580 }
581
582 inline static bool IsNameStartChar( unsigned char ch ) {
583 if ( ch >= 128 ) {
584 // This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
585 return true;
586 }
587 if ( isalpha( ch ) ) {
588 return true;
589 }
590 return ch == ':' || ch == '_';
591 }
592
593 inline static bool IsNameChar( unsigned char ch ) {
594 return IsNameStartChar( ch )
595 || isdigit( ch )
596 || ch == '.'
597 || ch == '-';
598 }
599
600 inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
601 if ( p == q ) {
602 return true;
603 }
604 TIXMLASSERT( p );
605 TIXMLASSERT( q );
606 TIXMLASSERT( nChar >= 0 );
607 return strncmp( p, q, nChar ) == 0;
608 }
609
610 inline static bool IsUTF8Continuation( char p ) {
611 return ( p & 0x80 ) != 0;
612 }
613
614 static const char* ReadBOM( const char* p, bool* hasBOM );
615 // p is the starting location,
616 // the UTF-8 value of the entity will be placed in value, and length filled in.
617 static const char* GetCharacterRef( const char* p, char* value, int* length );
618 static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
619
620 // converts primitive types to strings
621 static void ToStr( int v, char* buffer, int bufferSize );
622 static void ToStr( unsigned v, char* buffer, int bufferSize );
623 static void ToStr( bool v, char* buffer, int bufferSize );
624 static void ToStr( float v, char* buffer, int bufferSize );
625 static void ToStr( double v, char* buffer, int bufferSize );
626 static void ToStr(int64_t v, char* buffer, int bufferSize);
627
628 // converts strings to primitive types
629 static bool ToInt( const char* str, int* value );
630 static bool ToUnsigned( const char* str, unsigned* value );
631 static bool ToBool( const char* str, bool* value );
632 static bool ToFloat( const char* str, float* value );
633 static bool ToDouble( const char* str, double* value );
634 static bool ToInt64(const char* str, int64_t* value);
635
636 // Changes what is serialized for a boolean value.
637 // Default to "true" and "false". Shouldn't be changed
638 // unless you have a special testing or compatibility need.
639 // Be careful: static, global, & not thread safe.
640 // Be sure to set static const memory as parameters.
641 static void SetBoolSerialization(const char* writeTrue, const char* writeFalse);
642
643private:
644 static const char* writeBoolTrue;
645 static const char* writeBoolFalse;
646};
647
648
674class TINYXML2_LIB XMLNode
675{
676 friend class XMLDocument;
677 friend class XMLElement;
678public:
679
681 const XMLDocument* GetDocument() const {
682 TIXMLASSERT( _document );
683 return _document;
684 }
687 TIXMLASSERT( _document );
688 return _document;
689 }
690
693 return 0;
694 }
696 virtual XMLText* ToText() {
697 return 0;
698 }
701 return 0;
702 }
705 return 0;
706 }
709 return 0;
710 }
713 return 0;
714 }
715
716 virtual const XMLElement* ToElement() const {
717 return 0;
718 }
719 virtual const XMLText* ToText() const {
720 return 0;
721 }
722 virtual const XMLComment* ToComment() const {
723 return 0;
724 }
725 virtual const XMLDocument* ToDocument() const {
726 return 0;
727 }
728 virtual const XMLDeclaration* ToDeclaration() const {
729 return 0;
730 }
731 virtual const XMLUnknown* ToUnknown() const {
732 return 0;
733 }
734
744 const char* Value() const;
745
749 void SetValue( const char* val, bool staticMem=false );
750
752 int GetLineNum() const { return _parseLineNum; }
753
755 const XMLNode* Parent() const {
756 return _parent;
757 }
758
760 return _parent;
761 }
762
764 bool NoChildren() const {
765 return !_firstChild;
766 }
767
769 const XMLNode* FirstChild() const {
770 return _firstChild;
771 }
772
774 return _firstChild;
775 }
776
780 const XMLElement* FirstChildElement( const char* name = 0 ) const;
781
782 XMLElement* FirstChildElement( const char* name = 0 ) {
783 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
784 }
785
787 const XMLNode* LastChild() const {
788 return _lastChild;
789 }
790
792 return _lastChild;
793 }
794
798 const XMLElement* LastChildElement( const char* name = 0 ) const;
799
800 XMLElement* LastChildElement( const char* name = 0 ) {
801 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
802 }
803
805 const XMLNode* PreviousSibling() const {
806 return _prev;
807 }
808
810 return _prev;
811 }
812
814 const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
815
816 XMLElement* PreviousSiblingElement( const char* name = 0 ) {
817 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
818 }
819
821 const XMLNode* NextSibling() const {
822 return _next;
823 }
824
826 return _next;
827 }
828
830 const XMLElement* NextSiblingElement( const char* name = 0 ) const;
831
832 XMLElement* NextSiblingElement( const char* name = 0 ) {
833 return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
834 }
835
844
846 return InsertEndChild( addThis );
847 }
864 XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
865
870
874 void DeleteChild( XMLNode* node );
875
885 virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
886
900 XMLNode* DeepClone( XMLDocument* target ) const;
901
908 virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
909
932 virtual bool Accept( XMLVisitor* visitor ) const = 0;
933
939 void SetUserData(void* userData) { _userData = userData; }
940
946 void* GetUserData() const { return _userData; }
947
948protected:
950 virtual ~XMLNode();
951
952 virtual char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr);
953
958
961
964
966
967private:
968 MemPool* _memPool;
969 void Unlink( XMLNode* child );
970 static void DeleteNode( XMLNode* node );
971 void InsertChildPreamble( XMLNode* insertThis ) const;
972 const XMLElement* ToElementWithName( const char* name ) const;
973
974 XMLNode( const XMLNode& ); // not supported
975 XMLNode& operator=( const XMLNode& ); // not supported
976};
977
978
991class TINYXML2_LIB XMLText : public XMLNode
992{
993 friend class XMLDocument;
994public:
995 virtual bool Accept( XMLVisitor* visitor ) const;
996
997 virtual XMLText* ToText() {
998 return this;
999 }
1000 virtual const XMLText* ToText() const {
1001 return this;
1002 }
1003
1005 void SetCData( bool isCData ) {
1006 _isCData = isCData;
1007 }
1009 bool CData() const {
1010 return _isCData;
1011 }
1012
1013 virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1014 virtual bool ShallowEqual( const XMLNode* compare ) const;
1015
1016protected:
1017 XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
1018 virtual ~XMLText() {}
1019
1020 char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1021
1022private:
1023 bool _isCData;
1024
1025 XMLText( const XMLText& ); // not supported
1026 XMLText& operator=( const XMLText& ); // not supported
1027};
1028
1029
1031class TINYXML2_LIB XMLComment : public XMLNode
1032{
1033 friend class XMLDocument;
1034public:
1036 return this;
1037 }
1038 virtual const XMLComment* ToComment() const {
1039 return this;
1040 }
1041
1042 virtual bool Accept( XMLVisitor* visitor ) const;
1043
1044 virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1045 virtual bool ShallowEqual( const XMLNode* compare ) const;
1046
1047protected:
1049 virtual ~XMLComment();
1050
1051 char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr);
1052
1053private:
1054 XMLComment( const XMLComment& ); // not supported
1055 XMLComment& operator=( const XMLComment& ); // not supported
1056};
1057
1058
1070class TINYXML2_LIB XMLDeclaration : public XMLNode
1071{
1072 friend class XMLDocument;
1073public:
1075 return this;
1076 }
1077 virtual const XMLDeclaration* ToDeclaration() const {
1078 return this;
1079 }
1080
1081 virtual bool Accept( XMLVisitor* visitor ) const;
1082
1083 virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1084 virtual bool ShallowEqual( const XMLNode* compare ) const;
1085
1086protected:
1089
1090 char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1091
1092private:
1093 XMLDeclaration( const XMLDeclaration& ); // not supported
1094 XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
1095};
1096
1097
1105class TINYXML2_LIB XMLUnknown : public XMLNode
1106{
1107 friend class XMLDocument;
1108public:
1110 return this;
1111 }
1112 virtual const XMLUnknown* ToUnknown() const {
1113 return this;
1114 }
1115
1116 virtual bool Accept( XMLVisitor* visitor ) const;
1117
1118 virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1119 virtual bool ShallowEqual( const XMLNode* compare ) const;
1120
1121protected:
1123 virtual ~XMLUnknown();
1124
1125 char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1126
1127private:
1128 XMLUnknown( const XMLUnknown& ); // not supported
1129 XMLUnknown& operator=( const XMLUnknown& ); // not supported
1130};
1131
1132
1133
1140class TINYXML2_LIB XMLAttribute
1141{
1142 friend class XMLElement;
1143public:
1145 const char* Name() const;
1146
1148 const char* Value() const;
1149
1151 int GetLineNum() const { return _parseLineNum; }
1152
1154 const XMLAttribute* Next() const {
1155 return _next;
1156 }
1157
1162 int IntValue() const {
1163 int i = 0;
1164 QueryIntValue(&i);
1165 return i;
1166 }
1167
1168 int64_t Int64Value() const {
1169 int64_t i = 0;
1170 QueryInt64Value(&i);
1171 return i;
1172 }
1173
1175 unsigned UnsignedValue() const {
1176 unsigned i=0;
1177 QueryUnsignedValue( &i );
1178 return i;
1179 }
1181 bool BoolValue() const {
1182 bool b=false;
1183 QueryBoolValue( &b );
1184 return b;
1185 }
1187 double DoubleValue() const {
1188 double d=0;
1189 QueryDoubleValue( &d );
1190 return d;
1191 }
1193 float FloatValue() const {
1194 float f=0;
1195 QueryFloatValue( &f );
1196 return f;
1197 }
1198
1203 XMLError QueryIntValue( int* value ) const;
1205 XMLError QueryUnsignedValue( unsigned int* value ) const;
1207 XMLError QueryInt64Value(int64_t* value) const;
1209 XMLError QueryBoolValue( bool* value ) const;
1211 XMLError QueryDoubleValue( double* value ) const;
1213 XMLError QueryFloatValue( float* value ) const;
1214
1216 void SetAttribute( const char* value );
1218 void SetAttribute( int value );
1220 void SetAttribute( unsigned value );
1222 void SetAttribute(int64_t value);
1224 void SetAttribute( bool value );
1226 void SetAttribute( double value );
1228 void SetAttribute( float value );
1229
1230private:
1231 enum { BUF_SIZE = 200 };
1232
1233 XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1234 virtual ~XMLAttribute() {}
1235
1236 XMLAttribute( const XMLAttribute& ); // not supported
1237 void operator=( const XMLAttribute& ); // not supported
1238 void SetName( const char* name );
1239
1240 char* ParseDeep( char* p, bool processEntities, int* curLineNumPtr );
1241
1242 mutable StrPair _name;
1243 mutable StrPair _value;
1244 int _parseLineNum;
1245 XMLAttribute* _next;
1246 MemPool* _memPool;
1247};
1248
1249
1254class TINYXML2_LIB XMLElement : public XMLNode
1255{
1256 friend class XMLDocument;
1257public:
1259 const char* Name() const {
1260 return Value();
1261 }
1263 void SetName( const char* str, bool staticMem=false ) {
1264 SetValue( str, staticMem );
1265 }
1266
1268 return this;
1269 }
1270 virtual const XMLElement* ToElement() const {
1271 return this;
1272 }
1273 virtual bool Accept( XMLVisitor* visitor ) const;
1274
1298 const char* Attribute( const char* name, const char* value=0 ) const;
1299
1306 int IntAttribute(const char* name, int defaultValue = 0) const;
1308 unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;
1310 int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
1312 bool BoolAttribute(const char* name, bool defaultValue = false) const;
1314 double DoubleAttribute(const char* name, double defaultValue = 0) const;
1316 float FloatAttribute(const char* name, float defaultValue = 0) const;
1317
1331 XMLError QueryIntAttribute( const char* name, int* value ) const {
1332 const XMLAttribute* a = FindAttribute( name );
1333 if ( !a ) {
1334 return XML_NO_ATTRIBUTE;
1335 }
1336 return a->QueryIntValue( value );
1337 }
1338
1340 XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
1341 const XMLAttribute* a = FindAttribute( name );
1342 if ( !a ) {
1343 return XML_NO_ATTRIBUTE;
1344 }
1345 return a->QueryUnsignedValue( value );
1346 }
1347
1349 XMLError QueryInt64Attribute(const char* name, int64_t* value) const {
1350 const XMLAttribute* a = FindAttribute(name);
1351 if (!a) {
1352 return XML_NO_ATTRIBUTE;
1353 }
1354 return a->QueryInt64Value(value);
1355 }
1356
1358 XMLError QueryBoolAttribute( const char* name, bool* value ) const {
1359 const XMLAttribute* a = FindAttribute( name );
1360 if ( !a ) {
1361 return XML_NO_ATTRIBUTE;
1362 }
1363 return a->QueryBoolValue( value );
1364 }
1366 XMLError QueryDoubleAttribute( const char* name, double* value ) const {
1367 const XMLAttribute* a = FindAttribute( name );
1368 if ( !a ) {
1369 return XML_NO_ATTRIBUTE;
1370 }
1371 return a->QueryDoubleValue( value );
1372 }
1374 XMLError QueryFloatAttribute( const char* name, float* value ) const {
1375 const XMLAttribute* a = FindAttribute( name );
1376 if ( !a ) {
1377 return XML_NO_ATTRIBUTE;
1378 }
1379 return a->QueryFloatValue( value );
1380 }
1381
1382
1400 int QueryAttribute( const char* name, int* value ) const {
1401 return QueryIntAttribute( name, value );
1402 }
1403
1404 int QueryAttribute( const char* name, unsigned int* value ) const {
1405 return QueryUnsignedAttribute( name, value );
1406 }
1407
1408 int QueryAttribute(const char* name, int64_t* value) const {
1409 return QueryInt64Attribute(name, value);
1410 }
1411
1412 int QueryAttribute( const char* name, bool* value ) const {
1413 return QueryBoolAttribute( name, value );
1414 }
1415
1416 int QueryAttribute( const char* name, double* value ) const {
1417 return QueryDoubleAttribute( name, value );
1418 }
1419
1420 int QueryAttribute( const char* name, float* value ) const {
1421 return QueryFloatAttribute( name, value );
1422 }
1423
1425 void SetAttribute( const char* name, const char* value ) {
1426 XMLAttribute* a = FindOrCreateAttribute( name );
1427 a->SetAttribute( value );
1428 }
1430 void SetAttribute( const char* name, int value ) {
1431 XMLAttribute* a = FindOrCreateAttribute( name );
1432 a->SetAttribute( value );
1433 }
1435 void SetAttribute( const char* name, unsigned value ) {
1436 XMLAttribute* a = FindOrCreateAttribute( name );
1437 a->SetAttribute( value );
1438 }
1439
1441 void SetAttribute(const char* name, int64_t value) {
1442 XMLAttribute* a = FindOrCreateAttribute(name);
1443 a->SetAttribute(value);
1444 }
1445
1447 void SetAttribute( const char* name, bool value ) {
1448 XMLAttribute* a = FindOrCreateAttribute( name );
1449 a->SetAttribute( value );
1450 }
1452 void SetAttribute( const char* name, double value ) {
1453 XMLAttribute* a = FindOrCreateAttribute( name );
1454 a->SetAttribute( value );
1455 }
1457 void SetAttribute( const char* name, float value ) {
1458 XMLAttribute* a = FindOrCreateAttribute( name );
1459 a->SetAttribute( value );
1460 }
1461
1465 void DeleteAttribute( const char* name );
1466
1469 return _rootAttribute;
1470 }
1472 const XMLAttribute* FindAttribute( const char* name ) const;
1473
1502 const char* GetText() const;
1503
1538 void SetText( const char* inText );
1540 void SetText( int value );
1542 void SetText( unsigned value );
1544 void SetText(int64_t value);
1546 void SetText( bool value );
1548 void SetText( double value );
1550 void SetText( float value );
1551
1578 XMLError QueryIntText( int* ival ) const;
1580 XMLError QueryUnsignedText( unsigned* uval ) const;
1582 XMLError QueryInt64Text(int64_t* uval) const;
1584 XMLError QueryBoolText( bool* bval ) const;
1586 XMLError QueryDoubleText( double* dval ) const;
1588 XMLError QueryFloatText( float* fval ) const;
1589
1590 int IntText(int defaultValue = 0) const;
1591
1593 unsigned UnsignedText(unsigned defaultValue = 0) const;
1595 int64_t Int64Text(int64_t defaultValue = 0) const;
1597 bool BoolText(bool defaultValue = false) const;
1599 double DoubleText(double defaultValue = 0) const;
1601 float FloatText(float defaultValue = 0) const;
1602
1603 // internal:
1605 OPEN, // <foo>
1606 CLOSED, // <foo/>
1607 CLOSING // </foo>
1610 return _closingType;
1611 }
1612 virtual XMLNode* ShallowClone( XMLDocument* document ) const;
1613 virtual bool ShallowEqual( const XMLNode* compare ) const;
1614
1615protected:
1616 char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
1617
1618private:
1619 XMLElement( XMLDocument* doc );
1620 virtual ~XMLElement();
1621 XMLElement( const XMLElement& ); // not supported
1622 void operator=( const XMLElement& ); // not supported
1623
1624 XMLAttribute* FindAttribute( const char* name ) {
1625 return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));
1626 }
1627 XMLAttribute* FindOrCreateAttribute( const char* name );
1628 //void LinkAttribute( XMLAttribute* attrib );
1629 char* ParseAttributes( char* p, int* curLineNumPtr );
1630 static void DeleteAttribute( XMLAttribute* attribute );
1631 XMLAttribute* CreateAttribute();
1632
1633 enum { BUF_SIZE = 200 };
1634 ElementClosingType _closingType;
1635 // The attribute list is ordered; there is no 'lastAttribute'
1636 // because the list needs to be scanned for dupes before adding
1637 // a new attribute.
1638 XMLAttribute* _rootAttribute;
1639};
1640
1641
1646
1647
1653class TINYXML2_LIB XMLDocument : public XMLNode
1654{
1655 friend class XMLElement;
1656 // Gives access to SetError, but over-access for everything else.
1657 // Wishing C++ had "internal" scope.
1658 friend class XMLNode;
1659 friend class XMLText;
1660 friend class XMLComment;
1661 friend class XMLDeclaration;
1662 friend class XMLUnknown;
1663public:
1665 XMLDocument( bool processEntities = true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
1667
1669 TIXMLASSERT( this == _document );
1670 return this;
1671 }
1672 virtual const XMLDocument* ToDocument() const {
1673 TIXMLASSERT( this == _document );
1674 return this;
1675 }
1676
1687 XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
1688
1694 XMLError LoadFile( const char* filename );
1695
1708
1714 XMLError SaveFile( const char* filename, bool compact = false );
1715
1723 XMLError SaveFile( FILE* fp, bool compact = false );
1724
1725 bool ProcessEntities() const {
1726 return _processEntities;
1727 }
1729 return _whitespaceMode;
1730 }
1731
1735 bool HasBOM() const {
1736 return _writeBOM;
1737 }
1740 void SetBOM( bool useBOM ) {
1741 _writeBOM = useBOM;
1742 }
1743
1748 return FirstChildElement();
1749 }
1750 const XMLElement* RootElement() const {
1751 return FirstChildElement();
1752 }
1753
1768 void Print( XMLPrinter* streamer=0 ) const;
1769 virtual bool Accept( XMLVisitor* visitor ) const;
1770
1776 XMLElement* NewElement( const char* name );
1782 XMLComment* NewComment( const char* comment );
1788 XMLText* NewText( const char* text );
1800 XMLDeclaration* NewDeclaration( const char* text=0 );
1806 XMLUnknown* NewUnknown( const char* text );
1807
1812 void DeleteNode( XMLNode* node );
1813
1814 void ClearError() {
1815 SetError(XML_SUCCESS, 0, 0);
1816 }
1817
1819 bool Error() const {
1820 return _errorID != XML_SUCCESS;
1821 }
1824 return _errorID;
1825 }
1826 const char* ErrorName() const;
1827 static const char* ErrorIDToName(XMLError errorID);
1828
1832 const char* ErrorStr() const;
1833
1835 void PrintError() const;
1836
1838 int ErrorLineNum() const
1839 {
1840 return _errorLineNum;
1841 }
1842
1844 void Clear();
1845
1853 void DeepCopy(XMLDocument* target) const;
1854
1855 // internal
1856 char* Identify( char* p, XMLNode** node );
1857
1858 // internal
1860
1861 virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
1862 return 0;
1863 }
1864 virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
1865 return false;
1866 }
1867
1868private:
1869 XMLDocument( const XMLDocument& ); // not supported
1870 void operator=( const XMLDocument& ); // not supported
1871
1872 bool _writeBOM;
1873 bool _processEntities;
1874 XMLError _errorID;
1875 Whitespace _whitespaceMode;
1876 mutable StrPair _errorStr;
1877 int _errorLineNum;
1878 char* _charBuffer;
1879 int _parseCurLineNum;
1880 // Memory tracking does add some overhead.
1881 // However, the code assumes that you don't
1882 // have a bunch of unlinked nodes around.
1883 // Therefore it takes less memory to track
1884 // in the document vs. a linked list in the XMLNode,
1885 // and the performance is the same.
1886 DynArray<XMLNode*, 10> _unlinked;
1887
1888 MemPoolT< sizeof(XMLElement) > _elementPool;
1889 MemPoolT< sizeof(XMLAttribute) > _attributePool;
1890 MemPoolT< sizeof(XMLText) > _textPool;
1891 MemPoolT< sizeof(XMLComment) > _commentPool;
1892
1893 static const char* _errorNames[XML_ERROR_COUNT];
1894
1895 void Parse();
1896
1897 void SetError( XMLError error, int lineNum, const char* format, ... );
1898
1899 template<class NodeType, int PoolElementSize>
1900 NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
1901};
1902
1903template<class NodeType, int PoolElementSize>
1904inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
1905{
1906 TIXMLASSERT( sizeof( NodeType ) == PoolElementSize );
1907 TIXMLASSERT( sizeof( NodeType ) == pool.ItemSize() );
1908 NodeType* returnNode = new (pool.Alloc()) NodeType( this );
1909 TIXMLASSERT( returnNode );
1910 returnNode->_memPool = &pool;
1911
1912 _unlinked.Push(returnNode);
1913 return returnNode;
1914}
1915
1971class TINYXML2_LIB XMLHandle
1972{
1973public:
1975 XMLHandle( XMLNode* node ) : _node( node ) {
1976 }
1978 XMLHandle( XMLNode& node ) : _node( &node ) {
1979 }
1981 XMLHandle( const XMLHandle& ref ) : _node( ref._node ) {
1982 }
1985 _node = ref._node;
1986 return *this;
1987 }
1988
1991 return XMLHandle( _node ? _node->FirstChild() : 0 );
1992 }
1994 XMLHandle FirstChildElement( const char* name = 0 ) {
1995 return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
1996 }
1999 return XMLHandle( _node ? _node->LastChild() : 0 );
2000 }
2002 XMLHandle LastChildElement( const char* name = 0 ) {
2003 return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2004 }
2007 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2008 }
2010 XMLHandle PreviousSiblingElement( const char* name = 0 ) {
2011 return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2012 }
2015 return XMLHandle( _node ? _node->NextSibling() : 0 );
2016 }
2018 XMLHandle NextSiblingElement( const char* name = 0 ) {
2019 return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2020 }
2021
2024 return _node;
2025 }
2028 return ( _node ? _node->ToElement() : 0 );
2029 }
2032 return ( _node ? _node->ToText() : 0 );
2033 }
2036 return ( _node ? _node->ToUnknown() : 0 );
2037 }
2040 return ( _node ? _node->ToDeclaration() : 0 );
2041 }
2042
2043private:
2044 XMLNode* _node;
2045};
2046
2047
2052class TINYXML2_LIB XMLConstHandle
2053{
2054public:
2055 XMLConstHandle( const XMLNode* node ) : _node( node ) {
2056 }
2057 XMLConstHandle( const XMLNode& node ) : _node( &node ) {
2058 }
2059 XMLConstHandle( const XMLConstHandle& ref ) : _node( ref._node ) {
2060 }
2061
2063 _node = ref._node;
2064 return *this;
2065 }
2066
2068 return XMLConstHandle( _node ? _node->FirstChild() : 0 );
2069 }
2070 const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
2071 return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2072 }
2074 return XMLConstHandle( _node ? _node->LastChild() : 0 );
2075 }
2076 const XMLConstHandle LastChildElement( const char* name = 0 ) const {
2077 return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2078 }
2080 return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
2081 }
2082 const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
2083 return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2084 }
2086 return XMLConstHandle( _node ? _node->NextSibling() : 0 );
2087 }
2088 const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
2089 return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2090 }
2091
2092
2093 const XMLNode* ToNode() const {
2094 return _node;
2095 }
2096 const XMLElement* ToElement() const {
2097 return ( _node ? _node->ToElement() : 0 );
2098 }
2099 const XMLText* ToText() const {
2100 return ( _node ? _node->ToText() : 0 );
2101 }
2102 const XMLUnknown* ToUnknown() const {
2103 return ( _node ? _node->ToUnknown() : 0 );
2104 }
2106 return ( _node ? _node->ToDeclaration() : 0 );
2107 }
2108
2109private:
2110 const XMLNode* _node;
2111};
2112
2113
2156class TINYXML2_LIB XMLPrinter : public XMLVisitor
2157{
2158public:
2165 XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
2166 virtual ~XMLPrinter() {}
2167
2169 void PushHeader( bool writeBOM, bool writeDeclaration );
2173 void OpenElement( const char* name, bool compactMode=false );
2175 void PushAttribute( const char* name, const char* value );
2176 void PushAttribute( const char* name, int value );
2177 void PushAttribute( const char* name, unsigned value );
2178 void PushAttribute(const char* name, int64_t value);
2179 void PushAttribute( const char* name, bool value );
2180 void PushAttribute( const char* name, double value );
2182 virtual void CloseElement( bool compactMode=false );
2183
2185 void PushText( const char* text, bool cdata=false );
2187 void PushText( int value );
2189 void PushText( unsigned value );
2191 void PushText(int64_t value);
2193 void PushText( bool value );
2195 void PushText( float value );
2197 void PushText( double value );
2198
2200 void PushComment( const char* comment );
2201
2202 void PushDeclaration( const char* value );
2203 void PushUnknown( const char* value );
2204
2205 virtual bool VisitEnter( const XMLDocument& /*doc*/ );
2206 virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
2207 return true;
2208 }
2209
2210 virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
2211 virtual bool VisitExit( const XMLElement& element );
2212
2213 virtual bool Visit( const XMLText& text );
2214 virtual bool Visit( const XMLComment& comment );
2215 virtual bool Visit( const XMLDeclaration& declaration );
2216 virtual bool Visit( const XMLUnknown& unknown );
2217
2222 const char* CStr() const {
2223 return _buffer.Mem();
2224 }
2230 int CStrSize() const {
2231 return _buffer.Size();
2232 }
2238 _buffer.Clear();
2239 _buffer.Push(0);
2240 _firstElement = true;
2241 }
2242
2243protected:
2244 virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
2245
2249 virtual void PrintSpace( int depth );
2250 void Print( const char* format, ... );
2251 void Write( const char* data, size_t size );
2252 inline void Write( const char* data ) { Write( data, strlen( data ) ); }
2253 void Putc( char ch );
2254
2258
2259private:
2260 void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
2261
2262 bool _firstElement;
2263 FILE* _fp;
2264 int _depth;
2265 int _textDepth;
2266 bool _processEntities;
2267 bool _compactMode;
2268
2269 enum {
2270 ENTITY_RANGE = 64,
2271 BUF_SIZE = 200
2272 };
2273 bool _entityFlag[ENTITY_RANGE];
2274 bool _restrictedEntityFlag[ENTITY_RANGE];
2275
2276 DynArray< char, 20 > _buffer;
2277
2278 // Prohibit cloning, intentionally not implemented
2279 XMLPrinter( const XMLPrinter& );
2280 XMLPrinter& operator=( const XMLPrinter& );
2281};
2282
2283
2284} // tinyxml2
2285} // namespace External
2286} // namespace Aws
2287
2288#if defined(_MSC_VER)
2289# pragma warning(pop)
2290#endif
2291
2292#endif // TINYXML2_INCLUDED
const T & operator[](int i) const
Definition tinyxml2.h:266
virtual void Free(void *)=0
virtual int ItemSize() const =0
void Trace(const char *name)
Definition tinyxml2.h:418
virtual void Free(void *mem)
Definition tinyxml2.h:406
virtual int ItemSize() const
Definition tinyxml2.h:373
void Set(char *start, char *end, int flags)
Definition tinyxml2.h:159
void SetStr(const char *str, int flags=0)
void SetInternedStr(const char *str)
Definition tinyxml2.h:174
void TransferTo(StrPair *other)
char * ParseText(char *in, const char *endTag, int strFlags, int *curLineNumPtr)
const char * Value() const
The value of the attribute.
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
float FloatValue() const
Query as a float. See IntValue()
Definition tinyxml2.h:1193
bool BoolValue() const
Query as a boolean. See IntValue()
Definition tinyxml2.h:1181
void SetAttribute(int64_t value)
Set the attribute to value.
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition tinyxml2.h:1151
void SetAttribute(double value)
Set the attribute to value.
const XMLAttribute * Next() const
The next attribute in the list.
Definition tinyxml2.h:1154
void SetAttribute(int value)
Set the attribute to value.
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition tinyxml2.h:1175
void SetAttribute(bool value)
Set the attribute to value.
const char * Name() const
The name of the attribute.
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
void SetAttribute(const char *value)
Set the attribute to a string value.
void SetAttribute(float value)
Set the attribute to value.
void SetAttribute(unsigned value)
Set the attribute to value.
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
double DoubleValue() const
Query as a double. See IntValue()
Definition tinyxml2.h:1187
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
XMLError QueryIntValue(int *value) const
virtual const XMLComment * ToComment() const
Definition tinyxml2.h:1038
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition tinyxml2.h:1035
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual bool ShallowEqual(const XMLNode *compare) const
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
virtual bool Accept(XMLVisitor *visitor) const
XMLConstHandle & operator=(const XMLConstHandle &ref)
Definition tinyxml2.h:2062
const XMLConstHandle NextSiblingElement(const char *name=0) const
Definition tinyxml2.h:2088
XMLConstHandle(const XMLConstHandle &ref)
Definition tinyxml2.h:2059
const XMLElement * ToElement() const
Definition tinyxml2.h:2096
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
Definition tinyxml2.h:2082
const XMLConstHandle LastChild() const
Definition tinyxml2.h:2073
const XMLConstHandle LastChildElement(const char *name=0) const
Definition tinyxml2.h:2076
const XMLConstHandle FirstChild() const
Definition tinyxml2.h:2067
const XMLDeclaration * ToDeclaration() const
Definition tinyxml2.h:2105
const XMLConstHandle PreviousSibling() const
Definition tinyxml2.h:2079
const XMLConstHandle NextSibling() const
Definition tinyxml2.h:2085
const XMLUnknown * ToUnknown() const
Definition tinyxml2.h:2102
const XMLConstHandle FirstChildElement(const char *name=0) const
Definition tinyxml2.h:2070
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition tinyxml2.h:1074
virtual XMLNode * ShallowClone(XMLDocument *document) const
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
virtual bool ShallowEqual(const XMLNode *compare) const
virtual bool Accept(XMLVisitor *visitor) const
virtual const XMLDeclaration * ToDeclaration() const
Definition tinyxml2.h:1077
void Print(XMLPrinter *streamer=0) const
XMLError SaveFile(const char *filename, bool compact=false)
virtual bool ShallowEqual(const XMLNode *) const
Definition tinyxml2.h:1864
XMLError LoadFile(const char *filename)
int ErrorLineNum() const
Return the line where the error occurred, or zero if unknown.
Definition tinyxml2.h:1838
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition tinyxml2.h:1861
bool Error() const
Return true if there was an error parsing the document.
Definition tinyxml2.h:1819
void PrintError() const
A (trivial) utility function that prints the ErrorStr() to stdout.
static const char * ErrorIDToName(XMLError errorID)
XMLDeclaration * NewDeclaration(const char *text=0)
char * Identify(char *p, XMLNode **node)
XMLDocument(bool processEntities=true, Whitespace whitespaceMode=PRESERVE_WHITESPACE)
constructor
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition tinyxml2.h:1668
XMLElement * NewElement(const char *name)
XMLText * NewText(const char *text)
const XMLElement * RootElement() const
Definition tinyxml2.h:1750
virtual bool Accept(XMLVisitor *visitor) const
void Clear()
Clear the document, resetting it to the initial state.
XMLError Parse(const char *xml, size_t nBytes=(size_t)(-1))
XMLError SaveFile(FILE *fp, bool compact=false)
XMLUnknown * NewUnknown(const char *text)
XMLComment * NewComment(const char *comment)
XMLError ErrorID() const
Return the errorID.
Definition tinyxml2.h:1823
virtual const XMLDocument * ToDocument() const
Definition tinyxml2.h:1672
void DeepCopy(XMLDocument *target) const
virtual bool Accept(XMLVisitor *visitor) const
void DeleteAttribute(const char *name)
unsigned UnsignedAttribute(const char *name, unsigned defaultValue=0) const
See IntAttribute()
bool BoolText(bool defaultValue=false) const
See QueryIntText()
int IntAttribute(const char *name, int defaultValue=0) const
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition tinyxml2.h:1430
virtual bool ShallowEqual(const XMLNode *compare) const
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition tinyxml2.h:1263
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
void SetText(int64_t value)
Convenience method for setting text inside an element. See SetText() for important limitations.
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition tinyxml2.h:1447
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1358
void SetText(int value)
Convenience method for setting text inside an element. See SetText() for important limitations.
int64_t Int64Text(int64_t defaultValue=0) const
See QueryIntText()
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLError QueryFloatText(float *fval) const
See QueryIntText()
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1340
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition tinyxml2.h:1457
void SetText(double value)
Convenience method for setting text inside an element. See SetText() for important limitations.
virtual const XMLElement * ToElement() const
Definition tinyxml2.h:1270
float FloatText(float defaultValue=0) const
See QueryIntText()
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1374
double DoubleText(double defaultValue=0) const
See QueryIntText()
void SetText(bool value)
Convenience method for setting text inside an element. See SetText() for important limitations.
int QueryAttribute(const char *name, bool *value) const
Definition tinyxml2.h:1412
ElementClosingType ClosingType() const
Definition tinyxml2.h:1609
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
int QueryAttribute(const char *name, double *value) const
Definition tinyxml2.h:1416
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
void SetText(float value)
Convenience method for setting text inside an element. See SetText() for important limitations.
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition tinyxml2.h:1259
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
int IntText(int defaultValue=0) const
unsigned UnsignedText(unsigned defaultValue=0) const
See QueryIntText()
int QueryAttribute(const char *name, int64_t *value) const
Definition tinyxml2.h:1408
void SetText(const char *inText)
bool BoolAttribute(const char *name, bool defaultValue=false) const
See IntAttribute()
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition tinyxml2.h:1435
void SetText(unsigned value)
Convenience method for setting text inside an element. See SetText() for important limitations.
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition tinyxml2.h:1425
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1349
const char * Attribute(const char *name, const char *value=0) const
XMLError QueryIntAttribute(const char *name, int *value) const
Definition tinyxml2.h:1331
double DoubleAttribute(const char *name, double defaultValue=0) const
See IntAttribute()
int QueryAttribute(const char *name, float *value) const
Definition tinyxml2.h:1420
XMLError QueryIntText(int *ival) const
int QueryAttribute(const char *name, unsigned int *value) const
Definition tinyxml2.h:1404
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition tinyxml2.h:1267
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition tinyxml2.h:1452
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition tinyxml2.h:1441
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition tinyxml2.h:1468
int64_t Int64Attribute(const char *name, int64_t defaultValue=0) const
See IntAttribute()
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1366
int QueryAttribute(const char *name, int *value) const
Definition tinyxml2.h:1400
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition tinyxml2.h:1994
XMLHandle FirstChild()
Get the first child of this handle.
Definition tinyxml2.h:1990
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition tinyxml2.h:2031
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition tinyxml2.h:2035
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition tinyxml2.h:2039
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition tinyxml2.h:2023
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition tinyxml2.h:2027
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition tinyxml2.h:2006
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition tinyxml2.h:2002
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition tinyxml2.h:2010
XMLHandle LastChild()
Get the last child of this handle.
Definition tinyxml2.h:1998
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition tinyxml2.h:1981
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition tinyxml2.h:2018
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition tinyxml2.h:1975
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition tinyxml2.h:1984
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition tinyxml2.h:2014
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition tinyxml2.h:1978
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition tinyxml2.h:708
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition tinyxml2.h:821
virtual const XMLDeclaration * ToDeclaration() const
Definition tinyxml2.h:728
virtual bool ShallowEqual(const XMLNode *compare) const =0
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition tinyxml2.h:769
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name.
virtual const XMLComment * ToComment() const
Definition tinyxml2.h:722
XMLElement * FirstChildElement(const char *name=0)
Definition tinyxml2.h:782
bool NoChildren() const
Returns true if this node has no children.
Definition tinyxml2.h:764
virtual bool Accept(XMLVisitor *visitor) const =0
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition tinyxml2.h:686
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
virtual const XMLUnknown * ToUnknown() const
Definition tinyxml2.h:731
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition tinyxml2.h:696
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition tinyxml2.h:805
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLNode * InsertEndChild(XMLNode *addThis)
XMLNode * DeepClone(XMLDocument *target) const
virtual const XMLElement * ToElement() const
Definition tinyxml2.h:716
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition tinyxml2.h:700
void SetValue(const char *val, bool staticMem=false)
virtual const XMLDocument * ToDocument() const
Definition tinyxml2.h:725
XMLElement * LastChildElement(const char *name=0)
Definition tinyxml2.h:800
XMLElement * PreviousSiblingElement(const char *name=0)
Definition tinyxml2.h:816
const XMLElement * LastChildElement(const char *name=0) const
XMLElement * NextSiblingElement(const char *name=0)
Definition tinyxml2.h:832
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition tinyxml2.h:755
const char * Value() const
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition tinyxml2.h:787
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition tinyxml2.h:712
virtual char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition tinyxml2.h:704
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
Definition tinyxml2.h:752
const XMLElement * FirstChildElement(const char *name=0) const
XMLNode * LinkEndChild(XMLNode *addThis)
Definition tinyxml2.h:845
void DeleteChild(XMLNode *node)
void SetUserData(void *userData)
Definition tinyxml2.h:939
virtual const XMLText * ToText() const
Definition tinyxml2.h:719
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition tinyxml2.h:681
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition tinyxml2.h:692
virtual bool CompactMode(const XMLElement &)
Definition tinyxml2.h:2244
void OpenElement(const char *name, bool compactMode=false)
void Write(const char *data, size_t size)
void PushAttribute(const char *name, int value)
void PushUnknown(const char *value)
void PushText(double value)
Add a text node from a double.
virtual bool Visit(const XMLComment &comment)
Visit a comment node.
virtual bool Visit(const XMLDeclaration &declaration)
Visit a declaration.
void PushText(bool value)
Add a text node from a bool.
virtual bool Visit(const XMLText &text)
Visit a text node.
void PushText(const char *text, bool cdata=false)
Add a text node.
void PushAttribute(const char *name, int64_t value)
virtual void PrintSpace(int depth)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:2206
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
DynArray< const char *, 10 > _stack
Definition tinyxml2.h:2257
void PushText(unsigned value)
Add a text node from an unsigned.
void PushText(float value)
Add a text node from a float.
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
void PushAttribute(const char *name, bool value)
void Write(const char *data)
Definition tinyxml2.h:2252
void PushText(int value)
Add a text node from an integer.
void Print(const char *format,...)
void PushHeader(bool writeBOM, bool writeDeclaration)
void PushAttribute(const char *name, double value)
virtual bool VisitExit(const XMLElement &element)
Visit an element.
void PushAttribute(const char *name, unsigned value)
virtual bool Visit(const XMLUnknown &unknown)
Visit an unknown node.
virtual bool VisitEnter(const XMLElement &element, const XMLAttribute *attribute)
Visit an element.
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
void PushText(int64_t value)
Add a text node from an unsigned.
void PushDeclaration(const char *value)
void PushComment(const char *comment)
Add a comment.
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
bool CData() const
Returns true if this is a CDATA text element.
Definition tinyxml2.h:1009
virtual bool ShallowEqual(const XMLNode *compare) const
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition tinyxml2.h:1005
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition tinyxml2.h:997
virtual bool Accept(XMLVisitor *visitor) const
virtual const XMLText * ToText() const
Definition tinyxml2.h:1000
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual const XMLUnknown * ToUnknown() const
Definition tinyxml2.h:1112
virtual bool Accept(XMLVisitor *visitor) const
char * ParseDeep(char *p, StrPair *parentEndTag, int *curLineNumPtr)
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition tinyxml2.h:1109
static const char * SkipWhiteSpace(const char *p, int *curLineNumPtr)
Definition tinyxml2.h:560
static void ToStr(bool v, char *buffer, int bufferSize)
static bool IsUTF8Continuation(char p)
Definition tinyxml2.h:610
static bool ToInt64(const char *str, int64_t *value)
static void ToStr(float v, char *buffer, int bufferSize)
static bool ToBool(const char *str, bool *value)
static void ToStr(int64_t v, char *buffer, int bufferSize)
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
Definition tinyxml2.h:600
static char * SkipWhiteSpace(char *p, int *curLineNumPtr)
Definition tinyxml2.h:572
static void SetBoolSerialization(const char *writeTrue, const char *writeFalse)
static void ToStr(double v, char *buffer, int bufferSize)
static void ToStr(int v, char *buffer, int bufferSize)
static bool IsNameChar(unsigned char ch)
Definition tinyxml2.h:593
static bool ToUnsigned(const char *str, unsigned *value)
static const char * ReadBOM(const char *p, bool *hasBOM)
static bool ToDouble(const char *str, double *value)
static bool IsNameStartChar(unsigned char ch)
Definition tinyxml2.h:582
static const char * GetCharacterRef(const char *p, char *value, int *length)
static bool ToFloat(const char *str, float *value)
static bool IsWhiteSpace(char p)
Definition tinyxml2.h:578
static bool ToInt(const char *str, int *value)
static void ToStr(unsigned v, char *buffer, int bufferSize)
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition tinyxml2.h:510
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:492
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition tinyxml2.h:501
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition tinyxml2.h:518
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:496
virtual bool Visit(const XMLText &)
Visit a text node.
Definition tinyxml2.h:514
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition tinyxml2.h:505
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition tinyxml2.h:522
static const char * ALLOCATION_TAG
Definition tinyxml2.h:132
std::enable_if<!std::is_polymorphic< T >::value >::type Delete(T *pointerToT)
Definition AWSMemory.h:100