00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef TINYXML_INCLUDED
00027 #define TINYXML_INCLUDED
00028
00029 #ifdef _MSC_VER
00030 #pragma warning( disable : 4530 )
00031 #pragma warning( disable : 4786 )
00032 #endif
00033
00034 #include <ctype.h>
00035 #include <stdio.h>
00036 #include <stdlib.h>
00037 #include <string.h>
00038 #include <assert.h>
00039
00040
00041 #if defined( _DEBUG ) && !defined( DEBUG )
00042 #define DEBUG
00043 #endif
00044
00045 #if defined( DEBUG ) && defined( _MSC_VER )
00046 #include <windows.h>
00047 #define TIXML_LOG OutputDebugString
00048 #else
00049 #define TIXML_LOG printf
00050 #endif
00051
00052 #ifdef TIXML_USE_STL
00053 #include <string>
00054 #include <iostream>
00055
00056 #define TIXML_STRING std::string
00057 #define TIXML_ISTREAM std::istream
00058 #define TIXML_OSTREAM std::ostream
00059 #else
00060 #include "tinystr.h"
00061 #define TIXML_STRING TiXmlString
00062 #define TIXML_OSTREAM TiXmlOutStream
00063 #endif
00064
00065 class TiXmlDocument;
00066 class TiXmlElement;
00067 class TiXmlComment;
00068 class TiXmlUnknown;
00069 class TiXmlAttribute;
00070 class TiXmlText;
00071 class TiXmlDeclaration;
00072
00073 class TiXmlParsingData;
00074
00075
00076
00077
00078 struct TiXmlCursor
00079 {
00080 TiXmlCursor() { Clear(); }
00081 void Clear() { row = col = -1; }
00082
00083 int row;
00084 int col;
00085 };
00086
00087
00088
00089 enum
00090 {
00091 TIXML_SUCCESS,
00092 TIXML_NO_ATTRIBUTE,
00093 TIXML_WRONG_TYPE
00094 };
00095
00118 class TiXmlBase
00119 {
00120 friend class TiXmlNode;
00121 friend class TiXmlElement;
00122 friend class TiXmlDocument;
00123
00124 public:
00125 TiXmlBase() {}
00126 virtual ~TiXmlBase() {}
00127
00133 virtual void Print( FILE* cfile, int depth ) const = 0;
00134
00141 static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
00142
00144 static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
00145
00164 int Row() const { return location.row + 1; }
00165 int Column() const { return location.col + 1; }
00166
00167 protected:
00168
00169
00170 class StringToBuffer
00171 {
00172 public:
00173 StringToBuffer( const TIXML_STRING& str );
00174 ~StringToBuffer();
00175 char* buffer;
00176 };
00177
00178 static const char* SkipWhiteSpace( const char* );
00179 inline static bool IsWhiteSpace( int c ) { return ( isspace( c ) || c == '\n' || c == '\r' ); }
00180
00181 virtual void StreamOut (TIXML_OSTREAM *) const = 0;
00182
00183 #ifdef TIXML_USE_STL
00184 static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
00185 static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
00186 #endif
00187
00188
00189
00190
00191
00192 static const char* ReadName( const char* p, TIXML_STRING* name );
00193
00194
00195
00196
00197 static const char* ReadText( const char* in,
00198 TIXML_STRING* text,
00199 bool ignoreWhiteSpace,
00200 const char* endTag,
00201 bool ignoreCase );
00202
00203 virtual const char* Parse( const char* p, const TiXmlParsingData* data ) = 0;
00204
00205
00206 static const char* GetEntity( const char* in, char* value );
00207
00208
00209 inline static const char* GetChar( const char* p, char* _value )
00210 {
00211 assert( p );
00212 if ( *p == '&' )
00213 {
00214 return GetEntity( p, _value );
00215 }
00216 else
00217 {
00218 *_value = *p;
00219 return p+1;
00220 }
00221 }
00222
00223
00224
00225 static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out );
00226
00227 static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
00228
00229
00230 static bool StringEqual( const char* p,
00231 const char* endTag,
00232 bool ignoreCase );
00233
00234
00235 enum
00236 {
00237 TIXML_NO_ERROR = 0,
00238 TIXML_ERROR,
00239 TIXML_ERROR_OPENING_FILE,
00240 TIXML_ERROR_OUT_OF_MEMORY,
00241 TIXML_ERROR_PARSING_ELEMENT,
00242 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00243 TIXML_ERROR_READING_ELEMENT_VALUE,
00244 TIXML_ERROR_READING_ATTRIBUTES,
00245 TIXML_ERROR_PARSING_EMPTY,
00246 TIXML_ERROR_READING_END_TAG,
00247 TIXML_ERROR_PARSING_UNKNOWN,
00248 TIXML_ERROR_PARSING_COMMENT,
00249 TIXML_ERROR_PARSING_DECLARATION,
00250 TIXML_ERROR_DOCUMENT_EMPTY,
00251
00252 TIXML_ERROR_STRING_COUNT
00253 };
00254 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00255
00256 TiXmlCursor location;
00257
00258 private:
00259 struct Entity
00260 {
00261 const char* str;
00262 unsigned int strLength;
00263 char chr;
00264 };
00265 enum
00266 {
00267 NUM_ENTITY = 5,
00268 MAX_ENTITY_LENGTH = 6
00269
00270 };
00271 static Entity entity[ NUM_ENTITY ];
00272 static bool condenseWhiteSpace;
00273 };
00274
00275
00282 class TiXmlNode : public TiXmlBase
00283 {
00284 friend class TiXmlDocument;
00285 friend class TiXmlElement;
00286
00287 public:
00288 #ifdef TIXML_USE_STL
00289
00293 friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
00294
00311 friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
00312
00314 friend std::string& operator<< (std::string& out, const TiXmlNode& base );
00315
00316 #else
00317
00318 friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base);
00319 #endif
00320
00324 enum NodeType
00325 {
00326 DOCUMENT,
00327 ELEMENT,
00328 COMMENT,
00329 UNKNOWN,
00330 TEXT,
00331 DECLARATION,
00332 TYPECOUNT
00333 };
00334
00335 virtual ~TiXmlNode();
00336
00349 const char * Value() const { return value.c_str (); }
00350
00360 void SetValue(const char * _value) { value = _value;}
00361
00362 #ifdef TIXML_USE_STL
00363
00364 void SetValue( const std::string& _value )
00365 {
00366 StringToBuffer buf( _value );
00367 SetValue( buf.buffer ? buf.buffer : "" );
00368 }
00369 #endif
00370
00372 void Clear();
00373
00375 TiXmlNode* Parent() const { return parent; }
00376
00377 TiXmlNode* FirstChild() const { return firstChild; }
00378 TiXmlNode* FirstChild( const char * value ) const;
00379
00380 TiXmlNode* LastChild() const { return lastChild; }
00381 TiXmlNode* LastChild( const char * value ) const;
00382
00383 #ifdef TIXML_USE_STL
00384 TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
00385 TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
00386 #endif
00387
00404 TiXmlNode* IterateChildren( TiXmlNode* previous ) const;
00405
00407 TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const;
00408
00409 #ifdef TIXML_USE_STL
00410 TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
00411 #endif
00412
00416 TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
00417
00418
00428 TiXmlNode* LinkEndChild( TiXmlNode* addThis );
00429
00433 TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
00434
00438 TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
00439
00443 TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
00444
00446 bool RemoveChild( TiXmlNode* removeThis );
00447
00449 TiXmlNode* PreviousSibling() const { return prev; }
00450
00452 TiXmlNode* PreviousSibling( const char * ) const;
00453
00454 #ifdef TIXML_USE_STL
00455 TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
00456 TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
00457 #endif
00458
00460 TiXmlNode* NextSibling() const { return next; }
00461
00463 TiXmlNode* NextSibling( const char * ) const;
00464
00469 TiXmlElement* NextSiblingElement() const;
00470
00475 TiXmlElement* NextSiblingElement( const char * ) const;
00476
00477 #ifdef TIXML_USE_STL
00478 TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
00479 #endif
00480
00482 TiXmlElement* FirstChildElement() const;
00483
00485 TiXmlElement* FirstChildElement( const char * value ) const;
00486
00487 #ifdef TIXML_USE_STL
00488 TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
00489 #endif
00490
00495 virtual int Type() const { return type; }
00496
00500 TiXmlDocument* GetDocument() const;
00501
00503 bool NoChildren() const { return !firstChild; }
00504
00505 TiXmlDocument* ToDocument() const { return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; }
00506 TiXmlElement* ToElement() const { return ( this && type == ELEMENT ) ? (TiXmlElement*) this : 0; }
00507 TiXmlComment* ToComment() const { return ( this && type == COMMENT ) ? (TiXmlComment*) this : 0; }
00508 TiXmlUnknown* ToUnknown() const { return ( this && type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; }
00509 TiXmlText* ToText() const { return ( this && type == TEXT ) ? (TiXmlText*) this : 0; }
00510 TiXmlDeclaration* ToDeclaration() const { return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; }
00511
00512 virtual TiXmlNode* Clone() const = 0;
00513
00514 void SetUserData( void* user ) { userData = user; }
00515 void* GetUserData() { return userData; }
00516
00517 protected:
00518 TiXmlNode( NodeType type );
00519
00520 #ifdef TIXML_USE_STL
00521
00522 virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
00523 #endif
00524
00525
00526 TiXmlNode* Identify( const char* start );
00527 void CopyToClone( TiXmlNode* target ) const { target->SetValue (value.c_str() );
00528 target->userData = userData; }
00529
00530
00531 TIXML_STRING SValue() const { return value ; }
00532
00533 TiXmlNode* parent;
00534 NodeType type;
00535
00536 TiXmlNode* firstChild;
00537 TiXmlNode* lastChild;
00538
00539 TIXML_STRING value;
00540
00541 TiXmlNode* prev;
00542 TiXmlNode* next;
00543 void* userData;
00544 };
00545
00546
00554 class TiXmlAttribute : public TiXmlBase
00555 {
00556 friend class TiXmlAttributeSet;
00557
00558 public:
00560 TiXmlAttribute()
00561 {
00562 document = 0;
00563 prev = next = 0;
00564 }
00565
00566 #ifdef TIXML_USE_STL
00567
00568 TiXmlAttribute( const std::string& _name, const std::string& _value )
00569 {
00570 name = _name;
00571 value = _value;
00572 document = 0;
00573 prev = next = 0;
00574 }
00575 #endif
00576
00578 TiXmlAttribute( const char * _name, const char * _value )
00579 {
00580 name = _name;
00581 value = _value;
00582 document = 0;
00583 prev = next = 0;
00584 }
00585
00586 const char* Name() const { return name.c_str (); }
00587 const char* Value() const { return value.c_str (); }
00588 const int IntValue() const;
00589 const double DoubleValue() const;
00590
00600 int QueryIntValue( int* value ) const;
00602 int QueryDoubleValue( double* value ) const;
00603
00604 void SetName( const char* _name ) { name = _name; }
00605 void SetValue( const char* _value ) { value = _value; }
00606
00607 void SetIntValue( int value );
00608 void SetDoubleValue( double value );
00609
00610 #ifdef TIXML_USE_STL
00611
00612 void SetName( const std::string& _name )
00613 {
00614 StringToBuffer buf( _name );
00615 SetName ( buf.buffer ? buf.buffer : "error" );
00616 }
00618 void SetValue( const std::string& _value )
00619 {
00620 StringToBuffer buf( _value );
00621 SetValue( buf.buffer ? buf.buffer : "error" );
00622 }
00623 #endif
00624
00626 TiXmlAttribute* Next() const;
00628 TiXmlAttribute* Previous() const;
00629
00630 bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
00631 bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
00632 bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
00633
00634
00635
00636
00637
00638 virtual const char* Parse( const char* p, const TiXmlParsingData* data );
00639
00640
00641 virtual void Print( FILE* cfile, int depth ) const;
00642
00643 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00644
00645
00646 void SetDocument( TiXmlDocument* doc ) { document = doc; }
00647
00648 private:
00649 TiXmlDocument* document;
00650 TIXML_STRING name;
00651 TIXML_STRING value;
00652 TiXmlAttribute* prev;
00653 TiXmlAttribute* next;
00654 };
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669 class TiXmlAttributeSet
00670 {
00671 public:
00672 TiXmlAttributeSet();
00673 ~TiXmlAttributeSet();
00674
00675 void Add( TiXmlAttribute* attribute );
00676 void Remove( TiXmlAttribute* attribute );
00677
00678 TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00679 TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00680 TiXmlAttribute* Find( const char * name ) const;
00681
00682 private:
00683 TiXmlAttribute sentinel;
00684 };
00685
00686
00691 class TiXmlElement : public TiXmlNode
00692 {
00693 public:
00695 TiXmlElement (const char * in_value);
00696
00697 #ifdef TIXML_USE_STL
00698
00699 TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::ELEMENT )
00700 {
00701 firstChild = lastChild = 0;
00702 value = _value;
00703 }
00704 #endif
00705
00706 virtual ~TiXmlElement();
00707
00711 const char* Attribute( const char* name ) const;
00712
00719 const char* Attribute( const char* name, int* i ) const;
00720
00727 const char* Attribute( const char* name, double* d ) const;
00728
00736 int QueryIntAttribute( const char* name, int* value ) const;
00738 int QueryDoubleAttribute( const char* name, double* value ) const;
00739
00743 void SetAttribute( const char* name, const char * value );
00744
00745 #ifdef TIXML_USE_STL
00746 const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); }
00747 const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); }
00748
00750 void SetAttribute( const std::string& name, const std::string& _value )
00751 {
00752 StringToBuffer n( name );
00753 StringToBuffer v( _value );
00754 if ( n.buffer && v.buffer )
00755 SetAttribute (n.buffer, v.buffer );
00756 }
00758 void SetAttribute( const std::string& name, int _value )
00759 {
00760 StringToBuffer n( name );
00761 if ( n.buffer )
00762 SetAttribute (n.buffer, _value);
00763 }
00764 #endif
00765
00769 void SetAttribute( const char * name, int value );
00770
00773 void RemoveAttribute( const char * name );
00774 #ifdef TIXML_USE_STL
00775 void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
00776 #endif
00777
00778 TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
00779 TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
00780
00781
00782 virtual TiXmlNode* Clone() const;
00783
00784
00785 virtual void Print( FILE* cfile, int depth ) const;
00786
00787 protected:
00788
00789
00790 #ifdef TIXML_USE_STL
00791 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00792 #endif
00793 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00794
00795
00796
00797
00798
00799 virtual const char* Parse( const char* p, const TiXmlParsingData* data );
00800
00801
00802
00803
00804
00805 const char* ReadValue( const char* in, const TiXmlParsingData* prevData );
00806
00807 private:
00808 TiXmlAttributeSet attributeSet;
00809 };
00810
00811
00814 class TiXmlComment : public TiXmlNode
00815 {
00816 public:
00818 TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
00819 virtual ~TiXmlComment() {}
00820
00821
00822 virtual TiXmlNode* Clone() const;
00823
00824 virtual void Print( FILE* cfile, int depth ) const;
00825 protected:
00826
00827 #ifdef TIXML_USE_STL
00828 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00829 #endif
00830 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00831
00832
00833
00834
00835 virtual const char* Parse( const char* p, const TiXmlParsingData* data );
00836 };
00837
00838
00841 class TiXmlText : public TiXmlNode
00842 {
00843 friend class TiXmlElement;
00844 public:
00846 TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT)
00847 {
00848 SetValue( initValue );
00849 }
00850 virtual ~TiXmlText() {}
00851
00852 #ifdef TIXML_USE_STL
00853
00854 TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
00855 {
00856 SetValue( initValue );
00857 }
00858 #endif
00859
00860
00861 virtual void Print( FILE* cfile, int depth ) const;
00862
00863 protected :
00864
00865 virtual TiXmlNode* Clone() const;
00866 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
00867
00868 bool Blank() const;
00869
00870
00871
00872
00873 virtual const char* Parse( const char* p, const TiXmlParsingData* data );
00874
00875 #ifdef TIXML_USE_STL
00876 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00877 #endif
00878 };
00879
00880
00894 class TiXmlDeclaration : public TiXmlNode
00895 {
00896 public:
00898 TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
00899
00900 #ifdef TIXML_USE_STL
00901
00902 TiXmlDeclaration( const std::string& _version,
00903 const std::string& _encoding,
00904 const std::string& _standalone )
00905 : TiXmlNode( TiXmlNode::DECLARATION )
00906 {
00907 version = _version;
00908 encoding = _encoding;
00909 standalone = _standalone;
00910 }
00911 #endif
00912
00914 TiXmlDeclaration( const char* _version,
00915 const char* _encoding,
00916 const char* _standalone );
00917
00918 virtual ~TiXmlDeclaration() {}
00919
00921 const char * Version() const { return version.c_str (); }
00923 const char * Encoding() const { return encoding.c_str (); }
00925 const char * Standalone() const { return standalone.c_str (); }
00926
00927
00928 virtual TiXmlNode* Clone() const;
00929
00930 virtual void Print( FILE* cfile, int depth ) const;
00931
00932 protected:
00933
00934 #ifdef TIXML_USE_STL
00935 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00936 #endif
00937 virtual void StreamOut ( TIXML_OSTREAM * out) const;
00938
00939
00940
00941
00942 virtual const char* Parse( const char* p, const TiXmlParsingData* data );
00943
00944 private:
00945 TIXML_STRING version;
00946 TIXML_STRING encoding;
00947 TIXML_STRING standalone;
00948 };
00949
00950
00956 class TiXmlUnknown : public TiXmlNode
00957 {
00958 public:
00959 TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
00960 virtual ~TiXmlUnknown() {}
00961
00962
00963 virtual TiXmlNode* Clone() const;
00964
00965 virtual void Print( FILE* cfile, int depth ) const;
00966 protected:
00967 #ifdef TIXML_USE_STL
00968 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00969 #endif
00970 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
00971
00972
00973
00974
00975 virtual const char* Parse( const char* p, const TiXmlParsingData* data );
00976 };
00977
00978
00983 class TiXmlDocument : public TiXmlNode
00984 {
00985 public:
00987 TiXmlDocument();
00989 TiXmlDocument( const char * documentName );
00990
00991 #ifdef TIXML_USE_STL
00992
00993 TiXmlDocument( const std::string& documentName ) :
00994 TiXmlNode( TiXmlNode::DOCUMENT )
00995 {
00996 value = documentName;
00997 error = false;
00998 }
00999 #endif
01000
01001 virtual ~TiXmlDocument() {}
01002
01007 bool LoadFile();
01009 bool SaveFile() const;
01011 bool LoadFile( const char * filename );
01013 bool SaveFile( const char * filename ) const;
01014
01015 #ifdef TIXML_USE_STL
01016 bool LoadFile( const std::string& filename )
01017 {
01018 StringToBuffer f( filename );
01019 return ( f.buffer && LoadFile( f.buffer ));
01020 }
01021 bool SaveFile( const std::string& filename ) const
01022 {
01023 StringToBuffer f( filename );
01024 return ( f.buffer && SaveFile( f.buffer ));
01025 }
01026 #endif
01027
01030 virtual const char* Parse( const char* p, const TiXmlParsingData* data = 0 );
01031
01036 TiXmlElement* RootElement() const { return FirstChildElement(); }
01037
01043 bool Error() const { return error; }
01044
01046 const char * ErrorDesc() const { return errorDesc.c_str (); }
01047
01051 const int ErrorId() const { return errorId; }
01052
01060 int ErrorRow() { return errorLocation.row+1; }
01061 int ErrorCol() { return errorLocation.col+1; }
01062
01084 void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
01085
01086 int TabSize() const { return tabsize; }
01087
01091 void ClearError() { error = false;
01092 errorId = 0;
01093 errorDesc = "";
01094 errorLocation.row = errorLocation.col = 0;
01095
01096 }
01097
01099 void Print() const { Print( stdout, 0 ); }
01100
01101
01102 virtual void Print( FILE* cfile, int depth = 0 ) const;
01103
01104 void SetError( int err, const char* errorLocation, const TiXmlParsingData* prevData );
01105
01106 protected :
01107 virtual void StreamOut ( TIXML_OSTREAM * out) const;
01108
01109 virtual TiXmlNode* Clone() const;
01110 #ifdef TIXML_USE_STL
01111 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01112 #endif
01113
01114 private:
01115 bool error;
01116 int errorId;
01117 TIXML_STRING errorDesc;
01118 int tabsize;
01119 TiXmlCursor errorLocation;
01120 };
01121
01122
01203 class TiXmlHandle
01204 {
01205 public:
01207 TiXmlHandle( TiXmlNode* node ) { this->node = node; }
01209 TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
01210
01212 TiXmlHandle FirstChild() const;
01214 TiXmlHandle FirstChild( const char * value ) const;
01216 TiXmlHandle FirstChildElement() const;
01218 TiXmlHandle FirstChildElement( const char * value ) const;
01219
01223 TiXmlHandle Child( const char* value, int index ) const;
01227 TiXmlHandle Child( int index ) const;
01232 TiXmlHandle ChildElement( const char* value, int index ) const;
01237 TiXmlHandle ChildElement( int index ) const;
01238
01239 #ifdef TIXML_USE_STL
01240 TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
01241 TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
01242
01243 TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
01244 TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
01245 #endif
01246
01248 TiXmlNode* Node() const { return node; }
01250 TiXmlElement* Element() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
01252 TiXmlText* Text() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
01253
01254 private:
01255 TiXmlNode* node;
01256 };
01257
01258
01259 #endif
01260