24#ifndef TINYXML2_INCLUDED
25#define TINYXML2_INCLUDED
27#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
53#if defined(_DEBUG) || defined(__DEBUG__)
61#pragma warning(disable : 4251)
66#define TINYXML2_LIB __declspec(dllexport)
67#elif defined(TINYXML2_IMPORT)
68#define TINYXML2_LIB __declspec(dllimport)
73#define TINYXML2_LIB __attribute__((visibility("default")))
78#if !defined(TIXMLASSERT)
79#if defined(TINYXML2_DEBUG)
82#define TIXMLASSERT(x) \
84 if (!((void)0, (x))) { \
88#elif defined(ANDROID_NDK)
89#include <android/log.h>
90#define TIXMLASSERT(x) \
93 __android_log_assert("assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__); \
98#define TIXMLASSERT assert
101#define TIXMLASSERT(x) \
110static const int TIXML2_MAJOR_VERSION = 10;
111static const int TIXML2_MINOR_VERSION = 0;
112static const int TIXML2_PATCH_VERSION = 0;
114#define TINYXML2_MAJOR_VERSION 10
115#define TINYXML2_MINOR_VERSION 0
116#define TINYXML2_PATCH_VERSION 0
123static const int TINYXML2_MAX_ELEMENT_DEPTH = 500;
143class TINYXML2_LIB StrPair {
146 NEEDS_ENTITY_PROCESSING = 0x01,
147 NEEDS_NEWLINE_NORMALIZATION = 0x02,
148 NEEDS_WHITESPACE_COLLAPSING = 0x04,
150 TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
151 TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
153 ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
154 ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
155 COMMENT = NEEDS_NEWLINE_NORMALIZATION
158 StrPair() : _flags(0), _start(0), _end(0) {}
161 void Set(
char* start,
char* end,
int flags) {
167 _flags = flags | NEEDS_FLUSH;
170 const char* GetStr();
172 bool Empty()
const {
return _start == _end; }
174 void SetInternedStr(
const char* str) {
176 _start =
const_cast<char*
>(str);
179 void SetStr(
const char* str,
int flags = 0);
181 char* ParseText(
char* in,
const char* endTag,
int strFlags,
int* curLineNumPtr);
182 char* ParseName(
char* in);
184 void TransferTo(StrPair* other);
188 void CollapseWhitespace();
190 enum { NEEDS_FLUSH = 0x100, NEEDS_DELETE = 0x200 };
196 StrPair(
const StrPair& other);
197 void operator=(
const StrPair& other);
205template <
class T,
int INITIAL_SIZE>
class DynArray {
207 DynArray() : _mem(_pool), _allocated(INITIAL_SIZE), _size(0) {}
215 void Clear() { _size = 0; }
218 TIXMLASSERT(_size < INT_MAX);
219 EnsureCapacity(_size + 1);
224 T* PushArr(
int count) {
225 TIXMLASSERT(count >= 0);
226 TIXMLASSERT(_size <= INT_MAX - count);
227 EnsureCapacity(_size + count);
228 T* ret = &_mem[_size];
234 TIXMLASSERT(_size > 0);
239 void PopArr(
int count) {
240 TIXMLASSERT(_size >= count);
244 bool Empty()
const {
return _size == 0; }
246 T& operator[](
int i) {
247 TIXMLASSERT(i >= 0 && i < _size);
251 const T& operator[](
int i)
const {
252 TIXMLASSERT(i >= 0 && i < _size);
256 const T& PeekTop()
const {
257 TIXMLASSERT(_size > 0);
258 return _mem[_size - 1];
262 TIXMLASSERT(_size >= 0);
266 int Capacity()
const {
267 TIXMLASSERT(_allocated >= INITIAL_SIZE);
271 void SwapRemove(
int i) {
272 TIXMLASSERT(i >= 0 && i < _size);
273 TIXMLASSERT(_size > 0);
274 _mem[i] = _mem[_size - 1];
278 const T* Mem()
const {
289 DynArray(
const DynArray&);
290 void operator=(
const DynArray&);
292 void EnsureCapacity(
int cap) {
293 TIXMLASSERT(cap > 0);
294 if (cap > _allocated) {
295 TIXMLASSERT(cap <= INT_MAX / 2);
296 const int newAllocated = cap * 2;
297 T* newMem =
new T[
static_cast<unsigned int>(newAllocated)];
298 TIXMLASSERT(newAllocated >= _size);
299 memcpy(newMem, _mem,
sizeof(T) *
static_cast<size_t>(_size));
304 _allocated = newAllocated;
309 T _pool[
static_cast<size_t>(INITIAL_SIZE)];
321 virtual ~MemPool() {}
323 virtual int ItemSize()
const = 0;
324 virtual void* Alloc() = 0;
325 virtual void Free(
void*) = 0;
326 virtual void SetTracked() = 0;
332template <
int ITEM_SIZE>
class MemPoolT :
public MemPool {
334 MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
335 ~MemPoolT() { MemPoolT<ITEM_SIZE>::Clear(); }
339 while (!_blockPtrs.Empty()) {
340 Block* lastBlock = _blockPtrs.Pop();
350 virtual int ItemSize()
const override {
return ITEM_SIZE; }
351 int CurrentAllocs()
const {
return _currentAllocs; }
353 virtual void* Alloc()
override {
357 _blockPtrs.Push(block);
359 Item* blockItems = block->items;
360 for (
int i = 0; i < ITEMS_PER_BLOCK - 1; ++i) {
361 blockItems[i].next = &(blockItems[i + 1]);
363 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
366 Item*
const result = _root;
367 TIXMLASSERT(result != 0);
371 if (_currentAllocs > _maxAllocs) {
372 _maxAllocs = _currentAllocs;
379 virtual void Free(
void* mem)
override {
384 Item* item =
static_cast<Item*
>(mem);
386 memset(item, 0xfe,
sizeof(*item));
391 void Trace(
const char* name) {
392 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs, ITEM_SIZE,
393 _nAllocs, _blockPtrs.Size());
396 void SetTracked()
override { --_nUntracked; }
398 int Untracked()
const {
return _nUntracked; }
411 enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
414 MemPoolT(
const MemPoolT&);
415 void operator=(
const MemPoolT&);
419 char itemData[
static_cast<size_t>(ITEM_SIZE)];
422 Item items[ITEMS_PER_BLOCK];
480 XML_WRONG_ATTRIBUTE_TYPE,
481 XML_ERROR_FILE_NOT_FOUND,
482 XML_ERROR_FILE_COULD_NOT_BE_OPENED,
483 XML_ERROR_FILE_READ_ERROR,
484 XML_ERROR_PARSING_ELEMENT,
485 XML_ERROR_PARSING_ATTRIBUTE,
486 XML_ERROR_PARSING_TEXT,
487 XML_ERROR_PARSING_CDATA,
488 XML_ERROR_PARSING_COMMENT,
489 XML_ERROR_PARSING_DECLARATION,
490 XML_ERROR_PARSING_UNKNOWN,
491 XML_ERROR_EMPTY_DOCUMENT,
492 XML_ERROR_MISMATCHED_ELEMENT,
494 XML_CAN_NOT_CONVERT_TEXT,
496 XML_ELEMENT_DEPTH_EXCEEDED,
506 static const char* SkipWhiteSpace(
const char* p,
int* curLineNumPtr) {
509 while (IsWhiteSpace(*p)) {
510 if (curLineNumPtr && *p ==
'\n') {
518 static char* SkipWhiteSpace(
char*
const p,
int* curLineNumPtr) {
return const_cast<char*
>(SkipWhiteSpace(
const_cast<const char*
>(p), curLineNumPtr)); }
522 static bool IsWhiteSpace(
char p) {
return !IsUTF8Continuation(p) && isspace(
static_cast<unsigned char>(p)); }
524 inline static bool IsNameStartChar(
unsigned char ch) {
532 return ch ==
':' || ch ==
'_';
535 inline static bool IsNameChar(
unsigned char ch) {
return IsNameStartChar(ch) || isdigit(ch) || ch ==
'.' || ch ==
'-'; }
537 inline static bool IsPrefixHex(
const char* p) {
538 p = SkipWhiteSpace(p, 0);
539 return p && *p ==
'0' && (*(p + 1) ==
'x' || *(p + 1) ==
'X');
542 inline static bool StringEqual(
const char* p,
const char* q,
int nChar = INT_MAX) {
548 TIXMLASSERT(nChar >= 0);
549 return strncmp(p, q,
static_cast<size_t>(nChar)) == 0;
552 inline static bool IsUTF8Continuation(
const char p) {
return (p & 0x80) != 0; }
554 static const char* ReadBOM(
const char* p,
bool* hasBOM);
557 static const char* GetCharacterRef(
const char* p,
char* value,
int* length);
558 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length);
561 static void ToStr(
int v,
char* buffer,
int bufferSize);
562 static void ToStr(
unsigned v,
char* buffer,
int bufferSize);
563 static void ToStr(
bool v,
char* buffer,
int bufferSize);
564 static void ToStr(
float v,
char* buffer,
int bufferSize);
565 static void ToStr(
double v,
char* buffer,
int bufferSize);
566 static void ToStr(int64_t v,
char* buffer,
int bufferSize);
567 static void ToStr(uint64_t v,
char* buffer,
int bufferSize);
570 static bool ToInt(
const char* str,
int* value);
571 static bool ToUnsigned(
const char* str,
unsigned* value);
572 static bool ToBool(
const char* str,
bool* value);
573 static bool ToFloat(
const char* str,
float* value);
574 static bool ToDouble(
const char* str,
double* value);
575 static bool ToInt64(
const char* str, int64_t* value);
576 static bool ToUnsigned64(
const char* str, uint64_t* value);
582 static void SetBoolSerialization(
const char* writeTrue,
const char* writeFalse);
585 static const char* writeBoolTrue;
586 static const char* writeBoolFalse;
614class TINYXML2_LIB XMLNode {
615 friend class XMLDocument;
616 friend class XMLElement;
621 TIXMLASSERT(_document);
626 TIXMLASSERT(_document);
643 virtual const XMLElement* ToElement()
const {
return 0; }
644 virtual const XMLText* ToText()
const {
return 0; }
645 virtual const XMLComment* ToComment()
const {
return 0; }
646 virtual const XMLDocument* ToDocument()
const {
return 0; }
647 virtual const XMLDeclaration* ToDeclaration()
const {
return 0; }
648 virtual const XMLUnknown* ToUnknown()
const {
return 0; }
652 int ChildElementCount(
const char* value)
const;
654 int ChildElementCount()
const;
670 void SetValue(
const char* val,
bool staticMem =
false);
676 const XMLNode*
Parent()
const {
return _parent; }
678 XMLNode* Parent() {
return _parent; }
686 XMLNode* FirstChild() {
return _firstChild; }
693 XMLElement*
FirstChildElement(
const char* name = 0) {
return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement(name)); }
698 XMLNode* LastChild() {
return _lastChild; }
705 XMLElement*
LastChildElement(
const char* name = 0) {
return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name)); }
710 XMLNode* PreviousSibling() {
return _prev; }
715 XMLElement*
PreviousSiblingElement(
const char* name = 0) {
return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement(name)); }
720 XMLNode* NextSibling() {
return _next; }
725 XMLElement*
NextSiblingElement(
const char* name = 0) {
return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement(name)); }
736 XMLNode* LinkEndChild(XMLNode* addThis) {
return InsertEndChild(addThis); }
841 virtual char* ParseDeep(
char* p,
StrPair* parentEndTag,
int* curLineNumPtr);
859 static void DeleteNode(
XMLNode* node);
860 void InsertChildPreamble(
XMLNode* insertThis)
const;
861 const XMLElement* ToElementWithName(
const char* name)
const;
879class TINYXML2_LIB XMLText :
public XMLNode {
880 friend class XMLDocument;
885 virtual XMLText*
ToText()
override {
return this; }
886 virtual const XMLText* ToText()
const override {
return this; }
889 void SetCData(
bool isCData) { _isCData = isCData; }
891 bool CData()
const {
return _isCData; }
897 explicit XMLText(XMLDocument* doc) : XMLNode(doc), _isCData(false) {}
900 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr)
override;
905 XMLText(
const XMLText&);
906 XMLText& operator=(
const XMLText&);
910class TINYXML2_LIB XMLComment :
public XMLNode {
911 friend class XMLDocument;
914 virtual XMLComment*
ToComment()
override {
return this; }
915 virtual const XMLComment* ToComment()
const override {
return this; }
923 explicit XMLComment(XMLDocument* doc);
924 virtual ~XMLComment();
926 char* ParseDeep(
char* p,
StrPair* parentEndTag,
int* curLineNumPtr)
override;
929 XMLComment(
const XMLComment&);
930 XMLComment& operator=(
const XMLComment&);
944class TINYXML2_LIB XMLDeclaration :
public XMLNode {
945 friend class XMLDocument;
949 virtual const XMLDeclaration* ToDeclaration()
const override {
return this; }
957 explicit XMLDeclaration(XMLDocument* doc);
958 virtual ~XMLDeclaration();
960 char* ParseDeep(
char* p,
StrPair* parentEndTag,
int* curLineNumPtr)
override;
963 XMLDeclaration(
const XMLDeclaration&);
964 XMLDeclaration& operator=(
const XMLDeclaration&);
974class TINYXML2_LIB XMLUnknown :
public XMLNode {
975 friend class XMLDocument;
978 virtual XMLUnknown*
ToUnknown()
override {
return this; }
979 virtual const XMLUnknown* ToUnknown()
const override {
return this; }
987 explicit XMLUnknown(XMLDocument* doc);
988 virtual ~XMLUnknown();
990 char* ParseDeep(
char* p,
StrPair* parentEndTag,
int* curLineNumPtr)
override;
993 XMLUnknown(
const XMLUnknown&);
994 XMLUnknown& operator=(
const XMLUnknown&);
1003class TINYXML2_LIB XMLAttribute {
1004 friend class XMLElement;
1017 const XMLAttribute*
Next()
const {
return _next; }
1029 int64_t Int64Value()
const {
1031 QueryInt64Value(&i);
1035 uint64_t Unsigned64Value()
const {
1037 QueryUnsigned64Value(&i);
1102 enum { BUF_SIZE = 200 };
1104 XMLAttribute() : _name(), _value(), _parseLineNum(0), _next(0), _memPool(0) {}
1105 virtual ~XMLAttribute() {}
1107 XMLAttribute(
const XMLAttribute&);
1108 void operator=(
const XMLAttribute&);
1109 void SetName(
const char* name);
1111 char* ParseDeep(
char* p,
bool processEntities,
int* curLineNumPtr);
1113 mutable StrPair _name;
1114 mutable StrPair _value;
1116 XMLAttribute* _next;
1124class TINYXML2_LIB XMLElement :
public XMLNode {
1125 friend class XMLDocument;
1134 virtual const XMLElement* ToElement()
const override {
return this; }
1160 const char*
Attribute(
const char* name,
const char* value = 0)
const;
1198 return XML_NO_ATTRIBUTE;
1207 return XML_NO_ATTRIBUTE;
1216 return XML_NO_ATTRIBUTE;
1225 return XML_NO_ATTRIBUTE;
1234 return XML_NO_ATTRIBUTE;
1242 return XML_NO_ATTRIBUTE;
1250 return XML_NO_ATTRIBUTE;
1259 return XML_NO_ATTRIBUTE;
1261 *value = a->
Value();
1284 XMLError QueryAttribute(
const char* name,
unsigned int* value)
const {
return QueryUnsignedAttribute(name, value); }
1286 XMLError QueryAttribute(
const char* name, int64_t* value)
const {
return QueryInt64Attribute(name, value); }
1288 XMLError QueryAttribute(
const char* name, uint64_t* value)
const {
return QueryUnsigned64Attribute(name, value); }
1290 XMLError QueryAttribute(
const char* name,
bool* value)
const {
return QueryBoolAttribute(name, value); }
1292 XMLError QueryAttribute(
const char* name,
double* value)
const {
return QueryDoubleAttribute(name, value); }
1294 XMLError QueryAttribute(
const char* name,
float* value)
const {
return QueryFloatAttribute(name, value); }
1296 XMLError QueryAttribute(
const char* name,
const char** value)
const {
return QueryStringAttribute(name, value); }
1472 int IntText(
int defaultValue = 0)
const;
1502 enum ElementClosingType {
1507 ElementClosingType ClosingType()
const {
return _closingType; }
1512 char* ParseDeep(
char* p,
StrPair* parentEndTag,
int* curLineNumPtr)
override;
1515 XMLElement(XMLDocument* doc);
1516 virtual ~XMLElement();
1517 XMLElement(
const XMLElement&);
1518 void operator=(
const XMLElement&);
1521 char* ParseAttributes(
char* p,
int* curLineNumPtr);
1525 enum { BUF_SIZE = 200 };
1526 ElementClosingType _closingType;
1533enum Whitespace { PRESERVE_WHITESPACE, COLLAPSE_WHITESPACE, PEDANTIC_WHITESPACE };
1541 friend class XMLElement;
1544 friend class XMLNode;
1545 friend class XMLText;
1546 friend class XMLComment;
1547 friend class XMLDeclaration;
1548 friend class XMLUnknown;
1552 XMLDocument(
bool processEntities =
true, Whitespace whitespaceMode = PRESERVE_WHITESPACE);
1556 TIXMLASSERT(
this == _document);
1559 virtual const XMLDocument* ToDocument()
const override {
1560 TIXMLASSERT(
this == _document);
1574 XMLError
Parse(
const char* xml,
size_t nBytes =
static_cast<size_t>(-1));
1601 XMLError
SaveFile(
const char* filename,
bool compact =
false);
1612 bool ProcessEntities()
const {
return _processEntities; }
1613 Whitespace WhitespaceMode()
const {
return _whitespaceMode; }
1621 void SetBOM(
bool useBOM) { _writeBOM = useBOM; }
1627 const XMLElement* RootElement()
const {
return FirstChildElement(); }
1693 bool Error()
const {
return _errorID != XML_SUCCESS; }
1696 const char* ErrorName()
const;
1697 static const char* ErrorIDToName(XMLError errorID);
1723 char* Identify(
char* p, XMLNode** node,
bool first);
1726 void MarkInUse(
const XMLNode*
const);
1729 virtual bool ShallowEqual(
const XMLNode* )
const override {
return false; }
1736 bool _processEntities;
1738 Whitespace _whitespaceMode;
1742 int _parseCurLineNum;
1757 static const char* _errorNames[XML_ERROR_COUNT];
1761 void SetError(XMLError error,
int lineNum,
const char* format, ...);
1766 class DepthTracker {
1769 this->_document = document;
1770 document->PushDepth();
1772 ~DepthTracker() { _document->PopDepth(); }
1783template <
class NodeType,
int PoolElementSize>
inline NodeType* XMLDocument::CreateUnlinkedNode(
MemPoolT<PoolElementSize>& pool) {
1784 TIXMLASSERT(
sizeof(NodeType) == PoolElementSize);
1785 TIXMLASSERT(
sizeof(NodeType) == pool.ItemSize());
1786 NodeType* returnNode =
new (pool.Alloc()) NodeType(
this);
1787 TIXMLASSERT(returnNode);
1788 returnNode->_memPool = &pool;
1790 _unlinked.Push(returnNode);
1899class TINYXML2_LIB XMLConstHandle {
1901 explicit XMLConstHandle(
const XMLNode* node) : _node(node) {}
1902 explicit XMLConstHandle(
const XMLNode& node) : _node(&node) {}
1903 XMLConstHandle(
const XMLConstHandle& ref) : _node(ref._node) {}
1905 XMLConstHandle& operator=(
const XMLConstHandle& ref) {
1910 const XMLConstHandle FirstChild()
const {
return XMLConstHandle(_node ? _node->FirstChild() : 0); }
1911 const XMLConstHandle FirstChildElement(
const char* name = 0)
const {
return XMLConstHandle(_node ? _node->FirstChildElement(name) : 0); }
1912 const XMLConstHandle LastChild()
const {
return XMLConstHandle(_node ? _node->LastChild() : 0); }
1913 const XMLConstHandle LastChildElement(
const char* name = 0)
const {
return XMLConstHandle(_node ? _node->LastChildElement(name) : 0); }
1914 const XMLConstHandle PreviousSibling()
const {
return XMLConstHandle(_node ? _node->PreviousSibling() : 0); }
1915 const XMLConstHandle PreviousSiblingElement(
const char* name = 0)
const {
return XMLConstHandle(_node ? _node->PreviousSiblingElement(name) : 0); }
1916 const XMLConstHandle NextSibling()
const {
return XMLConstHandle(_node ? _node->NextSibling() : 0); }
1917 const XMLConstHandle NextSiblingElement(
const char* name = 0)
const {
return XMLConstHandle(_node ? _node->NextSiblingElement(name) : 0); }
1919 const XMLNode* ToNode()
const {
return _node; }
1920 const XMLElement* ToElement()
const {
return (_node ? _node->ToElement() : 0); }
1921 const XMLText* ToText()
const {
return (_node ? _node->ToText() : 0); }
1922 const XMLUnknown* ToUnknown()
const {
return (_node ? _node->ToUnknown() : 0); }
1923 const XMLDeclaration* ToDeclaration()
const {
return (_node ? _node->ToDeclaration() : 0); }
2019 void PushDeclaration(
const char* value);
2020 void PushUnknown(
const char* value);
2037 const char*
CStr()
const {
return _buffer.Mem(); }
2051 _firstElement = resetToFirstElement;
2055 virtual bool CompactMode(
const XMLElement&) {
return _compactMode; }
2061 virtual void Print(
const char* format, ...);
2062 virtual void Write(
const char* data,
size_t size);
2063 virtual void Putc(
char ch);
2065 inline void Write(
const char* data) { Write(data, strlen(data)); }
2067 void SealElementIfJustOpened();
2068 bool _elementJustOpened;
2077 void PrintString(
const char*,
bool restrictedEntitySet);
2083 bool _processEntities;
2086 enum { ENTITY_RANGE = 64, BUF_SIZE = 200 };
2087 bool _entityFlag[ENTITY_RANGE];
2088 bool _restrictedEntityFlag[ENTITY_RANGE];
2099#if defined(_MSC_VER)
Definition tinyxml2.h:205
Definition tinyxml2.h:332
Definition tinyxml2.h:318
Definition tinyxml2.h:143
Definition tinyxml2.h:1003
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition tinyxml2.h:1014
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition tinyxml2.h:1042
void SetAttribute(uint64_t value)
Set the attribute to value.
float FloatValue() const
Query as a float. See IntValue()
Definition tinyxml2.h:1060
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:1054
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:1048
void SetAttribute(double value)
Set the attribute to value.
const XMLAttribute * Next() const
The next attribute in the list.
Definition tinyxml2.h:1017
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:1023
void SetAttribute(unsigned value)
Set the attribute to value.
void SetAttribute(float value)
Set the attribute to value.
XMLError QueryUnsigned64Value(uint64_t *value) const
See QueryIntValue.
Definition tinyxml2.h:944
virtual XMLNode * ShallowClone(XMLDocument *document) const override
virtual bool ShallowEqual(const XMLNode *compare) const override
virtual XMLDeclaration * ToDeclaration() override
Safely cast to a Declaration, or null.
Definition tinyxml2.h:948
virtual bool Accept(XMLVisitor *visitor) const override
Definition tinyxml2.h:1540
virtual XMLNode * ShallowClone(XMLDocument *) const override
Definition tinyxml2.h:1728
XMLElement * RootElement()
Definition tinyxml2.h:1626
void SetBOM(bool useBOM)
Definition tinyxml2.h:1621
void PrintError() const
A (trivial) utility function that prints the ErrorStr() to stdout.
virtual XMLDocument * ToDocument() override
Safely cast to a Document, or null.
Definition tinyxml2.h:1555
XMLError LoadFile(const char *filename)
bool HasBOM() const
Definition tinyxml2.h:1618
bool Error() const
Return true if there was an error parsing the document.
Definition tinyxml2.h:1693
XMLComment * NewComment(const char *comment)
XMLElement * NewElement(const char *name)
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:1708
XMLDocument(bool processEntities=true, Whitespace whitespaceMode=PRESERVE_WHITESPACE)
constructor
XMLError LoadFile(FILE *)
void Clear()
Clear the document, resetting it to the initial state.
XMLError SaveFile(const char *filename, bool compact=false)
virtual bool Accept(XMLVisitor *visitor) const override
void Print(XMLPrinter *streamer=0) const
XMLError SaveFile(FILE *fp, bool compact=false)
void DeleteNode(XMLNode *node)
virtual bool ShallowEqual(const XMLNode *) const override
Definition tinyxml2.h:1729
XMLText * NewText(const char *text)
XMLDeclaration * NewDeclaration(const char *text=0)
const char * ErrorStr() const
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:1695
Definition tinyxml2.h:1124
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:1299
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1222
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1231
XMLError QueryUnsignedText(unsigned *uval) const
See QueryIntText()
const XMLAttribute * FindAttribute(const char *name) const
Query a specific attribute in the list.
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:1332
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1204
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:1348
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:1337
XMLError QueryAttribute(const char *name, int *value) const
Definition tinyxml2.h:1282
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1239
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()
virtual XMLNode * ShallowClone(XMLDocument *document) const override
void SetText(uint64_t value)
Convenience method for setting text inside an element. See SetText() for important limitations.
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:1213
XMLDeclaration * InsertNewDeclaration(const char *text)
See InsertNewChildElement()
double DoubleText(double defaultValue=0) const
See QueryIntText()
virtual XMLElement * ToElement() override
Safely cast to an Element, or null.
Definition tinyxml2.h:1133
XMLError QueryIntAttribute(const char *name, int *value) const
Definition tinyxml2.h:1195
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:1131
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition tinyxml2.h:1327
int64_t Int64Text(int64_t defaultValue=0) const
See QueryIntText()
virtual bool ShallowEqual(const XMLNode *compare) const override
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition tinyxml2.h:1304
XMLComment * InsertNewComment(const char *comment)
See InsertNewChildElement()
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition tinyxml2.h:1315
float FloatAttribute(const char *name, float defaultValue=0) const
See IntAttribute()
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition tinyxml2.h:1129
XMLElement * InsertNewChildElement(const char *name)
XMLError QueryUnsigned64Text(uint64_t *uval) const
See QueryIntText()
XMLText * InsertNewText(const char *text)
See InsertNewChildElement()
virtual bool Accept(XMLVisitor *visitor) const override
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1247
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
Definition tinyxml2.h:1321
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition tinyxml2.h:1256
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition tinyxml2.h:1309
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)
uint64_t Unsigned64Text(uint64_t defaultValue=0) const
See QueryIntText()
XMLError QueryFloatText(float *fval) const
See QueryIntText()
XMLUnknown * InsertNewUnknown(const char *text)
See InsertNewChildElement()
unsigned UnsignedAttribute(const char *name, unsigned defaultValue=0) const
See IntAttribute()
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition tinyxml2.h:1872
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition tinyxml2.h:1870
XMLHandle FirstChild()
Get the first child of this handle.
Definition tinyxml2.h:1864
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition tinyxml2.h:1881
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition tinyxml2.h:1866
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition tinyxml2.h:1874
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition tinyxml2.h:1889
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition tinyxml2.h:1852
XMLHandle LastChild()
Get the last child of this handle.
Definition tinyxml2.h:1868
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition tinyxml2.h:1858
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition tinyxml2.h:1854
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition tinyxml2.h:1876
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition tinyxml2.h:1883
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition tinyxml2.h:1885
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition tinyxml2.h:1887
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition tinyxml2.h:1878
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition tinyxml2.h:1856
Definition tinyxml2.h:614
void SetUserData(void *userData)
Definition tinyxml2.h:828
const char * Value() const
void SetValue(const char *val, bool staticMem=false)
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition tinyxml2.h:633
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition tinyxml2.h:639
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:835
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:625
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition tinyxml2.h:676
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition tinyxml2.h:635
const XMLElement * LastChildElement(const char *name=0) const
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition tinyxml2.h:637
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition tinyxml2.h:696
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition tinyxml2.h:620
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:708
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition tinyxml2.h:631
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:673
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition tinyxml2.h:641
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition tinyxml2.h:684
bool NoChildren() const
Returns true if this node has no children.
Definition tinyxml2.h:681
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLNode * InsertEndChild(XMLNode *addThis)
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition tinyxml2.h:718
Definition tinyxml2.h:1971
virtual void PrintSpace(int depth)
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)
virtual bool VisitExit(const XMLDocument &) override
Visit a document.
Definition tinyxml2.h:2023
virtual bool Visit(const XMLUnknown &unknown) override
Visit an unknown node.
int CStrSize() const
Definition tinyxml2.h:2043
void PushText(int value)
Add a text node from an integer.
void PushText(bool value)
Add a text node from a bool.
virtual bool VisitEnter(const XMLElement &element, const XMLAttribute *attribute) override
Visit an element.
void PushText(uint64_t value)
Add a text node from an unsigned 64bit integer.
virtual bool Visit(const XMLDeclaration &declaration) override
Visit a declaration.
void PushText(unsigned value)
Add a text node from an unsigned.
void ClearBuffer(bool resetToFirstElement=true)
Definition tinyxml2.h:2048
virtual bool VisitEnter(const XMLDocument &) override
Visit a document.
virtual bool Visit(const XMLComment &comment) override
Visit a comment node.
void PrepareForNewNode(bool compactMode)
void PushText(int64_t value)
Add a text node from a signed 64bit integer.
virtual bool VisitExit(const XMLElement &element) override
Visit an element.
void PushAttribute(const char *name, const char *value)
If streaming, add an attribute to an open element.
XMLPrinter(FILE *file=0, bool compact=false, int depth=0)
void PushText(double value)
Add a text node from a double.
const char * CStr() const
Definition tinyxml2.h:2037
virtual void CloseElement(bool compactMode=false)
If streaming, close the Element.
virtual bool Visit(const XMLText &text) override
Visit a text node.
void PushComment(const char *comment)
Add a comment.
Definition tinyxml2.h:879
virtual bool ShallowEqual(const XMLNode *compare) const override
virtual XMLText * ToText() override
Safely cast to Text, or null.
Definition tinyxml2.h:885
virtual XMLNode * ShallowClone(XMLDocument *document) const override
virtual bool Accept(XMLVisitor *visitor) const override
bool CData() const
Returns true if this is a CDATA text element.
Definition tinyxml2.h:891
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition tinyxml2.h:889
Definition tinyxml2.h:974
virtual bool ShallowEqual(const XMLNode *compare) const override
virtual XMLNode * ShallowClone(XMLDocument *document) const override
virtual XMLUnknown * ToUnknown() override
Safely cast to an Unknown, or null.
Definition tinyxml2.h:978
virtual bool Accept(XMLVisitor *visitor) const override
Definition tinyxml2.h:504
Definition tinyxml2.h:452
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition tinyxml2.h:473
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:459
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition tinyxml2.h:464
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:457
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition tinyxml2.h:471
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition tinyxml2.h:467
virtual bool Visit(const XMLText &)
Visit a text node.
Definition tinyxml2.h:469
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition tinyxml2.h:462
Definition tinyxml2.h:421
Definition tinyxml2.h:417