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
63 # pragma warning(push)
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)
83 # if defined(_MSC_VER)
84 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
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 ) {}
101 static const int TIXML2_MAJOR_VERSION = 8;
102 static const int TIXML2_MINOR_VERSION = 0;
103 static const int TIXML2_PATCH_VERSION = 0;
105 #define TINYXML2_MAJOR_VERSION 8
106 #define TINYXML2_MINOR_VERSION 0
107 #define TINYXML2_PATCH_VERSION 0
114 static const int TINYXML2_MAX_ELEMENT_DEPTH = 100;
123 class XMLDeclaration;
135 class TINYXML2_LIB StrPair
139 NEEDS_ENTITY_PROCESSING = 0x01,
140 NEEDS_NEWLINE_NORMALIZATION = 0x02,
141 NEEDS_WHITESPACE_COLLAPSING = 0x04,
143 TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
144 TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
146 ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
147 ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
148 COMMENT = NEEDS_NEWLINE_NORMALIZATION
151 StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
154 void Set(
char* start,
char* end,
int flags ) {
155 TIXMLASSERT( start );
160 _flags = flags | NEEDS_FLUSH;
163 const char* GetStr();
166 return _start == _end;
169 void SetInternedStr(
const char* str ) {
171 _start =
const_cast<char*
>(str);
174 void SetStr(
const char* str,
int flags=0 );
176 char* ParseText(
char* in,
const char* endTag,
int strFlags,
int* curLineNumPtr );
177 char* ParseName(
char* in );
179 void TransferTo( StrPair* other );
183 void CollapseWhitespace();
194 StrPair(
const StrPair& other );
195 void operator=(
const StrPair& other );
204 template <
class T,
int INITIAL_SIZE>
210 _allocated( INITIAL_SIZE ),
216 if ( _mem != _pool ) {
226 TIXMLASSERT( _size < INT_MAX );
227 EnsureCapacity( _size+1 );
232 T* PushArr(
int count ) {
233 TIXMLASSERT( count >= 0 );
234 TIXMLASSERT( _size <= INT_MAX - count );
235 EnsureCapacity( _size+count );
236 T* ret = &_mem[_size];
242 TIXMLASSERT( _size > 0 );
247 void PopArr(
int count ) {
248 TIXMLASSERT( _size >= count );
256 T& operator[](
int i) {
257 TIXMLASSERT( i>= 0 && i < _size );
261 const T& operator[](
int i)
const {
262 TIXMLASSERT( i>= 0 && i < _size );
266 const T& PeekTop()
const {
267 TIXMLASSERT( _size > 0 );
268 return _mem[ _size - 1];
272 TIXMLASSERT( _size >= 0 );
276 int Capacity()
const {
277 TIXMLASSERT( _allocated >= INITIAL_SIZE );
281 void SwapRemove(
int i) {
282 TIXMLASSERT(i >= 0 && i < _size);
283 TIXMLASSERT(_size > 0);
284 _mem[i] = _mem[_size - 1];
288 const T* Mem()
const {
299 DynArray(
const DynArray& );
300 void operator=(
const DynArray& );
302 void EnsureCapacity(
int cap ) {
303 TIXMLASSERT( cap > 0 );
304 if ( cap > _allocated ) {
305 TIXMLASSERT( cap <= INT_MAX / 2 );
306 const int newAllocated = cap * 2;
307 T* newMem =
new T[newAllocated];
308 TIXMLASSERT( newAllocated >= _size );
309 memcpy( newMem, _mem,
sizeof(T)*_size );
310 if ( _mem != _pool ) {
314 _allocated = newAllocated;
319 T _pool[INITIAL_SIZE];
333 virtual ~MemPool() {}
335 virtual int ItemSize()
const = 0;
336 virtual void* Alloc() = 0;
337 virtual void Free(
void* ) = 0;
338 virtual void SetTracked() = 0;
345 template<
int ITEM_SIZE >
346 class MemPoolT :
public MemPool
349 MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
351 MemPoolT< ITEM_SIZE >::Clear();
356 while( !_blockPtrs.Empty()) {
357 Block* lastBlock = _blockPtrs.Pop();
367 virtual int ItemSize()
const {
370 int CurrentAllocs()
const {
371 return _currentAllocs;
374 virtual void* Alloc() {
377 Block* block =
new Block();
378 _blockPtrs.Push( block );
380 Item* blockItems = block->items;
381 for(
int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
382 blockItems[i].next = &(blockItems[i + 1]);
384 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
387 Item*
const result = _root;
388 TIXMLASSERT( result != 0 );
392 if ( _currentAllocs > _maxAllocs ) {
393 _maxAllocs = _currentAllocs;
400 virtual void Free(
void* mem ) {
405 Item* item =
static_cast<Item*
>( mem );
406 #ifdef TINYXML2_DEBUG
407 memset( item, 0xfe,
sizeof( *item ) );
412 void Trace(
const char* name ) {
413 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
414 name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
415 ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
422 int Untracked()
const {
437 enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
440 MemPoolT(
const MemPoolT& );
441 void operator=(
const MemPoolT& );
445 char itemData[ITEM_SIZE];
448 Item items[ITEMS_PER_BLOCK];
450 DynArray< Block*, 10 > _blockPtrs;
525 XML_WRONG_ATTRIBUTE_TYPE,
526 XML_ERROR_FILE_NOT_FOUND,
527 XML_ERROR_FILE_COULD_NOT_BE_OPENED,
528 XML_ERROR_FILE_READ_ERROR,
529 XML_ERROR_PARSING_ELEMENT,
530 XML_ERROR_PARSING_ATTRIBUTE,
531 XML_ERROR_PARSING_TEXT,
532 XML_ERROR_PARSING_CDATA,
533 XML_ERROR_PARSING_COMMENT,
534 XML_ERROR_PARSING_DECLARATION,
535 XML_ERROR_PARSING_UNKNOWN,
536 XML_ERROR_EMPTY_DOCUMENT,
537 XML_ERROR_MISMATCHED_ELEMENT,
539 XML_CAN_NOT_CONVERT_TEXT,
541 XML_ELEMENT_DEPTH_EXCEEDED,
550 class TINYXML2_LIB XMLUtil
553 static const char* SkipWhiteSpace(
const char* p,
int* curLineNumPtr ) {
556 while( IsWhiteSpace(*p) ) {
557 if (curLineNumPtr && *p ==
'\n') {
565 static char* SkipWhiteSpace(
char*
const p,
int* curLineNumPtr ) {
566 return const_cast<char*
>( SkipWhiteSpace(
const_cast<const char*
>(p), curLineNumPtr ) );
571 static bool IsWhiteSpace(
char p ) {
572 return !IsUTF8Continuation(p) && isspace(
static_cast<unsigned char>(p) );
575 inline static bool IsNameStartChar(
unsigned char ch ) {
580 if ( isalpha( ch ) ) {
583 return ch ==
':' || ch ==
'_';
586 inline static bool IsNameChar(
unsigned char ch ) {
587 return IsNameStartChar( ch )
593 inline static bool IsPrefixHex(
const char* p) {
594 p = SkipWhiteSpace(p, 0);
595 return p && *p ==
'0' && ( *(p + 1) ==
'x' || *(p + 1) ==
'X');
598 inline static bool StringEqual(
const char* p,
const char* q,
int nChar=INT_MAX ) {
604 TIXMLASSERT( nChar >= 0 );
605 return strncmp( p, q, nChar ) == 0;
608 inline static bool IsUTF8Continuation(
const char p ) {
609 return ( p & 0x80 ) != 0;
612 static const char* ReadBOM(
const char* p,
bool* hasBOM );
615 static const char* GetCharacterRef(
const char* p,
char* value,
int* length );
616 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length );
619 static void ToStr(
int v,
char* buffer,
int bufferSize );
620 static void ToStr(
unsigned v,
char* buffer,
int bufferSize );
621 static void ToStr(
bool v,
char* buffer,
int bufferSize );
622 static void ToStr(
float v,
char* buffer,
int bufferSize );
623 static void ToStr(
double v,
char* buffer,
int bufferSize );
624 static void ToStr(int64_t v,
char* buffer,
int bufferSize);
625 static void ToStr(uint64_t v,
char* buffer,
int bufferSize);
628 static bool ToInt(
const char* str,
int* value );
629 static bool ToUnsigned(
const char* str,
unsigned* value );
630 static bool ToBool(
const char* str,
bool* value );
631 static bool ToFloat(
const char* str,
float* value );
632 static bool ToDouble(
const char* str,
double* value );
633 static bool ToInt64(
const char* str, int64_t* value);
634 static bool ToUnsigned64(
const char* str, uint64_t* value);
640 static void SetBoolSerialization(
const char* writeTrue,
const char* writeFalse);
643 static const char* writeBoolTrue;
644 static const char* writeBoolFalse;
681 TIXMLASSERT( _document );
686 TIXMLASSERT( _document );
718 virtual const XMLText* ToText()
const {
721 virtual const XMLComment* ToComment()
const {
724 virtual const XMLDocument* ToDocument()
const {
727 virtual const XMLDeclaration* ToDeclaration()
const {
730 virtual const XMLUnknown* ToUnknown()
const {
748 void SetValue(
const char* val,
bool staticMem=
false );
781 XMLElement* FirstChildElement(
const char* name = 0 ) {
782 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement( name ));
799 XMLElement* LastChildElement(
const char* name = 0 ) {
800 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name) );
815 XMLElement* PreviousSiblingElement(
const char* name = 0 ) {
816 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement( name ) );
831 XMLElement* NextSiblingElement(
const char* name = 0 ) {
832 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement( name ) );
845 return InsertEndChild( addThis );
951 virtual char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
955 mutable StrPair _value;
969 static void DeleteNode(
XMLNode* node );
970 void InsertChildPreamble(
XMLNode* insertThis )
const;
971 const XMLElement* ToElementWithName(
const char* name )
const;
999 virtual const XMLText* ToText()
const {
1019 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1024 XMLText(
const XMLText& );
1025 XMLText& operator=(
const XMLText& );
1037 virtual const XMLComment* ToComment()
const {
1050 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
1089 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1111 virtual const XMLUnknown* ToUnknown()
const {
1124 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1167 int64_t Int64Value()
const {
1169 QueryInt64Value(&i);
1173 uint64_t Unsigned64Value()
const {
1175 QueryUnsigned64Value(&i);
1182 QueryUnsignedValue( &i );
1188 QueryBoolValue( &b );
1194 QueryDoubleValue( &d );
1200 QueryFloatValue( &f );
1240 enum { BUF_SIZE = 200 };
1242 XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1243 virtual ~XMLAttribute() {}
1245 XMLAttribute(
const XMLAttribute& );
1246 void operator=(
const XMLAttribute& );
1247 void SetName(
const char* name );
1249 char* ParseDeep(
char* p,
bool processEntities,
int* curLineNumPtr );
1251 mutable StrPair _name;
1252 mutable StrPair _value;
1254 XMLAttribute* _next;
1272 void SetName(
const char* str,
bool staticMem=
false ) {
1273 SetValue( str, staticMem );
1279 virtual const XMLElement* ToElement()
const {
1307 const char*
Attribute(
const char* name,
const char* value=0 )
const;
1345 return XML_NO_ATTRIBUTE;
1354 return XML_NO_ATTRIBUTE;
1363 return XML_NO_ATTRIBUTE;
1372 return XML_NO_ATTRIBUTE;
1381 return XML_NO_ATTRIBUTE;
1389 return XML_NO_ATTRIBUTE;
1397 return XML_NO_ATTRIBUTE;
1406 return XML_NO_ATTRIBUTE;
1408 *value = a->
Value();
1432 return QueryIntAttribute( name, value );
1435 XMLError QueryAttribute(
const char* name,
unsigned int* value )
const {
1436 return QueryUnsignedAttribute( name, value );
1439 XMLError QueryAttribute(
const char* name, int64_t* value)
const {
1440 return QueryInt64Attribute(name, value);
1443 XMLError QueryAttribute(
const char* name, uint64_t* value)
const {
1444 return QueryUnsigned64Attribute(name, value);
1447 XMLError QueryAttribute(
const char* name,
bool* value )
const {
1448 return QueryBoolAttribute( name, value );
1451 XMLError QueryAttribute(
const char* name,
double* value )
const {
1452 return QueryDoubleAttribute( name, value );
1455 XMLError QueryAttribute(
const char* name,
float* value )
const {
1456 return QueryFloatAttribute( name, value );
1510 return _rootAttribute;
1635 int IntText(
int defaultValue = 0)
const;
1666 enum ElementClosingType {
1671 ElementClosingType ClosingType()
const {
1672 return _closingType;
1678 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1686 XMLAttribute* FindOrCreateAttribute(
const char* name );
1687 char* ParseAttributes(
char* p,
int* curLineNumPtr );
1688 static void DeleteAttribute(
XMLAttribute* attribute );
1691 enum { BUF_SIZE = 200 };
1692 ElementClosingType _closingType;
1701 PRESERVE_WHITESPACE,
1723 XMLDocument(
bool processEntities =
true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
1727 TIXMLASSERT(
this == _document );
1731 TIXMLASSERT(
this == _document );
1745 XMLError
Parse(
const char* xml,
size_t nBytes=
static_cast<size_t>(-1) );
1772 XMLError
SaveFile(
const char* filename,
bool compact =
false );
1783 bool ProcessEntities()
const {
1784 return _processEntities;
1786 Whitespace WhitespaceMode()
const {
1787 return _whitespaceMode;
1806 return FirstChildElement();
1809 return FirstChildElement();
1873 SetError(XML_SUCCESS, 0, 0);
1878 return _errorID != XML_SUCCESS;
1884 const char* ErrorName()
const;
1885 static const char* ErrorIDToName(XMLError errorID);
1898 return _errorLineNum;
1914 char* Identify(
char* p,
XMLNode** node );
1917 void MarkInUse(
const XMLNode*
const);
1931 bool _processEntities;
1933 Whitespace _whitespaceMode;
1934 mutable StrPair _errorStr;
1937 int _parseCurLineNum;
1945 DynArray<XMLNode*, 10> _unlinked;
1949 MemPoolT<
sizeof(
XMLText) > _textPool;
1952 static const char* _errorNames[XML_ERROR_COUNT];
1956 void SetError( XMLError error,
int lineNum,
const char* format, ... );
1961 class DepthTracker {
1964 this->_document = document;
1965 document->PushDepth();
1968 _document->PopDepth();
1971 XMLDocument * _document;
1976 template<
class NodeType,
int PoolElementSize>
1977 NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
1980 template<
class NodeType,
int PoolElementSize>
1981 inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
1983 TIXMLASSERT(
sizeof( NodeType ) == PoolElementSize );
1984 TIXMLASSERT(
sizeof( NodeType ) == pool.ItemSize() );
1985 NodeType* returnNode =
new (pool.Alloc()) NodeType(
this );
1986 TIXMLASSERT( returnNode );
1987 returnNode->_memPool = &pool;
1989 _unlinked.Push(returnNode);
2068 return XMLHandle( _node ? _node->FirstChild() : 0 );
2072 return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
2076 return XMLHandle( _node ? _node->LastChild() : 0 );
2080 return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2084 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2088 return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2092 return XMLHandle( _node ? _node->NextSibling() : 0 );
2096 return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2105 return ( _node ? _node->ToElement() : 0 );
2109 return ( _node ? _node->ToText() : 0 );
2113 return ( _node ? _node->ToUnknown() : 0 );
2117 return ( _node ? _node->ToDeclaration() : 0 );
2147 const XMLConstHandle FirstChildElement(
const char* name = 0 )
const {
2148 return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2153 const XMLConstHandle LastChildElement(
const char* name = 0 )
const {
2154 return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2159 const XMLConstHandle PreviousSiblingElement(
const char* name = 0 )
const {
2160 return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2165 const XMLConstHandle NextSiblingElement(
const char* name = 0 )
const {
2166 return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2170 const XMLNode* ToNode()
const {
2174 return ( _node ? _node->ToElement() : 0 );
2176 const XMLText* ToText()
const {
2177 return ( _node ? _node->ToText() : 0 );
2180 return ( _node ? _node->ToUnknown() : 0 );
2183 return ( _node ? _node->ToDeclaration() : 0 );
2253 void PushAttribute(
const char* name,
int value );
2254 void PushAttribute(
const char* name,
unsigned value );
2255 void PushAttribute(
const char* name, int64_t value );
2256 void PushAttribute(
const char* name, uint64_t value );
2257 void PushAttribute(
const char* name,
bool value );
2258 void PushAttribute(
const char* name,
double value );
2282 void PushDeclaration(
const char* value );
2283 void PushUnknown(
const char* value );
2303 return _buffer.Mem();
2311 return _buffer.Size();
2320 _firstElement = resetToFirstElement;
2324 virtual bool CompactMode(
const XMLElement& ) {
return _compactMode; }
2330 virtual void Print(
const char* format, ... );
2331 virtual void Write(
const char* data,
size_t size );
2332 virtual void Putc(
char ch );
2334 inline void Write(
const char* data) { Write(data, strlen(data)); }
2336 void SealElementIfJustOpened();
2337 bool _elementJustOpened;
2338 DynArray< const char*, 10 > _stack;
2345 void PrepareForNewNode(
bool compactMode );
2346 void PrintString(
const char*,
bool restrictedEntitySet );
2352 bool _processEntities;
2359 bool _entityFlag[ENTITY_RANGE];
2360 bool _restrictedEntityFlag[ENTITY_RANGE];
2362 DynArray< char, 20 > _buffer;
2365 XMLPrinter(
const XMLPrinter& );
2366 XMLPrinter& operator=(
const XMLPrinter& );
2372 #if defined(_MSC_VER)
2373 # pragma warning(pop)
2376 #endif // TINYXML2_INCLUDED
unsigned UnsignedAttribute(const char *name, unsigned defaultValue=0) const
See IntAttribute()
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
const char * Value() const
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:2058
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:504
int IntValue() const
Definition: tinyxml2.h:1161
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:691
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1192
uint64_t Unsigned64Text(uint64_t defaultValue=0) const
See QueryIntText()
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:703
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1465
Definition: tinyxml2.h:674
XMLDeclaration * InsertNewDeclaration(const char *text)
See InsertNewChildElement()
float FloatText(float defaultValue=0) const
See QueryIntText()
void DeleteAttribute(const char *name)
void SetUserData(void *userData)
Definition: tinyxml2.h:938
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1272
void OpenElement(const char *name, bool compactMode=false)
void Clear()
Clear the document, resetting it to the initial state.
void PushComment(const char *comment)
Add a comment.
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:2116
virtual bool Accept(XMLVisitor *visitor) const =0
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
Definition: tinyxml2.h:751
void SetText(const char *inText)
Definition: tinyxml2.h:991
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1276
XMLNode * InsertEndChild(XMLNode *addThis)
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1360
XMLError QueryUnsigned64Text(uint64_t *uval) const
See QueryIntText()
XMLComment * NewComment(const char *comment)
virtual bool Accept(XMLVisitor *visitor) const
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:2071
void PushText(unsigned value)
Add a text node from an unsigned.
void SetAttribute(int64_t value)
Set the attribute to value.
void ClearBuffer(bool resetToFirstElement=true)
Definition: tinyxml2.h:2317
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1369
Definition: tinyxml2.h:1105
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
int IntAttribute(const char *name, int defaultValue=0) const
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:2061
XMLElement * NewElement(const char *name)
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLError QueryUnsigned64Value(uint64_t *value) const
See QueryIntValue.
virtual bool ShallowEqual(const XMLNode *compare) const =0
XMLElement * InsertNewChildElement(const char *name)
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:516
void SetAttribute(float value)
Set the attribute to value.
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:804
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1482
void PushText(double value)
Add a text node from a double.
XMLUnknown * InsertNewUnknown(const char *text)
See InsertNewChildElement()
const XMLElement * LastChildElement(const char *name=0) const
void DeleteNode(XMLNode *node)
virtual XMLNode * ShallowClone(XMLDocument *document) const
int64_t Int64Text(int64_t defaultValue=0) const
See QueryIntText()
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:754
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1268
XMLNode * DeepClone(XMLDocument *target) const
void SetAttribute(unsigned value)
Set the attribute to value.
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:2112
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1198
virtual bool ShallowEqual(const XMLNode *compare) const
XMLUnknown * NewUnknown(const char *text)
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1798
const char * Value() const
The value of the attribute.
XMLError Parse(const char *xml, size_t nBytes=static_cast< size_t >(-1))
virtual bool Visit(const XMLUnknown &unknown)
Visit an unknown node.
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1493
virtual bool Accept(XMLVisitor *visitor) const
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:486
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:786
Definition: tinyxml2.h:1712
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1403
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:2087
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:2079
Definition: tinyxml2.h:2130
void PushText(int64_t value)
Add a text node from a signed 64bit integer.
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:2075
void DeepCopy(XMLDocument *target) const
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
XMLComment * InsertNewComment(const char *comment)
See InsertNewChildElement()
const char * Name() const
The name of the attribute.
XMLDeclaration * NewDeclaration(const char *text=0)
const XMLElement * FirstChildElement(const char *name=0) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:2067
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1498
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:2052
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:1004
virtual bool Visit(const XMLDeclaration &declaration)
Visit a declaration.
void SetAttribute(int value)
Set the attribute to value.
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:763
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1726
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:490
Definition: tinyxml2.h:1070
XMLNode * InsertAfterChild(XMLNode *afterThis, XMLNode *addThis)
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:820
bool BoolText(bool defaultValue=false) const
See QueryIntText()
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1180
virtual bool VisitEnter(const XMLElement &element, const XMLAttribute *attribute)
Visit an element.
void SetText(bool value)
Convenience method for setting text inside an element. See SetText() for important limitations.
virtual XMLNode * ShallowClone(XMLDocument *document) const =0
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:2095
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:2108
int CStrSize() const
Definition: tinyxml2.h:2310
const XMLElement * PreviousSiblingElement(const char *name=0) const
Get the previous (left) sibling element of this node, with an optionally supplied name.
void SetValue(const char *val, bool staticMem=false)
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
Definition: tinyxml2.h:481
void SetText(float value)
Convenience method for setting text inside an element. See SetText() for important limitations.
void SetAttribute(bool value)
Set the attribute to value.
const char * Attribute(const char *name, const char *value=0) const
virtual bool VisitExit(const XMLElement &element)
Visit an element.
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:680
void PushText(bool value)
Add a text node from a bool.
virtual bool Visit(const XMLText &text)
Visit a text node.
double DoubleText(double defaultValue=0) const
See QueryIntText()
XMLError QueryIntText(int *ival) const
XMLError SaveFile(const char *filename, bool compact=false)
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:996
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1919
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1476
int ErrorLineNum() const
Return the line where the error occurred, or zero if unknown.
Definition: tinyxml2.h:1896
void PushText(const char *text, bool cdata=false)
Add a text node.
void PushText(int value)
Add a text node from an integer.
void Print(XMLPrinter *streamer=0) const
void PrintError() const
A (trivial) utility function that prints the ErrorStr() to stdout.
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2286
void SetText(int64_t value)
Convenience method for setting text inside an element. See SetText() for important limitations.
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:495
Definition: tinyxml2.h:2234
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:2100
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1108
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1386
virtual bool Visit(const XMLComment &comment)
Visit a comment node.
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1488
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:1008
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1073
const char * ErrorStr() const
virtual bool ShallowEqual(const XMLNode *compare) const
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1877
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:707
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:508
void SetAttribute(const char *value)
Set the attribute to a string value.
void SetText(unsigned value)
Convenience method for setting text inside an element. See SetText() for important limitations.
XMLError LoadFile(const char *filename)
void PushText(uint64_t value)
Add a text node from an unsigned 64bit integer.
const char * GetText() const
void SetText(int value)
Convenience method for setting text inside an element. See SetText() for important limitations.
void DeleteChild(XMLNode *node)
XMLText * NewText(const char *text)
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:499
Definition: tinyxml2.h:2049
unsigned UnsignedText(unsigned defaultValue=0) const
See QueryIntText()
const char * CStr() const
Definition: tinyxml2.h:2302
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLError QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1431
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:695
uint64_t Unsigned64Attribute(const char *name, uint64_t defaultValue=0) const
See IntAttribute()
XMLError QueryBoolText(bool *bval) const
See QueryIntText()
XMLError QueryFloatText(float *fval) const
See QueryIntText()
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1351
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1922
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:711
XMLError SaveFile(FILE *fp, bool compact=false)
double DoubleAttribute(const char *name, double defaultValue=0) const
See IntAttribute()
virtual bool Accept(XMLVisitor *visitor) const
bool BoolAttribute(const char *name, bool defaultValue=false) const
See IntAttribute()
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition: tinyxml2.h:1150
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1153
void SetText(double value)
Convenience method for setting text inside an element. See SetText() for important limitations.
Definition: tinyxml2.h:1140
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:2083
void PushHeader(bool writeBOM, bool writeDeclaration)
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:768
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1509
virtual bool Accept(XMLVisitor *visitor) const
void SetText(uint64_t value)
Convenience method for setting text inside an element. See SetText() for important limitations.
virtual bool ShallowEqual(const XMLNode *compare) const
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:2055
void SetAttribute(uint64_t value)
Set the attribute to value.
XMLDocument(bool processEntities=true, Whitespace whitespaceMode=PRESERVE_WHITESPACE)
constructor
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1881
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1460
int64_t Int64Attribute(const char *name, int64_t defaultValue=0) const
See IntAttribute()
virtual void PrintSpace(int depth)
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:685
XMLText * InsertNewText(const char *text)
See InsertNewChildElement()
XMLElement * RootElement()
Definition: tinyxml2.h:1805
virtual bool ShallowEqual(const XMLNode *compare) const
XMLError LoadFile(FILE *)
Definition: tinyxml2.h:1264
void PushText(float value)
Add a text node from a float.
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:699
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:512
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1378
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1186
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1342
XMLError QueryIntValue(int *value) const
void * GetUserData() const
Definition: tinyxml2.h:945
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:2091
bool HasBOM() const
Definition: tinyxml2.h:1793
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1470
void SetAttribute(double value)
Set the attribute to value.
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1394
XMLError QueryDoubleText(double *dval) const
See QueryIntText()
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:2104