24 #ifndef TINYXML2_INCLUDED
25 #define TINYXML2_INCLUDED
27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
53 #if defined( _DEBUG ) || defined (__DEBUG__)
54 # ifndef TINYXML2_DEBUG
55 # define TINYXML2_DEBUG
60 # pragma warning(push)
61 # pragma warning(disable: 4251)
65 # ifdef TINYXML2_EXPORT
66 # define TINYXML2_LIB __declspec(dllexport)
67 # elif defined(TINYXML2_IMPORT)
68 # define TINYXML2_LIB __declspec(dllimport)
73 # define TINYXML2_LIB __attribute__((visibility("default")))
79 #if !defined(TIXMLASSERT)
80 #if defined(TINYXML2_DEBUG)
81 # if defined(_MSC_VER)
83 # define TIXMLASSERT( x ) do { if ( !((void)0,(x))) { __debugbreak(); } } while(false)
84 # elif defined (ANDROID_NDK)
85 # include <android/log.h>
86 # define TIXMLASSERT( x ) do { if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } } while(false)
89 # define TIXMLASSERT assert
92 # define TIXMLASSERT( x ) do {} while(false)
99 static const int TIXML2_MAJOR_VERSION = 11;
100 static const int TIXML2_MINOR_VERSION = 0;
101 static const int TIXML2_PATCH_VERSION = 0;
103 #define TINYXML2_MAJOR_VERSION 11
104 #define TINYXML2_MINOR_VERSION 0
105 #define TINYXML2_PATCH_VERSION 0
112 static const int TINYXML2_MAX_ELEMENT_DEPTH = 500;
121 class XMLDeclaration;
133 class TINYXML2_LIB StrPair
137 NEEDS_ENTITY_PROCESSING = 0x01,
138 NEEDS_NEWLINE_NORMALIZATION = 0x02,
139 NEEDS_WHITESPACE_COLLAPSING = 0x04,
141 TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
142 TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
144 ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
145 ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
146 COMMENT = NEEDS_NEWLINE_NORMALIZATION
149 StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
152 void Set(
char* start,
char* end,
int flags ) {
153 TIXMLASSERT( start );
158 _flags = flags | NEEDS_FLUSH;
161 const char* GetStr();
164 return _start == _end;
167 void SetInternedStr(
const char* str ) {
169 _start =
const_cast<char*
>(str);
172 void SetStr(
const char* str,
int flags=0 );
174 char* ParseText(
char* in,
const char* endTag,
int strFlags,
int* curLineNumPtr );
175 char* ParseName(
char* in );
177 void TransferTo( StrPair* other );
181 void CollapseWhitespace();
192 StrPair(
const StrPair& other );
193 void operator=(
const StrPair& other );
202 template <
class T,
size_t INITIAL_SIZE>
208 _allocated( INITIAL_SIZE ),
214 if ( _mem != _pool ) {
224 TIXMLASSERT( _size < INT_MAX );
225 EnsureCapacity( _size+1 );
230 T* PushArr(
size_t count ) {
231 TIXMLASSERT( _size <= SIZE_MAX - count );
232 EnsureCapacity( _size+count );
233 T* ret = &_mem[_size];
239 TIXMLASSERT( _size > 0 );
244 void PopArr(
size_t count ) {
245 TIXMLASSERT( _size >= count );
253 T& operator[](
size_t i) {
254 TIXMLASSERT( i < _size );
258 const T& operator[](
size_t i)
const {
259 TIXMLASSERT( i < _size );
263 const T& PeekTop()
const {
264 TIXMLASSERT( _size > 0 );
265 return _mem[ _size - 1];
268 size_t Size()
const {
269 TIXMLASSERT( _size >= 0 );
273 size_t Capacity()
const {
274 TIXMLASSERT( _allocated >= INITIAL_SIZE );
278 void SwapRemove(
size_t i) {
279 TIXMLASSERT(i < _size);
280 TIXMLASSERT(_size > 0);
281 _mem[i] = _mem[_size - 1];
285 const T* Mem()
const {
296 DynArray(
const DynArray& );
297 void operator=(
const DynArray& );
299 void EnsureCapacity(
size_t cap ) {
300 TIXMLASSERT( cap > 0 );
301 if ( cap > _allocated ) {
302 TIXMLASSERT( cap <= SIZE_MAX / 2 /
sizeof(T));
303 const size_t newAllocated = cap * 2;
304 T* newMem =
new T[newAllocated];
305 TIXMLASSERT( newAllocated >= _size );
306 memcpy( newMem, _mem,
sizeof(T) * _size );
307 if ( _mem != _pool ) {
311 _allocated = newAllocated;
316 T _pool[INITIAL_SIZE];
330 virtual ~MemPool() {}
332 virtual size_t ItemSize()
const = 0;
333 virtual void* Alloc() = 0;
334 virtual void Free(
void* ) = 0;
335 virtual void SetTracked() = 0;
342 template<
size_t ITEM_SIZE >
343 class MemPoolT :
public MemPool
346 MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
348 MemPoolT< ITEM_SIZE >::Clear();
353 while( !_blockPtrs.Empty()) {
354 Block* lastBlock = _blockPtrs.Pop();
364 virtual size_t ItemSize()
const override {
367 size_t CurrentAllocs()
const {
368 return _currentAllocs;
371 virtual void* Alloc()
override{
374 Block* block =
new Block;
375 _blockPtrs.Push( block );
377 Item* blockItems = block->items;
378 for(
size_t i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
379 blockItems[i].next = &(blockItems[i + 1]);
381 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
384 Item*
const result = _root;
385 TIXMLASSERT( result != 0 );
389 if ( _currentAllocs > _maxAllocs ) {
390 _maxAllocs = _currentAllocs;
397 virtual void Free(
void* mem )
override {
402 Item* item =
static_cast<Item*
>( mem );
403 #ifdef TINYXML2_DEBUG
404 memset( item, 0xfe,
sizeof( *item ) );
409 void Trace(
const char* name ) {
410 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
411 name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
412 ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
415 void SetTracked()
override {
419 size_t Untracked()
const {
434 enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
437 MemPoolT(
const MemPoolT& );
438 void operator=(
const MemPoolT& );
442 char itemData[
static_cast<size_t>(ITEM_SIZE)];
445 Item items[ITEMS_PER_BLOCK];
447 DynArray< Block*, 10 > _blockPtrs;
450 size_t _currentAllocs;
522 XML_WRONG_ATTRIBUTE_TYPE,
523 XML_ERROR_FILE_NOT_FOUND,
524 XML_ERROR_FILE_COULD_NOT_BE_OPENED,
525 XML_ERROR_FILE_READ_ERROR,
526 XML_ERROR_PARSING_ELEMENT,
527 XML_ERROR_PARSING_ATTRIBUTE,
528 XML_ERROR_PARSING_TEXT,
529 XML_ERROR_PARSING_CDATA,
530 XML_ERROR_PARSING_COMMENT,
531 XML_ERROR_PARSING_DECLARATION,
532 XML_ERROR_PARSING_UNKNOWN,
533 XML_ERROR_EMPTY_DOCUMENT,
534 XML_ERROR_MISMATCHED_ELEMENT,
536 XML_CAN_NOT_CONVERT_TEXT,
538 XML_ELEMENT_DEPTH_EXCEEDED,
547 class TINYXML2_LIB XMLUtil
550 static const char* SkipWhiteSpace(
const char* p,
int* curLineNumPtr ) {
553 while( IsWhiteSpace(*p) ) {
554 if (curLineNumPtr && *p ==
'\n') {
562 static char* SkipWhiteSpace(
char*
const p,
int* curLineNumPtr ) {
563 return const_cast<char*
>( SkipWhiteSpace(
const_cast<const char*
>(p), curLineNumPtr ) );
568 static bool IsWhiteSpace(
char p ) {
569 return !IsUTF8Continuation(p) && isspace(
static_cast<unsigned char>(p) );
572 inline static bool IsNameStartChar(
unsigned char ch ) {
577 if ( isalpha( ch ) ) {
580 return ch ==
':' || ch ==
'_';
583 inline static bool IsNameChar(
unsigned char ch ) {
584 return IsNameStartChar( ch )
590 inline static bool IsPrefixHex(
const char* p) {
591 p = SkipWhiteSpace(p, 0);
592 return p && *p ==
'0' && ( *(p + 1) ==
'x' || *(p + 1) ==
'X');
595 inline static bool StringEqual(
const char* p,
const char* q,
int nChar=INT_MAX ) {
601 TIXMLASSERT( nChar >= 0 );
602 return strncmp( p, q,
static_cast<size_t>(nChar) ) == 0;
605 inline static bool IsUTF8Continuation(
const char p ) {
606 return ( p & 0x80 ) != 0;
609 static const char* ReadBOM(
const char* p,
bool* hasBOM );
612 static const char* GetCharacterRef(
const char* p,
char* value,
int* length );
613 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length );
616 static void ToStr(
int v,
char* buffer,
int bufferSize );
617 static void ToStr(
unsigned v,
char* buffer,
int bufferSize );
618 static void ToStr(
bool v,
char* buffer,
int bufferSize );
619 static void ToStr(
float v,
char* buffer,
int bufferSize );
620 static void ToStr(
double v,
char* buffer,
int bufferSize );
621 static void ToStr(int64_t v,
char* buffer,
int bufferSize);
622 static void ToStr(uint64_t v,
char* buffer,
int bufferSize);
625 static bool ToInt(
const char* str,
int* value );
626 static bool ToUnsigned(
const char* str,
unsigned* value );
627 static bool ToBool(
const char* str,
bool* value );
628 static bool ToFloat(
const char* str,
float* value );
629 static bool ToDouble(
const char* str,
double* value );
630 static bool ToInt64(
const char* str, int64_t* value);
631 static bool ToUnsigned64(
const char* str, uint64_t* value);
637 static void SetBoolSerialization(
const char* writeTrue,
const char* writeFalse);
640 static const char* writeBoolTrue;
641 static const char* writeBoolFalse;
678 TIXMLASSERT( _document );
683 TIXMLASSERT( _document );
715 virtual const XMLText* ToText()
const {
718 virtual const XMLComment* ToComment()
const {
721 virtual const XMLDocument* ToDocument()
const {
724 virtual const XMLDeclaration* ToDeclaration()
const {
727 virtual const XMLUnknown* ToUnknown()
const {
733 int ChildElementCount(
const char *value)
const;
735 int ChildElementCount()
const;
751 void SetValue(
const char* val,
bool staticMem=
false );
784 XMLElement* FirstChildElement(
const char* name = 0 ) {
785 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement( name ));
802 XMLElement* LastChildElement(
const char* name = 0 ) {
803 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name) );
818 XMLElement* PreviousSiblingElement(
const char* name = 0 ) {
819 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement( name ) );
834 XMLElement* NextSiblingElement(
const char* name = 0 ) {
835 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement( name ) );
848 return InsertEndChild( addThis );
954 virtual char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
958 mutable StrPair _value;
972 static void DeleteNode(
XMLNode* node );
973 void InsertChildPreamble(
XMLNode* insertThis )
const;
974 const XMLElement* ToElementWithName(
const char* name )
const;
1002 virtual const XMLText* ToText()
const override {
1022 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr )
override;
1027 XMLText(
const XMLText& );
1028 XMLText& operator=(
const XMLText& );
1040 virtual const XMLComment* ToComment()
const override {
1053 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr)
override;
1092 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr )
override;
1114 virtual const XMLUnknown* ToUnknown()
const override {
1127 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr )
override;
1170 int64_t Int64Value()
const {
1172 QueryInt64Value(&i);
1176 uint64_t Unsigned64Value()
const {
1178 QueryUnsigned64Value(&i);
1185 QueryUnsignedValue( &i );
1191 QueryBoolValue( &b );
1197 QueryDoubleValue( &d );
1203 QueryFloatValue( &f );
1243 enum { BUF_SIZE = 200 };
1245 XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1246 virtual ~XMLAttribute() {}
1248 XMLAttribute(
const XMLAttribute& );
1249 void operator=(
const XMLAttribute& );
1250 void SetName(
const char* name );
1252 char* ParseDeep(
char* p,
bool processEntities,
int* curLineNumPtr );
1254 mutable StrPair _name;
1255 mutable StrPair _value;
1257 XMLAttribute* _next;
1275 void SetName(
const char* str,
bool staticMem=
false ) {
1276 SetValue( str, staticMem );
1282 virtual const XMLElement* ToElement()
const override {
1310 const char*
Attribute(
const char* name,
const char* value=0 )
const;
1348 return XML_NO_ATTRIBUTE;
1357 return XML_NO_ATTRIBUTE;
1366 return XML_NO_ATTRIBUTE;
1375 return XML_NO_ATTRIBUTE;
1384 return XML_NO_ATTRIBUTE;
1392 return XML_NO_ATTRIBUTE;
1400 return XML_NO_ATTRIBUTE;
1409 return XML_NO_ATTRIBUTE;
1411 *value = a->
Value();
1435 return QueryIntAttribute( name, value );
1438 XMLError QueryAttribute(
const char* name,
unsigned int* value )
const {
1439 return QueryUnsignedAttribute( name, value );
1442 XMLError QueryAttribute(
const char* name, int64_t* value)
const {
1443 return QueryInt64Attribute(name, value);
1446 XMLError QueryAttribute(
const char* name, uint64_t* value)
const {
1447 return QueryUnsigned64Attribute(name, value);
1450 XMLError QueryAttribute(
const char* name,
bool* value )
const {
1451 return QueryBoolAttribute( name, value );
1454 XMLError QueryAttribute(
const char* name,
double* value )
const {
1455 return QueryDoubleAttribute( name, value );
1458 XMLError QueryAttribute(
const char* name,
float* value )
const {
1459 return QueryFloatAttribute( name, value );
1462 XMLError QueryAttribute(
const char* name,
const char** value)
const {
1463 return QueryStringAttribute(name, value);
1517 return _rootAttribute;
1642 int IntText(
int defaultValue = 0)
const;
1673 enum ElementClosingType {
1678 ElementClosingType ClosingType()
const {
1679 return _closingType;
1685 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr )
override;
1693 XMLAttribute* FindOrCreateAttribute(
const char* name );
1694 char* ParseAttributes(
char* p,
int* curLineNumPtr );
1695 static void DeleteAttribute(
XMLAttribute* attribute );
1698 enum { BUF_SIZE = 200 };
1699 ElementClosingType _closingType;
1708 PRESERVE_WHITESPACE,
1709 COLLAPSE_WHITESPACE,
1731 XMLDocument(
bool processEntities =
true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
1735 TIXMLASSERT(
this == _document );
1738 virtual const XMLDocument* ToDocument()
const override {
1739 TIXMLASSERT(
this == _document );
1753 XMLError
Parse(
const char* xml,
size_t nBytes=
static_cast<size_t>(-1) );
1780 XMLError
SaveFile(
const char* filename,
bool compact =
false );
1791 bool ProcessEntities()
const {
1792 return _processEntities;
1794 Whitespace WhitespaceMode()
const {
1795 return _whitespaceMode;
1814 return FirstChildElement();
1817 return FirstChildElement();
1885 return _errorID != XML_SUCCESS;
1891 const char* ErrorName()
const;
1892 static const char* ErrorIDToName(XMLError errorID);
1905 return _errorLineNum;
1921 char* Identify(
char* p,
XMLNode** node,
bool first );
1924 void MarkInUse(
const XMLNode*
const);
1938 bool _processEntities;
1940 Whitespace _whitespaceMode;
1941 mutable StrPair _errorStr;
1944 int _parseCurLineNum;
1952 DynArray<XMLNode*, 10> _unlinked;
1956 MemPoolT<
sizeof(
XMLText) > _textPool;
1959 static const char* _errorNames[XML_ERROR_COUNT];
1963 void SetError( XMLError error,
int lineNum,
const char* format, ... );
1968 class DepthTracker {
1971 this->_document = document;
1972 document->PushDepth();
1975 _document->PopDepth();
1978 XMLDocument * _document;
1983 template<
class NodeType,
size_t PoolElementSize>
1984 NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
1987 template<
class NodeType,
size_t PoolElementSize>
1988 inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
1990 TIXMLASSERT(
sizeof( NodeType ) == PoolElementSize );
1991 TIXMLASSERT(
sizeof( NodeType ) == pool.ItemSize() );
1992 NodeType* returnNode =
new (pool.Alloc()) NodeType(
this );
1993 TIXMLASSERT( returnNode );
1994 returnNode->_memPool = &pool;
1996 _unlinked.Push(returnNode);
2075 return XMLHandle( _node ? _node->FirstChild() : 0 );
2079 return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
2083 return XMLHandle( _node ? _node->LastChild() : 0 );
2087 return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2091 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2095 return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2099 return XMLHandle( _node ? _node->NextSibling() : 0 );
2103 return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2112 return ( _node ? _node->ToElement() : 0 );
2116 return ( _node ? _node->ToText() : 0 );
2120 return ( _node ? _node->ToUnknown() : 0 );
2124 return ( _node ? _node->ToDeclaration() : 0 );
2154 const XMLConstHandle FirstChildElement(
const char* name = 0 )
const {
2155 return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2160 const XMLConstHandle LastChildElement(
const char* name = 0 )
const {
2161 return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2166 const XMLConstHandle PreviousSiblingElement(
const char* name = 0 )
const {
2167 return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2172 const XMLConstHandle NextSiblingElement(
const char* name = 0 )
const {
2173 return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2177 const XMLNode* ToNode()
const {
2181 return ( _node ? _node->ToElement() : 0 );
2183 const XMLText* ToText()
const {
2184 return ( _node ? _node->ToText() : 0 );
2187 return ( _node ? _node->ToUnknown() : 0 );
2190 return ( _node ? _node->ToDeclaration() : 0 );
2260 void PushAttribute(
const char* name,
int value );
2261 void PushAttribute(
const char* name,
unsigned value );
2262 void PushAttribute(
const char* name, int64_t value );
2263 void PushAttribute(
const char* name, uint64_t value );
2264 void PushAttribute(
const char* name,
bool value );
2265 void PushAttribute(
const char* name,
double value );
2289 void PushDeclaration(
const char* value );
2290 void PushUnknown(
const char* value );
2310 return _buffer.Mem();
2318 return _buffer.Size();
2327 _firstElement = resetToFirstElement;
2331 virtual bool CompactMode(
const XMLElement& ) {
return _compactMode; }
2337 virtual void Print(
const char* format, ... );
2338 virtual void Write(
const char* data,
size_t size );
2339 virtual void Putc(
char ch );
2341 inline void Write(
const char* data) { Write(data, strlen(data)); }
2343 void SealElementIfJustOpened();
2344 bool _elementJustOpened;
2345 DynArray< const char*, 10 > _stack;
2352 void PrepareForNewNode(
bool compactMode );
2353 void PrintString(
const char*,
bool restrictedEntitySet );
2359 bool _processEntities;
2366 bool _entityFlag[ENTITY_RANGE];
2367 bool _restrictedEntityFlag[ENTITY_RANGE];
2369 DynArray< char, 20 > _buffer;
2372 XMLPrinter(
const XMLPrinter& );
2373 XMLPrinter& operator=(
const XMLPrinter& );
2379 #if defined(_MSC_VER)
2380 # pragma warning(pop)
Definition: tinyxml2.h:1143
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition: tinyxml2.h:1153
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1183
void SetAttribute(uint64_t value)
Set the attribute to value.
const char * Value() const
The value of the attribute.
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1201
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
void SetAttribute(const char *value)
Set the attribute to a string value.
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1195
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
XMLError QueryIntValue(int *value) const
void SetAttribute(int64_t value)
Set the attribute to value.
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1189
void SetAttribute(double value)
Set the attribute to value.
void SetAttribute(bool value)
Set the attribute to value.
const char * Name() const
The name of the attribute.
void SetAttribute(int value)
Set the attribute to value.
int IntValue() const
Definition: tinyxml2.h:1164
void SetAttribute(unsigned value)
Set the attribute to value.
void SetAttribute(float value)
Set the attribute to value.
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1156
XMLError QueryUnsigned64Value(uint64_t *value) const
See QueryIntValue.
Definition: tinyxml2.h:2137
Definition: tinyxml2.h:1073
virtual XMLDeclaration * ToDeclaration() override
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1076
virtual bool ShallowEqual(const XMLNode *compare) const override
virtual XMLNode * ShallowClone(XMLDocument *document) const override
virtual bool Accept(XMLVisitor *visitor) const override
Definition: tinyxml2.h:1720
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1806
void PrintError() const
A (trivial) utility function that prints the ErrorStr() to stdout.
virtual XMLNode * ShallowClone(XMLDocument *) const override
Definition: tinyxml2.h:1926
XMLError LoadFile(const char *filename)
bool HasBOM() const
Definition: tinyxml2.h:1801
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1884
void ClearError()
Clears the error flags.
XMLUnknown * NewUnknown(const char *text)
int ErrorLineNum() const
Return the line where the error occurred, or zero if unknown.
Definition: tinyxml2.h:1903
XMLDocument(bool processEntities=true, Whitespace whitespaceMode=PRESERVE_WHITESPACE)
constructor
XMLError LoadFile(FILE *)
void Clear()
Clear the document, resetting it to the initial state.
XMLError SaveFile(const char *filename, bool compact=false)
virtual bool Accept(XMLVisitor *visitor) const override
void Print(XMLPrinter *streamer=0) const
XMLElement * NewElement(const char *name)
XMLError SaveFile(FILE *fp, bool compact=false)
XMLText * NewText(const char *text)
void DeleteNode(XMLNode *node)
virtual bool ShallowEqual(const XMLNode *) const override
Definition: tinyxml2.h:1929
virtual XMLDocument * ToDocument() override
Safely cast to a Document, or null.
Definition: tinyxml2.h:1734
XMLElement * RootElement()
Definition: tinyxml2.h:1813
const char * ErrorStr() const
XMLComment * NewComment(const char *comment)
XMLDeclaration * NewDeclaration(const char *text=0)
XMLError Parse(const char *xml, size_t nBytes=static_cast< size_t >(-1))
void DeepCopy(XMLDocument *target) const
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1888
Definition: tinyxml2.h:1267
double DoubleAttribute(const char *name, double defaultValue=0) const
See IntAttribute()
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1467
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1372
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1381
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
XMLText * InsertNewText(const char *text)
See InsertNewChildElement()
void SetText(const char *inText)
uint64_t Unsigned64Attribute(const char *name, uint64_t defaultValue=0) const
See IntAttribute()
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1500
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1354
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1516
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
float FloatText(float defaultValue=0) const
See QueryIntText()
unsigned UnsignedText(unsigned defaultValue=0) const
See QueryIntText()
void SetText(float value)
Convenience method for setting text inside an element. See SetText() for important limitations.
bool BoolAttribute(const char *name, bool defaultValue=false) const
See IntAttribute()
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1505
XMLError QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1434
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1389
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1271
int64_t Int64Attribute(const char *name, int64_t defaultValue=0) const
See IntAttribute()
void SetText(double value)
Convenience method for setting text inside an element. See SetText() for important limitations.
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
bool BoolText(bool defaultValue=false) const
See QueryIntText()
const char * GetText() const
void SetText(uint64_t value)
Convenience method for setting text inside an element. See SetText() for important limitations.
const char * Attribute(const char *name, const char *value=0) const
virtual XMLNode * ShallowClone(XMLDocument *document) const override
void SetText(int64_t value)
Convenience method for setting text inside an element. See SetText() for important limitations.
void SetText(unsigned value)
Convenience method for setting text inside an element. See SetText() for important limitations.
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1363
double DoubleText(double defaultValue=0) const
See QueryIntText()
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1345
XMLError QueryIntText(int *ival) const
int IntAttribute(const char *name, int defaultValue=0) const
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1275
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1495
int64_t Int64Text(int64_t defaultValue=0) const
See QueryIntText()
virtual bool ShallowEqual(const XMLNode *compare) const override
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1472
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1483
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
virtual XMLElement * ToElement() override
Safely cast to an Element, or null.
Definition: tinyxml2.h:1279
XMLElement * InsertNewChildElement(const char *name)
XMLError QueryUnsigned64Text(uint64_t *uval) const
See QueryIntText()
XMLUnknown * InsertNewUnknown(const char *text)
See InsertNewChildElement()
virtual bool Accept(XMLVisitor *visitor) const override
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1397
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1489
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1406
XMLDeclaration * InsertNewDeclaration(const char *text)
See InsertNewChildElement()
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1477
void SetText(bool value)
Convenience method for setting text inside an element. See SetText() for important limitations.
XMLComment * InsertNewComment(const char *comment)
See InsertNewChildElement()
void SetText(int value)
Convenience method for setting text inside an element. See SetText() for important limitations.
void DeleteAttribute(const char *name)
uint64_t Unsigned64Text(uint64_t defaultValue=0) const
See QueryIntText()
XMLError QueryFloatText(float *fval) const
See QueryIntText()
unsigned UnsignedAttribute(const char *name, unsigned defaultValue=0) const
See IntAttribute()
Definition: tinyxml2.h:2056
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:2107
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:2123
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:2090
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:2086
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:2074
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:2111
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:2115
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:2078
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:2068
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:2094
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:2059
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:2082
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:2062
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:2119
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:2098
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:2102
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:2065
Definition: tinyxml2.h:671
void SetUserData(void *userData)
Definition: tinyxml2.h:941
void SetValue(const char *val, bool staticMem=false)
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
const XMLElement * LastChildElement(const char *name=0) const
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:704
const XMLElement * FirstChildElement(const char *name=0) const
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:677
void DeleteChild(XMLNode *node)
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:692
XMLNode * DeepClone(XMLDocument *target) const
const char * Value() const
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:823
virtual bool ShallowEqual(const XMLNode *compare) const =0
void * GetUserData() const
Definition: tinyxml2.h:948
virtual bool Accept(XMLVisitor *visitor) const =0
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:700
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:708
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name.
XMLNode * InsertFirstChild(XMLNode *addThis)
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
Definition: tinyxml2.h:754
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:789
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:688
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:807
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:766
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:757
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:771
XMLNode * InsertEndChild(XMLNode *addThis)
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:682
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:696
Definition: tinyxml2.h:2241
virtual void PrintSpace(int depth)
void PushHeader(bool writeBOM, bool writeDeclaration)
const char * CStr() const
Definition: tinyxml2.h:2309
void PushText(const char *text, bool cdata=false)
Add a text node.
void PushText(float value)
Add a text node from a float.
void OpenElement(const char *name, bool compactMode=false)
virtual bool VisitExit(const XMLDocument &) override
Visit a document.
Definition: tinyxml2.h:2293
virtual bool Visit(const XMLUnknown &unknown) override
Visit an unknown node.
void PushText(int value)
Add a text node from an integer.
void PushText(bool value)
Add a text node from a bool.
virtual bool VisitEnter(const XMLElement &element, const XMLAttribute *attribute) override
Visit an element.
void PushText(uint64_t value)
Add a text node from an unsigned 64bit integer.
virtual bool Visit(const XMLDeclaration &declaration) override
Visit a declaration.
void PushText(unsigned value)
Add a text node from an unsigned.
void ClearBuffer(bool resetToFirstElement=true)
Definition: tinyxml2.h:2324
virtual bool VisitEnter(const XMLDocument &) override
Visit a document.
virtual bool Visit(const XMLComment &comment) override
Visit a comment node.
size_t CStrSize() const
Definition: tinyxml2.h:2317
void PushText(int64_t value)
Add a text node from a signed 64bit integer.
virtual bool VisitExit(const XMLElement &element) override
Visit an element.
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
void PushText(double value)
Add a text node from a double.
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
virtual bool Visit(const XMLText &text) override
Visit a text node.
void PushComment(const char *comment)
Add a comment.
Definition: tinyxml2.h:994
virtual bool ShallowEqual(const XMLNode *compare) const override
virtual XMLText * ToText() override
Safely cast to Text, or null.
Definition: tinyxml2.h:999
virtual bool Accept(XMLVisitor *visitor) const override
virtual XMLNode * ShallowClone(XMLDocument *document) const override
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:1011
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:1007
Definition: tinyxml2.h:1108
virtual bool ShallowEqual(const XMLNode *compare) const override
virtual XMLUnknown * ToUnknown() override
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1111
virtual bool Accept(XMLVisitor *visitor) const override
virtual XMLNode * ShallowClone(XMLDocument *document) const override
Definition: tinyxml2.h:478
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:513
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:487
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:496
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:483
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:509
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:501
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:505
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:492