26#ifndef PANDORA_TINYXML_INCLUDED
27#define PANDORA_TINYXML_INCLUDED
34#pragma warning( push )
35#pragma warning( disable : 4530 )
36#pragma warning( disable : 4786 )
46#if defined( _DEBUG ) && !defined( DEBUG )
54 #define TIXML_STRING std::string
57 #define TIXML_STRING TiXmlString
67 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
69 #define TIXML_SNPRINTF _snprintf_s
70 #define TIXML_SSCANF sscanf_s
71 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
74 #define TIXML_SNPRINTF _snprintf
75 #define TIXML_SSCANF sscanf
76 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
79 #define TIXML_SNPRINTF snprintf
80 #define TIXML_SSCANF sscanf
82 #define TIXML_SNPRINTF snprintf
83 #define TIXML_SSCANF sscanf
96class TiXmlDeclaration;
97class TiXmlParsingData;
220 virtual void Print( FILE* cfile,
int depth )
const = 0;
262 virtual const char*
Parse(
const char* p,
299 return ( isspace( (
unsigned char) c ) || c ==
'\n' || c ==
'\r' );
322 static const char*
ReadText(
const char* in,
324 bool ignoreWhiteSpace,
340 assert( *length >= 0 && *length < 5 );
350 return GetEntity( p, _value, length, encoding );
358 for(
int i=0; p[i] && i<*length; ++i ) {
361 return p + (*length);
393 if ( v < 128 )
return tolower( v );
536 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->FirstChild( _value ));
543 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->LastChild( _value ));
571 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( previous ) );
577 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( _value, previous ) );
627 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->PreviousSibling( _prev ) );
644 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSibling( _next ) );
662 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSiblingElement( _next ) );
679 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->FirstChildElement( _value ) );
877 virtual void Print( FILE* cfile,
int depth )
const {
878 Print( cfile, depth, 0 );
967 const char*
Attribute(
const char* name )
const;
975 const char*
Attribute(
const char* name,
int* i )
const;
983 const char*
Attribute(
const char* name,
double* d )
const;
1012 #ifdef TIXML_USE_STL
1017 *_value = std::string( cstr );
1037 std::stringstream sstream( node->
ValueStr() );
1038 sstream >> *outValue;
1039 if ( !sstream.fail() )
1057 void SetAttribute(
const char* name,
const char * _value );
1059 #ifdef TIXML_USE_STL
1060 const std::string*
Attribute(
const std::string& name )
const;
1061 const std::string*
Attribute(
const std::string& name,
int* i )
const;
1062 const std::string*
Attribute(
const std::string& name,
double* d )
const;
1087 #ifdef TIXML_USE_STL
1133 virtual void Print( FILE* cfile,
int depth )
const;
1153 #ifdef TIXML_USE_STL
1186 virtual void Print( FILE* cfile,
int depth )
const;
1204 #ifdef TIXML_USE_STL
1234 #ifdef TIXML_USE_STL
1247 virtual void Print( FILE* cfile,
int depth )
const;
1270 #ifdef TIXML_USE_STL
1301 const std::string& _encoding,
1302 const std::string& _standalone );
1307 const char* _encoding,
1308 const char* _standalone );
1326 virtual void Print( FILE* cfile,
int depth )
const {
1327 Print( cfile, depth, 0 );
1342 #ifdef TIXML_USE_STL
1373 virtual void Print( FILE* cfile,
int depth )
const;
1387 #ifdef TIXML_USE_STL
1408 #ifdef TIXML_USE_STL
1428 bool SaveFile(
const char * filename )
const;
1438 #ifdef TIXML_USE_STL
1441 return LoadFile( filename.c_str(), encoding );
1445 return SaveFile( filename.c_str() );
1535 virtual void Print( FILE* cfile,
int depth = 0 )
const;
1549 #ifdef TIXML_USE_STL
1682 #ifdef TIXML_USE_STL
1786 #ifdef TIXML_USE_STL
1793 for(
int i=0; i<
depth; ++i )
1809#pragma warning( pop )
const char * Name() const
Return the name of this attribute.
int QueryIntValue(int *_value) const
double DoubleValue() const
Return the value of this attribute, converted to a double.
const char * Value() const
Return the value of this attribute.
bool operator<(const TiXmlAttribute &rhs) const
void SetValue(const char *_value)
Set the value.
bool operator==(const TiXmlAttribute &rhs) const
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
void operator=(const TiXmlAttribute &base)
TiXmlAttribute(const TiXmlAttribute &)
TiXmlAttribute * Previous()
virtual void Print(FILE *cfile, int depth) const
void SetValue(const std::string &_value)
STL std::string form.
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
void SetName(const char *_name)
Set the name of this attribute.
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
void SetIntValue(int _value)
Set the value from an integer.
void SetDoubleValue(double _value)
Set the value from a double.
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
bool operator>(const TiXmlAttribute &rhs) const
int IntValue() const
Return the value of this attribute, converted to an integer.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
void SetName(const std::string &_name)
STL std::string form.
TiXmlAttribute(const std::string &_name, const std::string &_value)
std::string constructor.
void SetDocument(TiXmlDocument *doc)
const std::string & ValueStr() const
Return the value of this attribute.
const TIXML_STRING & NameTStr() const
TiXmlAttribute()
Construct an empty attribute.
TiXmlAttribute * FindOrCreate(const char *_name)
const TiXmlAttribute * First() const
const TiXmlAttribute * Last() const
TiXmlAttribute * Find(const char *_name) const
TiXmlAttribute * FindOrCreate(const std::string &_name)
void Add(TiXmlAttribute *attribute)
TiXmlAttribute * Find(const std::string &_name) const
TiXmlAttributeSet(const TiXmlAttributeSet &)
void Remove(TiXmlAttribute *attribute)
void operator=(const TiXmlAttributeSet &)
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
static int ToLower(int v, TiXmlEncoding encoding)
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
static bool IsWhiteSpace(char c)
int Column() const
See Row()
static const char * errorString[TIXML_ERROR_STRING_COUNT]
static Entity entity[NUM_ENTITY]
static bool condenseWhiteSpace
static bool StreamTo(std::istream *in, int character, TIXML_STRING *tag)
@ TIXML_ERROR_PARSING_DECLARATION
@ TIXML_ERROR_DOCUMENT_TOP_ONLY
@ TIXML_ERROR_READING_ATTRIBUTES
@ TIXML_ERROR_DOCUMENT_EMPTY
@ TIXML_ERROR_STRING_COUNT
@ TIXML_ERROR_PARSING_UNKNOWN
@ TIXML_ERROR_READING_ELEMENT_VALUE
@ TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME
@ TIXML_ERROR_PARSING_EMPTY
@ TIXML_ERROR_PARSING_COMMENT
@ TIXML_ERROR_OPENING_FILE
@ TIXML_ERROR_PARSING_ELEMENT
@ TIXML_ERROR_EMBEDDED_NULL
@ TIXML_ERROR_PARSING_CDATA
@ TIXML_ERROR_READING_END_TAG
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
static const int utf8ByteTable[256]
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
static void SetCondenseWhiteSpace(bool condense)
void operator=(const TiXmlBase &base)
void * GetUserData()
Get a pointer to arbitrary user data.
void SetUserData(void *user)
Set a pointer to arbitrary user data.
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
static bool StreamWhiteSpace(std::istream *in, TIXML_STRING *tag)
static bool IsWhiteSpace(int c)
TiXmlBase(const TiXmlBase &)
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
const void * GetUserData() const
Get a pointer to arbitrary user data.
void * userData
Field containing a generic user pointer.
virtual void Print(FILE *cfile, int depth) const =0
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
const char * Encoding() const
Encoding. Will return an empty string if none was found.
virtual ~TiXmlDeclaration()
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
TiXmlDeclaration()
Construct an empty declaration.
TiXmlDeclaration(const std::string &_version, const std::string &_encoding, const std::string &_standalone)
Constructor.
void CopyTo(TiXmlDeclaration *target) const
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
TiXmlDeclaration & operator=(const TiXmlDeclaration ©)
const char * Standalone() const
Is this a standalone document?
virtual bool Accept(TiXmlVisitor *visitor) const
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
virtual void Print(FILE *cfile, int depth) const
const char * Version() const
Version. Will return an empty string if none was found.
TiXmlDocument(const std::string &documentName)
Constructor.
virtual TiXmlNode * Clone() const
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
bool SaveFile(const std::string &filename) const
< STL std::string version.
virtual bool Accept(TiXmlVisitor *content) const
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlDocument & operator=(const TiXmlDocument ©)
void CopyTo(TiXmlDocument *target) const
TiXmlCursor errorLocation
const TiXmlElement * RootElement() const
TiXmlDocument()
Create an empty document, that has no name.
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
TiXmlElement * RootElement()
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
void SetTabSize(int _tabsize)
int ErrorCol() const
The column where the error occured. See ErrorRow()
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
void CopyTo(TiXmlElement *target) const
int QueryValueAttribute(const std::string &name, std::string *outValue) const
const std::string * Attribute(const std::string &name) const
int QueryDoubleAttribute(const std::string &name, double *_value) const
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
TiXmlElement & operator=(const TiXmlElement &base)
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
int QueryIntAttribute(const std::string &name, int *_value) const
TiXmlElement(const std::string &_value)
std::string constructor.
const std::string * Attribute(const std::string &name, double *d) const
void SetAttribute(const std::string &name, int _value)
STL std::string form.
virtual bool Accept(TiXmlVisitor *visitor) const
int QueryUnsignedAttribute(const char *name, unsigned *_value) const
QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
int QueryStringAttribute(const char *name, std::string *_value) const
QueryStringAttribute examines the attribute - see QueryIntAttribute().
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
const char * Attribute(const char *name) const
TiXmlAttribute * LastAttribute()
void SetAttribute(const char *name, const char *_value)
TiXmlAttribute * FirstAttribute()
const std::string * Attribute(const std::string &name, int *i) const
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
void SetDoubleAttribute(const std::string &name, double value)
void SetAttribute(const std::string &name, const std::string &_value)
STL std::string form.
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
int QueryValueAttribute(const std::string &name, T *outValue) const
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
virtual void Print(FILE *cfile, int depth) const
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
TiXmlAttributeSet attributeSet
const char * GetText() const
int QueryIntAttribute(const char *name, int *_value) const
void RemoveAttribute(const std::string &name)
STL std::string form.
const char * ReadValue(const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
int QueryBoolAttribute(const char *name, bool *_value) const
void RemoveAttribute(const char *name)
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
TiXmlElement * Element() const
TiXmlHandle FirstChildElement(const std::string &_value) const
TiXmlUnknown * ToUnknown() const
TiXmlHandle ChildElement(const std::string &_value, int index) const
TiXmlHandle FirstChild() const
Return a handle to the first child node.
TiXmlHandle Child(const char *value, int index) const
TiXmlNode * ToNode() const
TiXmlText * ToText() const
TiXmlElement * ToElement() const
TiXmlHandle ChildElement(const char *value, int index) const
TiXmlHandle FirstChild(const std::string &_value) const
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
TiXmlHandle operator=(const TiXmlHandle &ref)
TiXmlUnknown * Unknown() const
TiXmlHandle Child(const std::string &_value, int index) const
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
const TiXmlNode * LastChild() const
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
TiXmlNode * LastChild(const char *_value)
The last child of this node matching 'value'. Will be null if there are no children.
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
void Clear()
Delete all the children of this node. Does not affect 'this'.
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * NextSibling(const char *_next)
virtual TiXmlNode * Clone() const =0
TiXmlNode * PreviousSibling()
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * FirstChild(const char *_value)
The first child of this node with the matching 'value'. Will be null if none found.
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
TiXmlElement * NextSiblingElement(const char *_next)
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
const std::string & ValueStr() const
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
TiXmlElement * NextSiblingElement()
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlNode * Parent() const
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
TiXmlElement * FirstChildElement(const char *_value)
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
TiXmlNode(const TiXmlNode &)
TiXmlNode * NextSibling()
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
void SetValue(const char *_value)
bool NoChildren() const
Returns true if this node has no children.
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
void operator=(const TiXmlNode &base)
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
const TiXmlElement * NextSiblingElement() const
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
TiXmlNode * Parent()
One step up the DOM.
void CopyTo(TiXmlNode *target) const
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
TiXmlDocument * GetDocument()
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
virtual bool Accept(TiXmlVisitor *visitor) const =0
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
friend class TiXmlElement
TiXmlNode * IterateChildren(const TiXmlNode *previous)
const char * Value() const
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
const TiXmlDocument * GetDocument() const
TiXmlNode * PreviousSibling(const char *_prev)
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
const TIXML_STRING & ValueTStr() const
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
friend std::istream & operator>>(std::istream &in, TiXmlNode &base)
TiXmlElement * FirstChildElement()
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
void SetValue(const std::string &_value)
STL std::string form.
friend std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)
void SetLineBreak(const char *_lineBreak)
const char * CStr()
Return the result.
const char * LineBreak()
Query the current line breaking string.
const std::string & Str()
Return the result.
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
void SetIndent(const char *_indent)
const char * Indent()
Query the indention string.
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
size_t Size()
Return the length of the result string.
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
bool CDATA() const
Queries whether this represents text using a CDATA section.
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
virtual bool Accept(TiXmlVisitor *content) const
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlText & operator=(const TiXmlText &base)
TiXmlText(const char *initValue)
TiXmlText(const TiXmlText ©)
TiXmlText(const std::string &initValue)
Constructor.
virtual void Print(FILE *cfile, int depth) const
void CopyTo(TiXmlText *target) const
virtual void Print(FILE *cfile, int depth) const
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual bool Accept(TiXmlVisitor *content) const
TiXmlUnknown(const TiXmlUnknown ©)
void CopyTo(TiXmlUnknown *target) const
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
TiXmlUnknown & operator=(const TiXmlUnknown ©)
virtual bool Visit(const TiXmlUnknown &)
Visit an unknown node.
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
virtual bool Visit(const TiXmlText &)
Visit a text node.
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
const int TIXML_PATCH_VERSION
const int TIXML_MINOR_VERSION
const TiXmlEncoding TIXML_DEFAULT_ENCODING
const int TIXML_MAJOR_VERSION