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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifndef TINYXML_INCLUDED
00065 #define TINYXML_INCLUDED
00066
00067 #ifdef _MSC_VER
00068 #pragma warning( push )
00069 #pragma warning( disable : 4530 )
00070 #pragma warning( disable : 4786 )
00071 #endif
00072
00073 #include <ctype.h>
00074 #include <stdio.h>
00075 #include <stdlib.h>
00076 #include <string.h>
00077 #include <assert.h>
00078
00079
00080 #if defined( _DEBUG ) && !defined( DEBUG )
00081 #define DEBUG
00082 #endif
00083
00084 #ifdef TIXML_USE_STL
00085 #include <string>
00086 #include <iostream>
00087 #define TIXML_STRING std::string
00088 #define TIXML_ISTREAM std::istream
00089 #define TIXML_OSTREAM std::ostream
00090 #else
00091 #include "tinystr.h"
00092 #define TIXML_STRING TiXmlString
00093 #define TIXML_OSTREAM TiXmlOutStream
00094 #endif
00095
00096
00097
00098
00099
00100
00101 #define TIXML_SAFE // TinyXml isn't fully buffer overrun protected, safe code. This is work in progress.
00102 #ifdef TIXML_SAFE
00103 #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
00104
00105 #define TIXML_SNPRINTF _snprintf_s
00106 #define TIXML_SNSCANF _snscanf_s
00107 #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
00108
00109
00110 #define TIXML_SNPRINTF _snprintf
00111 #define TIXML_SNSCANF _snscanf
00112 #elif defined(__GNUC__) && (__GNUC__ >= 3 )
00113
00114
00115 #define TIXML_SNPRINTF snprintf
00116 #define TIXML_SNSCANF snscanf
00117 #endif
00118 #endif
00119
00120 namespace RTT { namespace marsh {
00121
00122 class TiXmlDocument;
00123 class TiXmlElement;
00124 class TiXmlComment;
00125 class TiXmlUnknown;
00126 class TiXmlAttribute;
00127 class TiXmlText;
00128 class TiXmlDeclaration;
00129 class TiXmlParsingData;
00130
00131 const int TIXML_MAJOR_VERSION = 2;
00132 const int TIXML_MINOR_VERSION = 4;
00133 const int TIXML_PATCH_VERSION = 3;
00134
00135
00136
00137
00138 struct TiXmlCursor
00139 {
00140 TiXmlCursor() { Clear(); }
00141 void Clear() { row = col = -1; }
00142
00143 int row;
00144 int col;
00145 };
00146
00147
00148
00149 enum
00150 {
00151 TIXML_SUCCESS,
00152 TIXML_NO_ATTRIBUTE,
00153 TIXML_WRONG_TYPE
00154 };
00155
00156
00157
00158 enum TiXmlEncoding
00159 {
00160 TIXML_ENCODING_UNKNOWN,
00161 TIXML_ENCODING_UTF8,
00162 TIXML_ENCODING_LEGACY
00163 };
00164
00165 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
00166
00189 class TiXmlBase
00190 {
00191 friend class TiXmlNode;
00192 friend class TiXmlElement;
00193 friend class TiXmlDocument;
00194
00195 public:
00196 TiXmlBase() : userData(0) {}
00197 virtual ~TiXmlBase() {}
00198
00204 virtual void Print( FILE* cfile, int depth ) const = 0;
00205
00212 static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; }
00213
00215 static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; }
00216
00235 int Row() const { return location.row + 1; }
00236 int Column() const { return location.col + 1; }
00237
00238 void SetUserData( void* user ) { userData = user; }
00239 void* GetUserData() { return userData; }
00240
00241
00242
00243 static const int utf8ByteTable[256];
00244
00245 virtual const char* Parse( const char* p,
00246 TiXmlParsingData* data,
00247 TiXmlEncoding encoding ) = 0;
00248
00249 enum
00250 {
00251 TIXML_NO_ERROR = 0,
00252 TIXML_ERROR,
00253 TIXML_ERROR_OPENING_FILE,
00254 TIXML_ERROR_OUT_OF_MEMORY,
00255 TIXML_ERROR_PARSING_ELEMENT,
00256 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00257 TIXML_ERROR_READING_ELEMENT_VALUE,
00258 TIXML_ERROR_READING_ATTRIBUTES,
00259 TIXML_ERROR_PARSING_EMPTY,
00260 TIXML_ERROR_READING_END_TAG,
00261 TIXML_ERROR_PARSING_UNKNOWN,
00262 TIXML_ERROR_PARSING_COMMENT,
00263 TIXML_ERROR_PARSING_DECLARATION,
00264 TIXML_ERROR_DOCUMENT_EMPTY,
00265 TIXML_ERROR_EMBEDDED_NULL,
00266 TIXML_ERROR_PARSING_CDATA,
00267
00268 TIXML_ERROR_STRING_COUNT
00269 };
00270
00271 protected:
00272
00273
00274
00275 class StringToBuffer
00276 {
00277 public:
00278 StringToBuffer( const TIXML_STRING& str );
00279 ~StringToBuffer();
00280 char* buffer;
00281 };
00282
00283 static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
00284 inline static bool IsWhiteSpace( char c )
00285 {
00286 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
00287 }
00288 inline static bool IsWhiteSpace( int c )
00289 {
00290 if ( c < 256 )
00291 return IsWhiteSpace( (char) c );
00292 return false;
00293 }
00294
00295 virtual void StreamOut (TIXML_OSTREAM *) const = 0;
00296
00297 #ifdef TIXML_USE_STL
00298 static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
00299 static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
00300 #endif
00301
00302
00303
00304
00305
00306 static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
00307
00308
00309
00310
00311 static const char* ReadText( const char* in,
00312 TIXML_STRING* text,
00313 bool ignoreWhiteSpace,
00314 const char* endTag,
00315 bool ignoreCase,
00316 TiXmlEncoding encoding );
00317
00318
00319 static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
00320
00321
00322
00323 inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
00324 {
00325 assert( p );
00326 if ( encoding == TIXML_ENCODING_UTF8 )
00327 {
00328 *length = utf8ByteTable[ *((unsigned char*)p) ];
00329 assert( *length >= 0 && *length < 5 );
00330 }
00331 else
00332 {
00333 *length = 1;
00334 }
00335
00336 if ( *length == 1 )
00337 {
00338 if ( *p == '&' )
00339 return GetEntity( p, _value, length, encoding );
00340 *_value = *p;
00341 return p+1;
00342 }
00343 else if ( *length )
00344 {
00345
00346
00347 for( int i=0; p[i] && i<*length; ++i ) {
00348 _value[i] = p[i];
00349 }
00350 return p + (*length);
00351 }
00352 else
00353 {
00354
00355 return 0;
00356 }
00357 }
00358
00359
00360
00361 static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out );
00362
00363 static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
00364
00365
00366
00367
00368 static bool StringEqual( const char* p,
00369 const char* endTag,
00370 bool ignoreCase,
00371 TiXmlEncoding encoding );
00372
00373 static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00374
00375 TiXmlCursor location;
00376
00378 void* userData;
00379
00380
00381
00382 static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
00383 static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
00384 inline static int ToLower( int v, TiXmlEncoding encoding )
00385 {
00386 if ( encoding == TIXML_ENCODING_UTF8 )
00387 {
00388 if ( v < 128 ) return tolower( v );
00389 return v;
00390 }
00391 else
00392 {
00393 return tolower( v );
00394 }
00395 }
00396 static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
00397
00398 private:
00399 TiXmlBase( const TiXmlBase& );
00400 void operator=( const TiXmlBase& base );
00401
00402 struct Entity
00403 {
00404 const char* str;
00405 unsigned int strLength;
00406 char chr;
00407 };
00408 enum
00409 {
00410 NUM_ENTITY = 5,
00411 MAX_ENTITY_LENGTH = 6
00412
00413 };
00414 static Entity entity[ NUM_ENTITY ];
00415 static bool condenseWhiteSpace;
00416 };
00417
00418
00425 class TiXmlNode : public TiXmlBase
00426 {
00427 friend class TiXmlDocument;
00428 friend class TiXmlElement;
00429
00430 public:
00431 #ifdef TIXML_USE_STL
00432
00436 friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
00437
00454 friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
00455
00457 friend std::string& operator<< (std::string& out, const TiXmlNode& base );
00458
00459 #else
00460
00461 friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base);
00462 #endif
00463
00467 enum NodeType
00468 {
00469 DOCUMENT,
00470 ELEMENT,
00471 COMMENT,
00472 UNKNOWN,
00473 TEXT,
00474 DECLARATION,
00475 TYPECOUNT
00476 };
00477
00478 virtual ~TiXmlNode();
00479
00492 const char *Value() const { return value.c_str (); }
00493
00494 #ifdef TIXML_USE_STL
00495
00499 const std::string& ValueStr() const { return value; }
00500 #endif
00501
00511 void SetValue(const char * _value) { value = _value;}
00512
00513 #ifdef TIXML_USE_STL
00514
00515 void SetValue( const std::string& _value ) { value = _value; }
00516 #endif
00517
00519 void Clear();
00520
00522 TiXmlNode* Parent() { return parent; }
00523 const TiXmlNode* Parent() const { return parent; }
00524
00525 const TiXmlNode* FirstChild() const { return firstChild; }
00526 TiXmlNode* FirstChild() { return firstChild; }
00527 const TiXmlNode* FirstChild( const char * value ) const;
00528 TiXmlNode* FirstChild( const char * value );
00529
00530 const TiXmlNode* LastChild() const { return lastChild; }
00531 TiXmlNode* LastChild() { return lastChild; }
00532 const TiXmlNode* LastChild( const char * value ) const;
00533 TiXmlNode* LastChild( const char * value );
00534
00535 #ifdef TIXML_USE_STL
00536 const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); }
00537 TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); }
00538 const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); }
00539 TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); }
00540 #endif
00541
00558 const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
00559 TiXmlNode* IterateChildren( TiXmlNode* previous );
00560
00562 const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
00563 TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous );
00564
00565 #ifdef TIXML_USE_STL
00566 const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); }
00567 TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); }
00568 #endif
00569
00573 TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
00574
00575
00585 TiXmlNode* LinkEndChild( TiXmlNode* addThis );
00586
00590 TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
00591
00595 TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
00596
00600 TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
00601
00603 bool RemoveChild( TiXmlNode* removeThis );
00604
00606 const TiXmlNode* PreviousSibling() const { return prev; }
00607 TiXmlNode* PreviousSibling() { return prev; }
00608
00610 const TiXmlNode* PreviousSibling( const char * ) const;
00611 TiXmlNode* PreviousSibling( const char * );
00612
00613 #ifdef TIXML_USE_STL
00614 const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); }
00615 TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); }
00616 const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); }
00617 TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); }
00618 #endif
00619
00621 const TiXmlNode* NextSibling() const { return next; }
00622 TiXmlNode* NextSibling() { return next; }
00623
00625 const TiXmlNode* NextSibling( const char * ) const;
00626 TiXmlNode* NextSibling( const char * );
00627
00632 const TiXmlElement* NextSiblingElement() const;
00633 TiXmlElement* NextSiblingElement();
00634
00639 const TiXmlElement* NextSiblingElement( const char * ) const;
00640 TiXmlElement* NextSiblingElement( const char * );
00641
00642 #ifdef TIXML_USE_STL
00643 const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); }
00644 TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); }
00645 #endif
00646
00648 const TiXmlElement* FirstChildElement() const;
00649 TiXmlElement* FirstChildElement();
00650
00652 const TiXmlElement* FirstChildElement( const char * value ) const;
00653 TiXmlElement* FirstChildElement( const char * value );
00654
00655 #ifdef TIXML_USE_STL
00656 const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); }
00657 TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); }
00658 #endif
00659
00664 int Type() const { return type; }
00665
00669 const TiXmlDocument* GetDocument() const;
00670 TiXmlDocument* GetDocument();
00671
00673 bool NoChildren() const { return !firstChild; }
00674
00675 virtual const TiXmlDocument* ToDocument() const { return 0; }
00676 virtual const TiXmlElement* ToElement() const { return 0; }
00677 virtual const TiXmlComment* ToComment() const { return 0; }
00678 virtual const TiXmlUnknown* ToUnknown() const { return 0; }
00679 virtual const TiXmlText* ToText() const { return 0; }
00680 virtual const TiXmlDeclaration* ToDeclaration() const { return 0; }
00681
00682 virtual TiXmlDocument* ToDocument() { return 0; }
00683 virtual TiXmlElement* ToElement() { return 0; }
00684 virtual TiXmlComment* ToComment() { return 0; }
00685 virtual TiXmlUnknown* ToUnknown() { return 0; }
00686 virtual TiXmlText* ToText() { return 0; }
00687 virtual TiXmlDeclaration* ToDeclaration() { return 0; }
00688
00692 virtual TiXmlNode* Clone() const = 0;
00693
00694 protected:
00695 TiXmlNode( NodeType _type );
00696
00697
00698
00699 void CopyTo( TiXmlNode* target ) const;
00700
00701 #ifdef TIXML_USE_STL
00702
00703 virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
00704 #endif
00705
00706
00707 TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
00708
00709 TiXmlNode* parent;
00710 NodeType type;
00711
00712 TiXmlNode* firstChild;
00713 TiXmlNode* lastChild;
00714
00715 TIXML_STRING value;
00716
00717 TiXmlNode* prev;
00718 TiXmlNode* next;
00719
00720 private:
00721 TiXmlNode( const TiXmlNode& );
00722 void operator=( const TiXmlNode& base );
00723 };
00724
00725
00733 class TiXmlAttribute : public TiXmlBase
00734 {
00735 friend class TiXmlAttributeSet;
00736
00737 public:
00739 TiXmlAttribute() : TiXmlBase()
00740 {
00741 document = 0;
00742 prev = next = 0;
00743 }
00744
00745 #ifdef TIXML_USE_STL
00746
00747 TiXmlAttribute( const std::string& _name, const std::string& _value )
00748 {
00749 name = _name;
00750 value = _value;
00751 document = 0;
00752 prev = next = 0;
00753 }
00754 #endif
00755
00757 TiXmlAttribute( const char * _name, const char * _value )
00758 {
00759 name = _name;
00760 value = _value;
00761 document = 0;
00762 prev = next = 0;
00763 }
00764
00765 const char* Name() const { return name.c_str (); }
00766 const char* Value() const { return value.c_str (); }
00767 int IntValue() const;
00768 double DoubleValue() const;
00769
00770
00771 const TIXML_STRING& NameTStr() const { return name; }
00772
00782 int QueryIntValue( int* _value ) const;
00784 int QueryDoubleValue( double* _value ) const;
00785
00786 void SetName( const char* _name ) { name = _name; }
00787 void SetValue( const char* _value ) { value = _value; }
00788
00789 void SetIntValue( int _value );
00790 void SetDoubleValue( double _value );
00791
00792 #ifdef TIXML_USE_STL
00793
00794 void SetName( const std::string& _name ) { name = _name; }
00796 void SetValue( const std::string& _value ) { value = _value; }
00797 #endif
00798
00800 const TiXmlAttribute* Next() const;
00801 TiXmlAttribute* Next();
00803 const TiXmlAttribute* Previous() const;
00804 TiXmlAttribute* Previous();
00805
00806 bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
00807 bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
00808 bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
00809
00810
00811
00812
00813 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
00814
00815
00816 virtual void Print( FILE* cfile, int depth ) const;
00817
00818 virtual void StreamOut( TIXML_OSTREAM * out ) const;
00819
00820
00821 void SetDocument( TiXmlDocument* doc ) { document = doc; }
00822
00823 private:
00824 TiXmlAttribute( const TiXmlAttribute& );
00825 void operator=( const TiXmlAttribute& base );
00826
00827 TiXmlDocument* document;
00828 TIXML_STRING name;
00829 TIXML_STRING value;
00830 TiXmlAttribute* prev;
00831 TiXmlAttribute* next;
00832 };
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847 class TiXmlAttributeSet
00848 {
00849 public:
00850 TiXmlAttributeSet();
00851 ~TiXmlAttributeSet();
00852
00853 void Add( TiXmlAttribute* attribute );
00854 void Remove( TiXmlAttribute* attribute );
00855
00856 const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00857 TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00858 const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00859 TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00860
00861 const TiXmlAttribute* Find( const TIXML_STRING& name ) const;
00862 TiXmlAttribute* Find( const TIXML_STRING& name );
00863
00864 private:
00865
00866
00867 TiXmlAttributeSet( const TiXmlAttributeSet& );
00868 void operator=( const TiXmlAttributeSet& );
00869
00870 TiXmlAttribute sentinel;
00871 };
00872
00873
00878 class TiXmlElement : public TiXmlNode
00879 {
00880 public:
00882 TiXmlElement (const char * in_value);
00883
00884 #ifdef TIXML_USE_STL
00885
00886 TiXmlElement( const std::string& _value );
00887 #endif
00888
00889 TiXmlElement( const TiXmlElement& );
00890
00891 void operator=( const TiXmlElement& base );
00892
00893 virtual ~TiXmlElement();
00894
00898 const char* Attribute( const char* name ) const;
00899
00906 const char* Attribute( const char* name, int* i ) const;
00907
00914 const char* Attribute( const char* name, double* d ) const;
00915
00923 int QueryIntAttribute( const char* name, int* _value ) const;
00925 int QueryDoubleAttribute( const char* name, double* _value ) const;
00927 int QueryFloatAttribute( const char* name, float* _value ) const {
00928 double d;
00929 int result = QueryDoubleAttribute( name, &d );
00930 if ( result == TIXML_SUCCESS ) {
00931 *_value = (float)d;
00932 }
00933 return result;
00934 }
00935
00939 void SetAttribute( const char* name, const char * _value );
00940
00941 #ifdef TIXML_USE_STL
00942 const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); }
00943 const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); }
00944 const char* Attribute( const std::string& name, double* d ) const { return Attribute( name.c_str(), d ); }
00945 int QueryIntAttribute( const std::string& name, int* _value ) const { return QueryIntAttribute( name.c_str(), _value ); }
00946 int QueryDoubleAttribute( const std::string& name, double* _value ) const { return QueryDoubleAttribute( name.c_str(), _value ); }
00947
00949 void SetAttribute( const std::string& name, const std::string& _value );
00951 void SetAttribute( const std::string& name, int _value );
00952 #endif
00953
00957 void SetAttribute( const char * name, int value );
00958
00962 void SetDoubleAttribute( const char * name, double value );
00963
00966 void RemoveAttribute( const char * name );
00967 #ifdef TIXML_USE_STL
00968 void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); }
00969 #endif
00970
00971 const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); }
00972 TiXmlAttribute* FirstAttribute() { return attributeSet.First(); }
00973 const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); }
00974 TiXmlAttribute* LastAttribute() { return attributeSet.Last(); }
00975
01008 const char* GetText() const;
01009
01011 virtual TiXmlNode* Clone() const;
01012
01013 virtual void Print( FILE* cfile, int depth ) const;
01014
01015
01016
01017
01018 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01019
01020 virtual const TiXmlElement* ToElement() const { return this; }
01021 virtual TiXmlElement* ToElement() { return this; }
01022
01023 protected:
01024
01025 void CopyTo( TiXmlElement* target ) const;
01026 void ClearThis();
01027
01028
01029 #ifdef TIXML_USE_STL
01030 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01031 #endif
01032 virtual void StreamOut( TIXML_OSTREAM * out ) const;
01033
01034
01035
01036
01037
01038 const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01039
01040 private:
01041
01042 TiXmlAttributeSet attributeSet;
01043 };
01044
01045
01048 class TiXmlComment : public TiXmlNode
01049 {
01050 public:
01052 TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
01053 TiXmlComment( const TiXmlComment& );
01054 void operator=( const TiXmlComment& base );
01055
01056 virtual ~TiXmlComment() {}
01057
01059 virtual TiXmlNode* Clone() const;
01061 virtual void Print( FILE* cfile, int depth ) const;
01062
01063
01064
01065
01066 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01067
01068 virtual const TiXmlComment* ToComment() const { return this; }
01069 virtual TiXmlComment* ToComment() { return this; }
01070
01071 protected:
01072 void CopyTo( TiXmlComment* target ) const;
01073
01074
01075 #ifdef TIXML_USE_STL
01076 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01077 #endif
01078 virtual void StreamOut( TIXML_OSTREAM * out ) const;
01079
01080 private:
01081
01082 };
01083
01084
01090 class TiXmlText : public TiXmlNode
01091 {
01092 friend class TiXmlElement;
01093 public:
01098 TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
01099 {
01100 SetValue( initValue );
01101 cdata = false;
01102 }
01103 virtual ~TiXmlText() {}
01104
01105 #ifdef TIXML_USE_STL
01106
01107 TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
01108 {
01109 SetValue( initValue );
01110 cdata = false;
01111 }
01112 #endif
01113
01114 TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
01115 void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
01116
01118 virtual void Print( FILE* cfile, int depth ) const;
01119
01121 bool CDATA() { return cdata; }
01123 void SetCDATA( bool _cdata ) { cdata = _cdata; }
01124
01125 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01126
01127 virtual const TiXmlText* ToText() const { return this; }
01128 virtual TiXmlText* ToText() { return this; }
01129
01130 protected :
01132 virtual TiXmlNode* Clone() const;
01133 void CopyTo( TiXmlText* target ) const;
01134
01135 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
01136 bool Blank() const;
01137
01138 #ifdef TIXML_USE_STL
01139 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01140 #endif
01141
01142 private:
01143 bool cdata;
01144 };
01145
01146
01160 class TiXmlDeclaration : public TiXmlNode
01161 {
01162 public:
01164 TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
01165
01166 #ifdef TIXML_USE_STL
01167
01168 TiXmlDeclaration( const std::string& _version,
01169 const std::string& _encoding,
01170 const std::string& _standalone );
01171 #endif
01172
01174 TiXmlDeclaration( const char* _version,
01175 const char* _encoding,
01176 const char* _standalone );
01177
01178 TiXmlDeclaration( const TiXmlDeclaration& copy );
01179 void operator=( const TiXmlDeclaration& copy );
01180
01181 virtual ~TiXmlDeclaration() {}
01182
01184 const char *Version() const { return version.c_str (); }
01186 const char *Encoding() const { return encoding.c_str (); }
01188 const char *Standalone() const { return standalone.c_str (); }
01189
01191 virtual TiXmlNode* Clone() const;
01193 virtual void Print( FILE* cfile, int depth ) const;
01194
01195 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01196
01197 virtual const TiXmlDeclaration* ToDeclaration() const { return this; }
01198 virtual TiXmlDeclaration* ToDeclaration() { return this; }
01199
01200 protected:
01201 void CopyTo( TiXmlDeclaration* target ) const;
01202
01203 #ifdef TIXML_USE_STL
01204 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01205 #endif
01206 virtual void StreamOut ( TIXML_OSTREAM * out) const;
01207
01208 private:
01209
01210 TIXML_STRING version;
01211 TIXML_STRING encoding;
01212 TIXML_STRING standalone;
01213 };
01214
01215
01223 class TiXmlUnknown : public TiXmlNode
01224 {
01225 public:
01226 TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
01227 virtual ~TiXmlUnknown() {}
01228
01229 TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
01230 void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
01231
01233 virtual TiXmlNode* Clone() const;
01235 virtual void Print( FILE* cfile, int depth ) const;
01236
01237 virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01238
01239 virtual const TiXmlUnknown* ToUnknown() const { return this; }
01240 virtual TiXmlUnknown* ToUnknown() { return this; }
01241
01242 protected:
01243 void CopyTo( TiXmlUnknown* target ) const;
01244
01245 #ifdef TIXML_USE_STL
01246 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01247 #endif
01248 virtual void StreamOut ( TIXML_OSTREAM * out ) const;
01249
01250 private:
01251
01252 };
01253
01254
01259 class TiXmlDocument : public TiXmlNode
01260 {
01261 public:
01263 TiXmlDocument();
01265 TiXmlDocument( const char * documentName );
01266
01267 #ifdef TIXML_USE_STL
01268
01269 TiXmlDocument( const std::string& documentName );
01270 #endif
01271
01272 TiXmlDocument( const TiXmlDocument& copy );
01273 void operator=( const TiXmlDocument& copy );
01274
01275 virtual ~TiXmlDocument() {}
01276
01281 bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01283 bool SaveFile() const;
01285 bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01287 bool SaveFile( const char * filename ) const;
01293 bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01295 bool SaveFile( FILE* ) const;
01296
01297 #ifdef TIXML_USE_STL
01298 bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )
01299 {
01300 StringToBuffer f( filename );
01301 return ( f.buffer && LoadFile( f.buffer, encoding ));
01302 }
01303 bool SaveFile( const std::string& filename ) const
01304 {
01305 StringToBuffer f( filename );
01306 return ( f.buffer && SaveFile( f.buffer ));
01307 }
01308 #endif
01309
01314 virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01315
01320 const TiXmlElement* RootElement() const { return FirstChildElement(); }
01321 TiXmlElement* RootElement() { return FirstChildElement(); }
01322
01328 bool Error() const { return error; }
01329
01331 const char * ErrorDesc() const { return errorDesc.c_str (); }
01332
01336 int ErrorId() const { return errorId; }
01337
01345 int ErrorRow() { return errorLocation.row+1; }
01346 int ErrorCol() { return errorLocation.col+1; }
01347
01372 void SetTabSize( int _tabsize ) { tabsize = _tabsize; }
01373
01374 int TabSize() const { return tabsize; }
01375
01379 void ClearError() { error = false;
01380 errorId = 0;
01381 errorDesc = "";
01382 errorLocation.row = errorLocation.col = 0;
01383
01384 }
01385
01387 void Print() const { Print( stdout, 0 ); }
01388
01390 virtual void Print( FILE* cfile, int depth = 0 ) const;
01391
01392 void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01393
01394 virtual const TiXmlDocument* ToDocument() const { return this; }
01395 virtual TiXmlDocument* ToDocument() { return this; }
01396
01397 protected :
01398 virtual void StreamOut ( TIXML_OSTREAM * out) const;
01399
01400 virtual TiXmlNode* Clone() const;
01401 #ifdef TIXML_USE_STL
01402 virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag );
01403 #endif
01404
01405 private:
01406 void CopyTo( TiXmlDocument* target ) const;
01407
01408 bool error;
01409 int errorId;
01410 TIXML_STRING errorDesc;
01411 int tabsize;
01412 TiXmlCursor errorLocation;
01413 bool useMicrosoftBOM;
01414 };
01415
01416
01497 class TiXmlHandle
01498 {
01499 public:
01501 TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
01503 TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
01504 TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
01505
01507 TiXmlHandle FirstChild() const;
01509 TiXmlHandle FirstChild( const char * value ) const;
01511 TiXmlHandle FirstChildElement() const;
01513 TiXmlHandle FirstChildElement( const char * value ) const;
01514
01518 TiXmlHandle Child( const char* value, int index ) const;
01522 TiXmlHandle Child( int index ) const;
01527 TiXmlHandle ChildElement( const char* value, int index ) const;
01532 TiXmlHandle ChildElement( int index ) const;
01533
01534 #ifdef TIXML_USE_STL
01535 TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); }
01536 TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); }
01537
01538 TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); }
01539 TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
01540 #endif
01541
01543 TiXmlNode* Node() const { return node; }
01545 TiXmlElement* Element() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
01547 TiXmlText* Text() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
01549 TiXmlUnknown* Unknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
01550
01551 private:
01552 TiXmlNode* node;
01553 };
01554
01555 }}
01556
01557 #ifdef _MSC_VER
01558 #pragma warning( pop )
01559 #endif
01560
01561 #endif
01562