tinyxml.h
Go to the documentation of this file.
00001 /*
00002 www.sourceforge.net/projects/tinyxml
00003 Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
00004 
00005 This software is provided 'as-is', without any express or implied
00006 warranty. In no event will the authors be held liable for any
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to anyone to use this software for any
00010 purpose, including commercial applications, and to alter it and
00011 redistribute it freely, subject to the following restrictions:
00012 
00013 1. The origin of this software must not be misrepresented; you must
00014 not claim that you wrote the original software. If you use this
00015 software in a product, an acknowledgment in the product documentation
00016 would be appreciated but is not required.
00017 
00018 2. Altered source versions must be plainly marked as such, and
00019 must not be misrepresented as being the original software.
00020 
00021 3. This notice may not be removed or altered from any source
00022 distribution.
00023 */
00024 
00025 
00026 #ifndef TINYXML_INCLUDED
00027 #define TINYXML_INCLUDED
00028 
00029 #if defined(_SYSTEM_WIN32_) && !defined(_IC_STATIC_)
00030 # ifdef TINYXML_EXPORT
00031 #  define TINYXML_IMPORT_EXPORT __declspec(dllexport)
00032 # else
00033 #  define TINYXML_IMPORT_EXPORT __declspec(dllimport)
00034 # endif
00035 #elif defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 2) && !defined(_IC_STATIC_)
00036 # define TINYXML_IMPORT_EXPORT __attribute__ ((visibility("default")))
00037 #else
00038 # define TINYXML_IMPORT_EXPORT
00039 #endif
00040 
00041 #ifdef _MSC_VER
00042 #pragma warning( push )
00043 #pragma warning( disable : 4530 )
00044 #pragma warning( disable : 4786 )
00045 #pragma warning( disable : 4251 )
00046 #endif
00047 
00048 #include <ctype.h>
00049 #include <stdio.h>
00050 #include <stdlib.h>
00051 #include <string.h>
00052 #include <assert.h>
00053 
00054 // Help out windows:
00055 #if defined( _DEBUG ) && !defined( DEBUG )
00056 #define DEBUG
00057 #endif
00058 
00059 #ifdef TIXML_USE_STL
00060         #include <string>
00061         #include <iostream>
00062         #include <sstream>
00063         #define TIXML_STRING            std::string
00064 #else
00065         #include "tinystr.h"
00066         #define TIXML_STRING            TiXmlString
00067 #endif
00068 
00069 // Deprecated library function hell. Compilers want to use the
00070 // new safe versions. This probably doesn't fully address the problem,
00071 // but it gets closer. There are too many compilers for me to fully
00072 // test. If you get compilation troubles, undefine TIXML_SAFE
00073 #define TIXML_SAFE
00074 
00075 #ifdef TIXML_SAFE
00076         #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
00077                 // Microsoft visual studio, version 2005 and higher.
00078                 #define TIXML_SNPRINTF _snprintf_s
00079                 #define TIXML_SSCANF   sscanf_s
00080         #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
00081                 // Microsoft visual studio, version 6 and higher.
00082                 //#pragma message( "Using _sn* functions." )
00083                 #define TIXML_SNPRINTF _snprintf
00084                 #define TIXML_SSCANF   sscanf
00085         #elif defined(__GNUC__) && (__GNUC__ >= 3 )
00086                 // GCC version 3 and higher.s
00087                 //#warning( "Using sn* functions." )
00088                 #define TIXML_SNPRINTF snprintf
00089                 #define TIXML_SSCANF   sscanf
00090         #else
00091                 #define TIXML_SNPRINTF snprintf
00092                 #define TIXML_SSCANF   sscanf
00093         #endif
00094 #endif  
00095 
00096 class TiXmlDocument;
00097 class TiXmlElement;
00098 class TiXmlComment;
00099 class TiXmlUnknown;
00100 class TiXmlAttribute;
00101 class TiXmlText;
00102 class TiXmlDeclaration;
00103 class TiXmlParsingData;
00104 
00105 const int TIXML_MAJOR_VERSION = 2;
00106 const int TIXML_MINOR_VERSION = 6;
00107 const int TIXML_PATCH_VERSION = 1;
00108 
00109 /*      Internal structure for tracking location of items 
00110         in the XML file.
00111 */
00112 struct TINYXML_IMPORT_EXPORT TiXmlCursor
00113 {
00114         TiXmlCursor()           { Clear(); }
00115         void Clear()            { row = col = -1; }
00116 
00117         int row;        // 0 based.
00118         int col;        // 0 based.
00119 };
00120 
00121 
00141 class TINYXML_IMPORT_EXPORT TiXmlVisitor
00142 {
00143 public:
00144         virtual ~TiXmlVisitor() {}
00145 
00147         virtual bool VisitEnter( const TiXmlDocument& /*doc*/ )                 { return true; }
00149         virtual bool VisitExit( const TiXmlDocument& /*doc*/ )                  { return true; }
00150 
00152         virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ )    { return true; }
00154         virtual bool VisitExit( const TiXmlElement& /*element*/ )               { return true; }
00155 
00157         virtual bool Visit( const TiXmlDeclaration& /*declaration*/ )   { return true; }
00159         virtual bool Visit( const TiXmlText& /*text*/ )                                 { return true; }
00161         virtual bool Visit( const TiXmlComment& /*comment*/ )                   { return true; }
00163         virtual bool Visit( const TiXmlUnknown& /*unknown*/ )                   { return true; }
00164 };
00165 
00166 // Only used by Attribute::Query functions
00167 enum 
00168 { 
00169         TIXML_SUCCESS,
00170         TIXML_NO_ATTRIBUTE,
00171         TIXML_WRONG_TYPE
00172 };
00173 
00174 
00175 // Used by the parsing routines.
00176 enum TINYXML_IMPORT_EXPORT TiXmlEncoding
00177 {
00178         TIXML_ENCODING_UNKNOWN,
00179         TIXML_ENCODING_UTF8,
00180         TIXML_ENCODING_LEGACY
00181 };
00182 
00183 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
00184 
00207 class TINYXML_IMPORT_EXPORT TiXmlBase
00208 {
00209         friend class TiXmlNode;
00210         friend class TiXmlElement;
00211         friend class TiXmlDocument;
00212 
00213 public:
00214         TiXmlBase()     :       userData(0)             {}
00215         virtual ~TiXmlBase()                    {}
00216 
00226         virtual void Print( FILE* cfile, int depth ) const = 0;
00227 
00234         static void SetCondenseWhiteSpace( bool condense )              { condenseWhiteSpace = condense; }
00235 
00237         static bool IsWhiteSpaceCondensed()                                             { return condenseWhiteSpace; }
00238 
00257         int Row() const                 { return location.row + 1; }
00258         int Column() const              { return location.col + 1; }    
00259 
00260         void  SetUserData( void* user )                 { userData = user; }    
00261         void* GetUserData()                                             { return userData; }    
00262         const void* GetUserData() const                 { return userData; }    
00263 
00264         // Table that returs, for a given lead byte, the total number of bytes
00265         // in the UTF-8 sequence.
00266         static const int utf8ByteTable[256];
00267 
00268         virtual const char* Parse(      const char* p, 
00269                                                                 TiXmlParsingData* data, 
00270                                                                 TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
00271 
00275         static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
00276 
00277         enum
00278         {
00279                 TIXML_NO_ERROR = 0,
00280                 TIXML_ERROR,
00281                 TIXML_ERROR_OPENING_FILE,
00282                 TIXML_ERROR_PARSING_ELEMENT,
00283                 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00284                 TIXML_ERROR_READING_ELEMENT_VALUE,
00285                 TIXML_ERROR_READING_ATTRIBUTES,
00286                 TIXML_ERROR_PARSING_EMPTY,
00287                 TIXML_ERROR_READING_END_TAG,
00288                 TIXML_ERROR_PARSING_UNKNOWN,
00289                 TIXML_ERROR_PARSING_COMMENT,
00290                 TIXML_ERROR_PARSING_DECLARATION,
00291                 TIXML_ERROR_DOCUMENT_EMPTY,
00292                 TIXML_ERROR_EMBEDDED_NULL,
00293                 TIXML_ERROR_PARSING_CDATA,
00294                 TIXML_ERROR_DOCUMENT_TOP_ONLY,
00295 
00296                 TIXML_ERROR_STRING_COUNT
00297         };
00298 
00299 protected:
00300 
00301         static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
00302 
00303         static bool IsWhiteSpace( char c )              
00304         { 
00305                 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 
00306         }
00307         static bool IsWhiteSpace( int c )
00308         {
00309                 if ( c < 256 )
00310                         return IsWhiteSpace( (char) c );
00311                 return false;   // Again, only truly correct for English/Latin...but usually works.
00312         }
00313 
00314         #ifdef TIXML_USE_STL
00315         static bool     StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
00316         static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
00317         #endif
00318 
00319         /*      Reads an XML name into the string provided. Returns
00320                 a pointer just past the last character of the name,
00321                 or 0 if the function has an error.
00322         */
00323         static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
00324 
00325         /*      Reads text. Returns a pointer past the given end tag.
00326                 Wickedly complex options, but it keeps the (sensitive) code in one place.
00327         */
00328         static const char* ReadText(    const char* in,                         // where to start
00329                                                                         TIXML_STRING* text,                     // the string read
00330                                                                         bool ignoreWhiteSpace,          // whether to keep the white space
00331                                                                         const char* endTag,                     // what ends this text
00332                                                                         bool ignoreCase,                        // whether to ignore case in the end tag
00333                                                                         TiXmlEncoding encoding );       // the current encoding
00334 
00335         // If an entity has been found, transform it into a character.
00336         static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
00337 
00338         // Get a character, while interpreting entities.
00339         // The length can be from 0 to 4 bytes.
00340         static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
00341         {
00342                 assert( p );
00343                 if ( encoding == TIXML_ENCODING_UTF8 )
00344                 {
00345                         *length = utf8ByteTable[ *((const unsigned char*)p) ];
00346                         assert( *length >= 0 && *length < 5 );
00347                 }
00348                 else
00349                 {
00350                         *length = 1;
00351                 }
00352 
00353                 if ( *length == 1 )
00354                 {
00355                         if ( *p == '&' )
00356                                 return GetEntity( p, _value, length, encoding );
00357                         *_value = *p;
00358                         return p+1;
00359                 }
00360                 else if ( *length )
00361                 {
00362                         //strncpy( _value, p, *length );        // lots of compilers don't like this function (unsafe),
00363                                                                                                 // and the null terminator isn't needed
00364                         for( int i=0; p[i] && i<*length; ++i ) {
00365                                 _value[i] = p[i];
00366                         }
00367                         return p + (*length);
00368                 }
00369                 else
00370                 {
00371                         // Not valid text.
00372                         return 0;
00373                 }
00374         }
00375 
00376         // Return true if the next characters in the stream are any of the endTag sequences.
00377         // Ignore case only works for english, and should only be relied on when comparing
00378         // to English words: StringEqual( p, "version", true ) is fine.
00379         static bool StringEqual(        const char* p,
00380                                                                 const char* endTag,
00381                                                                 bool ignoreCase,
00382                                                                 TiXmlEncoding encoding );
00383 
00384         static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00385 
00386         TiXmlCursor location;
00387 
00389         void*                   userData;
00390         
00391         // None of these methods are reliable for any language except English.
00392         // Good for approximation, not great for accuracy.
00393         static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
00394         static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
00395         static int ToLower( int v, TiXmlEncoding encoding )
00396         {
00397                 if ( encoding == TIXML_ENCODING_UTF8 )
00398                 {
00399                         if ( v < 128 ) return tolower( v );
00400                         return v;
00401                 }
00402                 else
00403                 {
00404                         return tolower( v );
00405                 }
00406         }
00407         static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
00408 
00409 private:
00410         TiXmlBase( const TiXmlBase& );                          // not implemented.
00411         void operator=( const TiXmlBase& base );        // not allowed.
00412 
00413         struct Entity
00414         {
00415                 const char*     str;
00416                 unsigned int    strLength;
00417                 char                chr;
00418         };
00419         enum
00420         {
00421                 NUM_ENTITY = 5,
00422                 MAX_ENTITY_LENGTH = 6
00423 
00424         };
00425         static Entity entity[ NUM_ENTITY ];
00426         static bool condenseWhiteSpace;
00427 };
00428 
00429 
00436 class TINYXML_IMPORT_EXPORT TiXmlNode : public TiXmlBase
00437 {
00438         friend class TiXmlDocument;
00439         friend class TiXmlElement;
00440 
00441 public:
00442         #ifdef TIXML_USE_STL    
00443 
00447             TINYXML_IMPORT_EXPORT friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
00448 
00465             TINYXML_IMPORT_EXPORT friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
00466 
00468                 TINYXML_IMPORT_EXPORT friend std::string& operator<< (std::string& out, const TiXmlNode& base );
00469 
00470         #endif
00471 
00475         enum NodeType
00476         {
00477                 TINYXML_DOCUMENT,
00478                 TINYXML_ELEMENT,
00479                 TINYXML_COMMENT,
00480                 TINYXML_UNKNOWN,
00481                 TINYXML_TEXT,
00482                 TINYXML_DECLARATION,
00483                 TINYXML_TYPECOUNT
00484         };
00485 
00486         virtual ~TiXmlNode();
00487 
00500         const char *Value() const { return value.c_str (); }
00501 
00502     #ifdef TIXML_USE_STL
00503 
00507         const std::string& ValueStr() const { return value; }
00508         #endif
00509 
00510         const TIXML_STRING& ValueTStr() const { return value; }
00511 
00521         void SetValue(const char * _value) { value = _value;}
00522 
00523     #ifdef TIXML_USE_STL
00524 
00525         void SetValue( const std::string& _value )      { value = _value; }
00526         #endif
00527 
00529         void Clear();
00530 
00532         TiXmlNode* Parent()                                                     { return parent; }
00533         const TiXmlNode* Parent() const                         { return parent; }
00534 
00535         const TiXmlNode* FirstChild()   const           { return firstChild; }  
00536         TiXmlNode* FirstChild()                                         { return firstChild; }
00537         const TiXmlNode* FirstChild( const char * value ) const;                        
00538 
00539         TiXmlNode* FirstChild( const char * _value ) {
00540                 // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
00541                 // call the method, cast the return back to non-const.
00542                 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
00543         }
00544         const TiXmlNode* LastChild() const      { return lastChild; }           
00545         TiXmlNode* LastChild()  { return lastChild; }
00546         
00547         const TiXmlNode* LastChild( const char * value ) const;                 
00548         TiXmlNode* LastChild( const char * _value ) {
00549                 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
00550         }
00551 
00552     #ifdef TIXML_USE_STL
00553         const TiXmlNode* FirstChild( const std::string& _value ) const  {       return FirstChild (_value.c_str ());    }       
00554         TiXmlNode* FirstChild( const std::string& _value )                              {       return FirstChild (_value.c_str ());    }       
00555         const TiXmlNode* LastChild( const std::string& _value ) const   {       return LastChild (_value.c_str ());     }       
00556         TiXmlNode* LastChild( const std::string& _value )                               {       return LastChild (_value.c_str ());     }       
00557         #endif
00558 
00575         const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
00576         TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
00577                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
00578         }
00579 
00581         const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
00582         TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
00583                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
00584         }
00585 
00586     #ifdef TIXML_USE_STL
00587         const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const  {       return IterateChildren (_value.c_str (), previous);     }       
00588         TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) {    return IterateChildren (_value.c_str (), previous);     }       
00589         #endif
00590 
00594         TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
00595 
00596 
00606         TiXmlNode* LinkEndChild( TiXmlNode* addThis );
00607 
00611         TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
00612 
00616         TiXmlNode* InsertAfterChild(  TiXmlNode* afterThis, const TiXmlNode& addThis );
00617 
00621         TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
00622 
00624         bool RemoveChild( TiXmlNode* removeThis );
00625 
00627         const TiXmlNode* PreviousSibling() const                        { return prev; }
00628         TiXmlNode* PreviousSibling()                                            { return prev; }
00629 
00631         const TiXmlNode* PreviousSibling( const char * ) const;
00632         TiXmlNode* PreviousSibling( const char *_prev ) {
00633                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
00634         }
00635 
00636     #ifdef TIXML_USE_STL
00637         const TiXmlNode* PreviousSibling( const std::string& _value ) const     {       return PreviousSibling (_value.c_str ());       }       
00638         TiXmlNode* PreviousSibling( const std::string& _value )                         {       return PreviousSibling (_value.c_str ());       }       
00639         const TiXmlNode* NextSibling( const std::string& _value) const          {       return NextSibling (_value.c_str ());   }       
00640         TiXmlNode* NextSibling( const std::string& _value)                                      {       return NextSibling (_value.c_str ());   }       
00641         #endif
00642 
00644         const TiXmlNode* NextSibling() const                            { return next; }
00645         TiXmlNode* NextSibling()                                                        { return next; }
00646 
00648         const TiXmlNode* NextSibling( const char * ) const;
00649         TiXmlNode* NextSibling( const char* _next ) {
00650                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
00651         }
00652 
00657         const TiXmlElement* NextSiblingElement() const;
00658         TiXmlElement* NextSiblingElement() {
00659                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
00660         }
00661 
00666         const TiXmlElement* NextSiblingElement( const char * ) const;
00667         TiXmlElement* NextSiblingElement( const char *_next ) {
00668                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
00669         }
00670 
00671     #ifdef TIXML_USE_STL
00672         const TiXmlElement* NextSiblingElement( const std::string& _value) const        {       return NextSiblingElement (_value.c_str ());    }       
00673         TiXmlElement* NextSiblingElement( const std::string& _value)                            {       return NextSiblingElement (_value.c_str ());    }       
00674         #endif
00675 
00677         const TiXmlElement* FirstChildElement() const;
00678         TiXmlElement* FirstChildElement() {
00679                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
00680         }
00681 
00683         const TiXmlElement* FirstChildElement( const char * _value ) const;
00684         TiXmlElement* FirstChildElement( const char * _value ) {
00685                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
00686         }
00687 
00688     #ifdef TIXML_USE_STL
00689         const TiXmlElement* FirstChildElement( const std::string& _value ) const        {       return FirstChildElement (_value.c_str ());     }       
00690         TiXmlElement* FirstChildElement( const std::string& _value )                            {       return FirstChildElement (_value.c_str ());     }       
00691         #endif
00692 
00697         int Type() const        { return type; }
00698 
00702         const TiXmlDocument* GetDocument() const;
00703         TiXmlDocument* GetDocument() {
00704                 return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
00705         }
00706 
00708         bool NoChildren() const                                         { return !firstChild; }
00709 
00710         virtual const TiXmlDocument*    ToDocument()    const { return 0; } 
00711         virtual const TiXmlElement*     ToElement()     const { return 0; } 
00712         virtual const TiXmlComment*     ToComment()     const { return 0; } 
00713         virtual const TiXmlUnknown*     ToUnknown()     const { return 0; } 
00714         virtual const TiXmlText*        ToText()        const { return 0; } 
00715         virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } 
00716 
00717         virtual TiXmlDocument*          ToDocument()    { return 0; } 
00718         virtual TiXmlElement*           ToElement()         { return 0; } 
00719         virtual TiXmlComment*           ToComment()     { return 0; } 
00720         virtual TiXmlUnknown*           ToUnknown()         { return 0; } 
00721         virtual TiXmlText*                  ToText()        { return 0; } 
00722         virtual TiXmlDeclaration*       ToDeclaration() { return 0; } 
00723 
00727         virtual TiXmlNode* Clone() const = 0;
00728 
00751         virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
00752 
00753 protected:
00754         TiXmlNode( NodeType _type );
00755 
00756         // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
00757         // and the assignment operator.
00758         void CopyTo( TiXmlNode* target ) const;
00759 
00760         #ifdef TIXML_USE_STL
00761             // The real work of the input operator.
00762         virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
00763         #endif
00764 
00765         // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
00766         TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
00767 
00768         TiXmlNode*              parent;
00769         NodeType                type;
00770 
00771         TiXmlNode*              firstChild;
00772         TiXmlNode*              lastChild;
00773 
00774         TIXML_STRING    value;
00775 
00776         TiXmlNode*              prev;
00777         TiXmlNode*              next;
00778 
00779 private:
00780         TiXmlNode( const TiXmlNode& );                          // not implemented.
00781         void operator=( const TiXmlNode& base );        // not allowed.
00782 };
00783 
00784 
00792 class TINYXML_IMPORT_EXPORT TiXmlAttribute : public TiXmlBase
00793 {
00794         friend class TiXmlAttributeSet;
00795 
00796 public:
00798         TiXmlAttribute() : TiXmlBase()
00799         {
00800                 document = 0;
00801                 prev = next = 0;
00802         }
00803 
00804         #ifdef TIXML_USE_STL
00805 
00806         TiXmlAttribute( const std::string& _name, const std::string& _value )
00807         {
00808                 name = _name;
00809                 value = _value;
00810                 document = 0;
00811                 prev = next = 0;
00812         }
00813         #endif
00814 
00816         TiXmlAttribute( const char * _name, const char * _value )
00817         {
00818                 name = _name;
00819                 value = _value;
00820                 document = 0;
00821                 prev = next = 0;
00822         }
00823 
00824         const char*             Name()  const           { return name.c_str(); }                
00825         const char*             Value() const           { return value.c_str(); }               
00826         #ifdef TIXML_USE_STL
00827         const std::string& ValueStr() const     { return value; }                               
00828         #endif
00829         int                             IntValue() const;                                                                       
00830         double                  DoubleValue() const;                                                            
00831 
00832         // Get the tinyxml string representation
00833         const TIXML_STRING& NameTStr() const { return name; }
00834 
00844         int QueryIntValue( int* _value ) const;
00846         int QueryDoubleValue( double* _value ) const;
00847 
00848         void SetName( const char* _name )       { name = _name; }                               
00849         void SetValue( const char* _value )     { value = _value; }                             
00850 
00851         void SetIntValue( int _value );                                                                         
00852         void SetDoubleValue( double _value );                                                           
00853 
00854     #ifdef TIXML_USE_STL
00855 
00856         void SetName( const std::string& _name )        { name = _name; }       
00858         void SetValue( const std::string& _value )      { value = _value; }
00859         #endif
00860 
00862         const TiXmlAttribute* Next() const;
00863         TiXmlAttribute* Next() {
00864                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); 
00865         }
00866 
00868         const TiXmlAttribute* Previous() const;
00869         TiXmlAttribute* Previous() {
00870                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); 
00871         }
00872 
00873         bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
00874         bool operator<( const TiXmlAttribute& rhs )      const { return name < rhs.name; }
00875         bool operator>( const TiXmlAttribute& rhs )  const { return name > rhs.name; }
00876 
00877         /*      Attribute parsing starts: first letter of the name
00878                                                  returns: the next char after the value end quote
00879         */
00880         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
00881 
00882         // Prints this Attribute to a FILE stream.
00883         virtual void Print( FILE* cfile, int depth ) const {
00884                 Print( cfile, depth, 0 );
00885         }
00886         void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
00887 
00888         // [internal use]
00889         // Set the document pointer so the attribute can report errors.
00890         void SetDocument( TiXmlDocument* doc )  { document = doc; }
00891 
00892 private:
00893         TiXmlAttribute( const TiXmlAttribute& );                                // not implemented.
00894         void operator=( const TiXmlAttribute& base );   // not allowed.
00895 
00896         TiXmlDocument*  document;       // A pointer back to a document, for error reporting.
00897         TIXML_STRING name;
00898         TIXML_STRING value;
00899         TiXmlAttribute* prev;
00900         TiXmlAttribute* next;
00901 };
00902 
00903 
00904 /*      A class used to manage a group of attributes.
00905         It is only used internally, both by the ELEMENT and the DECLARATION.
00906         
00907         The set can be changed transparent to the Element and Declaration
00908         classes that use it, but NOT transparent to the Attribute
00909         which has to implement a next() and previous() method. Which makes
00910         it a bit problematic and prevents the use of STL.
00911 
00912         This version is implemented with circular lists because:
00913                 - I like circular lists
00914                 - it demonstrates some independence from the (typical) doubly linked list.
00915 */
00916 class TINYXML_IMPORT_EXPORT TiXmlAttributeSet
00917 {
00918 public:
00919         TiXmlAttributeSet();
00920         ~TiXmlAttributeSet();
00921 
00922         void Add( TiXmlAttribute* attribute );
00923         void Remove( TiXmlAttribute* attribute );
00924 
00925         const TiXmlAttribute* First()   const   { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00926         TiXmlAttribute* First()                                 { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00927         const TiXmlAttribute* Last() const              { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00928         TiXmlAttribute* Last()                                  { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00929 
00930         TiXmlAttribute* Find( const char* _name ) const;
00931         TiXmlAttribute* FindOrCreate( const char* _name );
00932 
00933 #       ifdef TIXML_USE_STL
00934         TiXmlAttribute* Find( const std::string& _name ) const;
00935         TiXmlAttribute* FindOrCreate( const std::string& _name );
00936 #       endif
00937 
00938 
00939 private:
00940         //*ME:  Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
00941         //*ME:  this class must be also use a hidden/disabled copy-constructor !!!
00942         TiXmlAttributeSet( const TiXmlAttributeSet& );  // not allowed
00943         void operator=( const TiXmlAttributeSet& );     // not allowed (as TiXmlAttribute)
00944 
00945         TiXmlAttribute sentinel;
00946 };
00947 
00948 
00953 class TINYXML_IMPORT_EXPORT TiXmlElement : public TiXmlNode
00954 {
00955 public:
00957         TiXmlElement (const char * in_value);
00958 
00959         #ifdef TIXML_USE_STL
00960 
00961         TiXmlElement( const std::string& _value );
00962         #endif
00963 
00964         TiXmlElement( const TiXmlElement& );
00965 
00966         TiXmlElement& operator=( const TiXmlElement& base );
00967 
00968         virtual ~TiXmlElement();
00969 
00973         const char* Attribute( const char* name ) const;
00974 
00981         const char* Attribute( const char* name, int* i ) const;
00982 
00989         const char* Attribute( const char* name, double* d ) const;
00990 
00998         int QueryIntAttribute( const char* name, int* _value ) const;
01000         int QueryDoubleAttribute( const char* name, double* _value ) const;
01002         int QueryFloatAttribute( const char* name, float* _value ) const {
01003                 double d;
01004                 int result = QueryDoubleAttribute( name, &d );
01005                 if ( result == TIXML_SUCCESS ) {
01006                         *_value = (float)d;
01007                 }
01008                 return result;
01009         }
01010 
01011     #ifdef TIXML_USE_STL
01012 
01013         int QueryStringAttribute( const char* name, std::string* _value ) const {
01014                 const char* cstr = Attribute( name );
01015                 if ( cstr ) {
01016                         *_value = std::string( cstr );
01017                         return TIXML_SUCCESS;
01018                 }
01019                 return TIXML_NO_ATTRIBUTE;
01020         }
01021 
01030         template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
01031         {
01032                 const TiXmlAttribute* node = attributeSet.Find( name );
01033                 if ( !node )
01034                         return TIXML_NO_ATTRIBUTE;
01035 
01036                 std::stringstream sstream( node->ValueStr() );
01037                 sstream >> *outValue;
01038                 if ( !sstream.fail() )
01039                         return TIXML_SUCCESS;
01040                 return TIXML_WRONG_TYPE;
01041         }
01042 
01043         int QueryValueAttribute( const std::string& name, std::string* outValue ) const
01044         {
01045                 const TiXmlAttribute* node = attributeSet.Find( name );
01046                 if ( !node )
01047                         return TIXML_NO_ATTRIBUTE;
01048                 *outValue = node->ValueStr();
01049                 return TIXML_SUCCESS;
01050         }
01051         #endif
01052 
01056         void SetAttribute( const char* name, const char * _value );
01057 
01058     #ifdef TIXML_USE_STL
01059         const std::string* Attribute( const std::string& name ) const;
01060         const std::string* Attribute( const std::string& name, int* i ) const;
01061         const std::string* Attribute( const std::string& name, double* d ) const;
01062         int QueryIntAttribute( const std::string& name, int* _value ) const;
01063         int QueryDoubleAttribute( const std::string& name, double* _value ) const;
01064 
01066         void SetAttribute( const std::string& name, const std::string& _value );
01068         void SetAttribute( const std::string& name, int _value );
01070         void SetDoubleAttribute( const std::string& name, double value );
01071         #endif
01072 
01076         void SetAttribute( const char * name, int value );
01077 
01081         void SetDoubleAttribute( const char * name, double value );
01082 
01085         void RemoveAttribute( const char * name );
01086     #ifdef TIXML_USE_STL
01087         void RemoveAttribute( const std::string& name ) {       RemoveAttribute (name.c_str ());        }       
01088         #endif
01089 
01090         const TiXmlAttribute* FirstAttribute() const    { return attributeSet.First(); }                
01091         TiXmlAttribute* FirstAttribute()                                { return attributeSet.First(); }
01092         const TiXmlAttribute* LastAttribute()   const   { return attributeSet.Last(); }         
01093         TiXmlAttribute* LastAttribute()                                 { return attributeSet.Last(); }
01094 
01127         const char* GetText() const;
01128 
01130         virtual TiXmlNode* Clone() const;
01131         // Print the Element to a FILE stream.
01132         virtual void Print( FILE* cfile, int depth ) const;
01133 
01134         /*      Attribtue parsing starts: next char past '<'
01135                                                  returns: next char past '>'
01136         */
01137         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01138 
01139         virtual const TiXmlElement*     ToElement()     const { return this; } 
01140         virtual TiXmlElement*           ToElement()               { return this; } 
01141 
01144         virtual bool Accept( TiXmlVisitor* visitor ) const;
01145 
01146 protected:
01147 
01148         void CopyTo( TiXmlElement* target ) const;
01149         void ClearThis();       // like clear, but initializes 'this' object as well
01150 
01151         // Used to be public [internal use]
01152         #ifdef TIXML_USE_STL
01153         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01154         #endif
01155         /*      [internal use]
01156                 Reads the "value" of the element -- another element, or text.
01157                 This should terminate with the current end tag.
01158         */
01159         const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01160 
01161 private:
01162         TiXmlAttributeSet attributeSet;
01163 };
01164 
01165 
01168 class TINYXML_IMPORT_EXPORT TiXmlComment : public TiXmlNode
01169 {
01170 public:
01172         TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
01174         TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {
01175                 SetValue( _value );
01176         }
01177         TiXmlComment( const TiXmlComment& );
01178         TiXmlComment& operator=( const TiXmlComment& base );
01179 
01180         virtual ~TiXmlComment() {}
01181 
01183         virtual TiXmlNode* Clone() const;
01184         // Write this Comment to a FILE stream.
01185         virtual void Print( FILE* cfile, int depth ) const;
01186 
01187         /*      Attribtue parsing starts: at the ! of the !--
01188                                                  returns: next char past '>'
01189         */
01190         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01191 
01192         virtual const TiXmlComment*  ToComment() const { return this; } 
01193         virtual TiXmlComment*  ToComment() { return this; } 
01194 
01197         virtual bool Accept( TiXmlVisitor* visitor ) const;
01198 
01199 protected:
01200         void CopyTo( TiXmlComment* target ) const;
01201 
01202         // used to be public
01203         #ifdef TIXML_USE_STL
01204         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01205         #endif
01206 //      virtual void StreamOut( TIXML_OSTREAM * out ) const;
01207 
01208 private:
01209 
01210 };
01211 
01212 
01218 class TINYXML_IMPORT_EXPORT TiXmlText : public TiXmlNode
01219 {
01220         friend class TiXmlElement;
01221 public:
01226         TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
01227         {
01228                 SetValue( initValue );
01229                 cdata = false;
01230         }
01231         virtual ~TiXmlText() {}
01232 
01233         #ifdef TIXML_USE_STL
01234 
01235         TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
01236         {
01237                 SetValue( initValue );
01238                 cdata = false;
01239         }
01240         #endif
01241 
01242         TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT )       { copy.CopyTo( this ); }
01243         TiXmlText& operator=( const TiXmlText& base )                                                           { base.CopyTo( this ); return *this; }
01244 
01245         // Write this text object to a FILE stream.
01246         virtual void Print( FILE* cfile, int depth ) const;
01247 
01249         bool CDATA() const                              { return cdata; }
01251         void SetCDATA( bool _cdata )    { cdata = _cdata; }
01252 
01253         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01254 
01255         virtual const TiXmlText* ToText() const { return this; } 
01256         virtual TiXmlText*       ToText()       { return this; } 
01257 
01260         virtual bool Accept( TiXmlVisitor* content ) const;
01261 
01262 protected :
01264         virtual TiXmlNode* Clone() const;
01265         void CopyTo( TiXmlText* target ) const;
01266 
01267         bool Blank() const;     // returns true if all white space and new lines
01268         // [internal use]
01269         #ifdef TIXML_USE_STL
01270         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01271         #endif
01272 
01273 private:
01274         bool cdata;                     // true if this should be input and output as a CDATA style text element
01275 };
01276 
01277 
01291 class TINYXML_IMPORT_EXPORT TiXmlDeclaration : public TiXmlNode
01292 {
01293 public:
01295         TiXmlDeclaration()   : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {}
01296 
01297 #ifdef TIXML_USE_STL
01298 
01299         TiXmlDeclaration(       const std::string& _version,
01300                                                 const std::string& _encoding,
01301                                                 const std::string& _standalone );
01302 #endif
01303 
01305         TiXmlDeclaration(       const char* _version,
01306                                                 const char* _encoding,
01307                                                 const char* _standalone );
01308 
01309         TiXmlDeclaration( const TiXmlDeclaration& copy );
01310         TiXmlDeclaration& operator=( const TiXmlDeclaration& copy );
01311 
01312         virtual ~TiXmlDeclaration()     {}
01313 
01315         const char *Version() const                     { return version.c_str (); }
01317         const char *Encoding() const            { return encoding.c_str (); }
01319         const char *Standalone() const          { return standalone.c_str (); }
01320 
01322         virtual TiXmlNode* Clone() const;
01323         // Print this declaration to a FILE stream.
01324         virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
01325         virtual void Print( FILE* cfile, int depth ) const {
01326                 Print( cfile, depth, 0 );
01327         }
01328 
01329         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01330 
01331         virtual const TiXmlDeclaration* ToDeclaration() const { return this; } 
01332         virtual TiXmlDeclaration*       ToDeclaration()       { return this; } 
01333 
01336         virtual bool Accept( TiXmlVisitor* visitor ) const;
01337 
01338 protected:
01339         void CopyTo( TiXmlDeclaration* target ) const;
01340         // used to be public
01341         #ifdef TIXML_USE_STL
01342         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01343         #endif
01344 
01345 private:
01346 
01347         TIXML_STRING version;
01348         TIXML_STRING encoding;
01349         TIXML_STRING standalone;
01350 };
01351 
01352 
01360 class TINYXML_IMPORT_EXPORT TiXmlUnknown : public TiXmlNode
01361 {
01362 public:
01363         TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN )        {}
01364         virtual ~TiXmlUnknown() {}
01365 
01366         TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN )              { copy.CopyTo( this ); }
01367         TiXmlUnknown& operator=( const TiXmlUnknown& copy )                                                                             { copy.CopyTo( this ); return *this; }
01368 
01370         virtual TiXmlNode* Clone() const;
01371         // Print this Unknown to a FILE stream.
01372         virtual void Print( FILE* cfile, int depth ) const;
01373 
01374         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01375 
01376         virtual const TiXmlUnknown*     ToUnknown()     const { return this; } 
01377         virtual TiXmlUnknown*           ToUnknown()         { return this; } 
01378 
01381         virtual bool Accept( TiXmlVisitor* content ) const;
01382 
01383 protected:
01384         void CopyTo( TiXmlUnknown* target ) const;
01385 
01386         #ifdef TIXML_USE_STL
01387         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01388         #endif
01389 
01390 private:
01391 
01392 };
01393 
01394 
01399 class TINYXML_IMPORT_EXPORT TiXmlDocument : public TiXmlNode
01400 {
01401 public:
01403         TiXmlDocument();
01405         TiXmlDocument( const char * documentName );
01406 
01407         #ifdef TIXML_USE_STL
01408 
01409         TiXmlDocument( const std::string& documentName );
01410         #endif
01411 
01412         TiXmlDocument( const TiXmlDocument& copy );
01413         TiXmlDocument& operator=( const TiXmlDocument& copy );
01414 
01415         virtual ~TiXmlDocument() {}
01416 
01421         bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01423         bool SaveFile() const;
01425         bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01427         bool SaveFile( const char * filename ) const;
01433         bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01435         bool SaveFile( FILE* ) const;
01436 
01437         #ifdef TIXML_USE_STL
01438         bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )                   
01439         {
01440                 return LoadFile( filename.c_str(), encoding );
01441         }
01442         bool SaveFile( const std::string& filename ) const              
01443         {
01444                 return SaveFile( filename.c_str() );
01445         }
01446         #endif
01447 
01452         virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01453 
01458         const TiXmlElement* RootElement() const         { return FirstChildElement(); }
01459         TiXmlElement* RootElement()                                     { return FirstChildElement(); }
01460 
01466         bool Error() const                                              { return error; }
01467 
01469         const char * ErrorDesc() const  { return errorDesc.c_str (); }
01470 
01474         int ErrorId()   const                           { return errorId; }
01475 
01483         int ErrorRow() const    { return errorLocation.row+1; }
01484         int ErrorCol() const    { return errorLocation.col+1; } 
01485 
01510         void SetTabSize( int _tabsize )         { tabsize = _tabsize; }
01511 
01512         int TabSize() const     { return tabsize; }
01513 
01517         void ClearError()                                               {       error = false; 
01518                                                                                                 errorId = 0; 
01519                                                                                                 errorDesc = ""; 
01520                                                                                                 errorLocation.row = errorLocation.col = 0; 
01521                                                                                                 //errorLocation.last = 0; 
01522                                                                                         }
01523 
01525         void Print() const                                              { Print( stdout, 0 ); }
01526 
01527         /* Write the document to a string using formatted printing ("pretty print"). This
01528                 will allocate a character array (new char[]) and return it as a pointer. The
01529                 calling code pust call delete[] on the return char* to avoid a memory leak.
01530         */
01531         //char* PrintToMemory() const; 
01532 
01534         virtual void Print( FILE* cfile, int depth = 0 ) const;
01535         // [internal use]
01536         void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01537 
01538         virtual const TiXmlDocument*    ToDocument()    const { return this; } 
01539         virtual TiXmlDocument*          ToDocument()          { return this; } 
01540 
01543         virtual bool Accept( TiXmlVisitor* content ) const;
01544 
01545 protected :
01546         // [internal use]
01547         virtual TiXmlNode* Clone() const;
01548         #ifdef TIXML_USE_STL
01549         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01550         #endif
01551 
01552 private:
01553         void CopyTo( TiXmlDocument* target ) const;
01554 
01555         bool error;
01556         int  errorId;
01557         TIXML_STRING errorDesc;
01558         int tabsize;
01559         TiXmlCursor errorLocation;
01560         bool useMicrosoftBOM;           // the UTF-8 BOM were found when read. Note this, and try to write.
01561 };
01562 
01563 
01644 class TINYXML_IMPORT_EXPORT TiXmlHandle
01645 {
01646 public:
01648         TiXmlHandle( TiXmlNode* _node )                                 { this->node = _node; }
01650         TiXmlHandle( const TiXmlHandle& ref )                   { this->node = ref.node; }
01651         TiXmlHandle operator=( const TiXmlHandle& ref ) { if (&ref != this) this->node = ref.node; return *this; }
01652 
01654         TiXmlHandle FirstChild() const;
01656         TiXmlHandle FirstChild( const char * value ) const;
01658         TiXmlHandle FirstChildElement() const;
01660         TiXmlHandle FirstChildElement( const char * value ) const;
01661 
01665         TiXmlHandle Child( const char* value, int index ) const;
01669         TiXmlHandle Child( int index ) const;
01674         TiXmlHandle ChildElement( const char* value, int index ) const;
01679         TiXmlHandle ChildElement( int index ) const;
01680 
01681         #ifdef TIXML_USE_STL
01682         TiXmlHandle FirstChild( const std::string& _value ) const                               { return FirstChild( _value.c_str() ); }
01683         TiXmlHandle FirstChildElement( const std::string& _value ) const                { return FirstChildElement( _value.c_str() ); }
01684 
01685         TiXmlHandle Child( const std::string& _value, int index ) const                 { return Child( _value.c_str(), index ); }
01686         TiXmlHandle ChildElement( const std::string& _value, int index ) const  { return ChildElement( _value.c_str(), index ); }
01687         #endif
01688 
01691         TiXmlNode* ToNode() const                       { return node; } 
01694         TiXmlElement* ToElement() const         { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
01697         TiXmlText* ToText() const                       { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
01700         TiXmlUnknown* ToUnknown() const         { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
01701 
01705         TiXmlNode* Node() const                 { return ToNode(); } 
01709         TiXmlElement* Element() const   { return ToElement(); }
01713         TiXmlText* Text() const                 { return ToText(); }
01717         TiXmlUnknown* Unknown() const   { return ToUnknown(); }
01718 
01719 private:
01720         TiXmlNode* node;
01721 };
01722 
01723 
01743 class TINYXML_IMPORT_EXPORT TiXmlPrinter : public TiXmlVisitor
01744 {
01745 public:
01746         TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
01747                                          buffer(), indent( "    " ), lineBreak( "\n" ) {}
01748 
01749         virtual bool VisitEnter( const TiXmlDocument& doc );
01750         virtual bool VisitExit( const TiXmlDocument& doc );
01751 
01752         virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
01753         virtual bool VisitExit( const TiXmlElement& element );
01754 
01755         virtual bool Visit( const TiXmlDeclaration& declaration );
01756         virtual bool Visit( const TiXmlText& text );
01757         virtual bool Visit( const TiXmlComment& comment );
01758         virtual bool Visit( const TiXmlUnknown& unknown );
01759 
01763         void SetIndent( const char* _indent )                   { indent = _indent ? _indent : "" ; }
01765         const char* Indent()                                                    { return indent.c_str(); }
01770         void SetLineBreak( const char* _lineBreak )             { lineBreak = _lineBreak ? _lineBreak : ""; }
01772         const char* LineBreak()                                                 { return lineBreak.c_str(); }
01773 
01777         void SetStreamPrinting()                                                { indent = "";
01778                                                                                                           lineBreak = "";
01779                                                                                                         }       
01781         const char* CStr()                                                              { return buffer.c_str(); }
01783         size_t Size()                                                                   { return buffer.size(); }
01784 
01785         #ifdef TIXML_USE_STL
01786 
01787         const std::string& Str()                                                { return buffer; }
01788         #endif
01789 
01790 private:
01791         void DoIndent() {
01792                 for( int i=0; i<depth; ++i )
01793                         buffer += indent;
01794         }
01795         void DoLineBreak() {
01796                 buffer += lineBreak;
01797         }
01798 
01799         int depth;
01800         bool simpleTextPrint;
01801         TIXML_STRING buffer;
01802         TIXML_STRING indent;
01803         TIXML_STRING lineBreak;
01804 };
01805 
01806 
01807 #ifdef _MSC_VER
01808 #pragma warning( pop )
01809 #endif
01810 
01811 #endif
01812 


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19