Go to the documentation of this file.
24 #ifndef TINYXML2_INCLUDED
25 #define TINYXML2_INCLUDED
27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
53 #if defined( _DEBUG ) || defined (__DEBUG__)
54 # ifndef TINYXML2_DEBUG
55 # define TINYXML2_DEBUG
60 # pragma warning(push)
61 # pragma warning(disable: 4251)
65 # ifdef TINYXML2_EXPORT
66 # define TINYXML2_LIB __declspec(dllexport)
67 # elif defined(TINYXML2_IMPORT)
68 # define TINYXML2_LIB __declspec(dllimport)
73 # define TINYXML2_LIB __attribute__((visibility("default")))
79 #if !defined(TIXMLASSERT)
80 #if defined(TINYXML2_DEBUG)
81 # if defined(_MSC_VER)
82 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
83 # define TIXMLASSERT( x ) do { if ( !((void)0,(x))) { __debugbreak(); } } while(false)
84 # elif defined (ANDROID_NDK)
85 # include <android/log.h>
86 # define TIXMLASSERT( x ) do { if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } } while(false)
89 # define TIXMLASSERT assert
92 # define TIXMLASSERT( x ) do {} while(false)
103 #define TINYXML2_MAJOR_VERSION 10
104 #define TINYXML2_MINOR_VERSION 0
105 #define TINYXML2_PATCH_VERSION 0
121 class XMLDeclaration;
137 NEEDS_ENTITY_PROCESSING = 0x01,
138 NEEDS_NEWLINE_NORMALIZATION = 0x02,
139 NEEDS_WHITESPACE_COLLAPSING = 0x04,
141 TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
142 TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
144 ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
145 ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
146 COMMENT = NEEDS_NEWLINE_NORMALIZATION
149 StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
152 void Set(
char* start,
char*
end,
int flags ) {
158 _flags = flags | NEEDS_FLUSH;
161 const char* GetStr();
164 return _start == _end;
169 _start =
const_cast<char*
>(str);
172 void SetStr(
const char* str,
int flags=0 );
174 char* ParseText(
char* in,
const char* endTag,
int strFlags,
int* curLineNumPtr );
175 char* ParseName(
char* in );
177 void TransferTo(
StrPair* other );
181 void CollapseWhitespace();
193 void operator=(
const StrPair& other );
202 template <
class T,
int INITIAL_SIZE>
304 const int newAllocated = cap * 2;
305 T* newMem =
new T[
static_cast<unsigned int>(newAllocated)];
307 memcpy( newMem,
_mem,
sizeof(T)*
static_cast<size_t>(
_size) );
317 T
_pool[
static_cast<size_t>(INITIAL_SIZE)];
334 virtual void*
Alloc() = 0;
335 virtual void Free(
void* ) = 0;
343 template<
int ITEM_SIZE >
375 Block* block =
new Block;
378 Item* blockItems = block->items;
380 blockItems[i].next = &(blockItems[i + 1]);
385 Item*
const result =
_root;
398 virtual void Free(
void* mem )
override {
403 Item* item =
static_cast<Item*
>( mem );
404 #ifdef TINYXML2_DEBUG
405 memset( item, 0xfe,
sizeof( *item ) );
411 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
554 while( IsWhiteSpace(*
p) ) {
555 if (curLineNumPtr && *
p ==
'\n') {
564 return const_cast<char*
>( SkipWhiteSpace(
const_cast<const char*
>(
p), curLineNumPtr ) );
570 return !IsUTF8Continuation(
p) && isspace(
static_cast<unsigned char>(
p) );
578 if ( isalpha( ch ) ) {
581 return ch ==
':' || ch ==
'_';
585 return IsNameStartChar( ch )
592 p = SkipWhiteSpace(
p, 0);
593 return p && *
p ==
'0' && ( *(
p + 1) ==
'x' || *(
p + 1) ==
'X');
596 inline static bool StringEqual(
const char*
p,
const char* q,
int nChar=INT_MAX ) {
603 return strncmp(
p, q,
static_cast<size_t>(nChar) ) == 0;
607 return (
p & 0x80 ) != 0;
610 static const char* ReadBOM(
const char*
p,
bool* hasBOM );
613 static const char* GetCharacterRef(
const char*
p,
char* value,
int* length );
614 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length );
617 static void ToStr(
int v,
char*
buffer,
int bufferSize );
618 static void ToStr(
unsigned v,
char*
buffer,
int bufferSize );
619 static void ToStr(
bool v,
char*
buffer,
int bufferSize );
620 static void ToStr(
float v,
char*
buffer,
int bufferSize );
621 static void ToStr(
double v,
char*
buffer,
int bufferSize );
622 static void ToStr(int64_t v,
char*
buffer,
int bufferSize);
623 static void ToStr(uint64_t v,
char*
buffer,
int bufferSize);
626 static bool ToInt(
const char* str,
int* value );
627 static bool ToUnsigned(
const char* str,
unsigned* value );
628 static bool ToBool(
const char* str,
bool* value );
629 static bool ToFloat(
const char* str,
float* value );
630 static bool ToDouble(
const char* str,
double* value );
631 static bool ToInt64(
const char* str, int64_t* value);
632 static bool ToUnsigned64(
const char* str, uint64_t* value);
638 static void SetBoolSerialization(
const char* writeTrue,
const char* writeFalse);
734 int ChildElementCount(
const char *
value)
const;
736 int ChildElementCount()
const;
747 const char* Value()
const;
752 void SetValue(
const char* val,
bool staticMem=
false );
783 const XMLElement* FirstChildElement(
const char* name = 0 )
const;
786 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement( name ));
801 const XMLElement* LastChildElement(
const char* name = 0 )
const;
804 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name) );
817 const XMLElement* PreviousSiblingElement(
const char* name = 0 )
const ;
820 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement( name ) );
833 const XMLElement* NextSiblingElement(
const char* name = 0 )
const;
836 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement( name ) );
849 return InsertEndChild( addThis );
872 void DeleteChildren();
877 void DeleteChild(
XMLNode* node );
911 virtual bool ShallowEqual(
const XMLNode* compare )
const = 0;
935 virtual bool Accept(
XMLVisitor* visitor )
const = 0;
955 virtual char* ParseDeep(
char*
p,
StrPair* parentEndTag,
int* curLineNumPtr);
973 static void DeleteNode(
XMLNode* node );
974 void InsertChildPreamble(
XMLNode* insertThis )
const;
975 const XMLElement* ToElementWithName(
const char* name )
const;
998 virtual bool Accept(
XMLVisitor* visitor )
const override;
1017 virtual bool ShallowEqual(
const XMLNode* compare )
const override;
1023 char* ParseDeep(
char*
p,
StrPair* parentEndTag,
int* curLineNumPtr )
override;
1045 virtual bool Accept(
XMLVisitor* visitor )
const override;
1048 virtual bool ShallowEqual(
const XMLNode* compare )
const override;
1054 char* ParseDeep(
char*
p,
StrPair* parentEndTag,
int* curLineNumPtr)
override;
1084 virtual bool Accept(
XMLVisitor* visitor )
const override;
1087 virtual bool ShallowEqual(
const XMLNode* compare )
const override;
1093 char* ParseDeep(
char*
p,
StrPair* parentEndTag,
int* curLineNumPtr )
override;
1119 virtual bool Accept(
XMLVisitor* visitor )
const override;
1122 virtual bool ShallowEqual(
const XMLNode* compare )
const override;
1128 char* ParseDeep(
char*
p,
StrPair* parentEndTag,
int* curLineNumPtr )
override;
1148 const char* Name()
const;
1151 const char* Value()
const;
1173 QueryInt64Value(&i);
1179 QueryUnsigned64Value(&i);
1186 QueryUnsignedValue( &i );
1192 QueryBoolValue( &b );
1198 QueryDoubleValue( &d );
1204 QueryFloatValue( &
f );
1227 void SetAttribute(
const char*
value );
1229 void SetAttribute(
int value );
1231 void SetAttribute(
unsigned value );
1233 void SetAttribute(int64_t
value);
1235 void SetAttribute(uint64_t
value);
1237 void SetAttribute(
bool value );
1239 void SetAttribute(
double value );
1241 void SetAttribute(
float value );
1244 enum { BUF_SIZE = 200 };
1246 XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1251 void SetName(
const char* name );
1253 char* ParseDeep(
char*
p,
bool processEntities,
int* curLineNumPtr );
1276 void SetName(
const char* str,
bool staticMem=
false ) {
1277 SetValue( str, staticMem );
1286 virtual bool Accept(
XMLVisitor* visitor )
const override;
1311 const char* Attribute(
const char* name,
const char*
value=0 )
const;
1319 int IntAttribute(
const char* name,
int defaultValue = 0)
const;
1321 unsigned UnsignedAttribute(
const char* name,
unsigned defaultValue = 0)
const;
1323 int64_t Int64Attribute(
const char* name, int64_t defaultValue = 0)
const;
1325 uint64_t Unsigned64Attribute(
const char* name, uint64_t defaultValue = 0)
const;
1327 bool BoolAttribute(
const char* name,
bool defaultValue =
false)
const;
1329 double DoubleAttribute(
const char* name,
double defaultValue = 0)
const;
1331 float FloatAttribute(
const char* name,
float defaultValue = 0)
const;
1436 return QueryIntAttribute( name,
value );
1440 return QueryUnsignedAttribute( name,
value );
1444 return QueryInt64Attribute(name,
value);
1448 return QueryUnsigned64Attribute(name,
value);
1452 return QueryBoolAttribute( name,
value );
1456 return QueryDoubleAttribute( name,
value );
1460 return QueryFloatAttribute( name,
value );
1464 return QueryStringAttribute(name,
value);
1514 void DeleteAttribute(
const char* name );
1518 return _rootAttribute;
1521 const XMLAttribute* FindAttribute(
const char* name )
const;
1551 const char* GetText()
const;
1587 void SetText(
const char* inText );
1589 void SetText(
int value );
1591 void SetText(
unsigned value );
1593 void SetText(int64_t
value);
1595 void SetText(uint64_t
value);
1597 void SetText(
bool value );
1599 void SetText(
double value );
1601 void SetText(
float value );
1629 XMLError QueryIntText(
int* ival )
const;
1631 XMLError QueryUnsignedText(
unsigned* uval )
const;
1633 XMLError QueryInt64Text(int64_t* uval)
const;
1635 XMLError QueryUnsigned64Text(uint64_t* uval)
const;
1637 XMLError QueryBoolText(
bool* bval )
const;
1639 XMLError QueryDoubleText(
double* dval )
const;
1641 XMLError QueryFloatText(
float* fval )
const;
1643 int IntText(
int defaultValue = 0)
const;
1646 unsigned UnsignedText(
unsigned defaultValue = 0)
const;
1648 int64_t Int64Text(int64_t defaultValue = 0)
const;
1650 uint64_t Unsigned64Text(uint64_t defaultValue = 0)
const;
1652 bool BoolText(
bool defaultValue =
false)
const;
1654 double DoubleText(
double defaultValue = 0)
const;
1656 float FloatText(
float defaultValue = 0)
const;
1662 XMLElement* InsertNewChildElement(
const char* name);
1664 XMLComment* InsertNewComment(
const char* comment);
1666 XMLText* InsertNewText(
const char* text);
1670 XMLUnknown* InsertNewUnknown(
const char* text);
1680 return _closingType;
1683 virtual bool ShallowEqual(
const XMLNode* compare )
const override;
1686 char* ParseDeep(
char*
p,
StrPair* parentEndTag,
int* curLineNumPtr )
override;
1694 XMLAttribute* FindOrCreateAttribute(
const char* name );
1695 char* ParseAttributes(
char*
p,
int* curLineNumPtr );
1696 static void DeleteAttribute(
XMLAttribute* attribute );
1699 enum { BUF_SIZE = 200 };
1754 XMLError Parse(
const char* xml,
size_t nBytes=
static_cast<size_t>(-1) );
1761 XMLError LoadFile(
const char* filename );
1781 XMLError SaveFile(
const char* filename,
bool compact =
false );
1790 XMLError SaveFile( FILE* fp,
bool compact =
false );
1793 return _processEntities;
1796 return _whitespaceMode;
1815 return FirstChildElement();
1818 return FirstChildElement();
1836 virtual bool Accept(
XMLVisitor* visitor )
const override;
1849 XMLComment* NewComment(
const char* comment );
1855 XMLText* NewText(
const char* text );
1879 void DeleteNode(
XMLNode* node );
1892 const char* ErrorName()
const;
1893 static const char* ErrorIDToName(
XMLError errorID);
1898 const char* ErrorStr()
const;
1901 void PrintError()
const;
1906 return _errorLineNum;
1922 char* Identify(
char*
p,
XMLNode** node,
bool first );
1925 void MarkInUse(
const XMLNode*
const);
1964 void SetError(
XMLError error,
int lineNum,
const char* format, ... );
1972 this->_document = document;
1976 _document->PopDepth();
1984 template<
class NodeType,
int PoolElementSize>
1988 template<
class NodeType,
int PoolElementSize>
1995 returnNode->_memPool = &pool;
2076 return XMLHandle( _node ? _node->FirstChild() : 0 );
2080 return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
2084 return XMLHandle( _node ? _node->LastChild() : 0 );
2088 return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2092 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2096 return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2100 return XMLHandle( _node ? _node->NextSibling() : 0 );
2104 return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2113 return ( _node ? _node->ToElement() : 0 );
2117 return ( _node ? _node->ToText() : 0 );
2121 return ( _node ? _node->ToUnknown() : 0 );
2125 return ( _node ? _node->ToDeclaration() : 0 );
2156 return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2162 return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2168 return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2174 return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2182 return ( _node ? _node->ToElement() : 0 );
2185 return ( _node ? _node->ToText() : 0 );
2188 return ( _node ? _node->ToUnknown() : 0 );
2191 return ( _node ? _node->ToDeclaration() : 0 );
2250 XMLPrinter( FILE* file=0,
bool compact =
false,
int depth = 0 );
2254 void PushHeader(
bool writeBOM,
bool writeDeclaration );
2258 void OpenElement(
const char* name,
bool compactMode=
false );
2260 void PushAttribute(
const char* name,
const char* value );
2261 void PushAttribute(
const char* name,
int value );
2262 void PushAttribute(
const char* name,
unsigned value );
2263 void PushAttribute(
const char* name, int64_t value );
2264 void PushAttribute(
const char* name, uint64_t value );
2265 void PushAttribute(
const char* name,
bool value );
2266 void PushAttribute(
const char* name,
double value );
2268 virtual void CloseElement(
bool compactMode=
false );
2271 void PushText(
const char* text,
bool cdata=
false );
2273 void PushText(
int value );
2275 void PushText(
unsigned value );
2277 void PushText( int64_t value );
2279 void PushText( uint64_t value );
2281 void PushText(
bool value );
2283 void PushText(
float value );
2285 void PushText(
double value );
2288 void PushComment(
const char* comment );
2290 void PushDeclaration(
const char* value );
2291 void PushUnknown(
const char* value );
2293 virtual bool VisitEnter(
const XMLDocument& )
override;
2299 virtual bool VisitExit(
const XMLElement& element )
override;
2301 virtual bool Visit(
const XMLText& text )
override;
2302 virtual bool Visit(
const XMLComment& comment )
override;
2303 virtual bool Visit(
const XMLDeclaration& declaration )
override;
2304 virtual bool Visit(
const XMLUnknown& unknown )
override;
2311 return _buffer.Mem();
2319 return _buffer.Size();
2328 _firstElement = resetToFirstElement;
2337 virtual void PrintSpace(
int depth );
2338 virtual void Print(
const char* format, ... );
2339 virtual void Write(
const char* data,
size_t size );
2340 virtual void Putc(
char ch );
2342 inline void Write(
const char* data) {
Write(data, strlen(data)); }
2344 void SealElementIfJustOpened();
2353 void PrepareForNewNode(
bool compactMode );
2354 void PrintString(
const char*,
bool restrictedEntitySet );
2367 bool _entityFlag[ENTITY_RANGE];
2368 bool _restrictedEntityFlag[ENTITY_RANGE];
2380 #if defined(_MSC_VER)
2381 # pragma warning(pop)
2384 #endif // TINYXML2_INCLUDED
void operator=(const DynArray &)
constexpr auto size(const C &c) -> decltype(c.size())
virtual void SetTracked()=0
virtual XMLElement * ToElement() override
Safely cast to an Element, or null.
virtual XMLNode * ShallowClone(XMLDocument *) const override
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
const XMLText * ToText() const
virtual const XMLText * ToText() const
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
virtual XMLText * ToText() override
Safely cast to Text, or null.
bool Error() const
Return true if there was an error parsing the document.
virtual bool Visit(const XMLComment &)
Visit a comment node.
const char * Value() const
The value of the attribute.
NodeType
Enumerates the possible types of nodes.
int ErrorLineNum() const
Return the line where the error occurred, or zero if unknown.
Item items[ITEMS_PER_BLOCK]
bool CData() const
Returns true if this is a CDATA text element.
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
XMLAttribute * _rootAttribute
DynArray< const char *, 10 > _stack
const XMLNode * ToNode() const
void SetAttribute(const char *value)
Set the attribute to a string value.
XMLHandle(const XMLHandle &ref)
Copy constructor.
virtual bool VisitExit(const XMLDocument &)
Visit a document.
static char * SkipWhiteSpace(char *const p, int *curLineNumPtr)
virtual XMLUnknown * ToUnknown() override
Safely cast to an Unknown, or null.
void Trace(const char *name)
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
@ XML_ERROR_PARSING_UNKNOWN
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
static const char * ToStr(const Color &c)
bool NoChildren() const
Returns true if this node has no children.
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
@ XML_ERROR_FILE_NOT_FOUND
virtual const XMLElement * ToElement() const
@ XML_ERROR_FILE_COULD_NOT_BE_OPENED
@ XML_WRONG_ATTRIBUTE_TYPE
NodeType * CreateUnlinkedNode(MemPoolT< PoolElementSize > &pool)
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
virtual int ItemSize() const =0
virtual bool VisitExit(const XMLDocument &) override
Visit a document.
const T & PeekTop() const
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
static const int TIXML2_MAJOR_VERSION
double DoubleValue() const
Query as a double. See IntValue()
@ XML_ERROR_PARSING_DECLARATION
@ XML_ERROR_FILE_READ_ERROR
@ XML_ERROR_PARSING_ELEMENT
XMLError ErrorID() const
Return the errorID.
XMLHandle(XMLNode &node)
Create a handle from a node.
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
XMLElement * FirstChildElement(const char *name=0)
XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
const XMLDeclaration * ToDeclaration() const
Whitespace WhitespaceMode() const
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
static const int TIXML2_MINOR_VERSION
constexpr E value(std::size_t i) noexcept
virtual const XMLComment * ToComment() const
virtual bool VisitExit(const XMLElement &)
Visit an element.
DynArray< char, 20 > _buffer
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
static const int TINYXML2_MAX_ELEMENT_DEPTH
const XMLElement * ToElement() const
Whitespace _whitespaceMode
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
constexpr auto end(const C &c) -> decltype(c.end())
XMLError QueryAttribute(const char *name, const char **value) const
@ XML_ERROR_PARSING_COMMENT
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
void Set(char *start, char *end, int flags)
XMLConstHandle(const XMLNode *node)
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
virtual const XMLDeclaration * ToDeclaration() const override
XMLError QueryAttribute(const char *name, uint64_t *value) const
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
const XMLConstHandle NextSibling() const
bool ProcessEntities() const
const XMLElement * RootElement() const
const char * CStr() const
ElementClosingType _closingType
const XMLConstHandle LastChildElement(const char *name=0) const
static const char * writeBoolTrue
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
virtual XMLDeclaration * ToDeclaration() override
Safely cast to a Declaration, or null.
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
constexpr auto count
Sink that counts all arguments.
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
static bool IsNameStartChar(unsigned char ch)
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
DynArray< XMLNode *, 10 > _unlinked
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
static const char * writeBoolFalse
DepthTracker(XMLDocument *document)
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
buffer(const CharT *, const CharT *) -> buffer< deduce_encoding< CharT >>
virtual void * Alloc() override
void SetInternedStr(const char *str)
XMLNode * LinkEndChild(XMLNode *addThis)
XMLText(XMLDocument *doc)
auto child(const lexy::parse_tree< Reader, TokenKind, MemoryResource > &tree, typename lexy::parse_tree< Reader, TokenKind, MemoryResource >::node node, Predicate predicate) -> std::optional< typename lexy::parse_tree< Reader, TokenKind, MemoryResource >::node >
Returns the first child that matches predicate, if there is any.
const XMLConstHandle FirstChild() const
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
XMLError QueryAttribute(const char *name, double *value) const
XMLError QueryAttribute(const char *name, unsigned int *value) const
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
const XMLUnknown * ToUnknown() const
XMLText * ToText()
Safe cast to XMLText. This can return null.
int CurrentAllocs() const
XMLHandle LastChild()
Get the last child of this handle.
ElementClosingType ClosingType() const
virtual const XMLDocument * ToDocument() const
const XMLNode * Parent() const
Get the parent of this node on the DOM.
@ XML_ERROR_PARSING_CDATA
virtual const XMLElement * ToElement() const override
virtual bool CompactMode(const XMLElement &)
XMLElement * RootElement()
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
void SetUserData(void *userData)
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
virtual XMLDocument * ToDocument() override
Safely cast to a Document, or null.
static bool IsUTF8Continuation(const char p)
void * GetUserData() const
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
static bool IsPrefixHex(const char *p)
void ClearBuffer(bool resetToFirstElement=true)
const XMLConstHandle LastChild() const
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
@ XML_ERROR_PARSING_ATTRIBUTE
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
XMLError QueryUnsigned64Value(uint64_t *value) const
See QueryIntValue.
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
const T & operator[](int i) const
const XMLConstHandle NextSiblingElement(const char *name=0) const
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
bool BoolValue() const
Query as a boolean. See IntValue()
virtual bool Visit(const XMLText &)
Visit a text node.
virtual void Free(void *)=0
XMLConstHandle & operator=(const XMLConstHandle &ref)
XMLElement * PreviousSiblingElement(const char *name=0)
XMLElement * NextSiblingElement(const char *name=0)
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
char itemData[static_cast< size_t >(ITEM_SIZE)]
XMLError QueryAttribute(const char *name, float *value) const
virtual const XMLDocument * ToDocument() const override
virtual void Free(void *mem) override
static bool IsWhiteSpace(char p)
virtual const XMLUnknown * ToUnknown() const override
const XMLConstHandle PreviousSiblingElement(const char *name=0) const
XMLElement * LastChildElement(const char *name=0)
void Write(const char *data)
virtual XMLText * ToText()
Safely cast to Text, or null.
virtual const XMLText * ToText() const override
XMLConstHandle(const XMLConstHandle &ref)
XMLError QueryIntAttribute(const char *name, int *value) const
static bool StringEqual(const char *p, const char *q, int nChar=INT_MAX)
@ XML_CAN_NOT_CONVERT_TEXT
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
void EnsureCapacity(int cap)
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
@ XML_ELEMENT_DEPTH_EXCEEDED
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
float FloatValue() const
Query as a float. See IntValue()
int64_t Int64Value() const
uint64_t Unsigned64Value() const
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
static const char * SkipWhiteSpace(const char *p, int *curLineNumPtr)
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
@ XML_ERROR_MISMATCHED_ELEMENT
DynArray< Block *, 10 > _blockPtrs
XMLError QueryAttribute(const char *name, int *value) const
static bool IsNameChar(unsigned char ch)
void operator=(const MemPoolT &)
const XMLConstHandle FirstChildElement(const char *name=0) const
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
XMLError QueryAttribute(const char *name, bool *value) const
virtual const XMLUnknown * ToUnknown() const
static const int TIXML2_PATCH_VERSION
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
virtual const XMLDeclaration * ToDeclaration() const
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
XMLError QueryAttribute(const char *name, int64_t *value) const
virtual int ItemSize() const override
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
constexpr auto p
Parses the production.
XMLNode * PreviousSibling()
XMLConstHandle(const XMLNode &node)
@ XML_ERROR_EMPTY_DOCUMENT
XMLHandle NextSibling()
Get the next sibling of this handle.
void SetTracked() override
XMLHandle FirstChild()
Get the first child of this handle.
virtual bool ShallowEqual(const XMLNode *) const override
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
T _pool[static_cast< size_t >(INITIAL_SIZE)]
XMLError QueryIntValue(int *value) const
const XMLAttribute * Next() const
The next attribute in the list.
const XMLConstHandle PreviousSibling() const
const char * Name() const
Get the name of an element (which is the Value() of the node.)