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 
   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) 
   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) 
   99static const int TIXML2_MAJOR_VERSION = 10;
 
  100static const int TIXML2_MINOR_VERSION = 0;
 
  101static const int TIXML2_PATCH_VERSION = 0;
 
  103#define TINYXML2_MAJOR_VERSION 10 
  104#define TINYXML2_MINOR_VERSION 0 
  105#define TINYXML2_PATCH_VERSION 0 
  112static const int TINYXML2_MAX_ELEMENT_DEPTH = 500;
 
  133class TINYXML2_LIB StrPair
 
  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 ); 
 
  202template <
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            const int newAllocated = cap * 2;
 
  305            T* newMem = 
new T[
static_cast<unsigned int>(newAllocated)];
 
  306            TIXMLASSERT( newAllocated >= _size );
 
  307            memcpy( newMem, _mem, 
sizeof(T)*
static_cast<size_t>(_size) );   
 
  308            if ( _mem != _pool ) {
 
  312            _allocated = newAllocated;
 
  317    T   _pool[
static_cast<size_t>(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;
 
  343template< 
int ITEM_SIZE >
 
  344class 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 override{
 
  368    int CurrentAllocs()
 const       {
 
  369        return _currentAllocs;
 
  372    virtual void* Alloc()
 override{
 
  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 )
 override {
 
  403        Item* item = 
static_cast<Item*
>( mem );
 
  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() );
 
  416    void SetTracked()
 override {
 
  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[
static_cast<size_t>(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,
 
  548class 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* 
const 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 IsPrefixHex( 
const char* p) {
 
  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 )  {
 
  602        TIXMLASSERT( nChar >= 0 );
 
  603        return strncmp( p, q, 
static_cast<size_t>(nChar) ) == 0;
 
  606    inline static bool IsUTF8Continuation( 
const char p ) {
 
  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);
 
  641    static const char* writeBoolTrue;
 
  642    static const char* writeBoolFalse;
 
  679        TIXMLASSERT( _document );
 
 
  684        TIXMLASSERT( _document );
 
 
  716    virtual const XMLText*          ToText()
 const          {
 
  719    virtual const XMLComment*       ToComment()
 const       {
 
  722    virtual const XMLDocument*      ToDocument()
 const      {
 
  725    virtual const XMLDeclaration*   ToDeclaration()
 const   {
 
  728    virtual const XMLUnknown*       ToUnknown()
 const       {
 
  734    int ChildElementCount(
const char *value) 
const;
 
  736    int ChildElementCount() 
const;
 
  752    void SetValue( 
const char* val, 
bool staticMem=
false );
 
  785    XMLElement* FirstChildElement( 
const char* name = 0 )   {
 
  786        return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->FirstChildElement( name ));
 
  803    XMLElement* LastChildElement( 
const char* name = 0 )    {
 
  804        return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->LastChildElement(name) );
 
  819    XMLElement* PreviousSiblingElement( 
const char* name = 0 ) {
 
  820        return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->PreviousSiblingElement( name ) );
 
  835    XMLElement* NextSiblingElement( 
const char* name = 0 )  {
 
  836        return const_cast<XMLElement*
>(
const_cast<const XMLNode*
>(
this)->NextSiblingElement( name ) );
 
  849        return InsertEndChild( addThis );
 
  955    virtual char* ParseDeep( 
char* p, StrPair* parentEndTag, 
int* curLineNumPtr);
 
  959    mutable StrPair _value;
 
  973    static void DeleteNode( 
XMLNode* node );
 
  974    void InsertChildPreamble( 
XMLNode* insertThis ) 
const;
 
  975    const XMLElement* ToElementWithName( 
const char* name ) 
const;
 
 
 1003    virtual const XMLText* ToText()
 const override {
 
 1023    char* ParseDeep( 
char* p, StrPair* parentEndTag, 
int* curLineNumPtr ) 
override;
 
 1028    XMLText( 
const XMLText& );  
 
 1029    XMLText& operator=( 
const XMLText& );   
 
 
 1041    virtual const XMLComment* ToComment()
 const override {
 
 1054    char* ParseDeep( 
char* p, StrPair* parentEndTag, 
int* curLineNumPtr) 
override;
 
 
 1093    char* ParseDeep( 
char* p, StrPair* parentEndTag, 
int* curLineNumPtr ) 
override;
 
 
 1115    virtual const XMLUnknown* ToUnknown()
 const override {
 
 1128    char* ParseDeep( 
char* p, StrPair* parentEndTag, 
int* curLineNumPtr ) 
override;
 
 
 1171    int64_t Int64Value()
 const {
 
 1173        QueryInt64Value(&i);
 
 1177    uint64_t Unsigned64Value()
 const {
 
 1179        QueryUnsigned64Value(&i);
 
 1186        QueryUnsignedValue( &i );
 
 
 1192        QueryBoolValue( &b );
 
 
 1198        QueryDoubleValue( &d );
 
 
 1204        QueryFloatValue( &f );
 
 
 1244    enum { BUF_SIZE = 200 };
 
 1246    XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {}
 
 1247    virtual ~XMLAttribute() {}
 
 1249    XMLAttribute( 
const XMLAttribute& );    
 
 1250    void operator=( 
const XMLAttribute& );  
 
 1251    void SetName( 
const char* name );
 
 1253    char* ParseDeep( 
char* p, 
bool processEntities, 
int* curLineNumPtr );
 
 1255    mutable StrPair _name;
 
 1256    mutable StrPair _value;
 
 1258    XMLAttribute*   _next;
 
 
 1276    void SetName( 
const char* str, 
bool staticMem=
false )   {
 
 1277        SetValue( str, staticMem );
 
 
 1283    virtual const XMLElement* ToElement()
 const override {
 
 1311    const char* 
Attribute( 
const char* name, 
const char* value=0 ) 
const;
 
 1349            return XML_NO_ATTRIBUTE;
 
 
 1358            return XML_NO_ATTRIBUTE;
 
 
 1367            return XML_NO_ATTRIBUTE;
 
 
 1376            return XML_NO_ATTRIBUTE;
 
 
 1385            return XML_NO_ATTRIBUTE;
 
 
 1393            return XML_NO_ATTRIBUTE;
 
 
 1401            return XML_NO_ATTRIBUTE;
 
 
 1410            return XML_NO_ATTRIBUTE;
 
 1412        *value = a->
Value();
 
 
 1436        return QueryIntAttribute( name, value );
 
 
 1439    XMLError QueryAttribute( 
const char* name, 
unsigned int* value )
 const {
 
 1440        return QueryUnsignedAttribute( name, value );
 
 1443    XMLError QueryAttribute(
const char* name, int64_t* value)
 const {
 
 1444        return QueryInt64Attribute(name, value);
 
 1447    XMLError QueryAttribute(
const char* name, uint64_t* value)
 const {
 
 1448        return QueryUnsigned64Attribute(name, value);
 
 1451    XMLError QueryAttribute( 
const char* name, 
bool* value )
 const {
 
 1452        return QueryBoolAttribute( name, value );
 
 1455    XMLError QueryAttribute( 
const char* name, 
double* value )
 const {
 
 1456        return QueryDoubleAttribute( name, value );
 
 1459    XMLError QueryAttribute( 
const char* name, 
float* value )
 const {
 
 1460        return QueryFloatAttribute( name, value );
 
 1463    XMLError QueryAttribute(
const char* name, 
const char** value)
 const {
 
 1464        return QueryStringAttribute(name, value);
 
 1518        return _rootAttribute;
 
 
 1643    int IntText(
int defaultValue = 0) 
const;
 
 1674    enum ElementClosingType {
 
 1679    ElementClosingType ClosingType()
 const {
 
 1680        return _closingType;
 
 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 };
 
 1700    ElementClosingType _closingType;
 
 
 1709    PRESERVE_WHITESPACE,
 
 1710    COLLAPSE_WHITESPACE,
 
 1732    XMLDocument( 
bool processEntities = 
true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
 
 1736        TIXMLASSERT( 
this == _document );
 
 
 1739    virtual const XMLDocument* ToDocument()
 const override {
 
 1740        TIXMLASSERT( 
this == _document );
 
 1754    XMLError 
Parse( 
const char* xml, 
size_t nBytes=
static_cast<size_t>(-1) );
 
 1781    XMLError 
SaveFile( 
const char* filename, 
bool compact = 
false );
 
 1792    bool ProcessEntities()
 const        {
 
 1793        return _processEntities;
 
 1795    Whitespace WhitespaceMode()
 const   {
 
 1796        return _whitespaceMode;
 
 1815        return FirstChildElement();
 
 
 1818        return FirstChildElement();
 
 1886        return _errorID != XML_SUCCESS;
 
 
 1892    const char* ErrorName() 
const;
 
 1893    static const char* ErrorIDToName(XMLError errorID);
 
 1906        return _errorLineNum;
 
 
 1922    char* Identify( 
char* p, 
XMLNode** node, 
bool first );
 
 1925    void MarkInUse(
const XMLNode* 
const);
 
 1939    bool            _processEntities;
 
 1941    Whitespace      _whitespaceMode;
 
 1942    mutable StrPair _errorStr;
 
 1945    int             _parseCurLineNum;
 
 1953    DynArray<XMLNode*, 10> _unlinked;
 
 1957    MemPoolT< 
sizeof(
XMLText) >      _textPool;
 
 1960    static const char* _errorNames[XML_ERROR_COUNT];
 
 1964    void SetError( XMLError error, 
int lineNum, 
const char* format, ... );
 
 1969    class DepthTracker {
 
 1972            this->_document = document;
 
 1973            document->PushDepth();
 
 1976            _document->PopDepth();
 
 1979        XMLDocument * _document;
 
 1984    template<
class NodeType, 
int PoolElementSize>
 
 1985    NodeType* CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool );
 
 
 1988template<
class NodeType, 
int PoolElementSize>
 
 1989inline NodeType* XMLDocument::CreateUnlinkedNode( MemPoolT<PoolElementSize>& pool )
 
 1991    TIXMLASSERT( 
sizeof( NodeType ) == PoolElementSize );
 
 1992    TIXMLASSERT( 
sizeof( NodeType ) == pool.ItemSize() );
 
 1993    NodeType* returnNode = 
new (pool.Alloc()) NodeType( 
this );
 
 1994    TIXMLASSERT( returnNode );
 
 1995    returnNode->_memPool = &pool;
 
 1997    _unlinked.Push(returnNode);
 
 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 );
 
 
 
 2155    const XMLConstHandle FirstChildElement( 
const char* name = 0 )
 const                {
 
 2156        return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
 
 2161    const XMLConstHandle LastChildElement( 
const char* name = 0 )
 const             {
 
 2162        return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
 
 2167    const XMLConstHandle PreviousSiblingElement( 
const char* name = 0 )
 const       {
 
 2168        return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
 
 2173    const XMLConstHandle NextSiblingElement( 
const char* name = 0 )
 const           {
 
 2174        return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
 
 2178    const XMLNode* ToNode()
 const               {
 
 2182        return ( _node ? _node->ToElement() : 0 );
 
 2184    const XMLText* ToText()
 const               {
 
 2185        return ( _node ? _node->ToText() : 0 );
 
 2188        return ( _node ? _node->ToUnknown() : 0 );
 
 2191        return ( _node ? _node->ToDeclaration() : 0 );
 
 
 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 );
 
 2290    void PushDeclaration( 
const char* value );
 
 2291    void PushUnknown( 
const char* value );
 
 2311        return _buffer.Mem();
 
 
 2319        return _buffer.Size();
 
 
 2328        _firstElement = resetToFirstElement;
 
 
 2332    virtual bool CompactMode( 
const XMLElement& )   { 
return _compactMode; }
 
 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();
 
 2345    bool _elementJustOpened;
 
 2346    DynArray< const char*, 10 > _stack;
 
 2353    void PrepareForNewNode( 
bool compactMode );
 
 2354    void PrintString( 
const char*, 
bool restrictedEntitySet );  
 
 2360    bool _processEntities;
 
 2367    bool _entityFlag[ENTITY_RANGE];
 
 2368    bool _restrictedEntityFlag[ENTITY_RANGE];
 
 2370    DynArray< char, 20 > _buffer;
 
 2373    XMLPrinter( 
const XMLPrinter& );
 
 2374    XMLPrinter& operator=( 
const XMLPrinter& );
 
 
 2380#if defined(_MSC_VER) 
 2381#   pragma warning(pop) 
Definition tinyxml2.h:1144
int GetLineNum() const
Gets the line number the attribute is in, if the document was parsed from a file.
Definition tinyxml2.h:1154
XMLError QueryFloatValue(float *value) const
See QueryIntValue.
unsigned UnsignedValue() const
Query as an unsigned integer. See IntValue()
Definition tinyxml2.h:1184
void SetAttribute(uint64_t value)
Set the attribute to value.
float FloatValue() const
Query as a float. See IntValue()
Definition tinyxml2.h:1202
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:1196
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:1190
void SetAttribute(double value)
Set the attribute to value.
const XMLAttribute * Next() const
The next attribute in the list.
Definition tinyxml2.h:1157
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:1165
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:2138
Definition tinyxml2.h:1074
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:1077
virtual bool Accept(XMLVisitor *visitor) const override
Definition tinyxml2.h:1721
virtual XMLNode * ShallowClone(XMLDocument *) const override
Definition tinyxml2.h:1927
XMLElement * RootElement()
Definition tinyxml2.h:1814
void SetBOM(bool useBOM)
Definition tinyxml2.h:1807
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:1735
XMLError LoadFile(const char *filename)
bool HasBOM() const
Definition tinyxml2.h:1802
bool Error() const
Return true if there was an error parsing the document.
Definition tinyxml2.h:1885
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:1904
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:1930
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:1889
Definition tinyxml2.h:1268
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:1468
XMLError QueryInt64Text(int64_t *uval) const
See QueryIntText()
XMLError QueryUnsigned64Attribute(const char *name, uint64_t *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1373
XMLError QueryBoolAttribute(const char *name, bool *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1382
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:1501
XMLError QueryUnsignedAttribute(const char *name, unsigned int *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1355
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:1517
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:1506
XMLError QueryAttribute(const char *name, int *value) const
Definition tinyxml2.h:1435
XMLError QueryDoubleAttribute(const char *name, double *value) const
See QueryIntAttribute()
Definition tinyxml2.h:1390
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:1364
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:1280
XMLError QueryIntAttribute(const char *name, int *value) const
Definition tinyxml2.h:1346
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:1276
void SetAttribute(const char *name, bool value)
Sets the named attribute to value.
Definition tinyxml2.h:1496
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:1473
XMLComment * InsertNewComment(const char *comment)
See InsertNewChildElement()
void SetAttribute(const char *name, int64_t value)
Sets the named attribute to value.
Definition tinyxml2.h:1484
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:1272
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:1398
void SetAttribute(const char *name, uint64_t value)
Sets the named attribute to value.
Definition tinyxml2.h:1490
XMLError QueryStringAttribute(const char *name, const char **value) const
See QueryIntAttribute()
Definition tinyxml2.h:1407
void SetAttribute(const char *name, unsigned value)
Sets the named attribute to value.
Definition tinyxml2.h:1478
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()
Definition tinyxml2.h:2057
XMLHandle PreviousSibling()
Get the previous sibling of this handle.
Definition tinyxml2.h:2091
XMLHandle LastChildElement(const char *name=0)
Get the last child element of this handle.
Definition tinyxml2.h:2087
XMLHandle FirstChild()
Get the first child of this handle.
Definition tinyxml2.h:2075
XMLNode * ToNode()
Safe cast to XMLNode. This can return null.
Definition tinyxml2.h:2108
XMLHandle FirstChildElement(const char *name=0)
Get the first child element of this handle.
Definition tinyxml2.h:2079
XMLHandle PreviousSiblingElement(const char *name=0)
Get the previous sibling element of this handle.
Definition tinyxml2.h:2095
XMLDeclaration * ToDeclaration()
Safe cast to XMLDeclaration. This can return null.
Definition tinyxml2.h:2124
XMLHandle(XMLNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition tinyxml2.h:2060
XMLHandle LastChild()
Get the last child of this handle.
Definition tinyxml2.h:2083
XMLHandle & operator=(const XMLHandle &ref)
Assignment.
Definition tinyxml2.h:2069
XMLHandle(XMLNode &node)
Create a handle from a node.
Definition tinyxml2.h:2063
XMLHandle NextSibling()
Get the next sibling of this handle.
Definition tinyxml2.h:2099
XMLElement * ToElement()
Safe cast to XMLElement. This can return null.
Definition tinyxml2.h:2112
XMLText * ToText()
Safe cast to XMLText. This can return null.
Definition tinyxml2.h:2116
XMLUnknown * ToUnknown()
Safe cast to XMLUnknown. This can return null.
Definition tinyxml2.h:2120
XMLHandle NextSiblingElement(const char *name=0)
Get the next sibling element of this handle.
Definition tinyxml2.h:2103
XMLHandle(const XMLHandle &ref)
Copy constructor.
Definition tinyxml2.h:2066
Definition tinyxml2.h:672
void SetUserData(void *userData)
Definition tinyxml2.h:942
const char * Value() const
void SetValue(const char *val, bool staticMem=false)
virtual XMLText * ToText()
Safely cast to Text, or null.
Definition tinyxml2.h:693
virtual XMLDeclaration * ToDeclaration()
Safely cast to a Declaration, or null.
Definition tinyxml2.h:705
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:949
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:683
const XMLNode * Parent() const
Get the parent of this node on the DOM.
Definition tinyxml2.h:758
virtual XMLComment * ToComment()
Safely cast to a Comment, or null.
Definition tinyxml2.h:697
const XMLElement * LastChildElement(const char *name=0) const
virtual XMLDocument * ToDocument()
Safely cast to a Document, or null.
Definition tinyxml2.h:701
const XMLNode * LastChild() const
Get the last child node, or null if none exists.
Definition tinyxml2.h:790
const XMLDocument * GetDocument() const
Get the XMLDocument that owns this XMLNode.
Definition tinyxml2.h:678
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:808
virtual XMLElement * ToElement()
Safely cast to an Element, or null.
Definition tinyxml2.h:689
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:755
virtual XMLUnknown * ToUnknown()
Safely cast to an Unknown, or null.
Definition tinyxml2.h:709
const XMLNode * FirstChild() const
Get the first child node, or null if none exists.
Definition tinyxml2.h:772
bool NoChildren() const
Returns true if this node has no children.
Definition tinyxml2.h:767
XMLNode * InsertFirstChild(XMLNode *addThis)
XMLNode * InsertEndChild(XMLNode *addThis)
const XMLNode * NextSibling() const
Get the next (right) sibling node of this node.
Definition tinyxml2.h:824
Definition tinyxml2.h:2242
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:2294
virtual bool Visit(const XMLUnknown &unknown) override
Visit an unknown node.
int CStrSize() const
Definition tinyxml2.h:2318
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:2325
virtual bool VisitEnter(const XMLDocument &) override
Visit a document.
virtual bool Visit(const XMLComment &comment) override
Visit a comment node.
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:2310
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:995
virtual bool ShallowEqual(const XMLNode *compare) const override
virtual XMLText * ToText() override
Safely cast to Text, or null.
Definition tinyxml2.h:1000
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:1012
void SetCData(bool isCData)
Declare whether this should be CDATA or standard text.
Definition tinyxml2.h:1008
Definition tinyxml2.h:1109
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:1112
virtual bool Accept(XMLVisitor *visitor) const override
Definition tinyxml2.h:479
virtual bool Visit(const XMLUnknown &)
Visit an unknown node.
Definition tinyxml2.h:514
virtual bool VisitExit(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:488
virtual bool VisitExit(const XMLElement &)
Visit an element.
Definition tinyxml2.h:497
virtual bool VisitEnter(const XMLDocument &)
Visit a document.
Definition tinyxml2.h:484
virtual bool Visit(const XMLComment &)
Visit a comment node.
Definition tinyxml2.h:510
virtual bool Visit(const XMLDeclaration &)
Visit a declaration.
Definition tinyxml2.h:502
virtual bool Visit(const XMLText &)
Visit a text node.
Definition tinyxml2.h:506
virtual bool VisitEnter(const XMLElement &, const XMLAttribute *)
Visit an element.
Definition tinyxml2.h:493