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
53 #define TIXML_STRING TiXmlString
63 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
65 #define TIXML_SNPRINTF _snprintf_s
66 #define TIXML_SSCANF sscanf_s
67 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
70 #define TIXML_SNPRINTF _snprintf
71 #define TIXML_SSCANF sscanf
72 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
75 #define TIXML_SNPRINTF snprintf
76 #define TIXML_SSCANF sscanf
78 #define TIXML_SNPRINTF snprintf
79 #define TIXML_SSCANF sscanf
90 class TiXmlParsingData;
213 virtual void Print( FILE* cfile,
int depth )
const = 0;
255 virtual const char*
Parse(
const char*
p,
256 TiXmlParsingData*
data,
292 return ( isspace( (
unsigned char) c ) || c ==
'\n' || c ==
'\r' );
302 static bool StreamWhiteSpace( std::istream *
in,
TIXML_STRING * tag );
303 static bool StreamTo( std::istream *
in,
int character,
TIXML_STRING * tag );
317 bool ignoreWhiteSpace,
333 assert( *length >= 0 && *length < 5 );
343 return GetEntity( p, _value, length, encoding );
354 return p + (*length);
386 if ( v < 128 )
return tolower( v );
403 unsigned int strLength;
409 MAX_ENTITY_LENGTH = 6
412 static Entity entity[ NUM_ENTITY ];
413 static bool condenseWhiteSpace;
529 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->FirstChild( _value ));
536 return const_cast< TiXmlNode*
> ((
const_cast< const TiXmlNode*
>(
this))->LastChild( _value ));
564 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( previous ) );
570 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->IterateChildren( _value, previous ) );
620 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->PreviousSibling( _prev ) );
637 return const_cast< TiXmlNode*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSibling( _next ) );
655 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->NextSiblingElement( _next ) );
672 return const_cast< TiXmlElement*
>( (
const_cast< const TiXmlNode*
>(
this))->FirstChildElement( _value ) );
816 int IntValue()
const;
817 double DoubleValue()
const;
831 int QueryIntValue(
int* _value )
const;
833 int QueryDoubleValue(
double* _value )
const;
838 void SetIntValue(
int _value );
839 void SetDoubleValue(
double _value );
871 Print( cfile, depth, 0 );
920 # ifdef TIXML_USE_STL
960 const char* Attribute(
const char*
name )
const;
968 const char* Attribute(
const char* name,
int*
i )
const;
976 const char* Attribute(
const char* name,
double*
d )
const;
985 int QueryIntAttribute(
const char* name,
int* _value )
const;
987 int QueryDoubleAttribute(
const char* name,
double* _value )
const;
991 int result = QueryDoubleAttribute( name, &d );
999 int QueryStringAttribute(
const char* name,
std::string* _value )
const {
1001 const char* cstr = Attribute( name );
1017 template<
typename T >
int QueryValueAttribute(
const std::string& name, T* outValue )
const
1023 std::stringstream sstream( node->ValueStr() );
1024 sstream >> *outValue;
1025 if ( !sstream.fail() )
1035 *outValue = node->ValueStr();
1043 void SetAttribute(
const char* name,
const char * _value );
1045 #ifdef TIXML_USE_STL
1049 int QueryIntAttribute(
const std::string& name,
int* _value )
const;
1050 int QueryDoubleAttribute(
const std::string& name,
double* _value )
const;
1055 void SetAttribute(
const std::string& name,
int _value );
1063 void SetAttribute(
const char * name,
int value );
1068 void SetDoubleAttribute(
const char * name,
double value );
1072 void RemoveAttribute(
const char * name );
1073 #ifdef TIXML_USE_STL
1074 void RemoveAttribute(
const std::string& name ) { RemoveAttribute (name.c_str ()); }
1114 const char* GetText()
const;
1119 virtual void Print( FILE* cfile,
int depth )
const;
1139 #ifdef TIXML_USE_STL
1146 const char* ReadValue(
const char*
in, TiXmlParsingData* prevData,
TiXmlEncoding encoding );
1172 virtual void Print( FILE* cfile,
int depth )
const;
1190 #ifdef TIXML_USE_STL
1220 #ifdef TIXML_USE_STL
1233 virtual void Print( FILE* cfile,
int depth )
const;
1256 #ifdef TIXML_USE_STL
1284 #ifdef TIXML_USE_STL
1293 const char* _encoding,
1294 const char* _standalone );
1304 const char *
Encoding()
const {
return encoding.c_str (); }
1313 Print( cfile, depth, 0 );
1328 #ifdef TIXML_USE_STL
1359 virtual void Print( FILE* cfile,
int depth )
const;
1373 #ifdef TIXML_USE_STL
1394 #ifdef TIXML_USE_STL
1410 bool SaveFile()
const;
1414 bool SaveFile(
const char *
filename )
const;
1422 bool SaveFile( FILE* )
const;
1424 #ifdef TIXML_USE_STL
1427 return LoadFile( filename.c_str(), encoding );
1429 bool SaveFile(
const std::string& filename )
const
1431 return SaveFile( filename.c_str() );
1456 const char *
ErrorDesc()
const {
return errorDesc.c_str (); }
1507 errorLocation.row = errorLocation.col = 0;
1521 virtual void Print( FILE* cfile,
int depth = 0 )
const;
1523 void SetError(
int err,
const char* errorLocation, TiXmlParsingData* prevData,
TiXmlEncoding encoding );
1535 #ifdef TIXML_USE_STL
1547 bool useMicrosoftBOM;
1668 #ifdef TIXML_USE_STL
1670 TiXmlHandle FirstChildElement(
const std::string& _value )
const {
return FirstChildElement( _value.c_str() ); }
1734 buffer(), indent(
" " ), lineBreak(
"\n" ) {}
1750 void SetIndent(
const char* _indent ) { indent = _indent ? _indent :
"" ; }
1752 const char*
Indent() {
return indent.c_str(); }
1757 void SetLineBreak(
const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak :
""; }
1772 #ifdef TIXML_USE_STL
1779 for(
int i=0; i<
depth; ++
i )
1782 void DoLineBreak() {
1787 bool simpleTextPrint;
1795 #pragma warning( pop )
TiXmlAttribute * LastAttribute()
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null not of the requested type.
EGLSurface EGLint attribute
TiXmlNode * Parent()
One step up the DOM.
void SetTabSize(int _tabsize)
void operator=(const TiXmlText &base)
TiXmlNode * LinkEndChild(TiXmlNode *addThis)
static const char * ReadName(const char *p, TIXML_STRING *name, TiXmlEncoding encoding)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
TiXmlHandle operator=(const TiXmlHandle &ref)
const TIXML_STRING & NameTStr() const
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.
void CopyTo(TiXmlElement *target) const
virtual ~TiXmlDeclaration()
const TiXmlNode * LastChild() const
int Column() const
See Row()
virtual TiXmlNode * Clone() const =0
const TiXmlAttribute * First() const
const char * Standalone() const
Is this a standalone document?
static void SetCondenseWhiteSpace(bool condense)
static bool IsWhiteSpace(char c)
size_t Size()
Return the length of the result string.
bool RemoveChild(TiXmlNode *removeThis)
Delete a child of this node.
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.
TiXmlElement * FirstChildElement(const char *_value)
virtual const TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
EGLImageKHR EGLint * name
std::istream & operator>>(std::istream &is, Zeni::String &str)
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 SetIndent(const char *_indent)
virtual TiXmlText * ToText()
Cast to a more defined type. Will return null not of the requested type.
return Display return Display Bool Bool int d
virtual TiXmlUnknown * ToUnknown()
Cast to a more defined type. Will return null if not of the requested type.
static int IsAlphaNum(unsigned char anyByte, TiXmlEncoding encoding)
const char * Value() const
const void * GetUserData() const
Get a pointer to arbitrary user data.
TiXmlElement * Element() const
TiXmlDocument * GetDocument()
TiXmlElement * ToElement() const
static bool IsWhiteSpace(int c)
const char * Name() const
Return the name of this attribute.
virtual void Print(FILE *cfile, int depth) const
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
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().
EGLContext EGLenum target
int ErrorCol() const
The column where the error occured. See ErrorRow()
TiXmlUnknown * ToUnknown() const
const TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
EGLContext EGLenum EGLClientBuffer buffer
TiXmlNode * ReplaceChild(TiXmlNode *replaceThis, const TiXmlNode &withThis)
TiXmlText(const char *initValue)
virtual bool VisitExit(const TiXmlElement &)
Visit an element.
virtual bool Visit(const TiXmlComment &)
Visit a comment node.
void SetName(const char *_name)
Set the name of this attribute.
const TiXmlEncoding TIXML_DEFAULT_ENCODING
TiXmlAttribute()
Construct an empty attribute.
GLenum GLenum GLvoid * row
TiXmlText(const TiXmlText ©)
virtual const char * Parse(const char *p, TiXmlParsingData *data=0, TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
virtual TiXmlDeclaration * ToDeclaration()
Cast to a more defined type. Will return null not of the requested 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.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void Clear()
Delete all the children of this node. Does not affect 'this'.
TiXmlElement * NextSiblingElement(const char *_next)
virtual bool VisitEnter(const TiXmlDocument &)
Visit a document.
const TiXmlElement * NextSiblingElement() const
static const int utf8ByteTable[256]
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.
static const char * ReadText(const char *in, TIXML_STRING *text, bool ignoreWhiteSpace, const char *endTag, bool ignoreCase, TiXmlEncoding encoding)
TiXmlElement * NextSiblingElement()
static void EncodeString(const TIXML_STRING &str, TIXML_STRING *out)
virtual const TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
GLint GLenum GLsizei GLsizei GLsizei depth
virtual bool Accept(TiXmlVisitor *visitor) const =0
void * userData
Field containing a generic user pointer.
void SetValue(const char *_value)
Set the value.
friend class TiXmlDocument
virtual void Print(FILE *cfile, int depth) const
TiXmlNode * InsertAfterChild(TiXmlNode *afterThis, const TiXmlNode &addThis)
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.
friend class TiXmlElement
const TIXML_STRING & ValueTStr() const
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)
std::ostream & operator<<(std::ostream &out, const Token &token)
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.
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.
GLenum GLenum GLenum input
EGLSurface EGLint void ** value
void SetValue(const char *_value)
const TiXmlNode * IterateChildren(const TiXmlNode *previous) const
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)
TiXmlAttribute * FirstAttribute()
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.
GLsizei const GLcharARB ** string
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.
TiXmlElement * FirstChildElement()
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)
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 const TiXmlComment * ToComment() const
Cast to a more defined type. Will return null if not of the requested type.
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()
const char * Value() const
Return the value of this attribute.
const char * LineBreak()
Query the current line breaking string.
TiXmlNode * LastChild()
The last child of this node. Will be null if there are no children.
const TiXmlDocument * GetDocument() const
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)
TiXmlUnknown * Unknown() const
void SetUserData(void *user)
Set a pointer to arbitrary user data.
virtual TiXmlElement * ToElement()
Cast to a more defined type. Will return null if not of the requested type.
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
bool CDATA() const
Queries whether this represents text using a CDATA section.
const TiXmlElement * RootElement() const
TiXmlNode * ToNode() 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)
TiXmlAttribute * Previous()
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.