26 #ifndef TINYXML_INCLUDED 
   27 #define TINYXML_INCLUDED 
   30 #pragma warning( disable : 4530 ) 
   31 #pragma warning( disable : 4786 ) 
   42 #if defined( _DEBUG ) && !defined( DEBUG ) 
   46 #if defined( DEBUG ) && defined( _MSC_VER ) 
   48 #define TIXML_LOG OutputDebugString 
   50 #define TIXML_LOG printf 
   56     #define TIXML_STRING    std::string 
   57     #define TIXML_ISTREAM   std::istream 
   58     #define TIXML_OSTREAM   std::ostream 
   61     #define TIXML_STRING    TiXmlString 
   62     #define TIXML_OSTREAM   TiXmlOutStream 
   72 class TiXmlParsingData;
 
   74 const int TIXML_MAJOR_VERSION = 2;
 
   75 const int TIXML_MINOR_VERSION = 3;
 
   76 const int TIXML_PATCH_VERSION = 4;
 
   84     void Clear()        { row = col = -1; }
 
  103     TIXML_ENCODING_UNKNOWN,
 
  105     TIXML_ENCODING_LEGACY
 
  108 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
 
  147     virtual void Print( FILE* cfile, 
int depth ) 
const = 0;
 
  178     int Row()
 const         { 
return location.row + 1; }
 
  179     int Column()
 const      { 
return location.col + 1; }    
 
  181     void  SetUserData( 
void* user )         { 
userData = user; }
 
  182     void* GetUserData()                     { 
return userData; }
 
  186     static const int utf8ByteTable[256];
 
  188     virtual const char* 
Parse(  
const char* p, 
 
  189                                 TiXmlParsingData* data, 
 
  190                                 TiXmlEncoding encoding  ) = 0;
 
  196         TIXML_ERROR_OPENING_FILE,
 
  197         TIXML_ERROR_OUT_OF_MEMORY,
 
  198         TIXML_ERROR_PARSING_ELEMENT,
 
  199         TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
 
  200         TIXML_ERROR_READING_ELEMENT_VALUE,
 
  201         TIXML_ERROR_READING_ATTRIBUTES,
 
  202         TIXML_ERROR_PARSING_EMPTY,
 
  203         TIXML_ERROR_READING_END_TAG,
 
  204         TIXML_ERROR_PARSING_UNKNOWN,
 
  205         TIXML_ERROR_PARSING_COMMENT,
 
  206         TIXML_ERROR_PARSING_DECLARATION,
 
  207         TIXML_ERROR_DOCUMENT_EMPTY,
 
  208         TIXML_ERROR_EMBEDDED_NULL,
 
  210         TIXML_ERROR_STRING_COUNT
 
  225     static const char*  SkipWhiteSpace( 
const char*, TiXmlEncoding encoding );
 
  226     inline static bool  IsWhiteSpace( 
char c )      
 
  228         return ( isspace( (
unsigned char) c ) || c == 
'\n' || c == 
'\r' ); 
 
  231     virtual void StreamOut (TIXML_OSTREAM *) 
