33 #ifndef TINYXML_INCLUDED
34 #define TINYXML_INCLUDED
37 #pragma warning( push )
38 #pragma warning( disable : 4530 )
39 #pragma warning( disable : 4786 )
49 #if defined( _DEBUG ) && !defined( DEBUG )
57 #define TIXML_STRING std::string
60 #define TIXML_STRING TiXmlString
70 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
72 #define TIXML_SNPRINTF _snprintf_s
73 #define TIXML_SNSCANF _snscanf_s
74 #define TIXML_SSCANF sscanf_s
75 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
78 #define TIXML_SNPRINTF _snprintf
79 #define TIXML_SNSCANF _snscanf
80 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
83 #define TIXML_SNPRINTF snprintf
84 #define TIXML_SNSCANF snscanf
217 virtual void Print( FILE* cfile,
int depth )
const = 0;
259 virtual const char*
Parse(
const char*
p,
296 return ( isspace( (
unsigned char) c ) || c ==
'\n' || c ==
'\r' );
321 bool ignoreWhiteSpace,
337 assert( *length >= 0 && *length < 5 );
347 return GetEntity( p, _value, length, encoding );
355 for(
int i=0; p[
i] &&
i<*length; ++
i ) {
358 return p + (*length);
390 if ( v < 128 )
return tolower( v );
533 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->FirstChild( _value ));
540 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->LastChild( _value ));
568 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( previous ) );
574 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( _value, previous ) );
624 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->PreviousSibling( _prev ) );
641 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSibling( _next ) );
659 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSiblingElement( _next ) );
676 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->FirstChildElement( _value ) );
875 Print( cfile, depth, 0 );
975 const char*
Attribute(
const char* name,
int*
i )
const;
983 const char*
Attribute(
const char* name,
double*
d )
const;
1005 #ifdef TIXML_USE_STL
1020 std::stringstream sstream( node->
ValueStr() );
1021 sstream >> *outValue;
1022 if ( !sstream.fail() )
1046 void SetAttribute(
const char* name,
const char * _value );
1048 #ifdef TIXML_USE_STL
1074 #ifdef TIXML_USE_STL
1120 virtual void Print( FILE* cfile,
int depth )
const;
1140 #ifdef TIXML_USE_STL
1174 virtual void Print( FILE* cfile,
int depth )
const;
1192 #ifdef TIXML_USE_STL
1222 #ifdef TIXML_USE_STL
1235 virtual void Print( FILE* cfile,
int depth )
const;
1258 #ifdef TIXML_USE_STL
1286 #ifdef TIXML_USE_STL
1295 const char* _encoding,
1296 const char* _standalone );
1315 Print( cfile, depth, 0 );
1330 #ifdef TIXML_USE_STL
1361 virtual void Print( FILE* cfile,
int depth )
const;
1375 #ifdef TIXML_USE_STL
1396 #ifdef TIXML_USE_STL
1426 #ifdef TIXML_USE_STL
1431 return LoadFile( filename.c_str(), encoding );
1527 virtual void Print( FILE* cfile,
int depth = 0 )
const;
1541 #ifdef TIXML_USE_STL
1674 #ifdef TIXML_USE_STL
1778 #ifdef TIXML_USE_STL
1801 #pragma warning( pop )
virtual void StreamIn(std::istream *in, std::string *tag)
static const int utf8ByteTable[256]
TiXmlHandle Child(const std::string &_value, int index) const
const TiXmlAttribute * First() const
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlNode * LastChild(const char *_value)
The last child of this node matching 'value'. Will be null if there are no children.
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
TiXmlUnknown * Unknown() const
TiXmlBase & operator=(const TiXmlBase &base)
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
virtual bool Accept(TiXmlVisitor *visitor) const
friend std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)
void SetUserData(void *user)
Set a pointer to arbitrary user data.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
const std::string & ValueTStr() const
virtual void StreamIn(std::istream *in, std::string *tag)
TiXmlUnknown(const TiXmlUnknown ©)
const TiXmlNode * Parent() const
tuple start
Check for commandline option errors.
const std::string & ValueStr() const
const TiXmlElement * RootElement() const
void SetLineBreak(const char *_lineBreak)
TiXmlElement * NextSiblingElement()
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
static bool StreamWhiteSpace(std::istream *in, std::string *tag)
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
TiXmlNode * PreviousSibling(const char *_prev)
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
const char * LineBreak()
Query the current line breaking string.
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
double DoubleValue() const
Return the value of this attribute, converted to a double.
virtual bool Visit(const TiXmlUnknown &)
Visit an unknow node.
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
int IntValue() const
Return the value of this attribute, converted to an integer.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlHandle FirstChild() const
Return a handle to the first child node.
void CopyTo(TiXmlUnknown *target) const
const void * GetUserData() const
Get a pointer to arbitrary user data.
void CopyTo(TiXmlDocument *target) const
static int ToLower(int v, TiXmlEncoding encoding)
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
TiXmlElement & operator=(const TiXmlElement &base)
void SetDoubleAttribute(const char *name, double value)
virtual void Print(FILE *cfile, int depth) const
static void EncodeString(const std::string &str, std::string *out)
virtual void Print(FILE *cfile, int depth) const
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
virtual void StreamIn(std::istream *in, std::string *tag)
TiXmlAttribute * FirstAttribute()
virtual void StreamIn(std::istream *in, std::string *tag)
TiXmlElement * FirstChildElement(const char *_value)
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
void SetValue(const std::string &_value)
STL std::string form.
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
bool SaveFile(const std::string &filename) const
< STL std::string version.
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
void SetName(const char *_name)
Set the name of this attribute.
TiXmlNode * NextSibling()
virtual void Print(FILE *cfile, int depth, std::string *str) const
void SetTabSize(int _tabsize)
TiXmlDocument()
Create an empty document, that has no name.
TiXmlAttribute()
Construct an empty attribute.
TiXmlHandle & operator=(const TiXmlHandle &ref)
const int TIXML_PATCH_VERSION
const char * Standalone() const
Is this a standalone document?
static const char *const errorString[TIXML_ERROR_STRING_COUNT]
TiXmlElement * ToElement() const
TiXmlElement * NextSiblingElement(const char *_next)
TiXmlElement * FirstChildElement()
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
const char * Value() const
Return the value of this attribute.
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
int QueryIntValue(int *_value) const
virtual void Print(FILE *cfile, int depth) const
friend std::istream & operator>>(std::istream &in, TiXmlNode &base)
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
void SetValue(const char *_value)
int ErrorCol() const
The column where the error occurred. See ErrorRow()
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
const std::string & NameTStr() const
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
static bool condenseWhiteSpace
static std::string const input
TiXmlNode * PreviousSibling()
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlAttribute * Find(const char *_name)
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
TiXmlHandle ChildElement(const std::string &_value, int index) const
TiXmlAttribute & operator=(const TiXmlAttribute &base)
const char * Encoding() const
Encoding. Will return an empty string if none was found.
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
const TiXmlNode * LastChild() const
const char * Name() const
Return the name of this attribute.
void SetDoubleValue(double _value)
Set the value from a double.
void * userData
Field containing a generic user pointer.
virtual bool Accept(TiXmlVisitor *visitor) const =0
TiXmlDocument * GetDocument()
const TiXmlAttribute * Last() const
static bool IsWhiteSpace(char c)
TiXmlAttributeSet attributeSet
virtual bool Visit(const TiXmlText &)
Visit a text node.
const TiXmlEncoding TIXML_DEFAULT_ENCODING
const char * Version() const
Version. Will return an empty string if none was found.
TiXmlNode * NextSibling(const char *_next)
TiXmlHandle ChildElement(const char *value, int index) const
virtual bool Accept(TiXmlVisitor *content) const
int Column() const
See Row()
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
TiXmlText(const TiXmlText ©)
const int TIXML_MAJOR_VERSION
static const char * ReadName(const char *p, std::string *name, TiXmlEncoding encoding)
void SetIndent(const char *_indent)
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
void RemoveAttribute(const char *name)
virtual TiXmlNode * Clone() const
void SetAttribute(const char *name, const char *_value)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual void Print(FILE *cfile, int depth) const
virtual void Print(FILE *cfile, int depth) const
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
const char * Indent()
Query the indention string.
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
virtual void StreamIn(std::istream *in, std::string *tag)=0
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
TiXmlElement(const char *in_value)
Construct an element.
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
const TiXmlAttribute * Find(const char *_name) const
static Entity entity[NUM_ENTITY]
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
virtual void StreamIn(std::istream *in, std::string *tag)
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
TiXmlText & operator=(const TiXmlText &base)
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
const char * ReadValue(const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
TiXmlHandle Child(const char *value, int index) const
void Add(TiXmlAttribute *attribute)
const std::string & ValueStr() const
Return the value of this attribute.
const TiXmlDocument * GetDocument() const
TiXmlNode & operator=(const TiXmlNode &base)
bool CDATA() const
Queries whether this represents text using a CDATA section.
static bool IsWhiteSpace(int c)
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if not of the requested type.
bool operator>(const TiXmlAttribute &rhs) const
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
TiXmlNode * ToNode() const
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
static void SetCondenseWhiteSpace(bool condense)
bool operator<(const TiXmlAttribute &rhs) const
const TiXmlElement * NextSiblingElement() const
TiXmlNode * Parent()
One step up the DOM.
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
bool operator==(const TiXmlAttribute &rhs) const
TiXmlDeclaration & operator=(const TiXmlDeclaration ©)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
static bool StreamTo(std::istream *in, int character, std::string *tag)
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlNode * IterateChildren(const TiXmlNode *previous)
int QueryIntAttribute(const char *name, int *_value) const
TiXmlHandle FirstChild(const std::string &_value) const
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
TiXmlAttribute * Previous()
TiXmlElement * Element() const
virtual bool Accept(TiXmlVisitor *content) const
TiXmlNode(NodeType _type)
TiXmlElement * RootElement()
int QueryValueAttribute(const std::string &name, T *outValue) const
void * GetUserData()
Get a pointer to arbitrary user data.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
void CopyTo(TiXmlNode *target) const
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
size_t Size()
Return the length of the result string.
void SetIntValue(int _value)
Set the value from an integer.
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
TiXmlText(const char *initValue)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
const char * Value() const
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
TiXmlDocument & operator=(const TiXmlDocument ©)
void CopyTo(TiXmlText *target) const
TiXmlUnknown & operator=(const TiXmlUnknown ©)
bool NoChildren() const
Returns true if this node has no children.
void CopyTo(TiXmlElement *target) const
virtual bool Accept(TiXmlVisitor *visitor) const
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
void RemoveAttribute(const std::string &name)
STL std::string form.
volatile std::atomic< bool > shutdown_flag false
void SetDocument(TiXmlDocument *doc)
const char * GetText() const
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null if not of the requested type.
void Remove(TiXmlAttribute *attribute)
void Clear()
Delete all the children of this node. Does not affect 'this'.
TiXmlHandle FirstChildElement(const std::string &_value) const
void SetValue(const char *_value)
Set the value.
const std::string & Str()
Return the result.
virtual ~TiXmlDeclaration()
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
TiXmlAttribute * LastAttribute()
TiXmlText * ToText() const
TiXmlDeclaration()
Construct an empty declaration.
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
const char * Attribute(const char *name) const
virtual void Print(FILE *cfile, int depth) const =0
static const char * ReadText(const char *in, std::string *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
virtual bool Accept(TiXmlVisitor *content) const
virtual TiXmlNode * Clone() const =0
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
void CopyTo(TiXmlDeclaration *target) const
TiXmlUnknown * ToUnknown() const
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
const char * CStr()
Return the result.
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
const int TIXML_MINOR_VERSION
TiXmlCursor errorLocation
TiXmlAttributeSet & operator=(const TiXmlAttributeSet &)
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
TiXmlAttribute * Find(const std::string &_name)