24#ifndef TINYXML2_INCLUDED
25#define TINYXML2_INCLUDED
27#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
56#if defined( _DEBUG ) || defined (__DEBUG__)
57# ifndef TINYXML2_DEBUG
58# define TINYXML2_DEBUG
64# pragma warning(disable: 4251)
68# ifdef TINYXML2_EXPORT
69# define TINYXML2_LIB __declspec(dllexport)
70# elif defined(TINYXML2_IMPORT)
71# define TINYXML2_LIB __declspec(dllimport)
76# define TINYXML2_LIB __attribute__((visibility("default")))
82#if defined(TINYXML2_DEBUG)
85# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
86# elif defined (ANDROID_NDK)
87# include <android/log.h>
88# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
91# define TIXMLASSERT assert
94# define TIXMLASSERT( x ) {}
101static const int TIXML2_MAJOR_VERSION = 6;
102static const int TIXML2_MINOR_VERSION = 2;
103static const int TIXML2_PATCH_VERSION = 0;
105#define TINYXML2_MAJOR_VERSION 6
106#define TINYXML2_MINOR_VERSION 2
107#define TINYXML2_PATCH_VERSION 0
114static const int TINYXML2_MAX_ELEMENT_DEPTH = 100;
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=( StrPair& other );
202template <
class T,
int INITIAL_SIZE>
208 _allocated( INITIAL_SIZE ),
214 if ( _mem != _pool ) {
224 TIXMLASSERT( _size < INT_MAX );
225 EnsureCapacity( _size+1 );
230 T* PushArr(
int count ) {
231 TIXMLASSERT( count >= 0 );
232 TIXMLASSERT( _size <= INT_MAX - count );
233 EnsureCapacity( _size+count );
234 T* ret = &_mem[_size];
240 TIXMLASSERT( _size > 0 );
245 void PopArr(
int count ) {
246 TIXMLASSERT( _size >= count );
254 T& operator[](
int i) {
255 TIXMLASSERT( i>= 0 && i < _size );
259 const T& operator[](
int i)
const {
260 TIXMLASSERT( i>= 0 && i < _size );
264 const T& PeekTop()
const {
265 TIXMLASSERT( _size > 0 );
266 return _mem[ _size - 1];
270 TIXMLASSERT( _size >= 0 );
274 int Capacity()
const {
275 TIXMLASSERT( _allocated >= INITIAL_SIZE );
279 void SwapRemove(
int i) {
280 TIXMLASSERT(i >= 0 && i < _size);
281 TIXMLASSERT(_size > 0);
282 _mem[i] = _mem[_size - 1];
286 const T* Mem()
const {
297 DynArray(
const DynArray& );
298 void operator=(
const DynArray& );
300 void EnsureCapacity(
int cap ) {
301 TIXMLASSERT( cap > 0 );
302 if ( cap > _allocated ) {
303 TIXMLASSERT( cap <= INT_MAX / 2 );
304 int newAllocated = cap * 2;
305 T* newMem =
new T[newAllocated];
306 TIXMLASSERT( newAllocated >= _size );
307 memcpy( newMem, _mem,
sizeof(T)*_size );
308 if ( _mem != _pool ) {
312 _allocated = newAllocated;
317 T _pool[INITIAL_SIZE];
331 virtual ~MemPool() {}
333 virtual int ItemSize()
const = 0;
334 virtual void* Alloc() = 0;
335 virtual void Free(
void* ) = 0;
336 virtual void SetTracked() = 0;
337 virtual void Clear() = 0;
344template<
int ITEM_SIZE >
345class MemPoolT :
public MemPool
348 MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
355 while( !_blockPtrs.Empty()) {
356 Block* lastBlock = _blockPtrs.Pop();
366 virtual int ItemSize()
const {
369 int CurrentAllocs()
const {
370 return _currentAllocs;
373 virtual void* Alloc() {
376 Block* block =
new Block();
377 _blockPtrs.Push( block );
379 Item* blockItems = block->items;
380 for(
int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
381 blockItems[i].next = &(blockItems[i + 1]);
383 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
386 Item*
const result = _root;
387 TIXMLASSERT( result != 0 );
391 if ( _currentAllocs > _maxAllocs ) {
392 _maxAllocs = _currentAllocs;
399 virtual void Free(
void* mem ) {
404 Item* item =
static_cast<Item*
>( mem );
406 memset( item, 0xfe,
sizeof( *item ) );
411 void Trace(
const char* name ) {
412 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
413 name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
414 ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
421 int Untracked()
const {
436 enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
439 MemPoolT(
const MemPoolT& );
440 void operator=(
const MemPoolT& );
444 char itemData[ITEM_SIZE];
447 Item items[ITEMS_PER_BLOCK];
449 DynArray< Block*, 10 > _blockPtrs;
524 XML_WRONG_ATTRIBUTE_TYPE,
525 XML_ERROR_FILE_NOT_FOUND,
526 XML_ERROR_FILE_COULD_NOT_BE_OPENED,
527 XML_ERROR_FILE_READ_ERROR,
528 UNUSED_XML_ERROR_ELEMENT_MISMATCH,
529 XML_ERROR_PARSING_ELEMENT,
530 XML_ERROR_PARSING_ATTRIBUTE,
531 UNUSED_XML_ERROR_IDENTIFYING_TAG,
532 XML_ERROR_PARSING_TEXT,
533 XML_ERROR_PARSING_CDATA,
534 XML_ERROR_PARSING_COMMENT,
535 XML_ERROR_PARSING_DECLARATION,
536 XML_ERROR_PARSING_UNKNOWN,
537 XML_ERROR_EMPTY_DOCUMENT,
538 XML_ERROR_MISMATCHED_ELEMENT,
540 XML_CAN_NOT_CONVERT_TEXT,
542 XML_ELEMENT_DEPTH_EXCEEDED,
551class TINYXML2_LIB XMLUtil
554 static const char* SkipWhiteSpace(
const char* p,
int* curLineNumPtr ) {
557 while( IsWhiteSpace(*p) ) {
558 if (curLineNumPtr && *p ==
'\n') {
566 static char* SkipWhiteSpace(
char* p,
int* curLineNumPtr ) {
567 return const_cast<char*
>( SkipWhiteSpace(
const_cast<const char*
>(p), curLineNumPtr ) );
572 static bool IsWhiteSpace(
char p ) {
573 return !IsUTF8Continuation(p) && isspace(
static_cast<unsigned char>(p) );
576 inline static bool IsNameStartChar(
unsigned char ch ) {
581 if ( isalpha( ch ) ) {
584 return ch ==
':' || ch ==
'_';
587 inline static bool IsNameChar(
unsigned char ch ) {
588 return IsNameStartChar( ch )
594 inline static bool StringEqual(
const char* p,
const char* q,
int nChar=INT_MAX ) {
600 TIXMLASSERT( nChar >= 0 );
601 return strncmp( p, q, nChar ) == 0;
604 inline static bool IsUTF8Continuation(
char p ) {
605 return ( p & 0x80 ) != 0;
608 static const char* ReadBOM(
const char* p,
bool* hasBOM );
611 static const char* GetCharacterRef(
const char* p,
char* value,
int* length );
612 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length );
615 static void ToStr(
int v,
char* buffer,
int bufferSize );
616 static void ToStr(
unsigned v,
char* buffer,
int bufferSize );
617 static void ToStr(
bool v,
char* buffer,
int bufferSize );
618 static void ToStr(
float v,
char* buffer,
int bufferSize );
619 static void ToStr(
double v,
char* buffer,
int bufferSize );
620 static void ToStr(int64_t v,
char* buffer,
int bufferSize);
623 static bool ToInt(
const char* str,
int* value );
624 static bool ToUnsigned(
const char* str,
unsigned* value );
625 static bool ToBool(
const char* str,
bool* value );
626 static bool ToFloat(
const char* str,
float* value );
627 static bool ToDouble(
const char* str,
double* value );
628 static bool ToInt64(
const char* str, int64_t* value);
635 static void SetBoolSerialization(
const char* writeTrue,
const char* writeFalse);
638 static const char* writeBoolTrue;
639 static const char* writeBoolFalse;
676 TIXMLASSERT( _document );
681 TIXMLASSERT( _document );
713 virtual const XMLText* ToText()
const {
716 virtual const XMLComment* ToComment()
const {
719 virtual const XMLDocument* ToDocument()
const {
722 virtual const XMLDeclaration* ToDeclaration()
const {
725 virtual const XMLUnknown* ToUnknown()
const {
743 void SetValue(
const char* val,
bool staticMem=
false );
776 XMLElement* FirstChildElement(
const char* name = 0 ) {
777 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement( name ));
794 XMLElement* LastChildElement(
const char* name = 0 ) {
795 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name) );
810 XMLElement* PreviousSiblingElement(
const char* name = 0 ) {
811 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement( name ) );
826 XMLElement* NextSiblingElement(
const char* name = 0 ) {
827 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement( name ) );
840 return InsertEndChild( addThis );
946 virtual char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
950 mutable StrPair _value;
964 static void DeleteNode(
XMLNode* node );
965 void InsertChildPreamble(
XMLNode* insertThis )
const;
966 const XMLElement* ToElementWithName(
const char* name )
const;
994 virtual const XMLText* ToText()
const {
1014 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1019 XMLText(
const XMLText& );
1020 XMLText& operator=(
const XMLText& );
1032 virtual const XMLComment* ToComment()
const {
1045 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
1084 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1106 virtual const XMLUnknown* ToUnknown()
const {
1119 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1162 int64_t Int64Value()
const {
1164 QueryInt64Value(&i);
1171 QueryUnsignedValue( &i );
1177 QueryBoolValue( &b );
1183 QueryDoubleValue( &d );
1189 QueryFloatValue( &f );
1225 enum { BUF_SIZE = 200 };
1227 XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1228 virtual ~XMLAttribute() {}
1230 XMLAttribute(
const XMLAttribute& );
1231 void operator=(
const XMLAttribute& );
1232 void SetName(
const char* name );
1234 char* ParseDeep(
char* p,
bool processEntities,
int* curLineNumPtr );
1236 mutable StrPair _name;
1237 mutable StrPair _value;
1239 XMLAttribute* _next;
1257 void SetName(
const char* str,
bool staticMem=
false ) {
1258 SetValue( str, staticMem );
1264 virtual const XMLElement* ToElement()
const {
1292 const char*
Attribute(
const char* name,
const char* value=0 )
const;
1328 return XML_NO_ATTRIBUTE;
1337 return XML_NO_ATTRIBUTE;
1346 return XML_NO_ATTRIBUTE;
1355 return XML_NO_ATTRIBUTE;
1363 return XML_NO_ATTRIBUTE;
1371 return XML_NO_ATTRIBUTE;
1380 return XML_NO_ATTRIBUTE;
1382 *value = a->
Value();
1406 return QueryIntAttribute( name, value );
1409 int QueryAttribute(
const char* name,
unsigned int* value )
const {
1410 return QueryUnsignedAttribute( name, value );
1413 int QueryAttribute(
const char* name, int64_t* value)
const {
1414 return QueryInt64Attribute(name, value);
1417 int QueryAttribute(
const char* name,
bool* value )
const {
1418 return QueryBoolAttribute( name, value );
1421 int QueryAttribute(
const char* name,
double* value )
const {
1422 return QueryDoubleAttribute( name, value );
1425 int QueryAttribute(
const char* name,
float* value )
const {
1426 return QueryFloatAttribute( name, value );
1474 return _rootAttribute;
1595 int IntText(
int defaultValue = 0)
const;
1609 enum ElementClosingType {
1614 ElementClosingType ClosingType()
const {
1615 return _closingType;
1621 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1632 XMLAttribute* FindOrCreateAttribute(
const char* name );
1634 char* ParseAttributes(
char* p,
int* curLineNumPtr );
1635 static void DeleteAttribute(
XMLAttribute* attribute );
1638 enum { BUF_SIZE = 200 };
1639 ElementClosingType _closingType;
1643 XMLAttribute* _rootAttribute;
1648 PRESERVE_WHITESPACE,
1670 XMLDocument(
bool processEntities =
true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
1674 TIXMLASSERT(
this == _document );
1678 TIXMLASSERT(
this == _document );
1692 XMLError
Parse(
const char* xml,
size_t nBytes=(
size_t)(-1) );
1719 XMLError
SaveFile(
const char* filename,
bool compact =
false );
1730 bool ProcessEntities()
const {
1731 return _processEntities;
1733 Whitespace WhitespaceMode()
const {
1734 return _whitespaceMode;
1753 return FirstChildElement();
1756 return FirstChildElement();
1820 SetError(XML_SUCCESS, 0, 0);
1825 return _errorID != XML_SUCCESS;
1831 const char* ErrorName()
const;
1832 static const char* ErrorIDToName(XMLError errorID);
1845 return _errorLineNum;
1861 char* Identify(
char* p,
XMLNode** node );
1878 bool _processEntities;
1880 Whitespace _whitespaceMode;
1881 mutable StrPair _errorStr;
1884 int _parseCurLineNum;
1892 DynArray<XMLNode*, 10> _unlinked;
1896 MemPoolT<
sizeof(
XMLText) > _textPool;
1899 static const char* _errorNames[XML_ERROR_COUNT];
1903 void SetError( XMLError error,
int lineNum,
const char* format, ... );
1908 class DepthTracker {
1911 this->_document = document;
1912 document->PushDepth();
1915 _document->PopDepth();
1918 XMLDocument * _document;
1923 template<
class NodeType,
int PoolElementSize>
1924 NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
1927template<
class NodeType,
int PoolElementSize>
1928inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
1930 TIXMLASSERT(
sizeof( NodeType ) == PoolElementSize );
1931 TIXMLASSERT(
sizeof( NodeType ) == pool.ItemSize() );
1932 NodeType* returnNode =
new (pool.Alloc()) NodeType(
this );
1933 TIXMLASSERT( returnNode );
1934 returnNode->_memPool = &pool;
1936 _unlinked.Push(returnNode);
2015 return XMLHandle( _node ? _node->FirstChild() : 0 );
2019 return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
2023 return XMLHandle( _node ? _node->LastChild() : 0 );
2027 return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2031 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2035 return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2039 return XMLHandle( _node ? _node->NextSibling() : 0 );
2043 return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2052 return ( _node ? _node->ToElement() : 0 );
2056 return ( _node ? _node->ToText() : 0 );
2060 return ( _node ? _node->ToUnknown() : 0 );
2064 return ( _node ? _node->ToDeclaration() : 0 );
2094 const XMLConstHandle FirstChildElement(
const char* name = 0 )
const {
2095 return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2100 const XMLConstHandle LastChildElement(
const char* name = 0 )
const {
2101 return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2106 const XMLConstHandle PreviousSiblingElement(
const char* name = 0 )
const {
2107 return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2112 const XMLConstHandle NextSiblingElement(
const char* name = 0 )
const {
2113 return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2117 const XMLNode* ToNode()
const {
2121 return ( _node ? _node->ToElement() : 0 );
2123 const XMLText* ToText()
const {
2124 return ( _node ? _node->ToText() : 0 );
2127 return ( _node ? _node->ToUnknown() : 0 );
2130 return ( _node ? _node->ToDeclaration() : 0 );
2200 void PushAttribute(
const char* name,
int value );
2201 void PushAttribute(
const char* name,
unsigned value );
2202 void PushAttribute(
const char* name, int64_t value);
2203 void PushAttribute(
const char* name,
bool value );
2204 void PushAttribute(
const char* name,
double value );
2226 void PushDeclaration(
const char* value );
2227 void PushUnknown(
const char* value );
2247 return _buffer.Mem();
2255 return _buffer.Size();
2264 _firstElement =
true;
2268 virtual bool CompactMode(
const XMLElement& ) {
return _compactMode; }
2274 void Print(
const char* format, ... );
2275 void Write(
const char* data,
size_t size );
2276 inline void Write(
const char* data ) { Write( data, strlen( data ) ); }
2277 void Putc(
char ch );
2279 void SealElementIfJustOpened();
2280 bool _elementJustOpened;
2281 DynArray< const char*, 10 > _stack;
2284 void PrintString(
const char*,
bool restrictedEntitySet );
2290 bool _processEntities;
2297 bool _entityFlag[ENTITY_RANGE];
2298 bool _restrictedEntityFlag[ENTITY_RANGE];
2300 DynArray< char, 20 > _buffer;
2303 XMLPrinter(
const XMLPrinter& );
2304 XMLPrinter& operator=(
const XMLPrinter& );
2310#if defined(_MSC_VER)
2311# pragma warning(pop)
Definition: tinyxml2.h:1135
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition: tinyxml2.h:1145
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1169
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1187
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:1181
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
const char * Name() const
The name of the attribute.
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:1175
void SetAttribute(double value)
Set the attribute to value.
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1148
const char * Value() const
The value of the attribute.
void SetAttribute(bool value)
Set the attribute to value.
void SetAttribute(int value)
Set the attribute to value.
int IntValue() const
Definition: tinyxml2.h:1156
void SetAttribute(unsigned value)
Set the attribute to value.
void SetAttribute(float value)
Set the attribute to value.
Definition: tinyxml2.h:2077
Definition: tinyxml2.h:1065
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1068
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.h:1659
XMLElement * RootElement()
Definition: tinyxml2.h:1752
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1745
XMLError Parse(const char *xml, size_t nBytes=(size_t)(-1))
void PrintError() const
A (trivial) utility function that prints the ErrorStr() to stdout.
XMLError LoadFile(const char *filename)
bool HasBOM() const
Definition: tinyxml2.h:1740
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1824
XMLComment * NewComment(const char *comment)
XMLElement * NewElement(const char *name)
XMLUnknown * NewUnknown(const char *text)
int ErrorLineNum() const
Return the line where the error occured, or zero if unknown.
Definition: tinyxml2.h:1843
XMLDocument(bool processEntities=true, Whitespace whitespaceMode=PRESERVE_WHITESPACE)
constructor
XMLError LoadFile(FILE *)
void Clear()
Clear the document, resetting it to the initial state.
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1869
XMLError SaveFile(const char *filename, bool compact=false)
void Print(XMLPrinter *streamer=0) const
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1673
XMLError SaveFile(FILE *fp, bool compact=false)
virtual bool Accept(XMLVisitor *visitor) const
void DeleteNode(XMLNode *node)
XMLText * NewText(const char *text)
XMLDeclaration * NewDeclaration(const char *text=0)
const char * ErrorStr() const
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1866
void DeepCopy(XMLDocument *target) const
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1828
Definition: tinyxml2.h:1249
int QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1405
const char * GetText() const
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:1430
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1352
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
virtual XMLNode * ShallowClone(XMLDocument *document) const
void SetText(const char *inText)
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1457
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1334
virtual bool Accept(XMLVisitor *visitor) const
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
float FloatText(float defaultValue=0) const
See QueryIntText()
const char * Attribute(const char *name, const char *value=0) const
unsigned UnsignedText(unsigned defaultValue=0) const
See QueryIntText()
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1473
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:1462
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1360
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()
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:1343
double DoubleText(double defaultValue=0) const
See QueryIntText()
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1325
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:1257
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1452
int64_t Int64Text(int64_t defaultValue=0) const
See QueryIntText()
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1435
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1446
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1261
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1253
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1368
virtual bool ShallowEqual(const XMLNode *compare) const
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1377
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1440
void SetText(bool value)
Convenience method for setting text inside an element. See SetText() for important limitations.
void SetText(int value)
Convenience method for setting text inside an element. See SetText() for important limitations.
void DeleteAttribute(const char *name)
XMLError QueryFloatText(float *fval) const
See QueryIntText()
unsigned UnsignedAttribute(const char *name, unsigned defaultValue=0) const
See IntAttribute()
Definition: tinyxml2.h:1996
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:2030
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:2026
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:2014
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:2047
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:2018
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:2034
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:2063
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1999
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:2022
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:2008
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:2002
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:2038
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:2051
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:2055
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:2059
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:2042
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:2005
Definition: tinyxml2.h:669
void SetUserData(void *userData)
Definition: tinyxml2.h:933
const char * Value() const
void SetValue(const char *val, bool staticMem=false)
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:690
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:702
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
void * GetUserData() const
Definition: tinyxml2.h:940
const XMLElement * FirstChildElement(const char *name=0) const
void DeleteChild(XMLNode *node)
XMLNode * DeepClone(XMLDocument *target) const
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:680
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:749
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:694
const XMLElement * LastChildElement(const char *name=0) const
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:698
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:781
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:675
virtual bool ShallowEqual(const XMLNode *compare) const =0
virtual bool Accept(XMLVisitor *visitor) const =0
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:799
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:686
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name.
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
Definition: tinyxml2.h:746
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:706
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:763
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:758
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLNode * InsertEndChild(XMLNode *addThis)
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:815
Definition: tinyxml2.h:2181
virtual void PrintSpace(int depth)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2230
void PushHeader(bool writeBOM, bool writeDeclaration)
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)
void ClearBuffer()
Definition: tinyxml2.h:2261
virtual bool Visit(const XMLText &text)
Visit a text node.
virtual bool VisitEnter(const XMLElement &element, const XMLAttribute *attribute)
Visit an element.
int CStrSize() const
Definition: tinyxml2.h:2254
void PushText(int value)
Add a text node from an integer.
virtual bool Visit(const XMLComment &comment)
Visit a comment node.
void PushText(bool value)
Add a text node from a bool.
void PushText(unsigned value)
Add a text node from an unsigned.
void PushText(int64_t value)
Add a text node from an unsigned.
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
virtual bool Visit(const XMLDeclaration &declaration)
Visit a declaration.
virtual bool Visit(const XMLUnknown &unknown)
Visit an unknown node.
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
void PushText(double value)
Add a text node from a double.
const char * CStr() const
Definition: tinyxml2.h:2246
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
virtual bool VisitExit(const XMLElement &element)
Visit an element.
void PushComment(const char *comment)
Add a comment.
Definition: tinyxml2.h:986
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:991
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:1003
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:999
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.h:1100
virtual bool ShallowEqual(const XMLNode *compare) const
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1103
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.h:480
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:515
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:489
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:498
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:485
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:511
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:503
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:507
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:494