const = 0;
 
  234         static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
 
  235         static bool StreamTo( TIXML_ISTREAM * in, 
int character, TIXML_STRING * tag );
 
  242     static const char* ReadName( 
const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
 
  247     static const char* ReadText(    
const char* in,             
 
  249                                     bool ignoreWhiteSpace,      
 
  252                                     TiXmlEncoding encoding );   
 
  255     static const char* GetEntity( 
const char* in, 
char* value, 
int* length, TiXmlEncoding encoding );
 
  259     inline static const char* GetChar( 
const char* p, 
char* _value, 
int* length, TiXmlEncoding encoding )
 
  262         if ( encoding == TIXML_ENCODING_UTF8 )
 
  264             *length = utf8ByteTable[ *((
unsigned char*)p) ];
 
  265             assert( *length >= 0 && *length < 5 );
 
  275                 return GetEntity( p, _value, length, encoding );
 
  281             strncpy( _value, p, *length );
 
  282             return p + (*length);
 
  293     static void PutString( 
const TIXML_STRING& str, TIXML_OSTREAM* out );
 
  295     static void PutString( 
const TIXML_STRING& str, TIXML_STRING* out );
 
  300     static bool StringEqual(    
const char* p,
 
  303                                 TiXmlEncoding encoding );
 
  305     static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
 
  314     static int IsAlpha( 
unsigned char anyByte, TiXmlEncoding encoding );
 
  315     static int IsAlphaNum( 
unsigned char anyByte, TiXmlEncoding encoding );
 
  316     inline static int ToLower( 
int v, TiXmlEncoding encoding )
 
  318         if ( encoding == TIXML_ENCODING_UTF8 )
 
  320             if ( v < 128 ) 
return tolower( v );
 
  328     static void ConvertUTF32ToUTF8( 
unsigned long input, 
char* output, 
int* length );
 
  337         unsigned int    strLength;
 
  343         MAX_ENTITY_LENGTH = 6
 
  346     static Entity entity[ NUM_ENTITY ];
 
  347     static bool condenseWhiteSpace;
 
  368         friend std::istream& operator >> (std::istream& in, 
TiXmlNode& base);
 
  386         friend std::ostream& operator<< (std::ostream& out, 
const TiXmlNode& base);
 
  389         friend std::string& operator<< (std::string& out, 
const TiXmlNode& base );
 
  393         friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, 
const TiXmlNode& base);
 
  424     const char * 
Value()
 const { 
return value.c_str (); }
 
  435     void SetValue(
const char * _value) { value = _value;}
 
  439     void SetValue( 
const std::string& _value )    
 
  441         StringToBuffer buf( _value );
 
  442         SetValue( buf.buffer ? buf.buffer : 
"" );       
 
  458     const TiXmlNode* LastChild()
 const  { 
return lastChild; }       
 
  460     const TiXmlNode* LastChild( 
const char * value ) 
const;         
 
  461     TiXmlNode* LastChild( 
const char * value ); 
 
  466     const TiXmlNode* LastChild( 
const std::string& _value )
 const   {   
return LastChild (_value.c_str ()); }   
 
  467     TiXmlNode* LastChild( 
const std::string& _value )               {   
return LastChild (_value.c_str ()); }   
 
  592     virtual int Type()
 const    { 
return type; }
 
  631         virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
 
  635     TiXmlNode* Identify( 
const char* start, TiXmlEncoding encoding );
 
  638     const TIXML_STRING& SValue()
 const  { 
return value ; }
 
  678     TiXmlAttribute( 
const std::string& _name, 
const std::string& _value )
 
  696     const char*     
Name()
  const       { 
return name.c_str (); }       
 
  697     const char*     
Value()
 const       { 
return value.c_str (); }      
 
  698     const int       IntValue() 
const;                                   
 
  699     const double    DoubleValue() 
