26#ifndef TINYXML_INCLUDED
27#define TINYXML_INCLUDED
30#pragma warning( disable : 4530 )
31#pragma warning( disable : 4786 )
40#include "cal3d/platform.h"
43#if defined( _DEBUG ) && !defined( DEBUG )
47#if defined( DEBUG ) && defined( _MSC_VER )
49#define TIXML_LOG OutputDebugString
51#define TIXML_LOG printf
59 #define TIXML_STRING std::string
60 #define TIXML_ISTREAM std::istream
61 #define TIXML_OSTREAM std::ostream
64 #define TIXML_STRING TiXmlString
65 #define TIXML_OSTREAM TiXmlOutStream
76 class TiXmlAttributeSet;
78 class TiXmlDeclaration;
80 class TiXmlParsingData;
88 void Clear() { row = col = -1; }
171 int Row()
const {
return location.row + 1; }
172 int Column()
const {
return location.col + 1; }
185 static const char* SkipWhiteSpace(
const char* );
186 inline static bool IsWhiteSpace(
int c ) {
return (
isspace( c ) || c ==
'\n' || c ==
'\r' ); }
188 virtual void StreamOut (TIXML_OSTREAM *)
const = 0;
191 static bool StreamWhiteSpace( TIXML_ISTREAM *
in, TIXML_STRING * tag );
192 static bool StreamTo( TIXML_ISTREAM *
in,
int character, TIXML_STRING * tag );
199 static const char* ReadName(
const char*
p, TIXML_STRING* name );
204 static const char* ReadText(
const char*
in,
213 static const char* GetEntity(
const char*
in,
char* value );
216 inline static const char* GetChar(
const char*
p,
char*
_value )
232 static void PutString(
const TIXML_STRING& str, TIXML_OSTREAM* out );
234 static void PutString(
const TIXML_STRING& str, TIXML_STRING* out );
237 static bool StringEqual(
const char* p,
246 TIXML_ERROR_OPENING_FILE,
247 TIXML_ERROR_OUT_OF_MEMORY,
248 TIXML_ERROR_PARSING_ELEMENT,
249 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
250 TIXML_ERROR_READING_ELEMENT_VALUE,
251 TIXML_ERROR_READING_ATTRIBUTES,
252 TIXML_ERROR_PARSING_EMPTY,
253 TIXML_ERROR_READING_END_TAG,
254 TIXML_ERROR_PARSING_UNKNOWN,
255 TIXML_ERROR_PARSING_COMMENT,
256 TIXML_ERROR_PARSING_DECLARATION,
257 TIXML_ERROR_DOCUMENT_EMPTY,
259 TIXML_ERROR_STRING_COUNT
261 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
263 TiXmlCursor location;
269 unsigned int strLength;
275 MAX_ENTITY_LENGTH = 6
278 static Entity entity[ NUM_ENTITY ];
279 static bool condenseWhiteSpace;
356 const char *
Value()
const {
return value.c_str (); }
374 SetValue(
buf.buffer ?
buf.buffer :
"" );
385 TiXmlNode* FirstChild(
const char * value )
const;
387 TiXmlNode* LastChild()
const {
return lastChild; }
388 TiXmlNode* LastChild(
const char * value )
const;
459 TiXmlNode* PreviousSibling(
const char * )
const;
470 TiXmlNode* NextSibling(
const char * )
const;
492 TiXmlElement* FirstChildElement(
const char * value )
const;
502 virtual int Type()
const {
return type; }
521 void SetUserData(
void*
user ) { userData =
user; }
522 void* GetUserData() {
return userData; }
525 TiXmlNode( NodeType type );
529 virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
533 TiXmlNode* Identify(
const char* start );
534 void CopyToClone( TiXmlNode* target )
const { target->SetValue (value.c_str() );
535 target->userData = userData; }
538 TIXML_STRING SValue()
const {
return value ; }
543 TiXmlNode* firstChild;
544 TiXmlNode* lastChild;
593 const char*
Name()
const {
return name.c_str (); }
594 const char*
Value()
const {
return value.c_str (); }
595 const int IntValue()
const;
596 const double DoubleValue()
const;
607 int QueryIntValue(
int* value )
const;
609 int QueryDoubleValue(
double* value )
const;
611 void SetName(
const char* _name ) { name = _name; }
614 void SetIntValue(
int value );
615 void SetDoubleValue(
double value );
622 SetName (
buf.buffer ?
buf.buffer :
"error" );
628 SetValue(
buf.buffer ?
buf.buffer :
"error" );
638 bool operator<(
const TiXmlAttribute& rhs )
const {
return name < rhs.name; }
639 bool operator>(
const TiXmlAttribute& rhs )
const {
return name > rhs.name; }
645 virtual const char* Parse(
const char* p, TiXmlParsingData* data );
648 virtual void Print( FILE* cfile,
int depth )
const;
650 virtual void StreamOut( TIXML_OSTREAM * out )
const;
653 void SetDocument( TiXmlDocument* doc ) { document = doc; }
656 TiXmlDocument* document;
659 TiXmlAttribute* prev;
660 TiXmlAttribute* next;
685 TiXmlAttribute* First()
const {
return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
686 TiXmlAttribute* Last()
const {
return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
708 firstChild = lastChild = 0;
718 const char* Attribute(
const char* name )
const;
726 const char* Attribute(
const char* name,
int*
i )
const;
734 const char* Attribute(
const char* name,
double* d )
const;
743 int QueryIntAttribute(
const char* name,
int* value )
const;
745 int QueryDoubleAttribute(
const char* name,
double* value )
const;
750 void SetAttribute(
const char* name,
const char * value );
753 const char* Attribute(
const std::string& name )
const {
return Attribute( name.c_str() ); }
754 const char* Attribute(
const std::string& name,
int* i )
const {
return Attribute( name.c_str(), i ); }
761 if (
n.buffer && v.buffer )
762 SetAttribute (
n.buffer, v.buffer );
765 void SetAttribute(
const std::string& name,
int _value )
767 StringToBuffer
n( name );
769 SetAttribute (
n.buffer,
_value);
776 void SetAttribute(
const char * name,
int value );
780 void RemoveAttribute(
const char * name );
798 virtual void StreamIn( TIXML_ISTREAM *
in, TIXML_STRING * tag );
800 virtual void StreamOut( TIXML_OSTREAM *
out )
const;
829 virtual TiXmlNode* Clone()
const;
831 virtual void Print( FILE* cfile,
int depth )
const;
835 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
837 virtual void StreamOut( TIXML_OSTREAM * out )
const;
842 virtual const char* Parse(
const char* p, TiXmlParsingData* data );
873 virtual void StreamOut ( TIXML_OSTREAM *
out )
const;
883 virtual void StreamIn( TIXML_ISTREAM *
in, TIXML_STRING * tag );
928 const char *
Version()
const {
return version.c_str (); }
930 const char *
Encoding()
const {
return encoding.c_str (); }
932 const char *
Standalone()
const {
return standalone.c_str (); }
942 virtual void StreamIn( TIXML_ISTREAM *
in, TIXML_STRING * tag );
944 virtual void StreamOut ( TIXML_OSTREAM *
out)
const;
952 TIXML_STRING version;
953 TIXML_STRING encoding;
954 TIXML_STRING standalone;
975 virtual void StreamIn( TIXML_ISTREAM *
in, TIXML_STRING * tag );
977 virtual void StreamOut ( TIXML_OSTREAM *
out )
const;
1017 bool SaveFile()
const;
1019 bool LoadFile(
const char * filename );
1021 bool SaveFile(
const char * filename )
const;
1023 #ifdef TIXML_USE_STL
1027 return (
f.buffer && LoadFile(
f.buffer ));
1032 return (
f.buffer && SaveFile(
f.buffer ));
1054 const char *
ErrorDesc()
const {
return errorDesc.c_str (); }
1093 int TabSize()
const {
return tabsize; }
1101 errorLocation.row = errorLocation.col = 0;
1114 virtual void StreamOut ( TIXML_OSTREAM *
out)
const;
1117 #ifdef TIXML_USE_STL
1118 virtual void StreamIn( TIXML_ISTREAM *
in, TIXML_STRING * tag );
1124 TIXML_STRING errorDesc;
1221 TiXmlHandle FirstChild(
const char * value )
const;
1225 TiXmlHandle FirstChildElement(
const char * value )
const;
1230 TiXmlHandle Child(
const char* value,
int index )
const;
1239 TiXmlHandle ChildElement(
const char* value,
int index )
const;
1246 #ifdef TIXML_USE_STL
1248 TiXmlHandle FirstChildElement(
const std::string& _value )
const {
return FirstChildElement( _value.c_str() ); }
1250 TiXmlHandle Child(
const std::string& _value,
int index )
const {
return Child( _value.c_str(), index ); }
1251 TiXmlHandle ChildElement(
const std::string& _value,
int index )
const {
return ChildElement( _value.c_str(), index ); }
1259 TiXmlText*
Text()
const {
return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
A container-safe smart pointer used for refcounted classes.
Definition refptr.h:11
An attribute is a name-value pair.
Definition tinyxml.h:562
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition tinyxml.h:585
void SetValue(const std::string &_value)
STL std::string form.
Definition tinyxml.h:625
TiXmlAttribute(const std::string &_name, const std::string &_value)
std::string constructor.
Definition tinyxml.h:575
const char * Name() const
Return the name of this attribute.
Definition tinyxml.h:593
void SetName(const char *_name)
Set the name of this attribute.
Definition tinyxml.h:611
const char * Value() const
Return the value of this attribute.
Definition tinyxml.h:594
void SetValue(const char *_value)
Set the value.
Definition tinyxml.h:612
TiXmlAttribute()
Construct an empty attribute.
Definition tinyxml.h:567
void SetName(const std::string &_name)
STL std::string form.
Definition tinyxml.h:619
TiXmlBase is a base class for every class in TinyXml.
Definition tinyxml.h:126
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
Definition tinyxml.h:148
int Column() const
See Row()
Definition tinyxml.h:172
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition tinyxml.h:171
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition tinyxml.h:151
virtual void Print(FILE *cfile, int depth) const =0
All TinyXml classes can print themselves to a filestream.
In correct XML the declaration is the first entry in the file.
Definition tinyxml.h:902
const char * Standalone() const
Is this a standalone document?
Definition tinyxml.h:932
TiXmlDeclaration()
Construct an empty declaration.
Definition tinyxml.h:905
const char * Encoding() const
Encoding. Will return empty if none was found.
Definition tinyxml.h:930
const char * Version() const
Version. Will return empty if none was found.
Definition tinyxml.h:928
TiXmlDeclaration(const std::string &_version, const std::string &_encoding, const std::string &_standalone)
Constructor.
Definition tinyxml.h:909
Always the top level node.
Definition tinyxml.h:991
bool SaveFile(const std::string &filename) const
< STL std::string version.
Definition tinyxml.h:1029
bool LoadFile(const std::string &filename)
Definition tinyxml.h:1024
int ErrorCol()
The column where the error occurred. See ErrorRow()
Definition tinyxml.h:1069
bool Error() const
If an error occurs, Error will be set to true.
Definition tinyxml.h:1051
int ErrorRow()
Returns the location (if known) of the error.
Definition tinyxml.h:1068
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition tinyxml.h:1054
TiXmlDocument(const std::string &documentName)
Constructor.
Definition tinyxml.h:1000
void SetTabSize(int _tabsize)
By calling this method, with a tab size greater than 0, the row and column of each node and attribute...
Definition tinyxml.h:1091
void Print() const
Dump the document to standard out.
Definition tinyxml.h:1106
const int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
Definition tinyxml.h:1059
void ClearError()
If you have handled the error, it can be reset with this call.
Definition tinyxml.h:1098
TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
Definition tinyxml.h:1044
The element is a container class.
Definition tinyxml.h:699
TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition tinyxml.h:785
void SetAttribute(const std::string &name, const std::string &_value)
STL std::string form.
Definition tinyxml.h:757
TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition tinyxml.h:786
TiXmlElement(const std::string &_value)
std::string constructor.
Definition tinyxml.h:706
void RemoveAttribute(const std::string &name)
STL std::string form.
Definition tinyxml.h:782
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition tinyxml.h:1211
TiXmlHandle(TiXmlNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition tinyxml.h:1214
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition tinyxml.h:1216
TiXmlNode * Node() const
Return the handle as a TiXmlNode. This may return null.
Definition tinyxml.h:1255
TiXmlElement * Element() const
Return the handle as a TiXmlElement. This may return null.
Definition tinyxml.h:1257
TiXmlText * Text() const
Return the handle as a TiXmlText. This may return null.
Definition tinyxml.h:1259
The parent class for everything in the Document Object Model.
Definition tinyxml.h:290
TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:516
TiXmlNode * IterateChildren(const std::string &_value, TiXmlNode *previous) const
STL std::string form.
Definition tinyxml.h:417
TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:512
TiXmlNode * FirstChild(const std::string &_value) const
The last child of this node matching 'value'. Will be null if there are no children.
Definition tinyxml.h:391
TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
Definition tinyxml.h:462
TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:514
virtual int Type() const
Query the type (as an enumerated value, above) of this node.
Definition tinyxml.h:502
TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition tinyxml.h:463
TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition tinyxml.h:384
TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
Definition tinyxml.h:485
bool NoChildren() const
Returns true if this node has no children.
Definition tinyxml.h:510
TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
Definition tinyxml.h:495
void SetValue(const std::string &_value)
STL std::string form.
Definition tinyxml.h:371
TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:517
TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:513
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Definition tinyxml.h:356
TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition tinyxml.h:456
TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
Definition tinyxml.h:392
TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition tinyxml.h:467
void SetValue(const char *_value)
Changes the value of the node.
Definition tinyxml.h:367
NodeType
The types of XML nodes supported by TinyXml.
Definition tinyxml.h:332
TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition tinyxml.h:515
TiXmlNode * Parent() const
One step up the DOM.
Definition tinyxml.h:382
Definition tinyxmlparser.cpp:47
XML text.
Definition tinyxml.h:849
TiXmlText(const std::string &initValue)
Constructor.
Definition tinyxml.h:861
TiXmlText(const char *initValue)
Constructor.
Definition tinyxml.h:853
Any tag that tinyXml doesn't recognize is saved as an unknown.
Definition tinyxml.h:964