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(TIXMLASSERT)
83 #if defined(TINYXML2_DEBUG)
84 # if defined(_MSC_VER)
86 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
87 # elif defined (ANDROID_NDK)
88 # include <android/log.h>
89 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
92 # define TIXMLASSERT assert
95 # define TIXMLASSERT( x ) {}
102 static const int TIXML2_MAJOR_VERSION = 9;
103 static const int TIXML2_MINOR_VERSION = 0;
104 static const int TIXML2_PATCH_VERSION = 0;
106 #define TINYXML2_MAJOR_VERSION 9
107 #define TINYXML2_MINOR_VERSION 0
108 #define TINYXML2_PATCH_VERSION 0
115 static const int TINYXML2_MAX_ELEMENT_DEPTH = 100;
124 class XMLDeclaration;
136 class TINYXML2_LIB StrPair
140 NEEDS_ENTITY_PROCESSING = 0x01,
141 NEEDS_NEWLINE_NORMALIZATION = 0x02,
142 NEEDS_WHITESPACE_COLLAPSING = 0x04,
144 TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
145 TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
147 ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
148 ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
149 COMMENT = NEEDS_NEWLINE_NORMALIZATION
152 StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
155 void Set(
char* start,
char* end,
int flags ) {
156 TIXMLASSERT( start );
161 _flags = flags | NEEDS_FLUSH;
164 const char* GetStr();
167 return _start == _end;
170 void SetInternedStr(
const char* str ) {
172 _start =
const_cast<char*
>(str);
175 void SetStr(
const char* str,
int flags=0 );
177 char* ParseText(
char* in,
const char* endTag,
int strFlags,
int* curLineNumPtr );
178 char* ParseName(
char* in );
180 void TransferTo( StrPair* other );
184 void CollapseWhitespace();
195 StrPair(
const StrPair& other );
196 void operator=(
const StrPair& other );
205 template <
class T,
int INITIAL_SIZE>
211 _allocated( INITIAL_SIZE ),
217 if ( _mem != _pool ) {
227 TIXMLASSERT( _size < INT_MAX );
228 EnsureCapacity( _size+1 );
233 T* PushArr(
int count ) {
234 TIXMLASSERT( count >= 0 );
235 TIXMLASSERT( _size <= INT_MAX - count );
236 EnsureCapacity( _size+count );
237 T* ret = &_mem[_size];
243 TIXMLASSERT( _size > 0 );
248 void PopArr(
int count ) {
249 TIXMLASSERT( _size >= count );
257 T& operator[](
int i) {
258 TIXMLASSERT( i>= 0 && i < _size );
262 const T& operator[](
int i)
const {
263 TIXMLASSERT( i>= 0 && i < _size );
267 const T& PeekTop()
const {
268 TIXMLASSERT( _size > 0 );
269 return _mem[ _size - 1];
273 TIXMLASSERT( _size >= 0 );
277 int Capacity()
const {
278 TIXMLASSERT( _allocated >= INITIAL_SIZE );
282 void SwapRemove(
int i) {
283 TIXMLASSERT(i >= 0 && i < _size);
284 TIXMLASSERT(_size > 0);
285 _mem[i] = _mem[_size - 1];
289 const T* Mem()
const {
300 DynArray(
const DynArray& );
301 void operator=(
const DynArray& );
303 void EnsureCapacity(
int cap ) {
304 TIXMLASSERT( cap > 0 );
305 if ( cap > _allocated ) {
306 TIXMLASSERT( cap <= INT_MAX / 2 );
307 const int newAllocated = cap * 2;
308 T* newMem =
new T[newAllocated];
309 TIXMLASSERT( newAllocated >= _size );
310 memcpy( newMem, _mem,
sizeof(T)*_size );
311 if ( _mem != _pool ) {
315 _allocated = newAllocated;
320 T _pool[INITIAL_SIZE];
334 virtual ~MemPool() {}
336 virtual int ItemSize()
const = 0;
337 virtual void* Alloc() = 0;
338 virtual void Free(
void* ) = 0;
339 virtual void SetTracked() = 0;
346 template<
int ITEM_SIZE >
347 class MemPoolT :
public MemPool
350 MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
352 MemPoolT< ITEM_SIZE >::Clear();
357 while( !_blockPtrs.Empty()) {
358 Block* lastBlock = _blockPtrs.Pop();
368 virtual int ItemSize()
const {
371 int CurrentAllocs()
const {
372 return _currentAllocs;
375 virtual void* Alloc() {
378 Block* block =
new Block();
379 _blockPtrs.Push( block );
381 Item* blockItems = block->items;
382 for(
int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
383 blockItems[i].next = &(blockItems[i + 1]);
385 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
388 Item*
const result = _root;
389 TIXMLASSERT( result != 0 );
393 if ( _currentAllocs > _maxAllocs ) {
394 _maxAllocs = _currentAllocs;
401 virtual void Free(
void* mem ) {
406 Item* item =
static_cast<Item*
>( mem );
407 #ifdef TINYXML2_DEBUG
408 memset( item, 0xfe,
sizeof( *item ) );
413 void Trace(
const char* name ) {
414 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
415 name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
416 ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
423 int Untracked()
const {
438 enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
441 MemPoolT(
const MemPoolT& );
442 void operator=(
const MemPoolT& );
446 char itemData[ITEM_SIZE];
449 Item items[ITEMS_PER_BLOCK];
451 DynArray< Block*, 10 > _blockPtrs;
526 XML_WRONG_ATTRIBUTE_TYPE,
527 XML_ERROR_FILE_NOT_FOUND,
528 XML_ERROR_FILE_COULD_NOT_BE_OPENED,
529 XML_ERROR_FILE_READ_ERROR,
530 XML_ERROR_PARSING_ELEMENT,
531 XML_ERROR_PARSING_ATTRIBUTE,
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,
551 class 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*
const 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 IsPrefixHex(
const char* p) {
595 p = SkipWhiteSpace(p, 0);
596 return p && *p ==
'0' && ( *(p + 1) ==
'x' || *(p + 1) ==
'X');
599 inline static bool StringEqual(
const char* p,
const char* q,
int nChar=INT_MAX ) {
605 TIXMLASSERT( nChar >= 0 );
606 return strncmp( p, q, nChar ) == 0;
609 inline static bool IsUTF8Continuation(
const char p ) {
610 return ( p & 0x80 ) != 0;
613 static const char* ReadBOM(
const char* p,
bool* hasBOM );
616 static const char* GetCharacterRef(
const char* p,
char* value,
int* length );
617 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length );
620 static void ToStr(
int v,
char* buffer,
int bufferSize );
621 static void ToStr(
unsigned v,
char* buffer,
int bufferSize );
622 static void ToStr(
bool v,
char* buffer,
int bufferSize );
623 static void ToStr(
float v,
char* buffer,
int bufferSize );
624 static void ToStr(
double v,
char* buffer,
int bufferSize );
625 static void ToStr(int64_t v,
char* buffer,
int bufferSize);
626 static void ToStr(uint64_t v,
char* buffer,
int bufferSize);
629 static bool ToInt(
const char* str,
int* value );
630 static bool ToUnsigned(
const char* str,
unsigned* value );
631 static bool ToBool(
const char* str,
bool* value );
632 static bool ToFloat(
const char* str,
float* value );
633 static bool ToDouble(
const char* str,
double* value );
634 static bool ToInt64(
const char* str, int64_t* value);
635 static bool ToUnsigned64(
const char* str, uint64_t* value);
641 static void SetBoolSerialization(
const char* writeTrue,
const char* writeFalse);
644 static const char* writeBoolTrue;
645 static const char* writeBoolFalse;
682 TIXMLASSERT( _document );
687 TIXMLASSERT( _document );
719 virtual const XMLText* ToText()
const {
722 virtual const XMLComment* ToComment()
const {
725 virtual const XMLDocument* ToDocument()
const {
728 virtual const XMLDeclaration* ToDeclaration()
const {
731 virtual const XMLUnknown* ToUnknown()
const {
749 void SetValue(
const char* val,
bool staticMem=
false );
782 XMLElement* FirstChildElement(
const char* name = 0 ) {
783 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement( name ));
800 XMLElement* LastChildElement(
const char* name = 0 ) {
801 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name) );
816 XMLElement* PreviousSiblingElement(
const char* name = 0 ) {
817 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement( name ) );
832 XMLElement* NextSiblingElement(
const char* name = 0 ) {
833 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement( name ) );
846 return InsertEndChild( addThis );
952 virtual char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
956 mutable StrPair _value;
970 static void DeleteNode(
XMLNode* node );
971 void InsertChildPreamble(
XMLNode* insertThis )
const;
972 const XMLElement* ToElementWithName(
const char* name )
const;
1000 virtual const XMLText* ToText()
const {
1020 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1025 XMLText(
const XMLText& );
1026 XMLText& operator=(
const XMLText& );
1038 virtual const XMLComment* ToComment()
const {
1051 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
1090 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1112 virtual const XMLUnknown* ToUnknown()
const {
1125 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1168 int64_t Int64Value()
const {
1170 QueryInt64Value(&i);
1174 uint64_t Unsigned64Value()
const {
1176 QueryUnsigned64Value(&i);
1183 QueryUnsignedValue( &i );
1189 QueryBoolValue( &b );
1195 QueryDoubleValue( &d );
1201 QueryFloatValue( &f );
1241 enum { BUF_SIZE = 200 };
1243 XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1244 virtual ~XMLAttribute() {}
1246 XMLAttribute(
const XMLAttribute& );
1247 void operator=(
const XMLAttribute& );
1248 void SetName(
const char* name );
1250 char* ParseDeep(
char* p,
bool processEntities,
int* curLineNumPtr );
1252 mutable StrPair _name;
1253 mutable StrPair _value;
1255 XMLAttribute* _next;
1273 void SetName(
const char* str,
bool staticMem=
false ) {
1274 SetValue( str, staticMem );
1280 virtual const XMLElement* ToElement()
const {
1308 const char*
Attribute(
const char* name,
const char* value=0 )
const;
1346 return XML_NO_ATTRIBUTE;
1355 return XML_NO_ATTRIBUTE;
1364 return XML_NO_ATTRIBUTE;
1373 return XML_NO_ATTRIBUTE;
1382 return XML_NO_ATTRIBUTE;
1390 return XML_NO_ATTRIBUTE;
1398 return XML_NO_ATTRIBUTE;
1407 return XML_NO_ATTRIBUTE;
1409 *value = a->
Value();
1433 return QueryIntAttribute( name, value );
1436 XMLError QueryAttribute(
const char* name,
unsigned int* value )
const {
1437 return QueryUnsignedAttribute( name, value );
1440 XMLError QueryAttribute(
const char* name, int64_t* value)
const {
1441 return QueryInt64Attribute(name, value);
1444 XMLError QueryAttribute(
const char* name, uint64_t* value)
const {
1445 return QueryUnsigned64Attribute(name, value);
1448 XMLError QueryAttribute(
const char* name,
bool* value )
const {
1449 return QueryBoolAttribute( name, value );
1452 XMLError QueryAttribute(
const char* name,
double* value )
const {
1453 return QueryDoubleAttribute( name, value );
1456 XMLError QueryAttribute(
const char* name,
float* value )
const {
1457 return QueryFloatAttribute( name, value );
1460 XMLError QueryAttribute(
const char* name,
const char** value)
const {
1461 return QueryStringAttribute(name, value);
1515 return _rootAttribute;
1640 int IntText(
int defaultValue = 0)
const;
1671 enum ElementClosingType {
1676 ElementClosingType ClosingType()
const {
1677 return _closingType;
1683 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1691 XMLAttribute* FindOrCreateAttribute(
const char* name );
1692 char* ParseAttributes(
char* p,
int* curLineNumPtr );
1693 static void DeleteAttribute(
XMLAttribute* attribute );
1696 enum { BUF_SIZE = 200 };
1697 ElementClosingType _closingType;
1706 PRESERVE_WHITESPACE,
1728 XMLDocument(
bool processEntities =
true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
1732 TIXMLASSERT(
this == _document );
1736 TIXMLASSERT(
this == _document );
1750 XMLError
Parse(
const char* xml,
size_t nBytes=
static_cast<size_t>(-1) );
1777 XMLError
SaveFile(
const char* filename,
bool compact =
false );
1788 bool ProcessEntities()
const {
1789 return _processEntities;
1791 Whitespace WhitespaceMode()
const {
1792 return _whitespaceMode;
1811 return FirstChildElement();
1814 return FirstChildElement();
1882 return _errorID != XML_SUCCESS;
1888 const char* ErrorName()
const;
1889 static const char* ErrorIDToName(XMLError errorID);
1902 return _errorLineNum;
1918 char* Identify(
char* p,
XMLNode** node );
1921 void MarkInUse(
const XMLNode*
const);
1935 bool _processEntities;
1937 Whitespace _whitespaceMode;
1938 mutable StrPair _errorStr;
1941 int _parseCurLineNum;
1949 DynArray<XMLNode*, 10> _unlinked;
1953 MemPoolT<
sizeof(
XMLText) > _textPool;
1956 static const char* _errorNames[XML_ERROR_COUNT];
1960 void SetError( XMLError error,
int lineNum,
const char* format, ... );
1965 class DepthTracker {
1968 this->_document = document;
1969 document->PushDepth();
1972 _document->PopDepth();
1975 XMLDocument * _document;
1980 template<
class NodeType,
int PoolElementSize>
1981 NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
1984 template<
class NodeType,
int PoolElementSize>
1985 inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
1987 TIXMLASSERT(
sizeof( NodeType ) == PoolElementSize );
1988 TIXMLASSERT(
sizeof( NodeType ) == pool.ItemSize() );
1989 NodeType* returnNode =
new (pool.Alloc()) NodeType(
this );
1990 TIXMLASSERT( returnNode );
1991 returnNode->_memPool = &pool;
1993 _unlinked.Push(returnNode);
2072 return XMLHandle( _node ? _node->FirstChild() : 0 );
2076 return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
2080 return XMLHandle( _node ? _node->LastChild() : 0 );
2084 return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2088 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2092 return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2096 return XMLHandle( _node ? _node->NextSibling() : 0 );
2100 return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2109 return ( _node ? _node->ToElement() : 0 );
2113 return ( _node ? _node->ToText() : 0 );
2117 return ( _node ? _node->ToUnknown() : 0 );
2121 return ( _node ? _node->ToDeclaration() : 0 );
2151 const XMLConstHandle FirstChildElement(
const char* name = 0 )
const {
2152 return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2157 const XMLConstHandle LastChildElement(
const char* name = 0 )
const {
2158 return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2163 const XMLConstHandle PreviousSiblingElement(
const char* name = 0 )
const {
2164 return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2169 const XMLConstHandle NextSiblingElement(
const char* name = 0 )
const {
2170 return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2174 const XMLNode* ToNode()
const {
2178 return ( _node ? _node->ToElement() : 0 );
2180 const XMLText* ToText()
const {
2181 return ( _node ? _node->ToText() : 0 );
2184 return ( _node ? _node->ToUnknown() : 0 );
2187 return ( _node ? _node->ToDeclaration() : 0 );
2257 void PushAttribute(
const char* name,
int value );
2258 void PushAttribute(
const char* name,
unsigned value );
2259 void PushAttribute(
const char* name, int64_t value );
2260 void PushAttribute(
const char* name, uint64_t value );
2261 void PushAttribute(
const char* name,
bool value );
2262 void PushAttribute(
const char* name,
double value );
2286 void PushDeclaration(
const char* value );
2287 void PushUnknown(
const char* value );
2307 return _buffer.Mem();
2315 return _buffer.Size();
2324 _firstElement = resetToFirstElement;
2328 virtual bool CompactMode(
const XMLElement& ) {
return _compactMode; }
2334 virtual void Print(
const char* format, ... );
2335 virtual void Write(
const char* data,
size_t size );
2336 virtual void Putc(
char ch );
2338 inline void Write(
const char* data) { Write(data, strlen(data)); }
2340 void SealElementIfJustOpened();
2341 bool _elementJustOpened;
2342 DynArray< const char*, 10 > _stack;
2349 void PrepareForNewNode(
bool compactMode );
2350 void PrintString(
const char*,
bool restrictedEntitySet );
2356 bool _processEntities;
2363 bool _entityFlag[ENTITY_RANGE];
2364 bool _restrictedEntityFlag[ENTITY_RANGE];
2366 DynArray< char, 20 > _buffer;
2369 XMLPrinter(
const XMLPrinter& );
2370 XMLPrinter& operator=(
const XMLPrinter& );
2376 #if defined(_MSC_VER)
2377 # pragma warning(pop)
Definition: tinyxml2.h:1141
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition: tinyxml2.h:1151
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1181
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:1199
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:1193
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:1187
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:1162
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:1154
XMLError QueryUnsigned64Value(uint64_t *value) const
See QueryIntValue.
Definition: tinyxml2.h:2134
Definition: tinyxml2.h:1071
virtual XMLNode * ShallowClone(XMLDocument *document) const
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1074
virtual bool Accept(XMLVisitor *visitor) const
virtual bool ShallowEqual(const XMLNode *compare) const
Definition: tinyxml2.h:1717
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1803
void PrintError() const
A (trivial) utility function that prints the ErrorStr() to stdout.
XMLError LoadFile(const char *filename)
bool HasBOM() const
Definition: tinyxml2.h:1798
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1881
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1731
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:1900
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:1926
XMLError SaveFile(const char *filename, bool compact=false)
void Print(XMLPrinter *streamer=0) const
XMLElement * NewElement(const char *name)
XMLError SaveFile(FILE *fp, bool compact=false)
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1923
XMLText * NewText(const char *text)
void DeleteNode(XMLNode *node)
XMLElement * RootElement()
Definition: tinyxml2.h:1810
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:1885
Definition: tinyxml2.h:1265
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:1465
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1370
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1379
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:1498
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1352
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:1514
virtual bool Accept(XMLVisitor *visitor) const
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:1503
XMLError QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1432
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1387
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1269
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
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:1361
double DoubleText(double defaultValue=0) const
See QueryIntText()
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1343
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:1273
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1493
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:1470
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1481
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
XMLElement * InsertNewChildElement(const char *name)
virtual XMLNode * ShallowClone(XMLDocument *document) const
XMLError QueryUnsigned64Text(uint64_t *uval) const
See QueryIntText()
XMLUnknown * InsertNewUnknown(const char *text)
See InsertNewChildElement()
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1395
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1487
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1277
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1404
XMLDeclaration * InsertNewDeclaration(const char *text)
See InsertNewChildElement()
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1475
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:2053
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:2104
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:2120
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:2087
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:2083
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:2071
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:2108
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:2112
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:2075
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:2065
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:2091
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:2056
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:2079
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:2059
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:2116
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:2095
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:2099
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:2062
Definition: tinyxml2.h:675
void SetUserData(void *userData)
Definition: tinyxml2.h:939
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:708
const XMLElement * FirstChildElement(const char *name=0) const
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:681
void DeleteChild(XMLNode *node)
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:696
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:821
virtual bool ShallowEqual(const XMLNode *compare) const =0
void * GetUserData() const
Definition: tinyxml2.h:946
virtual bool Accept(XMLVisitor *visitor) const =0
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:704
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:712
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:752
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:787
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:692
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:805
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:764
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:755
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:769
XMLNode * InsertEndChild(XMLNode *addThis)
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:686
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:700
Definition: tinyxml2.h:2238
virtual void PrintSpace(int depth)
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2290
void PushHeader(bool writeBOM, bool writeDeclaration)
const char * CStr() const
Definition: tinyxml2.h:2306
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 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:2314
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(uint64_t value)
Add a text node from an unsigned 64bit integer.
void PushText(unsigned value)
Add a text node from an unsigned.
void ClearBuffer(bool resetToFirstElement=true)
Definition: tinyxml2.h:2321
void PushText(int64_t value)
Add a text node from a signed 64bit integer.
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.
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:992
virtual bool Accept(XMLVisitor *visitor) const
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:997
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:1009
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:1005
virtual bool ShallowEqual(const XMLNode *compare) const
virtual XMLNode * ShallowClone(XMLDocument *document) const
Definition: tinyxml2.h:1106
virtual XMLNode * ShallowClone(XMLDocument *document) const
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:1109
Definition: tinyxml2.h:482
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:517
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:491
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:500
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:487
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:513
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:505
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:509
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:496