const;                                
 
  710     int QueryIntValue( 
int* value ) 
const;
 
  712     int QueryDoubleValue( 
double* value ) 
const;
 
  714     void SetName( 
const char* _name )   { name = _name; }               
 
  715     void SetValue( 
const char* _value ) { value = _value; }             
 
  717     void SetIntValue( 
int value );                                      
 
  718     void SetDoubleValue( 
double value );                                
 
  722     void SetName( 
const std::string& _name )    
 
  724         StringToBuffer buf( _name );
 
  725         SetName ( buf.buffer ? buf.buffer : 
"error" );  
 
  728     void SetValue( 
const std::string& _value )  
 
  730         StringToBuffer buf( _value );
 
  731         SetValue( buf.buffer ? buf.buffer : 
"error" );  
 
  742     bool operator==( 
const TiXmlAttribute& rhs )
 const { 
return rhs.name == name; }
 
  743     bool operator<( 
const TiXmlAttribute& rhs )
  const { 
return name < rhs.name; }
 
  744     bool operator>( 
const TiXmlAttribute& rhs )
  const { 
return name > rhs.name; }
 
  749     virtual const char* Parse( 
const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
 
  752     virtual void Print( FILE* cfile, 
int depth ) 
const;
 
  754     virtual void StreamOut( TIXML_OSTREAM * out ) 
const;
 
  792     const TiXmlAttribute* First()
   const   { 
return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
 
  793     TiXmlAttribute* First()                 { 
return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
 
  794     const TiXmlAttribute* Last()
 const      { 
return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
 
  795     TiXmlAttribute* Last()                  { 
return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
 
  834     const char* Attribute( 
const char* name ) 
const;
 
  842     const char* Attribute( 
const char* name, 
int* i ) 
const;
 
  850     const char* Attribute( 
const char* name, 
double* d ) 
const;
 
  859     int QueryIntAttribute( 
const char* name, 
int* value ) 
const;
 
  861     int QueryDoubleAttribute( 
const char* name, 
double* value ) 
const;
 
  865         int result = QueryDoubleAttribute( name, &d );
 
  873     void SetAttribute( 
const char* name, 
const char * value );
 
  876     const char* Attribute( 
const std::string& name )
 const              { 
return Attribute( name.c_str() ); }
 
  877     const char* Attribute( 
const std::string& name, 
int* i )
 const      { 
return Attribute( name.c_str(), i ); }
 
  878     const char* Attribute( 
const std::string& name, 
double* d )
 const   { 
return Attribute( name.c_str(), d ); }
 
  879     int QueryIntAttribute( 
const std::string& name, 
int* value )
 const  { 
return QueryIntAttribute( name.c_str(), value ); }
 
  880     int QueryDoubleAttribute( 
const std::string& name, 
double* value )
 const { 
return QueryDoubleAttribute( name.c_str(), value ); }
 
  883     void SetAttribute( 
const std::string& name, 
const std::string& _value ) 
 
  885         StringToBuffer n( name );
 
  886         StringToBuffer v( _value );
 
  887         if ( n.buffer && v.buffer )
 
  888             SetAttribute (n.buffer, v.buffer ); 
 
  891     void SetAttribute( 
const std::string& name, 
int _value )    
 
  893         StringToBuffer n( name );
 
  895             SetAttribute (n.buffer, _value);    
 
  902     void SetAttribute( 
const char * name, 
int value );
 
  907     void SetDoubleAttribute( 
const char * name, 
double value );
 
  911     void RemoveAttribute( 
const char * name );
 
  913     void RemoveAttribute( 
const std::string& name ) {   RemoveAttribute (name.c_str ());    }   
 
  924     virtual void Print( FILE* cfile, 
int depth ) 
const;
 
  929     virtual const char* Parse( 
const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
 
  938         virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
 
  940     virtual void StreamOut( TIXML_OSTREAM * out ) 
const;
 
  946     const char* ReadValue( 
const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
 
  969     virtual void Print( FILE* cfile, 
int depth ) 
const;
 
  974     virtual const char* Parse( 
const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
 
  981         virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
 
  983     virtual void StreamOut( TIXML_OSTREAM * out ) 
const;
 
 1003     #ifdef TIXML_USE_STL 
 1012     void operator=( 
const TiXmlText& base )                             { base.CopyTo( 
this ); }
 
 1015     virtual void Print( FILE* cfile, 
int depth ) 
const;
 
 1017     virtual const char* Parse( 
const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
 
 1024     virtual void StreamOut ( TIXML_OSTREAM * out ) 
const;
 
 1027     #ifdef TIXML_USE_STL 
 1028         virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
 
 1054 #ifdef TIXML_USE_STL 
 1057                         const std::string& _encoding,
 
 1058                         const std::string& _standalone );
 
 1063                         const char* _encoding,
 
 1064                         const char* _standalone );
 
 1072     const char *
Version()
 const         { 
return version.c_str (); }
 
 1074     const char *
Encoding()
 const        { 
return encoding.c_str (); }
 
 1081     virtual void Print( FILE* cfile, 
int depth ) 
const;
 
 1083     virtual const char* Parse( 
const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
 
 1088     #ifdef TIXML_USE_STL 
 1089         virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
 
 1091     virtual void StreamOut ( TIXML_OSTREAM * out) 
const;
 
 1095     TIXML_STRING version;
 
 1096     TIXML_STRING encoding;
 
 1097     TIXML_STRING standalone;
 
 1115     void operator=( 
const TiXmlUnknown& copy )                                      { copy.CopyTo( 
this ); }
 
 1120     virtual void Print( FILE* cfile, 
int depth ) 
const;
 
 1122     virtual const char* Parse( 
const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
 
 1127     #ifdef TIXML_USE_STL 
 1128         virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
 
 1130     virtual void StreamOut ( TIXML_OSTREAM * out ) 
const;
 
 1149     #ifdef TIXML_USE_STL 
 1163     bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
 
 1165     bool SaveFile() 
const;
 
 1167     bool LoadFile( 
const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
 
 1169     bool SaveFile( 
const char * filename ) 
const;
 
 1171     #ifdef TIXML_USE_STL 
 1172     bool LoadFile( 
const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )           
 
 1175         return ( f.buffer && LoadFile( f.buffer, encoding ));
 
 1177     bool SaveFile( 
const std::string& filename ) 
const       
 1180         return ( f.buffer && SaveFile( f.buffer ));
 
 1188     virtual const char* Parse( 
const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
 
 1205     const char * 
ErrorDesc()
 const  { 
return errorDesc.c_str (); }
 
 1244     int TabSize()
 const { 
return tabsize; }
 
 1252                                                 errorLocation.row = errorLocation.col = 0; 
 
 1260     virtual void Print( FILE* cfile, 
int depth = 0 ) 
const;
 
 1262     void SetError( 
int err, 
const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
 
 1265     virtual void StreamOut ( TIXML_OSTREAM * out) 
const;
 
 1268     #ifdef TIXML_USE_STL 
 1269         virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
 
 1277     TIXML_STRING errorDesc;
 
 1375     TiXmlHandle FirstChild( 
const char * value ) 
const;
 
 1379     TiXmlHandle FirstChildElement( 
const char * value ) 
const;
 
 1384     TiXmlHandle Child( 
const char* value, 
int index ) 
const;
 
 1393     TiXmlHandle ChildElement( 
const char* value, 
int index ) 
const;
 
 1400     #ifdef TIXML_USE_STL 
 1401     TiXmlHandle FirstChild( 
const std::string& _value )
 const               { 
return FirstChild( _value.c_str() ); }
 
 1402     TiXmlHandle FirstChildElement( 
const std::string& _value )
 const        { 
return FirstChildElement( _value.c_str() ); }
 
 1404     TiXmlHandle Child( 
const std::string& _value, 
int index )
 const         { 
return Child( _value.c_str(), index ); }
 
 1405     TiXmlHandle ChildElement( 
const std::string& _value, 
int index )
 const  { 
return ChildElement( _value.c_str(), index ); }
 
 1413     TiXmlText* 
Text()
 const         { 
return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
 
 1422 #pragma warning( default : 4530 ) 
 1423 #pragma warning( default : 4786 ) 
TiXmlElement * Element() const 
Return the handle as a TiXmlElement. This may return null. 
Definition: tinyxml.h:1411
const TiXmlDocument * GetDocument() const 
Definition: tinyxml.h:664
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
Definition: tinyxml.h:783
void Clear()
Delete all the children of this node. Does not affect 'this'. 
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
TiXmlUnknown * Unknown() const 
Return the handle as a TiXmlUnknown. This may return null;. 
Definition: tinyxml.h:1415
bool Error() const 
Definition: tinyxml.h:1202
const char * Encoding() const 
Encoding. Will return an empty string if none was found. 
Definition: tinyxml.h:1074
void SetValue(const char *_value)
Definition: tinyxml.h:435
TiXmlText(const char *initValue)
Constructor. 
Definition: tinyxml.h:997
TiXmlAttribute()
Construct an empty attribute. 
Definition: tinyxml.h:670
const char * ErrorDesc() const 
Contains a textual (english) description of the error if one occurs. 
Definition: tinyxml.h:1205
void ClearError()
Definition: tinyxml.h:1249
const TiXmlElement * ToElement() const 
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:604
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
int ErrorCol()
The column where the error occured. See ErrorRow() 
Definition: tinyxml.h:1220
int ErrorRow()
Definition: tinyxml.h:1219
void SetName(const char *_name)
Set the name of this attribute. 
Definition: tinyxml.h:714
virtual int Type() const 
Definition: tinyxml.h:592
const TiXmlText * ToText() const 
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:607
const char * Name() const 
Return the name of this attribute. 
Definition: tinyxml.h:696
virtual TiXmlNode * Clone() const  =0
TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:611
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
int Row() const 
Definition: tinyxml.h:178
TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:613
TiXmlText * Text() const 
Return the handle as a TiXmlText. This may return null. 
Definition: tinyxml.h:1413
void SetValue(const char *_value)
Set the value. 
Definition: tinyxml.h:715
const TiXmlNode * NextSibling() const 
Navigate to a sibling node. 
Definition: tinyxml.h:549
void SetTabSize(int _tabsize)
Definition: tinyxml.h:1242
const TiXmlElement * NextSiblingElement() const 
const TiXmlAttribute * FirstAttribute() const 
Access the first attribute in this element. 
Definition: tinyxml.h:916
TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:614
NodeType
Definition: tinyxml.h:399
int Column() const 
See Row() 
Definition: tinyxml.h:179
int QueryDoubleAttribute(const char *name, float *value) const 
QueryFloatAttribute examines the attribute - see QueryIntAttribute(). 
Definition: tinyxml.h:863
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const 
Definition: tinyxml.h:1048
const int ErrorId() const 
Definition: tinyxml.h:1210
Definition: tinyxml.h:1108
const TiXmlAttribute * LastAttribute() const 
Access the last attribute in this element. 
Definition: tinyxml.h:918
const TiXmlElement * FirstChildElement() const 
Convenience function to get through elements. 
TiXmlComment * ToComment()
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:612
const TiXmlUnknown * ToUnknown() const 
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:606
TiXmlNode * Parent()
One step up the DOM. 
Definition: tinyxml.h:450
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
const TiXmlDocument * ToDocument() const 
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:603
Definition: tinyxml.h:1141
TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:610
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor. 
Definition: tinyxml.h:1369
void Print() const 
Definition: tinyxml.h:1257
const char * Value() const 
Return the value of this attribute. 
Definition: tinyxml.h:697
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value. 
Definition: tinyxml.h:688
Definition: tinyxml.h:1363
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children. 
Definition: tinyxml.h:459
TiXmlHandle(TiXmlNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer. 
Definition: tinyxml.h:1367
static bool IsWhiteSpaceCondensed()
Return the current white space setting. 
Definition: tinyxml.h:158
const char * Version() const 
Version. Will return an empty string if none was found. 
Definition: tinyxml.h:1072
const char * Value() const 
Definition: tinyxml.h:424
void * userData
Field containing a generic user pointer. 
Definition: tinyxml.h:310
const TiXmlNode * PreviousSibling() const 
Navigate to a sibling node. 
Definition: tinyxml.h:534
Definition: tinyxml.h:132
const TiXmlElement * RootElement() const 
Definition: tinyxml.h:1194
TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:615
Definition: tinyxml.h:357
Definition: tinyxml.h:217
TiXmlNode * Node() const 
Return the handle as a TiXmlNode. This may return null. 
Definition: tinyxml.h:1409
Definition: tinyxml.h:992
virtual TiXmlNode * Clone() const 
Creates a new Element and returns it - the returned element is a copy. 
virtual void Print(FILE *cfile, int depth) const  =0
TiXmlDeclaration()
Construct an empty declaration. 
Definition: tinyxml.h:1052
const char * Standalone() const 
Is this a standalone document? 
Definition: tinyxml.h:1076
static void SetCondenseWhiteSpace(bool condense)
Definition: tinyxml.h:155
const TiXmlNode * FirstChild() const 
The first child of this node. Will be null if there are no children. 
Definition: tinyxml.h:453
const TiXmlComment * ToComment() const 
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:605
bool NoChildren() const 
Returns true if this node has no children. 
Definition: tinyxml.h:601
const TiXmlDeclaration * ToDeclaration() const 
Cast to a more defined type. Will return null not of the requested type. 
Definition: tinyxml.h:608
Definition: tinyxml.h:814
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.