26 #ifndef TINYXML_INCLUDED 27 #define TINYXML_INCLUDED 30 #pragma warning( push ) 31 #pragma warning( disable : 4530 ) 32 #pragma warning( disable : 4786 ) 42 #if defined( _DEBUG ) && !defined( DEBUG ) 50 #define TIXML_STRING std::string 55 #define TIXML_STRING TiXmlString 65 #if defined(_MSC_VER) && (_MSC_VER >= 1400) 67 #define TIXML_SNPRINTF _snprintf_s 68 #define TIXML_SSCANF sscanf_s 69 #elif defined(_MSC_VER) && (_MSC_VER >= 1200) 72 #define TIXML_SNPRINTF _snprintf 73 #define TIXML_SSCANF sscanf 74 #elif defined(__GNUC__) && (__GNUC__ >= 3) 77 #define TIXML_SNPRINTF snprintf 78 #define TIXML_SSCANF sscanf 80 #define TIXML_SNPRINTF snprintf 81 #define TIXML_SSCANF sscanf 244 virtual void Print(FILE *cfile,
int depth)
const = 0;
294 virtual const char *
Parse(
const char *p,
331 return (isspace((
unsigned char) c) || c ==
'\n' || c ==
'\r');
344 static bool StreamWhiteSpace( std::istream * in,
TIXML_STRING * tag );
345 static bool StreamTo( std::istream * in,
int character,
TIXML_STRING * tag );
357 static const char *
ReadText(
const char *in,
359 bool ignoreWhiteSpace,
374 *length = utf8ByteTable[*((
const unsigned char *) p)];
375 assert(*length >= 0 && *length < 5);
386 return GetEntity(p, _value, length, encoding);
395 for (
int i = 0; p[i] && i < *length; ++i)
399 return p + (*length);
434 {
return tolower(v); }
458 MAX_ENTITY_LENGTH = 6
502 friend std::ostream& operator<< (std::ostream& out,
const TiXmlNode& base);
505 friend std::string& operator<< (std::string& out,
const TiXmlNode& base );
538 {
return value.c_str(); }
545 const std::string& ValueStr()
const {
return value; }
564 void SetValue(
const std::string& _value ) {
value = _value; }
584 const char *
value)
const;
590 return const_cast< TiXmlNode *
> ((
const_cast< const TiXmlNode *
>(
this))->FirstChild(_value));
599 const char *value)
const;
602 return const_cast< TiXmlNode *
> ((
const_cast< const TiXmlNode *
>(
this))->LastChild(_value));
632 return const_cast< TiXmlNode *
>((
const_cast< const TiXmlNode *
>(
this))->IterateChildren(previous));
640 return const_cast< TiXmlNode *
>((
const_cast< const TiXmlNode *
>(
this))->IterateChildren(_value, previous));
695 return const_cast< TiXmlNode *
>((
const_cast< const TiXmlNode *
>(
this))->PreviousSibling(_prev));
717 return const_cast< TiXmlNode *
>((
const_cast< const TiXmlNode *
>(
this))->NextSibling(_next));
739 return const_cast< TiXmlElement *
>((
const_cast< const TiXmlNode *
>(
this))->NextSiblingElement(_next));
760 return const_cast< TiXmlElement *
>((
const_cast< const TiXmlNode *
>(
this))->FirstChildElement(_value));
853 virtual void StreamIn( std::istream* in,
TIXML_STRING* tag ) = 0;
896 TiXmlAttribute(
const std::string& _name,
const std::string& _value )
916 {
return name.c_str(); }
918 {
return value.c_str(); }
920 const std::string& ValueStr()
const {
return value; }
923 int IntValue()
const;
924 double DoubleValue()
const;
939 int QueryIntValue(
int *_value)
const;
942 int QueryDoubleValue(
double *_value)
const;
949 void SetIntValue(
int _value);
950 void SetDoubleValue(
double _value);
953 void SetName(
const std::string& _name ) { name = _name; }
956 void SetValue(
const std::string& _value ) { value = _value; }
976 {
return rhs.
name == name; }
979 {
return name < rhs.
name; }
982 {
return name > rhs.
name; }
990 virtual void Print(FILE *cfile,
int depth)
const 992 Print(cfile, depth, 0);
995 void Print(FILE *cfile,
int depth,
TIXML_STRING *str)
const;
1038 {
return (sentinel.next == &sentinel) ? 0 : sentinel.
next; }
1041 {
return (sentinel.next == &sentinel) ? 0 : sentinel.
next; }
1044 {
return (sentinel.prev == &sentinel) ? 0 : sentinel.
prev; }
1047 {
return (sentinel.prev == &sentinel) ? 0 : sentinel.
prev; }
1053 # ifdef TIXML_USE_STL 1079 #ifdef TIXML_USE_STL 1093 const char *Attribute(
const char *name)
const;
1101 const char *Attribute(
const char *name,
int *i)
const;
1109 const char *Attribute(
const char *name,
double *
d)
const;
1118 int QueryIntAttribute(
const char *name,
int *_value)
const;
1121 int QueryUnsignedAttribute(
const char *name,
unsigned *_value)
const;
1127 int QueryBoolAttribute(
const char *name,
bool *_value)
const;
1130 int QueryDoubleAttribute(
const char *name,
double *_value)
const;
1136 int result = QueryDoubleAttribute(name, &d);
1139 *_value = (float) d;
1144 #ifdef TIXML_USE_STL 1145 int QueryStringAttribute(
const char* name, std::string* _value )
const {
1147 const char* cstr = Attribute( name );
1149 *_value = std::string( cstr );
1163 template<
typename T >
int QueryValueAttribute(
const std::string& name, T* outValue )
const 1169 std::stringstream sstream( node->ValueStr() );
1170 sstream >> *outValue;
1171 if ( !sstream.fail() )
1176 int QueryValueAttribute(
const std::string& name, std::string* outValue )
const 1181 *outValue = node->ValueStr();
1189 void SetAttribute(
const char *name,
const char *_value);
1191 #ifdef TIXML_USE_STL 1192 const std::string* Attribute(
const std::string& name )
const;
1193 const std::string* Attribute(
const std::string& name,
int* i )
const;
1194 const std::string* Attribute(
const std::string& name,
double* d )
const;
1195 int QueryIntAttribute(
const std::string& name,
int* _value )
const;
1196 int QueryDoubleAttribute(
const std::string& name,
double* _value )
const;
1199 void SetAttribute(
const std::string& name,
const std::string& _value );
1201 void SetAttribute(
const std::string& name,
int _value );
1203 void SetDoubleAttribute(
const std::string& name,
double value );
1209 void SetAttribute(
const char *name,
int value);
1214 void SetDoubleAttribute(
const char *name,
double value);
1218 void RemoveAttribute(
const char *name);
1220 #ifdef TIXML_USE_STL 1221 void RemoveAttribute(
const std::string& name ) { RemoveAttribute (name.c_str ()); }
1225 {
return attributeSet.First(); }
1227 {
return attributeSet.First(); }
1230 {
return attributeSet.Last(); }
1232 {
return attributeSet.Last(); }
1266 const char *GetText()
const;
1272 virtual void Print(FILE *cfile,
int depth)
const;
1295 #ifdef TIXML_USE_STL 1296 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1336 virtual void Print(FILE *cfile,
int depth)
const;
1356 #ifdef TIXML_USE_STL 1357 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1389 #ifdef TIXML_USE_STL 1408 virtual void Print(FILE *cfile,
int depth)
const;
1437 #ifdef TIXML_USE_STL 1438 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1466 #ifdef TIXML_USE_STL 1469 const std::string& _encoding,
1470 const std::string& _standalone );
1475 const char *_encoding,
1476 const char *_standalone);
1487 {
return version.c_str(); }
1491 {
return encoding.c_str(); }
1495 {
return standalone.c_str(); }
1501 virtual void Print(FILE *cfile,
int depth,
TIXML_STRING *str)
const;
1503 virtual void Print(FILE *cfile,
int depth)
const 1505 Print(cfile, depth, 0);
1522 #ifdef TIXML_USE_STL 1523 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1563 virtual void Print(FILE *cfile,
int depth)
const;
1579 #ifdef TIXML_USE_STL 1580 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1601 #ifdef TIXML_USE_STL 1620 bool SaveFile()
const;
1626 bool SaveFile(
const char *filename)
const;
1636 bool SaveFile(FILE *)
const;
1638 #ifdef TIXML_USE_STL 1641 return LoadFile( filename.c_str(), encoding );
1643 bool SaveFile(
const std::string& filename )
const 1645 return SaveFile( filename.c_str() );
1660 {
return FirstChildElement(); }
1663 {
return FirstChildElement(); }
1675 {
return errorDesc.c_str(); }
1691 {
return errorLocation.row + 1; }
1694 {
return errorLocation.col + 1; }
1721 { tabsize = _tabsize; }
1734 errorLocation.row = errorLocation.col = 0;
1740 { Print(stdout, 0); }
1749 virtual void Print(FILE *cfile,
int depth = 0)
const;
1767 #ifdef TIXML_USE_STL 1768 virtual void StreamIn( std::istream * in,
TIXML_STRING * tag );
1868 { this->node = _node; }
1872 { this->node = ref.
node; }
1877 { this->node = ref.
node; }
1891 TiXmlHandle FirstChildElement(
const char *value)
const;
1896 TiXmlHandle Child(
const char *value,
int index)
const;
1907 TiXmlHandle ChildElement(
const char *value,
int index)
const;
1915 #ifdef TIXML_USE_STL 1916 TiXmlHandle FirstChild(
const std::string& _value )
const {
return FirstChild( _value.c_str() ); }
1917 TiXmlHandle FirstChildElement(
const std::string& _value )
const {
return FirstChildElement( _value.c_str() ); }
1919 TiXmlHandle Child(
const std::string& _value,
int index )
const {
return Child( _value.c_str(), index ); }
1920 TiXmlHandle ChildElement(
const std::string& _value,
int index )
const {
return ChildElement( _value.c_str(), index ); }
1931 {
return ((node && node->ToElement()) ? node->ToElement() : 0); }
1936 {
return ((node && node->ToText()) ? node->ToText() : 0); }
1941 {
return ((node && node->ToUnknown()) ? node->ToUnknown() : 0); }
1947 {
return ToNode(); }
1953 {
return ToElement(); }
1959 {
return ToText(); }
1965 {
return ToUnknown(); }
1995 buffer(), indent(
" "), lineBreak(
"\n")
2008 virtual bool Visit(
const TiXmlText &text);
2018 { indent = _indent ? _indent :
""; }
2022 {
return indent.c_str(); }
2029 { lineBreak = _lineBreak ? _lineBreak :
""; }
2033 {
return lineBreak.c_str(); }
2046 {
return buffer.c_str(); }
2050 {
return buffer.size(); }
2052 #ifdef TIXML_USE_STL 2053 const std::string& Str() {
return buffer; }
2060 for (
int i = 0; i < depth; ++i)
2066 buffer += lineBreak;
2078 #pragma warning( pop )
static const int utf8ByteTable[256]
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.
TiXmlUnknown * Unknown() const
virtual bool Accept(TiXmlVisitor *visitor) const
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.
TiXmlUnknown(const TiXmlUnknown ©)
const TiXmlNode * Parent() const
const TiXmlElement * RootElement() const
void SetLineBreak(const char *_lineBreak)
const TIXML_STRING & ValueTStr() const
TiXmlElement * NextSiblingElement()
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
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.
virtual bool Visit(const TiXmlUnknown &)
Visit an unknown node.
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
void CopyTo(TiXmlUnknown *target) const
const void * GetUserData() const
Get a pointer to arbitrary user data.
static int ToLower(int v, TiXmlEncoding encoding)
TiXmlNode * IterateChildren(const char *_value, const TiXmlNode *previous)
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
TiXmlElement & operator=(const TiXmlElement &base)
virtual void Print(FILE *cfile, int depth) const
const TIXML_STRING & NameTStr() const
TiXmlAttribute * FirstAttribute()
void operator=(const TiXmlAttributeSet &)
TiXmlElement * FirstChildElement(const char *_value)
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
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()
void SetTabSize(int _tabsize)
TiXmlAttribute()
Construct an empty attribute.
const int TIXML_PATCH_VERSION
const char * Standalone() const
Is this a standalone document?
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.
virtual void Print(FILE *cfile, int depth) const
static const char * errorString[TIXML_ERROR_STRING_COUNT]
void SetValue(const char *_value)
int ErrorCol() const
The column where the error occured. See ErrorRow()
TiXmlNode * InsertEndChild(const TiXmlNode &addThis)
static void ConvertUTF32ToUTF8(unsigned long input, char *output, int *length)
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
TiXmlNode * PreviousSibling()
virtual const TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null if not of the requested type.
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
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 * userData
Field containing a generic user pointer.
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)
int Column() const
See Row()
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
TiXmlText(const TiXmlText ©)
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
const int TIXML_MAJOR_VERSION
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.
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.
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.
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 TiXmlDeclaration * ToDeclaration() 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().
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
static const char * SkipWhiteSpace(const char *, TiXmlEncoding encoding)
TiXmlNode * Identify(const char *start, TiXmlEncoding encoding)
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.
std::istream & operator>>(std::istream &str, CSVRow &data)
const TiXmlDocument * GetDocument() const
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
static const char * GetEntity(const char *in, char *value, int *length, TiXmlEncoding encoding)
TiXmlNode * ToNode() const
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
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)
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
TiXmlHandle operator=(const TiXmlHandle &ref)
TiXmlNode * IterateChildren(const TiXmlNode *previous)
TiXmlAttribute * Previous()
TiXmlElement * Element() const
TiXmlNode(NodeType _type)
TiXmlElement * RootElement()
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
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.
size_t Size()
Return the length of the result string.
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)
TiXmlText(const char *initValue)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
const char * Value() const
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
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
const TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
void SetDocument(TiXmlDocument *doc)
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 SetValue(const char *_value)
Set the value.
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)
TiXmlUnknown * ToUnknown() const
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
virtual bool VisitEnter(const TiXmlElement &, const TiXmlAttribute *)
Visit an element.
virtual bool Visit(const TiXmlDeclaration &)
Visit a declaration.