32 #ifndef TINYXML_INCLUDED
33 #define TINYXML_INCLUDED
36 #pragma warning( push )
37 #pragma warning( disable : 4530 )
38 #pragma warning( disable : 4786 )
48 #if defined( _DEBUG ) && !defined( DEBUG )
56 #define TIXML_STRING std::string
59 #define TIXML_STRING TiXmlString
69 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
71 #define TIXML_SNPRINTF _snprintf_s
72 #define TIXML_SNSCANF _snscanf_s
73 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
76 #define TIXML_SNPRINTF _snprintf
77 #define TIXML_SNSCANF _snscanf
78 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
81 #define TIXML_SNPRINTF snprintf
82 #define TIXML_SNSCANF snscanf
228 virtual void Print(FILE* cfile,
int depth)
const = 0;
312 return (isspace((
unsigned char) c) || c ==
'\n' || c ==
'\r');
334 static const char*
ReadText(
const char* in,
336 bool ignoreWhiteSpace,
350 assert( *length >= 0 && *length < 5);
358 return GetEntity(p, _value, length, encoding);
365 for (
int i = 0; p[i] && i < *length; ++i) {
368 return p + (*length);
488 return value.c_str();
515 void SetValue(
const std::string& _value) {
543 return const_cast<TiXmlNode*
>((
const_cast<const TiXmlNode*
>(
this))->FirstChild(_value));
554 return const_cast<TiXmlNode*
>((
const_cast<const TiXmlNode*
>(
this))->LastChild(_value));
590 return const_cast<TiXmlNode*
>((
const_cast<const TiXmlNode*
>(
this))->IterateChildren(previous));
596 return const_cast<TiXmlNode*
>((
const_cast<const TiXmlNode*
>(
this))->IterateChildren(_value, previous));
653 return const_cast<TiXmlNode*
>((
const_cast<const TiXmlNode*
>(
this))->PreviousSibling(_prev));
682 return const_cast<TiXmlNode*
>((
const_cast<const TiXmlNode*
>(
this))->NextSibling(_next));
718 return const_cast<TiXmlElement*
>((
const_cast<const TiXmlNode*
>(
this))->PreviousSiblingElement(_next));
889 TiXmlAttribute(
const std::string& _name,
const std::string& _value) {
910 return value.c_str();
949 void SetName(
const std::string& _name) {
987 virtual void Print(FILE* cfile,
int depth)
const {
988 Print(cfile, depth, 0);
1045 #ifdef TIXML_USE_STL
1071 #ifdef TIXML_USE_STL
1092 const char*
Attribute(
const char* name)
const;
1104 const char*
Attribute(
const char* name,
int* i)
const;
1112 const char*
Attribute(
const char* name,
double* d)
const;
1129 *_value = (float) d;
1133 #ifdef TIXML_USE_STL
1145 std::stringstream sstream(node->
ValueStr());
1146 sstream >> *outValue;
1147 if (!sstream.fail())
1156 void SetAttribute(
const char* name,
const char * _value);
1158 #ifdef TIXML_USE_STL
1159 const std::string*
Attribute(
const std::string& name)
const;
1160 const std::string*
Attribute(
const std::string& name,
int* i)
const;
1161 const std::string*
Attribute(
const std::string& name,
double* d)
const;
1166 void SetAttribute(
const std::string& name,
const std::string& _value);
1168 void SetAttribute(
const std::string& name,
int _value);
1184 #ifdef TIXML_USE_STL
1240 virtual void Print(FILE* cfile,
int depth)
const;
1264 #ifdef TIXML_USE_STL
1300 virtual void Print(FILE* cfile,
int depth)
const;
1322 #ifdef TIXML_USE_STL
1351 #ifdef TIXML_USE_STL
1369 virtual void Print(FILE* cfile,
int depth)
const;
1400 #ifdef TIXML_USE_STL
1428 #ifdef TIXML_USE_STL
1429 TiXmlDeclaration(
const std::string& _version,
const std::string& _encoding,
const std::string& _standalone);
1434 TiXmlDeclaration(
const char* _version,
const char* _encoding,
const char* _standalone);
1459 virtual void Print(FILE* cfile,
int depth)
const {
1460 Print(cfile, depth, 0);
1479 #ifdef TIXML_USE_STL
1514 virtual void Print(FILE* cfile,
int depth)
const;
1532 #ifdef TIXML_USE_STL
1551 #ifdef TIXML_USE_STL
1572 bool SaveFile(
const char * filename)
const;
1582 #ifdef TIXML_USE_STL
1587 return LoadFile(filename.c_str(), encoding);
1703 virtual void Print(FILE* cfile,
int depth = 0)
const;
1721 #ifdef TIXML_USE_STL
1858 #ifdef TIXML_USE_STL
1867 return Child(_value.c_str(), index);
1964 indent = _indent ? _indent :
"";
1975 lineBreak = _lineBreak ? _lineBreak :
"";
1998 #ifdef TIXML_USE_STL
1999 const std::string&
Str() {
2007 for (
int i = 0; i <
depth; ++i)
2019 #pragma warning( pop )
TiXmlAttribute * LastAttribute()
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
TiXmlElement * NextSiblingElement(const std::string &_value)
STL std::string form.
const std::string & ValueStr() const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
const TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
TiXmlNode * Parent()
One step up the DOM.
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
void SetDoubleAttribute(const char *name, double value)
static bool StreamTo(std::istream *in, int character, TIXML_STRING *tag)
void SetTabSize(int _tabsize)
int QueryValueAttribute(const std::string &name, T *outValue) const
virtual TiXmlNode * Clone() const
Creates a copy of this Declaration and returns it.
TiXmlHandle FirstChildElement(const std::string &_value) const
void operator=(const TiXmlText &base)
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
static void PutString(const TIXML_STRING &str, TIXML_STRING *out)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlHandle operator=(const TiXmlHandle &ref)
const TIXML_STRING & NameTStr() const
TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous)
STL std::string form.
static const char * GetChar(const char *p, char *_value, int *length, TiXmlEncoding encoding)
void SetCDATA(bool _cdata)
Turns on or off a CDATA representation of text.
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
const char * Version() const
Version. Will return an empty string if none was found.
const std::string & ValueStr() const
Return the value of this attribute.
void CopyTo(TiXmlElement *target) const
virtual ~TiXmlDeclaration()
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlNode * NextSibling(const std::string &_value)
STL std::string form.
int QueryDoubleAttribute(const char *name, double *_value) const
QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
const TiXmlNode * LastChild() const
void operator=(const TiXmlAttribute &base)
int Column() const
See Row()
virtual TiXmlNode * Clone() const =0
const TiXmlAttribute * First() const
const char * Standalone() const
Is this a standalone document?
TinyXML class. See http://www.grinninglizard.com/tinyxml.
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
const TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
void operator=(const TiXmlBase &base)
void operator=(const TiXmlNode &base)
static void SetCondenseWhiteSpace(bool condense)
TinyXML class. See http://www.grinninglizard.com/tinyxml.
bool SaveFile() const
Save a file using the current document value. Returns true if successful.
static bool IsWhiteSpace(char c)
void SetDoubleValue(double _value)
Set the value from a double.
size_t Size()
Return the length of the result string.
void RemoveAttribute(const char *name)
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
const TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
TiXmlHandle(TiXmlNode *_node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
virtual bool Accept(TiXmlVisitor *visitor) const
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
const std::string & Str()
Return the result.
TiXmlElement * FirstChildElement(const char *_value)
TiXmlHandle Child(const std::string &_value, int index) const
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
void SetIntValue(int _value)
Set the value from an integer.
void CopyTo(TiXmlDeclaration *target) const
static int IsAlpha(unsigned char anyByte, TiXmlEncoding encoding)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)=0
const int TIXML_PATCH_VERSION
void operator=(const TiXmlDeclaration ©)
TiXmlDocument()
Create an empty document, that has no name.
void SetIndent(const char *_indent)
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlNode * Clone() const
Creates a copy of this Unknown and returns it.
TinyXML class. See http://www.grinninglizard.com/tinyxml.
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
const char * ReadValue(const char *in, TiXmlParsingData *prevData, TiXmlEncoding encoding)
const char * Value() const
const void * GetUserData() const
Get a pointer to arbitrary user data.
TiXmlElement * Element() const
TiXmlDocument * GetDocument()
const TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
bool LoadFile(const std::string &filename, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlElement * ToElement() const
void RemoveAttribute(const std::string &name)
STL std::string form.
int IntValue() const
Return the value of this attribute, converted to an integer.
static bool IsWhiteSpace(int c)
int QueryIntAttribute(const char *name, int *_value) const
const char * Name() const
Return the name of this attribute.
const TiXmlAttribute * Previous() const
Get the previous sibling attribute in the DOM. Returns null at beginning.
virtual void Print(FILE *cfile, int depth) const
TiXmlElement * PreviousSiblingElement(const char *_next)
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null if not of the requested type.
virtual TiXmlNode * Clone() const
Creates a new Element and returns it - the returned element is a copy.
void CopyTo(TiXmlText *target) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TiXmlNode * PreviousSibling(const std::string &_value)
STL std::string form.
const TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
const TiXmlNode * Parent() const
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
bool operator>(const TiXmlAttribute &rhs) const
virtual const TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
int QueryFloatAttribute(const char *name, float *_value) const
QueryFloatAttribute examines the attribute - see QueryIntAttribute().
void Add(TiXmlAttribute *attribute)
TiXmlAttribute * Find(const char *_name)
int ErrorCol() const
The column where the error occured. See ErrorRow()
TiXmlUnknown * ToUnknown() const
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
virtual bool Accept(TiXmlVisitor *visitor) const
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
TiXmlText(const char *initValue)
friend std::istream & operator>>(std::istream &in, TiXmlNode &base)
int QueryIntValue(int *_value) const
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
TiXmlNode * LastChild(const std::string &_value)
STL std::string form.
TiXmlAttributeSet attributeSet
void SetName(const char *_name)
Set the name of this attribute.
const TiXmlEncoding TIXML_DEFAULT_ENCODING
TiXmlAttribute()
Construct an empty attribute.
TiXmlElement * PreviousSiblingElement()
TiXmlText(const TiXmlText ©)
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TiXmlElement * FirstChildElement(const std::string &_value)
STL std::string form.
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested type.
TiXmlNode(NodeType _type)
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null if not of the requested type.
const int TIXML_MAJOR_VERSION
bool operator==(const TiXmlAttribute &rhs) const
virtual bool Visit(const TiXmlText &)
Visit a text node.
bool operator<(const TiXmlAttribute &rhs) const
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
void Clear()
Delete all the children of this node. Does not affect 'this'.
virtual bool Accept(TiXmlVisitor *content) const
TiXmlAttribute * Find(const std::string &_name)
virtual void Print(FILE *cfile, int depth, TIXML_STRING *str) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TiXmlElement * NextSiblingElement(const char *_next)
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TinyXML class. See http://www.grinninglizard.com/tinyxml.
const TiXmlElement * NextSiblingElement() const
static const int utf8ByteTable[256]
friend std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
TiXmlElement(const char *in_value)
Construct an element.
TinyXML class. See http://www.grinninglizard.com/tinyxml.
void operator=(const TiXmlAttributeSet &)
virtual bool Visit(const TiXmlUnknown &)
Visit an unknow node.
void operator=(const TiXmlElement &base)
TiXmlDeclaration()
Construct an empty declaration.
bool NoChildren() const
Returns true if this node has no children.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
virtual TiXmlNode * Clone() const
[internal use] Creates a new Element and returns it.
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
TiXmlElement * NextSiblingElement()
static Entity entity[NUM_ENTITY]
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
TiXmlHandle FirstChild(const std::string &_value) const
const TiXmlNode * IterateChildren(const std::string &_value, const TiXmlNode *previous) const
STL std::string form.
virtual TiXmlNode * Clone() const
virtual bool Accept(TiXmlVisitor *visitor) const =0
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
void * userData
Field containing a generic user pointer.
const char * Attribute(const char *name) const
void SetValue(const char *_value)
Set the value.
void SetError(int err, const char *errorLocation, TiXmlParsingData *prevData, TiXmlEncoding encoding)
virtual void Print(FILE *cfile, int depth) const
virtual bool Accept(TiXmlVisitor *content) const
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)=0
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
TinyXML class. See http://www.grinninglizard.com/tinyxml.
void operator=(const TiXmlDocument ©)
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null if not of the requested type.
static int ToLower(int v, TiXmlEncoding encoding)
void * GetUserData()
Get a pointer to arbitrary user data.
virtual TiXmlDocument * ToDocument()
Cast to a more defined type. Will return null not of the requested type.
const char * CStr()
Return the result.
TiXmlNode * NextSibling(const char *_next)
TiXmlElement * RootElement()
const TiXmlNode * NextSibling() const
Navigate to a sibling node.
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.
void CopyTo(TiXmlUnknown *target) const
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null if not of the requested type.
void SetAttribute(const char *name, const char *_value)
const char * Indent()
Query the indention string.
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
void SetValue(const char *_value)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
const char * Encoding() const
Encoding. Will return an empty string if none was found.
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
static bool StringEqual(const char *p, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
const char * GetText() const
TiXmlAttribute * FirstAttribute()
virtual void Print(FILE *cfile, int depth) const
virtual void Print(FILE *cfile, int depth) const =0
TiXmlNode * InsertBeforeChild(TiXmlNode *beforeThis, const TiXmlNode &addThis)
virtual TiXmlComment * ToComment()
Cast to a more defined type. Will return null if 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 SetDocument(TiXmlDocument *doc)
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
virtual bool Accept(TiXmlVisitor *content) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
int QueryDoubleValue(double *_value) const
QueryDoubleValue examines the value string. See QueryIntValue().
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TiXmlElement * FirstChildElement()
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlHandle ChildElement(const std::string &_value, int index) const
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
TiXmlNode * PreviousSibling(const char *_prev)
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
void SetLineBreak(const char *_lineBreak)
TiXmlHandle FirstChild() const
Return a handle to the first child node.
TiXmlNode * LastChild(const char *_value)
The last child of this node matching 'value'. Will be null if there are no children.
static const char * errorString[TIXML_ERROR_STRING_COUNT]
virtual bool VisitExit(const TiXmlDocument &doc)
Visit a document.
void SetValue(const std::string &_value)
STL std::string form.
virtual const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
TiXmlHandle Child(const char *value, int index) const
TiXmlUnknown(const TiXmlUnknown ©)
virtual bool VisitExit(const TiXmlDocument &)
Visit a document.
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null if not of the requested type.
TiXmlNode * PreviousSibling()
static bool condenseWhiteSpace
void Remove(TiXmlAttribute *attribute)
const char * Value() const
Return the value of this attribute.
const TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
virtual void StreamIn(std::istream *in, TIXML_STRING *tag)
TiXmlCursor errorLocation
const char * LineBreak()
Query the current line breaking string.
const TiXmlAttribute * Next() const
Get the next sibling attribute in the DOM. Returns null at end.
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
const TiXmlDocument * GetDocument() const
const TiXmlAttribute * AttributeNode(const char *name) const
virtual void Print(FILE *cfile, int depth) const
TinyXML class. See http://www.grinninglizard.com/tinyxml.
TiXmlNode * IterateChildren(const TiXmlNode *previous)
virtual const TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null if not of the requested type.
void operator=(const TiXmlUnknown ©)
const TiXmlAttribute * Last() const
const TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
TiXmlNode * FirstChild(const std::string &_value)
STL std::string form.
TiXmlUnknown * Unknown() const
void SetUserData(void *user)
Set a pointer to arbitrary user data.
const TiXmlNode * FirstChild(const std::string &_value) const
STL std::string form.
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
const TiXmlElement * PreviousSiblingElement() const
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
virtual bool VisitEnter(const TiXmlDocument &doc)
Visit a document.
virtual void Print(FILE *cfile, int depth) const
const TiXmlAttribute * Find(const char *_name) const
double DoubleValue() const
Return the value of this attribute, converted to a double.
virtual const char * Parse(const char *p, TiXmlParsingData *data, TiXmlEncoding encoding)
bool CDATA() const
Queries whether this represents text using a CDATA section.
void CopyTo(TiXmlDocument *target) const
const TiXmlElement * RootElement() const
TiXmlNode * ToNode() const
bool SaveFile(const std::string &filename) const
< STL std::string version.
TiXmlHandle ChildElement(const char *value, int index) const
TiXmlNode * NextSibling()
const int TIXML_MINOR_VERSION
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null not of the requested type.
const TiXmlElement * FirstChildElement() const
Convenience function to get through elements.
TiXmlText * ToText() const
void CopyTo(TiXmlNode *target) const
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
virtual bool Visit(const TiXmlDeclaration &declaration)
Visit a declaration.
TiXmlAttribute * Previous()
static bool StreamWhiteSpace(std::istream *in, TIXML_STRING *tag)
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.