24 #ifndef TINYXML2_INCLUDED 25 #define TINYXML2_INCLUDED 27 #if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) 56 #if defined( _DEBUG ) || defined (__DEBUG__) 57 # ifndef TINYXML2_DEBUG 58 # define TINYXML2_DEBUG 63 # pragma warning(push) 64 # pragma warning(disable: 4251) 68 # ifdef TINYXML2_EXPORT 69 # define TINYXML2_LIB __declspec(dllexport) 70 # elif defined(TINYXML2_IMPORT) 71 # define TINYXML2_LIB __declspec(dllimport) 76 # define TINYXML2_LIB __attribute__((visibility("default"))) 82 #if defined(TINYXML2_DEBUG) 83 # if defined(_MSC_VER) 84 # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like 85 # define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } 86 # elif defined (ANDROID_NDK) 87 # include <android/log.h> 88 # define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } 91 # define TIXMLASSERT assert 94 # define TIXMLASSERT( x ) {} 101 static const int TIXML2_MAJOR_VERSION = 7;
102 static const int TIXML2_MINOR_VERSION = 0;
103 static const int TIXML2_PATCH_VERSION = 0;
105 #define TINYXML2_MAJOR_VERSION 7 106 #define TINYXML2_MINOR_VERSION 0 107 #define TINYXML2_PATCH_VERSION 0 114 static const int TINYXML2_MAX_ELEMENT_DEPTH = 100;
123 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 ) {
153 TIXMLASSERT( start );
158 _flags = flags | NEEDS_FLUSH;
161 const char* GetStr();
164 return _start == _end;
167 void SetInternedStr(
const char* str ) {
169 _start =
const_cast<char*
>(str);
172 void SetStr(
const char* str,
int flags=0 );
174 char* ParseText(
char* in,
const char* endTag,
int strFlags,
int* curLineNumPtr );
175 char* ParseName(
char* in );
177 void TransferTo( StrPair* other );
181 void CollapseWhitespace();
192 StrPair(
const StrPair& other );
193 void operator=(
const StrPair& other );
202 template <
class T,
int INITIAL_SIZE>
208 _allocated( INITIAL_SIZE ),
214 if ( _mem != _pool ) {
224 TIXMLASSERT( _size < INT_MAX );
225 EnsureCapacity( _size+1 );
230 T* PushArr(
int count ) {
231 TIXMLASSERT( count >= 0 );
232 TIXMLASSERT( _size <= INT_MAX - count );
233 EnsureCapacity( _size+count );
234 T* ret = &_mem[_size];
240 TIXMLASSERT( _size > 0 );
245 void PopArr(
int count ) {
246 TIXMLASSERT( _size >= count );
254 T& operator[](
int i) {
255 TIXMLASSERT( i>= 0 && i < _size );
259 const T& operator[](
int i)
const {
260 TIXMLASSERT( i>= 0 && i < _size );
264 const T& PeekTop()
const {
265 TIXMLASSERT( _size > 0 );
266 return _mem[ _size - 1];
270 TIXMLASSERT( _size >= 0 );
274 int Capacity()
const {
275 TIXMLASSERT( _allocated >= INITIAL_SIZE );
279 void SwapRemove(
int i) {
280 TIXMLASSERT(i >= 0 && i < _size);
281 TIXMLASSERT(_size > 0);
282 _mem[i] = _mem[_size - 1];
286 const T* Mem()
const {
297 DynArray(
const DynArray& );
298 void operator=(
const DynArray& );
300 void EnsureCapacity(
int cap ) {
301 TIXMLASSERT( cap > 0 );
302 if ( cap > _allocated ) {
303 TIXMLASSERT( cap <= INT_MAX / 2 );
304 int newAllocated = cap * 2;
305 T* newMem =
new T[newAllocated];
306 TIXMLASSERT( newAllocated >= _size );
307 memcpy( newMem, _mem,
sizeof(T)*_size );
308 if ( _mem != _pool ) {
312 _allocated = newAllocated;
317 T _pool[INITIAL_SIZE];
331 virtual ~MemPool() {}
333 virtual int ItemSize()
const = 0;
334 virtual void* Alloc() = 0;
335 virtual void Free(
void* ) = 0;
336 virtual void SetTracked() = 0;
343 template<
int ITEM_SIZE >
344 class MemPoolT :
public MemPool
347 MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
349 MemPoolT< ITEM_SIZE >::Clear();
354 while( !_blockPtrs.Empty()) {
355 Block* lastBlock = _blockPtrs.Pop();
365 virtual int ItemSize()
const {
368 int CurrentAllocs()
const {
369 return _currentAllocs;
372 virtual void* Alloc() {
375 Block* block =
new Block();
376 _blockPtrs.Push( block );
378 Item* blockItems = block->items;
379 for(
int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) {
380 blockItems[i].next = &(blockItems[i + 1]);
382 blockItems[ITEMS_PER_BLOCK - 1].next = 0;
385 Item*
const result = _root;
386 TIXMLASSERT( result != 0 );
390 if ( _currentAllocs > _maxAllocs ) {
391 _maxAllocs = _currentAllocs;
398 virtual void Free(
void* mem ) {
403 Item* item =
static_cast<Item*
>( mem );
404 #ifdef TINYXML2_DEBUG 405 memset( item, 0xfe,
sizeof( *item ) );
410 void Trace(
const char* name ) {
411 printf(
"Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
412 name, _maxAllocs, _maxAllocs * ITEM_SIZE / 1024, _currentAllocs,
413 ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
420 int Untracked()
const {
435 enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
438 MemPoolT(
const MemPoolT& );
439 void operator=(
const MemPoolT& );
443 char itemData[ITEM_SIZE];
446 Item items[ITEMS_PER_BLOCK];
448 DynArray< Block*, 10 > _blockPtrs;
523 XML_WRONG_ATTRIBUTE_TYPE,
524 XML_ERROR_FILE_NOT_FOUND,
525 XML_ERROR_FILE_COULD_NOT_BE_OPENED,
526 XML_ERROR_FILE_READ_ERROR,
527 XML_ERROR_PARSING_ELEMENT,
528 XML_ERROR_PARSING_ATTRIBUTE,
529 XML_ERROR_PARSING_TEXT,
530 XML_ERROR_PARSING_CDATA,
531 XML_ERROR_PARSING_COMMENT,
532 XML_ERROR_PARSING_DECLARATION,
533 XML_ERROR_PARSING_UNKNOWN,
534 XML_ERROR_EMPTY_DOCUMENT,
535 XML_ERROR_MISMATCHED_ELEMENT,
537 XML_CAN_NOT_CONVERT_TEXT,
539 XML_ELEMENT_DEPTH_EXCEEDED,
548 class TINYXML2_LIB XMLUtil
551 static const char* SkipWhiteSpace(
const char* p,
int* curLineNumPtr ) {
554 while( IsWhiteSpace(*p) ) {
555 if (curLineNumPtr && *p ==
'\n') {
563 static char* SkipWhiteSpace(
char* p,
int* curLineNumPtr ) {
564 return const_cast<char*
>( SkipWhiteSpace( const_cast<const char*>(p), curLineNumPtr ) );
569 static bool IsWhiteSpace(
char p ) {
570 return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
573 inline static bool IsNameStartChar(
unsigned char ch ) {
578 if ( isalpha( ch ) ) {
581 return ch ==
':' || ch ==
'_';
584 inline static bool IsNameChar(
unsigned char ch ) {
585 return IsNameStartChar( ch )
591 inline static bool StringEqual(
const char* p,
const char* q,
int nChar=INT_MAX ) {
597 TIXMLASSERT( nChar >= 0 );
598 return strncmp( p, q, nChar ) == 0;
601 inline static bool IsUTF8Continuation(
char p ) {
602 return ( p & 0x80 ) != 0;
605 static const char* ReadBOM(
const char* p,
bool* hasBOM );
608 static const char* GetCharacterRef(
const char* p,
char* value,
int* length );
609 static void ConvertUTF32ToUTF8(
unsigned long input,
char* output,
int* length );
612 static void ToStr(
int v,
char* buffer,
int bufferSize );
613 static void ToStr(
unsigned v,
char* buffer,
int bufferSize );
614 static void ToStr(
bool v,
char* buffer,
int bufferSize );
615 static void ToStr(
float v,
char* buffer,
int bufferSize );
616 static void ToStr(
double v,
char* buffer,
int bufferSize );
617 static void ToStr(int64_t v,
char* buffer,
int bufferSize);
620 static bool ToInt(
const char* str,
int* value );
621 static bool ToUnsigned(
const char* str,
unsigned* value );
622 static bool ToBool(
const char* str,
bool* value );
623 static bool ToFloat(
const char* str,
float* value );
624 static bool ToDouble(
const char* str,
double* value );
625 static bool ToInt64(
const char* str, int64_t* value);
632 static void SetBoolSerialization(
const char* writeTrue,
const char* writeFalse);
635 static const char* writeBoolTrue;
636 static const char* writeBoolFalse;
673 TIXMLASSERT( _document );
678 TIXMLASSERT( _document );
710 virtual const XMLText* ToText()
const {
735 const char* Value()
const;
740 void SetValue(
const char* val,
bool staticMem=
false );
771 const XMLElement* FirstChildElement(
const char* name = 0 )
const;
773 XMLElement* FirstChildElement(
const char* name = 0 ) {
774 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement( name ));
789 const XMLElement* LastChildElement(
const char* name = 0 )
const;
791 XMLElement* LastChildElement(
const char* name = 0 ) {
792 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name) );
805 const XMLElement* PreviousSiblingElement(
const char* name = 0 )
const ;
807 XMLElement* PreviousSiblingElement(
const char* name = 0 ) {
808 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement( name ) );
821 const XMLElement* NextSiblingElement(
const char* name = 0 )
const;
823 XMLElement* NextSiblingElement(
const char* name = 0 ) {
824 return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement( name ) );
837 return InsertEndChild( addThis );
860 void DeleteChildren();
865 void DeleteChild(
XMLNode* node );
899 virtual bool ShallowEqual(
const XMLNode* compare )
const = 0;
923 virtual bool Accept(
XMLVisitor* visitor )
const = 0;
943 virtual char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
947 mutable StrPair _value;
961 static void DeleteNode(
XMLNode* node );
962 void InsertChildPreamble(
XMLNode* insertThis )
const;
963 const XMLElement* ToElementWithName(
const char* name )
const;
986 virtual bool Accept(
XMLVisitor* visitor )
const;
991 virtual const XMLText* ToText()
const {
1005 virtual bool ShallowEqual(
const XMLNode* compare )
const;
1011 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1029 virtual const XMLComment* ToComment()
const {
1033 virtual bool Accept(
XMLVisitor* visitor )
const;
1036 virtual bool ShallowEqual(
const XMLNode* compare )
const;
1042 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr);
1072 virtual bool Accept(
XMLVisitor* visitor )
const;
1075 virtual bool ShallowEqual(
const XMLNode* compare )
const;
1081 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1103 virtual const XMLUnknown* ToUnknown()
const {
1107 virtual bool Accept(
XMLVisitor* visitor )
const;
1110 virtual bool ShallowEqual(
const XMLNode* compare )
const;
1116 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1136 const char* Name()
const;
1139 const char* Value()
const;
1159 int64_t Int64Value()
const {
1161 QueryInt64Value(&i);
1168 QueryUnsignedValue( &i );
1174 QueryBoolValue( &b );
1180 QueryDoubleValue( &d );
1186 QueryFloatValue( &f );
1194 XMLError QueryIntValue(
int* value )
const;
1196 XMLError QueryUnsignedValue(
unsigned int* value )
const;
1198 XMLError QueryInt64Value(int64_t* value)
const;
1200 XMLError QueryBoolValue(
bool* value )
const;
1202 XMLError QueryDoubleValue(
double* value )
const;
1204 XMLError QueryFloatValue(
float* value )
const;
1207 void SetAttribute(
const char* value );
1209 void SetAttribute(
int value );
1211 void SetAttribute(
unsigned value );
1213 void SetAttribute(int64_t value);
1215 void SetAttribute(
bool value );
1217 void SetAttribute(
double value );
1219 void SetAttribute(
float value );
1222 enum { BUF_SIZE = 200 };
1224 XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
1229 void SetName(
const char* name );
1231 char* ParseDeep(
char* p,
bool processEntities,
int* curLineNumPtr );
1233 mutable StrPair _name;
1234 mutable StrPair _value;
1254 void SetName(
const char* str,
bool staticMem=
false ) {
1255 SetValue( str, staticMem );
1261 virtual const XMLElement* ToElement()
const {
1264 virtual bool Accept(
XMLVisitor* visitor )
const;
1289 const char* Attribute(
const char* name,
const char* value=0 )
const;
1297 int IntAttribute(
const char* name,
int defaultValue = 0)
const;
1299 unsigned UnsignedAttribute(
const char* name,
unsigned defaultValue = 0)
const;
1301 int64_t Int64Attribute(
const char* name, int64_t defaultValue = 0)
const;
1303 bool BoolAttribute(
const char* name,
bool defaultValue =
false)
const;
1305 double DoubleAttribute(
const char* name,
double defaultValue = 0)
const;
1307 float FloatAttribute(
const char* name,
float defaultValue = 0)
const;
1325 return XML_NO_ATTRIBUTE;
1334 return XML_NO_ATTRIBUTE;
1343 return XML_NO_ATTRIBUTE;
1352 return XML_NO_ATTRIBUTE;
1360 return XML_NO_ATTRIBUTE;
1368 return XML_NO_ATTRIBUTE;
1377 return XML_NO_ATTRIBUTE;
1379 *value = a->
Value();
1403 return QueryIntAttribute( name, value );
1406 XMLError QueryAttribute(
const char* name,
unsigned int* value )
const {
1407 return QueryUnsignedAttribute( name, value );
1410 XMLError QueryAttribute(
const char* name, int64_t* value)
const {
1411 return QueryInt64Attribute(name, value);
1414 XMLError QueryAttribute(
const char* name,
bool* value )
const {
1415 return QueryBoolAttribute( name, value );
1418 XMLError QueryAttribute(
const char* name,
double* value )
const {
1419 return QueryDoubleAttribute( name, value );
1422 XMLError QueryAttribute(
const char* name,
float* value )
const {
1423 return QueryFloatAttribute( name, value );
1467 void DeleteAttribute(
const char* name );
1471 return _rootAttribute;
1474 const XMLAttribute* FindAttribute(
const char* name )
const;
1504 const char* GetText()
const;
1540 void SetText(
const char* inText );
1542 void SetText(
int value );
1544 void SetText(
unsigned value );
1546 void SetText(int64_t value);
1548 void SetText(
bool value );
1550 void SetText(
double value );
1552 void SetText(
float value );
1580 XMLError QueryIntText(
int* ival )
const;
1582 XMLError QueryUnsignedText(
unsigned* uval )
const;
1584 XMLError QueryInt64Text(int64_t* uval)
const;
1586 XMLError QueryBoolText(
bool* bval )
const;
1588 XMLError QueryDoubleText(
double* dval )
const;
1590 XMLError QueryFloatText(
float* fval )
const;
1592 int IntText(
int defaultValue = 0)
const;
1595 unsigned UnsignedText(
unsigned defaultValue = 0)
const;
1597 int64_t Int64Text(int64_t defaultValue = 0)
const;
1599 bool BoolText(
bool defaultValue =
false)
const;
1601 double DoubleText(
double defaultValue = 0)
const;
1603 float FloatText(
float defaultValue = 0)
const;
1606 enum ElementClosingType {
1611 ElementClosingType ClosingType()
const {
1612 return _closingType;
1615 virtual bool ShallowEqual(
const XMLNode* compare )
const;
1618 char* ParseDeep(
char* p, StrPair* parentEndTag,
int* curLineNumPtr );
1626 XMLAttribute* FindOrCreateAttribute(
const char* name );
1627 char* ParseAttributes(
char* p,
int* curLineNumPtr );
1628 static void DeleteAttribute(
XMLAttribute* attribute );
1631 enum { BUF_SIZE = 200 };
1632 ElementClosingType _closingType;
1641 PRESERVE_WHITESPACE,
1663 XMLDocument(
bool processEntities =
true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
1667 TIXMLASSERT(
this == _document );
1671 TIXMLASSERT(
this == _document );
1685 XMLError Parse(
const char* xml,
size_t nBytes=(
size_t)(-1) );
1692 XMLError LoadFile(
const char* filename );
1705 XMLError LoadFile( FILE* );
1712 XMLError SaveFile(
const char* filename,
bool compact =
false );
1721 XMLError SaveFile( FILE* fp,
bool compact =
false );
1723 bool ProcessEntities()
const {
1724 return _processEntities;
1726 Whitespace WhitespaceMode()
const {
1727 return _whitespaceMode;
1746 return FirstChildElement();
1749 return FirstChildElement();
1767 virtual bool Accept(
XMLVisitor* visitor )
const;
1780 XMLComment* NewComment(
const char* comment );
1786 XMLText* NewText(
const char* text );
1810 void DeleteNode(
XMLNode* node );
1813 SetError(XML_SUCCESS, 0, 0);
1818 return _errorID != XML_SUCCESS;
1824 const char* ErrorName()
const;
1825 static const char* ErrorIDToName(XMLError errorID);
1830 const char* ErrorStr()
const;
1833 void PrintError()
const;
1838 return _errorLineNum;
1854 char* Identify(
char* p,
XMLNode** node );
1871 bool _processEntities;
1873 Whitespace _whitespaceMode;
1874 mutable StrPair _errorStr;
1877 int _parseCurLineNum;
1885 DynArray<XMLNode*, 10> _unlinked;
1887 MemPoolT< sizeof(XMLElement) > _elementPool;
1888 MemPoolT< sizeof(XMLAttribute) > _attributePool;
1889 MemPoolT< sizeof(XMLText) > _textPool;
1890 MemPoolT< sizeof(XMLComment) > _commentPool;
1892 static const char* _errorNames[XML_ERROR_COUNT];
1896 void SetError( XMLError error,
int lineNum,
const char* format, ... );
1901 class DepthTracker {
1904 this->_document = document;
1905 document->PushDepth();
1908 _document->PopDepth();
1916 template<
class NodeType,
int PoolElementSize>
1917 NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
1920 template<
class NodeType,
int PoolElementSize>
1921 inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
1923 TIXMLASSERT(
sizeof( NodeType ) == PoolElementSize );
1924 TIXMLASSERT(
sizeof( NodeType ) == pool.ItemSize() );
1925 NodeType* returnNode =
new (pool.Alloc()) NodeType(
this );
1926 TIXMLASSERT( returnNode );
1927 returnNode->_memPool = &pool;
1929 _unlinked.Push(returnNode);
2008 return XMLHandle( _node ? _node->FirstChild() : 0 );
2012 return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
2016 return XMLHandle( _node ? _node->LastChild() : 0 );
2020 return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
2024 return XMLHandle( _node ? _node->PreviousSibling() : 0 );
2028 return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2032 return XMLHandle( _node ? _node->NextSibling() : 0 );
2036 return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2045 return ( _node ? _node->ToElement() : 0 );
2049 return ( _node ? _node->ToText() : 0 );
2053 return ( _node ? _node->ToUnknown() : 0 );
2057 return ( _node ? _node->ToDeclaration() : 0 );
2087 const XMLConstHandle FirstChildElement(
const char* name = 0 )
const {
2088 return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
2093 const XMLConstHandle LastChildElement(
const char* name = 0 )
const {
2094 return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
2099 const XMLConstHandle PreviousSiblingElement(
const char* name = 0 )
const {
2100 return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
2105 const XMLConstHandle NextSiblingElement(
const char* name = 0 )
const {
2106 return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
2110 const XMLNode* ToNode()
const {
2114 return ( _node ? _node->ToElement() : 0 );
2116 const XMLText* ToText()
const {
2117 return ( _node ? _node->ToText() : 0 );
2120 return ( _node ? _node->ToUnknown() : 0 );
2123 return ( _node ? _node->ToDeclaration() : 0 );
2182 XMLPrinter( FILE* file=0,
bool compact =
false,
int depth = 0 );
2186 void PushHeader(
bool writeBOM,
bool writeDeclaration );
2190 void OpenElement(
const char* name,
bool compactMode=
false );
2192 void PushAttribute(
const char* name,
const char* value );
2193 void PushAttribute(
const char* name,
int value );
2194 void PushAttribute(
const char* name,
unsigned value );
2195 void PushAttribute(
const char* name, int64_t value);
2196 void PushAttribute(
const char* name,
bool value );
2197 void PushAttribute(
const char* name,
double value );
2199 virtual void CloseElement(
bool compactMode=
false );
2202 void PushText(
const char* text,
bool cdata=
false );
2204 void PushText(
int value );
2206 void PushText(
unsigned value );
2208 void PushText(int64_t value);
2210 void PushText(
bool value );
2212 void PushText(
float value );
2214 void PushText(
double value );
2217 void PushComment(
const char* comment );
2219 void PushDeclaration(
const char* value );
2220 void PushUnknown(
const char* value );
2228 virtual bool VisitExit(
const XMLElement& element );
2230 virtual bool Visit(
const XMLText& text );
2231 virtual bool Visit(
const XMLComment& comment );
2233 virtual bool Visit(
const XMLUnknown& unknown );
2240 return _buffer.Mem();
2248 return _buffer.Size();
2257 _firstElement =
true;
2261 virtual bool CompactMode(
const XMLElement& ) {
return _compactMode; }
2266 virtual void PrintSpace(
int depth );
2267 void Print(
const char* format, ... );
2268 void Write(
const char* data,
size_t size );
2269 inline void Write(
const char* data ) { Write( data, strlen( data ) ); }
2270 void Putc(
char ch );
2272 void SealElementIfJustOpened();
2273 bool _elementJustOpened;
2274 DynArray< const char*, 10 > _stack;
2277 void PrintString(
const char*,
bool restrictedEntitySet );
2283 bool _processEntities;
2290 bool _entityFlag[ENTITY_RANGE];
2291 bool _restrictedEntityFlag[ENTITY_RANGE];
2293 DynArray< char, 20 > _buffer;
2303 #if defined(_MSC_VER) 2304 # pragma warning(pop) 2307 #endif // TINYXML2_INCLUDED XMLError QueryInt64Attribute(const char *name, int64_t *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1340
XMLError QueryIntValue(int *value) const
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1349
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:488
virtual XMLNode * ShallowClone(XMLDocument *) const
Definition: tinyxml2.h:1859
virtual bool ShallowEqual(const XMLNode *) const
Definition: tinyxml2.h:1862
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition: tinyxml2.h:2011
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition: tinyxml2.h:2048
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
const char * CStr() const
Definition: tinyxml2.h:2239
XMLError ErrorID() const
Return the errorID.
Definition: tinyxml2.h:1821
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition: tinyxml2.h:2044
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:683
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1374
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:687
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1331
int CStrSize() const
Definition: tinyxml2.h:2247
float FloatValue() const
Query as a float. See IntValue()
Definition: tinyxml2.h:1184
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:1666
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition: tinyxml2.h:2052
const char * Name() const
Get the name of an element (which is the Value() of the node.)
Definition: tinyxml2.h:1250
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition: tinyxml2.h:1998
XMLHandle FirstChild()
Get the first child of this handle.
Definition: tinyxml2.h:2007
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition: tinyxml2.h:996
void SetUserData(void *userData)
Definition: tinyxml2.h:930
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition: tinyxml2.h:812
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition: tinyxml2.h:1166
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition: tinyxml2.h:2019
XMLHandle LastChild()
Get the last child of this handle.
Definition: tinyxml2.h:2015
Definition: tinyxml2.h:1988
Definition: tinyxml2.h:1061
XMLElement * RootElement()
Definition: tinyxml2.h:1745
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition: tinyxml2.h:988
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition: tinyxml2.h:1995
void SetName(const char *str, bool staticMem=false)
Set the name of the element.
Definition: tinyxml2.h:1254
void SetBOM(bool useBOM)
Definition: tinyxml2.h:1738
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml2.h:1992
void ClearBuffer()
Definition: tinyxml2.h:2254
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition: tinyxml2.h:1258
bool HasBOM() const
Definition: tinyxml2.h:1733
Definition: tinyxml2.h:116
XMLError QueryFloatAttribute(const char *name, float *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1365
XMLError QueryUnsignedValue(unsigned int *value) const
See QueryIntValue.
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition: tinyxml2.h:2040
bool BoolValue() const
Query as a boolean. See IntValue()
Definition: tinyxml2.h:1172
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition: tinyxml2.h:760
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:1065
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition: tinyxml2.h:502
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition: tinyxml2.h:514
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition: tinyxml2.h:1437
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition: tinyxml2.h:1357
Definition: tinyxml2.h:1245
XMLError QueryInt64Value(int64_t *value) const
See QueryIntValue.
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition: tinyxml2.h:2031
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file. ...
Definition: tinyxml2.h:1142
int IntValue() const
Definition: tinyxml2.h:1153
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:1100
bool CData() const
Returns true if this is a CDATA text element.
Definition: tinyxml2.h:1000
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition: tinyxml2.h:2023
Definition: tinyxml2.h:2069
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition: tinyxml2.h:2001
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:2223
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition: tinyxml2.h:493
bool Error() const
Return true if there was an error parsing the document.
Definition: tinyxml2.h:1817
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition: tinyxml2.h:484
Definition: tinyxml2.h:1096
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition: tinyxml2.h:695
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition: tinyxml2.h:778
Definition: tinyxml2.h:1131
XMLError QueryAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1402
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition: tinyxml2.h:1449
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition: tinyxml2.h:2056
void SetAttribute(const char *value)
Set the attribute to a string value.
void SetAttribute(const char *name, const char *value)
Sets the named attribute to value.
Definition: tinyxml2.h:1427
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition: tinyxml2.h:497
Definition: tinyxml2.h:2173
Definition: tinyxml2.h:1651
void * GetUserData() const
Definition: tinyxml2.h:937
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition: tinyxml2.h:1443
const char * Value() const
The value of the attribute.
void SetAttribute(const char *name, double value)
Sets the named attribute to value.
Definition: tinyxml2.h:1454
XMLError QueryDoubleValue(double *value) const
See QueryIntValue.
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition: tinyxml2.h:746
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition: tinyxml2.h:510
XMLError QueryBoolValue(bool *value) const
See QueryIntValue.
const XMLNode * PreviousSibling() const
Get the previous (left) sibling node of this node.
Definition: tinyxml2.h:796
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition: tinyxml2.h:2035
Definition: tinyxml2.h:665
XMLError QueryIntAttribute(const char *name, int *value) const
Definition: tinyxml2.h:1322
int GetLineNum() const
Gets the line number the node is in, if the document was parsed from a file.
Definition: tinyxml2.h:743
virtual bool Visit(const XMLText &)
Visit a text node.
Definition: tinyxml2.h:506
Definition: tinyxml2.h:982
Definition: tinyxml2.h:478
int ErrorLineNum() const
Return the line where the error occurred, or zero if unknown.
Definition: tinyxml2.h:1836
XMLDocument * GetDocument()
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:677
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition: tinyxml2.h:703
void SetAttribute(const char *name, float value)
Sets the named attribute to value.
Definition: tinyxml2.h:1459
const XMLAttribute * Next() const
The next attribute in the list.
Definition: tinyxml2.h:1145
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml2.h:755
double DoubleValue() const
Query as a double. See IntValue()
Definition: tinyxml2.h:1178
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition: tinyxml2.h:699
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition: tinyxml2.h:672
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition: tinyxml2.h:2027
void SetAttribute(const char *name, int value)
Sets the named attribute to value.
Definition: tinyxml2.h:1432
const XMLAttribute * FirstAttribute() const
Return the first attribute in the list.
Definition: tinyxml2.h:1470
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition: tinyxml2.h:691