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 #define TIXML_USE_STL
00053
00054 #ifdef TIXML_USE_STL
00055 #include <string>
00056 #include <iostream>
00057
00058 #define TIXML_STRING std::string
00059 #define TIXML_ISTREAM std::istream
00060 #define TIXML_OSTREAM std::ostream
00061 #else
00062 #include "tinystr.h"
00063 #define TIXML_STRING TiXmlString
00064 #define TIXML_OSTREAM TiXmlOutStream
00065 #endif
00066
00067 class TiXmlDocument;
00068 class TiXmlElement;
00069 class TiXmlComment;
00070 class TiXmlUnknown;
00071 class TiXmlAttribute;
00072 class TiXmlText;
00073 class TiXmlDeclaration;
00074
00075 class TiXmlParsingData;
00076
00077
00078
00079
00080 struct TiXmlCursor
00081 {
00082 TiXmlCursor() { Clear(); }
00083 void Clear() { row = col = -1; }
00084
00085 int row;
00086 int col;
00087 };
00088
00089
00090
00091 enum
00092 {
00093 TIXML_SUCCESS,
00094 TIXML_NO_ATTRIBUTE,
00095 TIXML_WRONG_TYPE
00096 };
00097
00120 class TiXmlBase
00121 {
00122 friend class TiXmlNode;
00123 friend class TiXmlElement;
00124 friend class TiXmlDocument;
00125
00126 public:
00127 TiXmlBase() {}
00128 virtual ~TiXmlBase() {}
00129
00135 virtual void Print( FILE* cfile, int depth ) const = 0;
00136
00143 static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
00144
00146 static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
00147
00166 int Row() const { return location.row + 1; }
00167 int Column() const { return location.col + 1; }
00168
00169 protected:
00170
00171
00172 class StringToBuffer
00173 {
00174 public:
00175 StringToBuffer( const TIXML_STRING& str );
00176 ~StringToBuffer();
00177 char* buffer;
00178 };
00179
00180 static const char* SkipWhiteSpace( const char* );
00181 inline static bool IsWhiteSpace( int c ) { return ( isspace( c ) || c == '\n' || c == '\r' ); }
00182
00183 virtual void StreamOut (TIXML_OSTREAM *) const = 0;
00184
00185 #ifdef TIXML_USE_STL
00186 static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
00187 static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
00188 #endif
00189
00190
00191
00192
00193
00194 static const char* ReadName( const char* p, TIXML_STRING* name );
00195
00196
00197
00198
00199 static const char* ReadText( const char* in,
00200 TIXML_STRING* text,
00201 bool ignoreWhiteSpace,
00202 const char* endTag,
00203 bool ignoreCase );
00204
00205 virtual const char* Parse( const char* p, TiXmlParsingData* data ) = 0;
00206
00207
00208 static const char* GetEntity( const char* in, char* value );
00209
00210
00211 inline static const char* GetChar( const char* p, char* _value )
00212 {
00213 assert( p );
00214 if ( *p == '&' )
00215 {
00216 return GetEntity( p, _value );
00217 }
00218 else
00219 {
00220 *_value = *p;
00221 return p+1;
00222 }
00223 }
00224
00225
00226
00227 static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out );
00228
00229 static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
00230
00231
00232 static bool StringEqual( const char* p,
00233 const char* endTag,
00234 bool ignoreCase );
00235
00236
00237 enum
00238 {
00239 TIXML_NO_ERROR = 0,
00240 TIXML_ERROR,
00241 TIXML_ERROR_OPENING_FILE,
00242 TIXML_ERROR_OUT_OF_MEMORY,
00243 TIXML_ERROR_PARSING_ELEMENT,
00244 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00245 TIXML_ERROR_READING_ELEMENT_VALUE,
00246 TIXML_ERROR_READING_ATTRIBUTES,
00247 TIXML_ERROR_PARSING_EMPTY,
00248 TIXML_ERROR_READING_END_TAG,
00249 TIXML_ERROR_PARSING_UNKNOWN,
00250 TIXML_ERROR_PARSING_COMMENT,
00251 TIXML_ERROR_PARSING_DECLARATION,
00252 TIXML_ERROR_DOCUMENT_EMPTY,
00253
00254 TIXML_ERROR_STRING_COUNT
00255 };
00256 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00257
00258 TiXmlCursor location;
00259
00260 private:
00261 struct Entity
00262 {
00263 const char* str;
00264 unsigned int strLength;
00265 char chr;
00266 };
00267 enum
00268 {
00269 NUM_ENTITY = 5,
00270 MAX_ENTITY_LENGTH = 6
00271
00272 };
00273 static Entity entity[ NUM_ENTITY ];
00274 static bool condenseWhiteSpace;
00275 };
00276
00277
00284 class TiXmlNode : public TiXmlBase
00285 {
00286 friend class TiXmlDocument;
00287 friend class TiXmlElement;
00288
00289 public:
00290 #ifdef TIXML_USE_STL
00291
00295 friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
00296
00313 friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
00314
00316 friend std::string& operator<< (std::string& out, const TiXmlNode& base );
00317
00318 #else
00319
00320 friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base);
00321 #endif
00322
00326 enum NodeType
00327 {
00328 DOCUMENT,
00329 ELEMENT,
00330 COMMENT,
00331 UNKNOWN,
00332 TEXT,
00333 DECLARATION,
00334 TYPECOUNT
00335 };
00336
00337 virtual ~TiXmlNode();
00338
00351 const char * Value() const { return value.c_str (); }
00352
00362 void SetValue(const char * _value) { value = _value;}
00363
00364 #ifdef TIXML_USE_STL
00365
00366 void SetValue( const std::string& _value )
00367 {
00368 StringToBuffer buf( _value );
00369 SetValue( buf.buffer ? buf.buffer : "" );
00370 }
00371 #endif
00372
00374 void Clear();
00375
00377 TiXmlNode* Parent() const { return parent; }
00378
00379 TiXmlNode* FirstChild() const { return firstChild; }
00380 TiXmlNode* FirstChild( const char * value ) const;
00381
00382 TiXmlNode* LastChild() const { return lastChild; }
00383 TiXmlNode* LastChild( const char * value ) const;
00384
00385 #ifdef TIXML_USE_STL
00386 TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
00387 TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
00388 #endif
00389
00406 TiXmlNode* IterateChildren( TiXmlNode* previous ) const;
00407
00409 TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const;
00410
00411 #ifdef TIXML_USE_STL
00412 TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
00413 #endif
00414
00418 TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
00419
00420
00430 TiXmlNode* LinkEndChild( TiXmlNode* addThis );
00431
00435 TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
00436
00440 TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
00441
00445 TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
00446
00448 bool RemoveChild( TiXmlNode* removeThis );
00449
00451 TiXmlNode* PreviousSibling() const { return prev; }
00452
00454 TiXmlNode* PreviousSibling( const char * ) const;
00455
00456 #ifdef TIXML_USE_STL
00457 TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
00458 TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
00459 #endif
00460
00462 TiXmlNode* NextSibling() const { return next; }
00463
00465 TiXmlNode* NextSibling( const char * ) const;
00466
00471 TiXmlElement* NextSiblingElement() const;
00472
00477 TiXmlElement* NextSiblingElement( const char * ) const;
00478
00479 #ifdef TIXML_USE_STL
00480 TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
00481 #endif
00482
00484 TiXmlElement* FirstChildElement() const;
00485
00487 TiXmlElement* FirstChildElement( const char * value ) const;
00488
00489 #ifdef TIXML_USE_STL
00490 TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
00491 #endif
00492
00497 virtual int Type() const { return type; }
00498
00502 TiXmlDocument* GetDocument() const;
00503
00505 bool NoChildren() const { return !firstChild; }
00506
00507 TiXmlDocument* ToDocument() const { return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; }
00508 TiXmlElement* ToElement() const { return ( this && type == ELEMENT ) ? (TiXmlElement*) this : 0; }
00509 TiXmlComment* ToComment() const { return ( this && type == COMMENT ) ? (TiXmlComment*) this : 0; }
00510 TiXmlUnknown* ToUnknown() const { return ( this && type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; }
00511 TiXmlText* ToText() const { return ( this && type == TEXT ) ? (TiXmlText*) this : 0; }
00512 TiXmlDeclaration* ToDeclaration() const { return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; }
00513
00514 virtual TiXmlNode* Clone() const = 0;
00515
00516 void SetUserData( void* user ) { userData = user; }
00517 void* GetUserData() { return userData; }
00518
00519 protected:
00520 TiXmlNode( NodeType type );
00521
00522 #ifdef TIXML_USE_STL
00523
00524 virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
00525 #endif
00526
00527
00528 TiXmlNode* Identify( const char* start );
00529 void CopyToClone( TiXmlNode* target ) const { target->SetValue (value.c_str() );
00530 target->userData = userData; }
00531
00532
00533 TIXML_STRING SValue() const { return value ; }
00534
00535 TiXmlNode* parent;
00536 NodeType type;
00537
00538 TiXmlNode* firstChild;
00539 TiXmlNode* lastChild;
00540
00541 TIXML_STRING value;
00542
00543 TiXmlNode* prev;
00544 TiXmlNode* next;
00545 void* userData;
00546 };
00547
00548
00556 class TiXmlAttribute : public TiXmlBase
00557 {
00558 friend class TiXmlAttributeSet;
00559
00560 public:
00562 TiXmlAttribute()
00563 {
00564 document = 0;
00565 prev = next = 0;
00566 }
00567
00568 #ifdef TIXML_USE_STL
00569
00570 TiXmlAttribute( const std::string& _name, const std::string& _value )
00571 {
00572 name = _name;
00573 value = _value;
00574 document = 0;
00575 prev = next = 0;
00576 }
00577 #endif
00578
00580 TiXmlAttribute( const char * _name, const char * _value )
00581 {
00582 name = _name;
00583 value = _value;
00584 document = 0;
00585 prev = next = 0;
00586 }
00587
00588 const char* Name() const { return name.c_str (); }
00589 const char* Value() const { return value.c_str (); }
00590 const int IntValue() const;
00591 const double DoubleValue() const;
00592
00602 int QueryIntValue( int* value ) const;
00604 int QueryDoubleValue( double* value ) const;
00605
00606 void SetName( const char* _name ) { name = _name; }
00607 void SetValue( const char* _value ) { value = _value; }
00608
00609 void SetIntValue( int value );
00610 void SetDoubleValue( double value );
00611
00612 #ifdef TIXML_USE_STL
00613
00614 void SetName( const std::string& _name )
00615 {
00616 StringToBuffer buf( _name );
00617 SetName ( buf.buffer ? buf.buffer : "error" );
00618 }
00620 void SetValue( const std::string& _value )
00621 {
00622 StringToBuffer buf( _value );
00623 SetValue( buf.buffer ? buf.buffer : "error" );
00624 }
00625 #endif
00626
00628 TiXmlAttribute* Next() const;
00630 TiXmlAttribute* Previous() const;
00631
00632 bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
00633 bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
00634 bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
00635
00636
00637
00638
00639
00640 virtual const char* Parse( const char* p, TiXmlParsingData* data );
00641
00642
00643 virtual void Print( FILE* cfile, int depth ) const;
00644
00645 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00646
00647
00648 void SetDocument( TiXmlDocument* doc ) { document = doc; }
00649
00650 private:
00651 TiXmlDocument* document;
00652 TIXML_STRING name;
00653 TIXML_STRING value;
00654 TiXmlAttribute* prev;
00655 TiXmlAttribute* next;
00656 };
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 class TiXmlAttributeSet
00672 {
00673 public:
00674 TiXmlAttributeSet();
00675 ~TiXmlAttributeSet();
00676
00677 void Add( TiXmlAttribute* attribute );
00678 void Remove( TiXmlAttribute* attribute );
00679
00680 TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00681 TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00682 TiXmlAttribute* Find( const char * name ) const;
00683
00684 private:
00685 TiXmlAttribute sentinel;
00686 };
00687
00688
00693 class TiXmlElement : public TiXmlNode
00694 {
00695 public:
00697 TiXmlElement (const char * in_value);
00698
00699 #ifdef TIXML_USE_STL
00700
00701 TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::ELEMENT )
00702 {
00703 firstChild = lastChild = 0;
00704 value = _value;
00705 }
00706 #endif
00707
00708 virtual ~TiXmlElement();
00709
00713 const char* Attribute( const char* name ) const;
00714
00721 const char* Attribute( const char* name, int* i ) const;
00722
00729 const char* Attribute( const char* name, double* d ) const;
00730
00738 int QueryIntAttribute( const char* name, int* value ) const;
00740 int QueryDoubleAttribute( const char* name, double* value ) const;
00741
00745 void SetAttribute( const char* name, const char * value );
00746
00747 #ifdef TIXML_USE_STL
00748 const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); }
00749 const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); }
00750
00752 void SetAttribute( const std::string& name, const std::string& _value )
00753 {
00754 StringToBuffer n( name );
00755 StringToBuffer v( _value );
00756 if ( n.buffer && v.buffer )
00757 SetAttribute (n.buffer, v.buffer );
00758 }
00760 void SetAttribute( const std::string& name, int _value )
00761 {
00762 StringToBuffer n( name );
00763 if ( n.buffer )
00764 SetAttribute (n.buffer, _value);
00765 }
00766 #endif
00767
00771 void SetAttribute( const char * name, int value );
00772
00775 void RemoveAttribute( const char * name );
00776 #ifdef TIXML_USE_STL
00777 void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
00778 #endif
00779
00780 TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
00781 TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
00782
00783
00784 virtual TiXmlNode* Clone() const;
00785
00786
00787 virtual void Print( FILE* cfile, int depth ) const;
00788
00789 protected:
00790
00791
00792 #ifdef TIXML_USE_STL
00793 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00794 #endif
00795 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00796
00797
00798
00799
00800
00801 virtual const char* Parse( const char* p, TiXmlParsingData* data );
00802
00803
00804
00805
00806
00807 const char* ReadValue( const char* in, TiXmlParsingData* prevData );
00808
00809 private:
00810 TiXmlAttributeSet attributeSet;
00811 };
00812
00813
00816 class TiXmlComment : public TiXmlNode
00817 {
00818 public:
00820 TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
00821 virtual ~TiXmlComment() {}
00822
00823
00824 virtual TiXmlNode* Clone() const;
00825
00826 virtual void Print( FILE* cfile, int depth ) const;
00827 protected:
00828
00829 #ifdef TIXML_USE_STL
00830 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00831 #endif
00832 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00833
00834
00835
00836
00837 virtual const char* Parse( const char* p, TiXmlParsingData* data );
00838 };
00839
00840
00843 class TiXmlText : public TiXmlNode
00844 {
00845 friend class TiXmlElement;
00846 public:
00848 TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT)
00849 {
00850 SetValue( initValue );
00851 }
00852 virtual ~TiXmlText() {}
00853
00854 #ifdef TIXML_USE_STL
00855
00856 TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
00857 {
00858 SetValue( initValue );
00859 }
00860 #endif
00861
00862
00863 virtual void Print( FILE* cfile, int depth ) const;
00864
00865 protected :
00866
00867 virtual TiXmlNode* Clone() const;
00868 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
00869
00870 bool Blank() const;
00871
00872
00873
00874
00875 virtual const char* Parse( const char* p, TiXmlParsingData* data );
00876
00877 #ifdef TIXML_USE_STL
00878 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00879 #endif
00880 };
00881
00882
00896 class TiXmlDeclaration : public TiXmlNode
00897 {
00898 public:
00900 TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
00901
00902 #ifdef TIXML_USE_STL
00903
00904 TiXmlDeclaration( const std::string& _version,
00905 const std::string& _encoding,
00906 const std::string& _standalone )
00907 : TiXmlNode( TiXmlNode::DECLARATION )
00908 {
00909 version = _version;
00910 encoding = _encoding;
00911 standalone = _standalone;
00912 }
00913 #endif
00914
00916 TiXmlDeclaration( const char* _version,
00917 const char* _encoding,
00918 const char* _standalone );
00919
00920 virtual ~TiXmlDeclaration() {}
00921
00923 const char * Version() const { return version.c_str (); }
00925 const char * Encoding() const { return encoding.c_str (); }
00927 const char * Standalone() const { return standalone.c_str (); }
00928
00929
00930 virtual TiXmlNode* Clone() const;
00931
00932 virtual void Print( FILE* cfile, int depth ) const;
00933
00934 protected:
00935
00936 #ifdef TIXML_USE_STL
00937 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00938 #endif
00939 virtual void StreamOut ( TIXML_OSTREAM * out) const;
00940
00941
00942
00943
00944 virtual const char* Parse( const char* p, TiXmlParsingData* data );
00945
00946 private:
00947 TIXML_STRING version;
00948 TIXML_STRING encoding;
00949 TIXML_STRING standalone;
00950 };
00951
00952
00958 class TiXmlUnknown : public TiXmlNode
00959 {
00960 public:
00961 TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
00962 virtual ~TiXmlUnknown() {}
00963
00964
00965 virtual TiXmlNode* Clone() const;
00966
00967 virtual void Print( FILE* cfile, int depth ) const;
00968 protected:
00969 #ifdef TIXML_USE_STL
00970 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
00971 #endif
00972 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
00973
00974
00975
00976
00977 virtual const char* Parse( const char* p, TiXmlParsingData* data );
00978 };
00979
00980
00985 class TiXmlDocument : public TiXmlNode
00986 {
00987 public:
00989 TiXmlDocument();
00991 TiXmlDocument( const char * documentName );
00992
00993 #ifdef TIXML_USE_STL
00994
00995 TiXmlDocument( const std::string& documentName ) :
00996 TiXmlNode( TiXmlNode::DOCUMENT )
00997 {
00998 tabsize = 4;
00999 value = documentName;
01000 error = false;
01001 }
01002 #endif
01003
01004 virtual ~TiXmlDocument() {}
01005
01010 bool LoadFile();
01012 bool SaveFile() const;
01014 bool LoadFile( const char * filename );
01016 bool SaveFile( const char * filename ) const;
01017
01018 #ifdef TIXML_USE_STL
01019 bool LoadFile( const std::string& filename )
01020 {
01021 StringToBuffer f( filename );
01022 return ( f.buffer && LoadFile( f.buffer ));
01023 }
01024 bool SaveFile( const std::string& filename ) const
01025 {
01026 StringToBuffer f( filename );
01027 return ( f.buffer && SaveFile( f.buffer ));
01028 }
01029 #endif
01030
01033 virtual const char* Parse( const char* p, TiXmlParsingData* data = 0 );
01034
01039 TiXmlElement* RootElement() const { return FirstChildElement(); }
01040
01046 bool Error() const { return error; }
01047
01049 const char * ErrorDesc() const { return errorDesc.c_str (); }
01050
01054 const int ErrorId() const { return errorId; }
01055
01063 int ErrorRow() { return errorLocation.row+1; }
01064 int ErrorCol() { return errorLocation.col+1; }
01065
01086 void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
01087
01088 int TabSize() const { return tabsize; }
01089
01093 void ClearError() { error = false;
01094 errorId = 0;
01095 errorDesc = "";
01096 errorLocation.row = errorLocation.col = 0;
01097
01098 }
01099
01101 void Print() const { Print( stdout, 0 ); }
01102
01103
01104 virtual void Print( FILE* cfile, int depth = 0 ) const;
01105
01106 void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData );
01107
01108 protected :
01109 virtual void StreamOut ( TIXML_OSTREAM * out) const;
01110
01111 virtual TiXmlNode* Clone() const;
01112 #ifdef TIXML_USE_STL
01113 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01114 #endif
01115
01116 private:
01117 bool error;
01118 int errorId;
01119 TIXML_STRING errorDesc;
01120 int tabsize;
01121 TiXmlCursor errorLocation;
01122 };
01123
01124
01205 class TiXmlHandle
01206 {
01207 public:
01209 TiXmlHandle( TiXmlNode* node ) { this->node = node; }
01211 TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
01212
01214 TiXmlHandle FirstChild() const;
01216 TiXmlHandle FirstChild( const char * value ) const;
01218 TiXmlHandle FirstChildElement() const;
01220 TiXmlHandle FirstChildElement( const char * value ) const;
01221
01225 TiXmlHandle Child( const char* value, int index ) const;
01229 TiXmlHandle Child( int index ) const;
01234 TiXmlHandle ChildElement( const char* value, int index ) const;
01239 TiXmlHandle ChildElement( int index ) const;
01240
01241 #ifdef TIXML_USE_STL
01242 TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
01243 TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
01244
01245 TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
01246 TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
01247 #endif
01248
01250 TiXmlNode* Node() const { return node; }
01252 TiXmlElement* Element() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
01254 TiXmlText* Text() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
01255
01256 private:
01257 TiXmlNode* node;
01258 };
01259
01260
01261 #endif
01262