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 77 class TiXmlDeclaration;
79 class TiXmlParsingData;
87 void Clear() { row = col = -1; }
139 virtual void Print( FILE* cfile,
int depth )
const = 0;
170 int Row()
const {
return location.row + 1; }
171 int Column()
const {
return location.col + 1; }
184 static const char* SkipWhiteSpace(
const char* );
185 inline static bool IsWhiteSpace(
int c ) {
return ( isspace( c ) || c ==
'\n' || c ==
'\r' ); }
187 virtual void StreamOut (TIXML_OSTREAM *)
const = 0;
190 static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
191 static bool StreamTo( TIXML_ISTREAM * in,
int character, TIXML_STRING * tag );
198 static const char* ReadName(
const char* p, TIXML_STRING* name );
203 static const char* ReadText(
const char* in,
205 bool ignoreWhiteSpace,
212 static const char* GetEntity(
const char* in,
char* value );
215 inline static const char* GetChar(
const char* p,
char* _value )
220 return GetEntity( p, _value );
231 static void PutString(
const TIXML_STRING& str, TIXML_OSTREAM* out );
233 static void PutString(
const TIXML_STRING& str, TIXML_STRING* out );
236 static bool StringEqual(
const char* p,
245 TIXML_ERROR_OPENING_FILE,
246 TIXML_ERROR_OUT_OF_MEMORY,
247 TIXML_ERROR_PARSING_ELEMENT,
248 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
249 TIXML_ERROR_READING_ELEMENT_VALUE,
250 TIXML_ERROR_READING_ATTRIBUTES,
251 TIXML_ERROR_PARSING_EMPTY,
252 TIXML_ERROR_READING_END_TAG,
253 TIXML_ERROR_PARSING_UNKNOWN,
254 TIXML_ERROR_PARSING_COMMENT,
255 TIXML_ERROR_PARSING_DECLARATION,
256 TIXML_ERROR_DOCUMENT_EMPTY,
258 TIXML_ERROR_STRING_COUNT
260 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
268 unsigned int strLength;
274 MAX_ENTITY_LENGTH = 6
277 static Entity entity[ NUM_ENTITY ];
278 static bool condenseWhiteSpace;
299 friend std::istream& operator >> (std::istream& in,
TiXmlNode& base);
317 friend std::ostream& operator<< (std::ostream& out,
const TiXmlNode& base);
320 friend std::string& operator<< (std::string& out,
const TiXmlNode& base );
324 friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out,
const TiXmlNode& base);
355 const char *
Value()
const {
return value.c_str (); }
366 void SetValue(
const char * _value) { value = _value;}
369 void SetValue(
const std::string& _value )
373 SetValue( buf.buffer ? buf.buffer :
"" );
384 TiXmlNode* FirstChild(
const char * value )
const;
386 TiXmlNode* LastChild()
const {
return lastChild; }
387 TiXmlNode* LastChild(
const char * value )
const;
452 bool RemoveChild(
TiXmlNode* removeThis );
458 TiXmlNode* PreviousSibling(
const char * )
const;
469 TiXmlNode* NextSibling(
const char * )
const;
491 TiXmlElement* FirstChildElement(
const char * value )
const;
501 virtual int Type()
const {
return type; }
520 void SetUserData(
void* user ) { userData = user; }
521 void* GetUserData() {
return userData; }
528 virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
532 TiXmlNode* Identify(
const char* start );
534 target->userData = userData; }
537 TIXML_STRING SValue()
const {
return value ; }
573 TiXmlAttribute(
const std::string& _name,
const std::string& _value )
592 const char*
Name()
const {
return name.c_str (); }
593 const char*
Value()
const {
return value.c_str (); }
594 const int IntValue()
const;
595 const double DoubleValue()
const;
606 int QueryIntValue(
int* value )
const;
608 int QueryDoubleValue(
double* value )
const;
610 void SetName(
const char* _name ) { name = _name; }
611 void SetValue(
const char* _value ) { value = _value; }
613 void SetIntValue(
int value );
614 void SetDoubleValue(
double value );
617 void SetName(
const std::string& _name )
621 SetName ( buf.buffer ? buf.buffer :
"error" );
627 SetValue( buf.buffer ? buf.buffer :
"error" );
636 bool operator==(
const TiXmlAttribute& rhs )
const {
return rhs.name == name; }
637 bool operator<(
const TiXmlAttribute& rhs )
const {
return name < rhs.name; }
638 bool operator>(
const TiXmlAttribute& rhs )
const {
return name > rhs.name; }
647 virtual void Print( FILE* cfile,
int depth )
const;
649 virtual void StreamOut( TIXML_OSTREAM * out )
const;
684 TiXmlAttribute* First()
const {
return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
685 TiXmlAttribute* Last()
const {
return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
707 firstChild = lastChild = 0;
717 const char* Attribute(
const char* name )
const;
725 const char* Attribute(
const char* name,
int* i )
const;
733 const char* Attribute(
const char* name,
double* d )
const;
742 int QueryIntAttribute(
const char* name,
int* value )
const;
744 int QueryDoubleAttribute(
const char* name,
double* value )
const;
749 void SetAttribute(
const char* name,
const char * value );
752 const char* Attribute(
const std::string& name )
const {
return Attribute( name.c_str() ); }
753 const char* Attribute(
const std::string& name,
int* i )
const {
return Attribute( name.c_str(), i ); }
756 void SetAttribute(
const std::string& name,
const std::string& _value )
760 if ( n.buffer && v.buffer )
761 SetAttribute (n.buffer, v.buffer );
764 void SetAttribute(
const std::string& name,
int _value )
768 SetAttribute (n.buffer, _value);
775 void SetAttribute(
const char * name,
int value );
779 void RemoveAttribute(
const char * name );
791 virtual void Print( FILE* cfile,
int depth )
const;
797 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
799 virtual void StreamOut( TIXML_OSTREAM * out )
const;
830 virtual void Print( FILE* cfile,
int depth )
const;
834 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
836 virtual void StreamOut( TIXML_OSTREAM * out )
const;
854 SetValue( initValue );
862 SetValue( initValue );
867 virtual void Print( FILE* cfile,
int depth )
const;
872 virtual void StreamOut ( TIXML_OSTREAM * out )
const;
882 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
909 const std::string& _encoding,
910 const std::string& _standalone )
914 encoding = _encoding;
915 standalone = _standalone;
921 const char* _encoding,
922 const char* _standalone );
927 const char *
Version()
const {
return version.c_str (); }
929 const char *
Encoding()
const {
return encoding.c_str (); }
931 const char *
Standalone()
const {
return standalone.c_str (); }
936 virtual void Print( FILE* cfile,
int depth )
const;
941 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
943 virtual void StreamOut ( TIXML_OSTREAM * out)
const;
951 TIXML_STRING version;
952 TIXML_STRING encoding;
953 TIXML_STRING standalone;
971 virtual void Print( FILE* cfile,
int depth )
const;
974 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
976 virtual void StreamOut ( TIXML_OSTREAM * out )
const;
1003 value = documentName;
1016 bool SaveFile()
const;
1018 bool LoadFile(
const char * filename );
1020 bool SaveFile(
const char * filename )
const;
1022 #ifdef TIXML_USE_STL 1026 return ( f.buffer && LoadFile( f.buffer ));
1031 return ( f.buffer && SaveFile( f.buffer ));
1053 const char *
ErrorDesc()
const {
return errorDesc.c_str (); }
1092 int TabSize()
const {
return tabsize; }
1100 errorLocation.row = errorLocation.col = 0;
1108 virtual void Print( FILE* cfile,
int depth = 0 )
const;
1110 void SetError(
int err,
const char* errorLocation,
TiXmlParsingData* prevData );
1113 virtual void StreamOut ( TIXML_OSTREAM * out)
const;
1116 #ifdef TIXML_USE_STL 1117 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
1123 TIXML_STRING errorDesc;
1220 TiXmlHandle FirstChild(
const char * value )
const;
1224 TiXmlHandle FirstChildElement(
const char * value )
const;
1229 TiXmlHandle Child(
const char* value,
int index )
const;
1238 TiXmlHandle ChildElement(
const char* value,
int index )
const;
1245 #ifdef TIXML_USE_STL 1246 TiXmlHandle FirstChild(
const std::string& _value )
const {
return FirstChild( _value.c_str() ); }
1247 TiXmlHandle FirstChildElement(
const std::string& _value )
const {
return FirstChildElement( _value.c_str() ); }
1249 TiXmlHandle Child(
const std::string& _value,
int index )
const {
return Child( _value.c_str(), index ); }
1250 TiXmlHandle ChildElement(
const std::string& _value,
int index )
const {
return ChildElement( _value.c_str(), index ); }
1258 TiXmlText*
Text()
const {
return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
int ErrorCol()
The column where the error occured. See ErrorRow()
Definition: tinyxml.h:1068
void ClearError()
If you have handled the error, it can be reset with this call.
Definition: tinyxml.h:1097
bool NoChildren() const
Returns true if this node has no children.
Definition: tinyxml.h:509
Any tag that tinyXml doesn't recognize is saved as an unknown.
Definition: tinyxml.h:962
const int ErrorId() const
Generally, you probably want the error string ( ErrorDesc() ).
Definition: tinyxml.h:1058
TiXmlNode * Parent() const
One step up the DOM.
Definition: tinyxml.h:381
A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thi...
Definition: tinyxml.h:1209
Definition: tinyxml.h:675
void SetValue(const char *_value)
Set the value.
Definition: tinyxml.h:611
TiXmlAttribute(const char *_name, const char *_value)
Construct an attribute with a name and value.
Definition: tinyxml.h:584
TiXmlText * ToText() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:515
const char * Encoding() const
Encoding. Will return empty if none was found.
Definition: tinyxml.h:929
NodeType
The types of XML nodes supported by TinyXml.
Definition: tinyxml.h:330
TiXmlNode * NextSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:466
XML text.
Definition: tinyxml.h:847
TiXmlElement * Element() const
Return the handle as a TiXmlElement. This may return null.
Definition: tinyxml.h:1256
TiXmlUnknown * ToUnknown() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:514
int ErrorRow()
Returns the location (if known) of the error.
Definition: tinyxml.h:1067
const char * Version() const
Version. Will return empty if none was found.
Definition: tinyxml.h:927
Definition: tinyxml.h:176
TiXmlText * Text() const
Return the handle as a TiXmlText. This may return null.
Definition: tinyxml.h:1258
In correct XML the declaration is the first entry in the file.
Definition: tinyxml.h:900
TiXmlHandle(const TiXmlHandle &ref)
Copy constructor.
Definition: tinyxml.h:1215
TiXmlNode * PreviousSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:461
TiXmlBase is a base class for every class in TinyXml.
Definition: tinyxml.h:124
const char * Value() const
The meaning of 'value' changes for the specific type of TiXmlNode.
Definition: tinyxml.h:355
An attribute is a name-value pair.
Definition: tinyxml.h:560
Always the top level node.
Definition: tinyxml.h:989
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:1090
virtual int Type() const
Query the type (as an enumerated value, above) of this node.
Definition: tinyxml.h:501
TiXmlDocument * ToDocument() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:511
TiXmlElement * NextSiblingElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:484
bool SaveFile(const std::string &filename) const
< STL std::string version.
Definition: tinyxml.h:1028
TiXmlText(const char *initValue)
Constructor.
Definition: tinyxml.h:852
TiXmlNode * Node() const
Return the handle as a TiXmlNode. This may return null.
Definition: tinyxml.h:1254
void SetAttribute(const std::string &name, const std::string &_value)
STL std::string form.
Definition: tinyxml.h:756
TiXmlNode * NextSibling(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:462
TiXmlDeclaration()
Construct an empty declaration.
Definition: tinyxml.h:904
Definition: tinyxmlparser.cpp:46
TiXmlAttribute * FirstAttribute() const
Access the first attribute in this element.
Definition: tinyxml.h:784
static void SetCondenseWhiteSpace(bool condense)
The world does not agree on whether white space should be kept or not.
Definition: tinyxml.h:147
void Print() const
Dump the document to standard out.
Definition: tinyxml.h:1105
TiXmlHandle(TiXmlNode *node)
Create a handle from any node (at any depth of the tree.) This can be a null pointer.
Definition: tinyxml.h:1213
TiXmlElement * FirstChildElement(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:494
TiXmlNode * FirstChild() const
The first child of this node. Will be null if there are no children.
Definition: tinyxml.h:383
TiXmlNode * PreviousSibling() const
Navigate to a sibling node.
Definition: tinyxml.h:455
TiXmlDeclaration * ToDeclaration() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:516
void SetValue(const std::string &_value)
STL std::string form.
Definition: tinyxml.h:624
int Column() const
See Row()
Definition: tinyxml.h:171
bool Error() const
If an error occurs, Error will be set to true.
Definition: tinyxml.h:1050
const char * Standalone() const
Is this a standalone document?
Definition: tinyxml.h:931
const char * Name() const
Return the name of this attribute.
Definition: tinyxml.h:592
const char * Value() const
Return the value of this attribute.
Definition: tinyxml.h:593
The element is a container class.
Definition: tinyxml.h:697
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:390
TiXmlAttribute()
Construct an empty attribute.
Definition: tinyxml.h:566
TiXmlAttribute * LastAttribute() const
Access the last attribute in this element.
Definition: tinyxml.h:785
const char * ErrorDesc() const
Contains a textual (english) description of the error if one occurs.
Definition: tinyxml.h:1053
The parent class for everything in the Document Object Model.
Definition: tinyxml.h:288
static bool IsWhiteSpaceCondensed()
Return the current white space setting.
Definition: tinyxml.h:150
TiXmlElement * RootElement() const
Get the root element – the only top level element – of the document.
Definition: tinyxml.h:1043
bool LoadFile(const std::string &filename)
Definition: tinyxml.h:1023
void SetName(const char *_name)
Set the name of this attribute.
Definition: tinyxml.h:610
int Row() const
Return the position, in the original source file, of this node or attribute.
Definition: tinyxml.h:170
TiXmlNode * LastChild(const std::string &_value) const
STL std::string form.
Definition: tinyxml.h:391
TiXmlElement * ToElement() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:512
void RemoveAttribute(const std::string &name)
STL std::string form.
Definition: tinyxml.h:781
void SetValue(const char *_value)
Changes the value of the node.
Definition: tinyxml.h:366
TiXmlNode * IterateChildren(const std::string &_value, TiXmlNode *previous) const
STL std::string form.
Definition: tinyxml.h:416
TiXmlComment * ToComment() const
Cast to a more defined type. Will return null not of the requested type.
Definition: tinyxml.h:513