CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/FWCore/Utilities/interface/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 THIS FILE WAS ALTERED BY Bill Tanenbaum, 10 November 2011.
00026 Coverity complains about assignment operators returning void,
00027 so fixed them to return a reference to the object.
00028 
00029 */
00030 
00031 #define TIXML_USE_STL
00032 
00033 #ifndef TINYXML_INCLUDED
00034 #define TINYXML_INCLUDED
00035 
00036 #ifdef _MSC_VER
00037 #pragma warning( push )
00038 #pragma warning( disable : 4530 )
00039 #pragma warning( disable : 4786 )
00040 #endif
00041 
00042 #include <ctype.h>
00043 #include <stdio.h>
00044 #include <stdlib.h>
00045 #include <string.h>
00046 #include <assert.h>
00047 
00048 // Help out windows:
00049 #if defined( _DEBUG ) && !defined( DEBUG )
00050 #define DEBUG
00051 #endif
00052 
00053 #ifdef TIXML_USE_STL
00054         #include <string>
00055         #include <iostream>
00056         #include <sstream>
00057         #define TIXML_STRING            std::string
00058 #else
00059         #include "tinystr.h"
00060         #define TIXML_STRING            TiXmlString
00061 #endif
00062 
00063 // Deprecated library function hell. Compilers want to use the
00064 // new safe versions. This probably doesn't fully address the problem,
00065 // but it gets closer. There are too many compilers for me to fully
00066 // test. If you get compilation troubles, undefine TIXML_SAFE
00067 #define TIXML_SAFE
00068 
00069 #ifdef TIXML_SAFE
00070         #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
00071                 // Microsoft visual studio, version 2005 and higher.
00072                 #define TIXML_SNPRINTF _snprintf_s
00073                 #define TIXML_SNSCANF  _snscanf_s
00074                 #define TIXML_SSCANF   sscanf_s
00075         #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
00076                 // Microsoft visual studio, version 6 and higher.
00077                 //#pragma message( "Using _sn* functions." )
00078                 #define TIXML_SNPRINTF _snprintf
00079                 #define TIXML_SNSCANF  _snscanf
00080         #elif defined(__GNUC__) && (__GNUC__ >= 3 )
00081                 // GCC version 3 and higher.s
00082                 //#warning( "Using sn* functions." )
00083                 #define TIXML_SNPRINTF snprintf
00084                 #define TIXML_SNSCANF  snscanf
00085         #endif
00086 #endif
00087 
00088 class TiXmlDocument;
00089 class TiXmlElement;
00090 class TiXmlComment;
00091 class TiXmlUnknown;
00092 class TiXmlAttribute;
00093 class TiXmlText;
00094 class TiXmlDeclaration;
00095 class TiXmlParsingData;
00096 
00097 const int TIXML_MAJOR_VERSION = 2;
00098 const int TIXML_MINOR_VERSION = 5;
00099 const int TIXML_PATCH_VERSION = 3;
00100 
00101 /*      Internal structure for tracking location of items
00102         in the XML file.
00103 */
00104 struct TiXmlCursor
00105 {
00106         TiXmlCursor()           { Clear(); }
00107         void Clear()            { row = col = -1; }
00108 
00109         int row;        // 0 based.
00110         int col;        // 0 based.
00111 };
00112 
00113 
00132 class TiXmlVisitor
00133 {
00134 public:
00135         virtual ~TiXmlVisitor() {}
00136 
00138         virtual bool VisitEnter( const TiXmlDocument& /*doc*/ )                 { return true; }
00140         virtual bool VisitExit( const TiXmlDocument& /*doc*/ )                  { return true; }
00141 
00143         virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ )    { return true; }
00145         virtual bool VisitExit( const TiXmlElement& /*element*/ )               { return true; }
00146 
00148         virtual bool Visit( const TiXmlDeclaration& /*declaration*/ )   { return true; }
00150         virtual bool Visit( const TiXmlText& /*text*/ )                                 { return true; }
00152         virtual bool Visit( const TiXmlComment& /*comment*/ )                   { return true; }
00154         virtual bool Visit( const TiXmlUnknown& /*unknown*/ )                   { return true; }
00155 };
00156 
00157 // Only used by Attribute::Query functions
00158 enum
00159 {
00160         TIXML_SUCCESS,
00161         TIXML_NO_ATTRIBUTE,
00162         TIXML_WRONG_TYPE
00163 };
00164 
00165 
00166 // Used by the parsing routines.
00167 enum TiXmlEncoding
00168 {
00169         TIXML_ENCODING_UNKNOWN,
00170         TIXML_ENCODING_UTF8,
00171         TIXML_ENCODING_LEGACY
00172 };
00173 
00174 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
00175 
00198 class TiXmlBase
00199 {
00200         friend class TiXmlNode;
00201         friend class TiXmlElement;
00202         friend class TiXmlDocument;
00203 
00204 public:
00205         TiXmlBase()     :       userData(0)             {}
00206         virtual ~TiXmlBase()                    {}
00207 
00217         virtual void Print( FILE* cfile, int depth ) const = 0;
00218 
00225         static void SetCondenseWhiteSpace( bool condense )              { condenseWhiteSpace = condense; }
00226 
00228         static bool IsWhiteSpaceCondensed()                                             { return condenseWhiteSpace; }
00229 
00248         int Row() const                 { return location.row + 1; }
00249         int Column() const              { return location.col + 1; }    
00250 
00251         void  SetUserData( void* user )                 { userData = user; }    
00252         void* GetUserData()                                             { return userData; }    
00253         const void* GetUserData() const                 { return userData; }    
00254 
00255         // Table that returs, for a given lead byte, the total number of bytes
00256         // in the UTF-8 sequence.
00257         static const int utf8ByteTable[256];
00258 
00259         virtual const char* Parse(      const char* p,
00260                                                                 TiXmlParsingData* data,
00261                                                                 TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
00262 
00266         static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
00267 
00268         enum
00269         {
00270                 TIXML_NO_ERROR = 0,
00271                 TIXML_ERROR,
00272                 TIXML_ERROR_OPENING_FILE,
00273                 TIXML_ERROR_OUT_OF_MEMORY,
00274                 TIXML_ERROR_PARSING_ELEMENT,
00275                 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00276                 TIXML_ERROR_READING_ELEMENT_VALUE,
00277                 TIXML_ERROR_READING_ATTRIBUTES,
00278                 TIXML_ERROR_PARSING_EMPTY,
00279                 TIXML_ERROR_READING_END_TAG,
00280                 TIXML_ERROR_PARSING_UNKNOWN,
00281                 TIXML_ERROR_PARSING_COMMENT,
00282                 TIXML_ERROR_PARSING_DECLARATION,
00283                 TIXML_ERROR_DOCUMENT_EMPTY,
00284                 TIXML_ERROR_EMBEDDED_NULL,
00285                 TIXML_ERROR_PARSING_CDATA,
00286                 TIXML_ERROR_DOCUMENT_TOP_ONLY,
00287 
00288                 TIXML_ERROR_STRING_COUNT
00289         };
00290 
00291 protected:
00292 
00293         static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
00294         inline static bool IsWhiteSpace( char c )
00295         {
00296                 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
00297         }
00298         inline static bool IsWhiteSpace( int c )
00299         {
00300                 if ( c < 256 )
00301                         return IsWhiteSpace( (char) c );
00302                 return false;   // Again, only truly correct for English/Latin...but usually works.
00303         }
00304 
00305         #ifdef TIXML_USE_STL
00306         static bool     StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
00307         static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
00308         #endif
00309 
00310         /*      Reads an XML name into the string provided. Returns
00311                 a pointer just past the last character of the name,
00312                 or 0 if the function has an error.
00313         */
00314         static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
00315 
00316         /*      Reads text. Returns a pointer past the given end tag.
00317                 Wickedly complex options, but it keeps the (sensitive) code in one place.
00318         */
00319         static const char* ReadText(    const char* in,                         // where to start
00320                                                                         TIXML_STRING* text,                     // the string read
00321                                                                         bool ignoreWhiteSpace,          // whether to keep the white space
00322                                                                         const char* endTag,                     // what ends this text
00323                                                                         bool ignoreCase,                        // whether to ignore case in the end tag
00324                                                                         TiXmlEncoding encoding );       // the current encoding
00325 
00326         // If an entity has been found, transform it into a character.
00327         static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
00328 
00329         // Get a character, while interpreting entities.
00330         // The length can be from 0 to 4 bytes.
00331         inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
00332         {
00333                 assert( p );
00334                 if ( encoding == TIXML_ENCODING_UTF8 )
00335                 {
00336                         *length = utf8ByteTable[ *((const unsigned char*)p) ];
00337                         assert( *length >= 0 && *length < 5 );
00338                 }
00339                 else
00340                 {
00341                         *length = 1;
00342                 }
00343 
00344                 if ( *length == 1 )
00345                 {
00346                         if ( *p == '&' )
00347                                 return GetEntity( p, _value, length, encoding );
00348                         *_value = *p;
00349                         return p+1;
00350                 }
00351                 else if ( *length )
00352                 {
00353                         //strncpy( _value, p, *length );        // lots of compilers don't like this function (unsafe),
00354                                                                                                 // and the null terminator isn't needed
00355                         for( int i=0; p[i] && i<*length; ++i ) {
00356                                 _value[i] = p[i];
00357                         }
00358                         return p + (*length);
00359                 }
00360                 else
00361                 {
00362                         // Not valid text.
00363                         return 0;
00364                 }
00365         }
00366 
00367         // Return true if the next characters in the stream are any of the endTag sequences.
00368         // Ignore case only works for english, and should only be relied on when comparing
00369         // to English words: StringEqual( p, "version", true ) is fine.
00370         static bool StringEqual(        const char* p,
00371                                                                 const char* endTag,
00372                                                                 bool ignoreCase,
00373                                                                 TiXmlEncoding encoding );
00374 
00375         static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00376 
00377         TiXmlCursor location;
00378 
00380         void*                   userData;
00381 
00382         // None of these methods are reliable for any language except English.
00383         // Good for approximation, not great for accuracy.
00384         static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
00385         static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
00386         inline static int ToLower( int v, TiXmlEncoding encoding )
00387         {
00388                 if ( encoding == TIXML_ENCODING_UTF8 )
00389                 {
00390                         if ( v < 128 ) return tolower( v );
00391                         return v;
00392                 }
00393                 else
00394                 {
00395                         return tolower( v );
00396                 }
00397         }
00398         static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
00399 
00400 private:
00401         TiXmlBase( const TiXmlBase& );                          // not implemented.
00402         TiXmlBase& operator=( const TiXmlBase& base );  // not allowed.
00403 
00404         struct Entity
00405         {
00406                 const char*     str;
00407                 unsigned int    strLength;
00408                 char                chr;
00409         };
00410         enum
00411         {
00412                 NUM_ENTITY = 5,
00413                 MAX_ENTITY_LENGTH = 6
00414 
00415         };
00416         static Entity entity[ NUM_ENTITY ];
00417         static bool condenseWhiteSpace;
00418 };
00419 
00420 
00427 class TiXmlNode : public TiXmlBase
00428 {
00429         friend class TiXmlDocument;
00430         friend class TiXmlElement;
00431 
00432 public:
00433         #ifdef TIXML_USE_STL
00434 
00438             friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
00439 
00456             friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
00457 
00459                 friend std::string& operator<< (std::string& out, const TiXmlNode& base );
00460 
00461         #endif
00462 
00466         enum NodeType
00467         {
00468                 DOCUMENT,
00469                 ELEMENT,
00470                 COMMENT,
00471                 UNKNOWN,
00472                 TEXT,
00473                 DECLARATION,
00474                 TYPECOUNT
00475         };
00476 
00477         virtual ~TiXmlNode();
00478 
00491         const char *Value() const { return value.c_str (); }
00492 
00493     #ifdef TIXML_USE_STL
00494 
00498         const std::string& ValueStr() const { return value; }
00499         #endif
00500 
00501         const TIXML_STRING& ValueTStr() const { return value; }
00502 
00512         void SetValue(const char * _value) { value = _value;}
00513 
00514     #ifdef TIXML_USE_STL
00515 
00516         void SetValue( const std::string& _value )      { value = _value; }
00517         #endif
00518 
00520         void Clear();
00521 
00523         TiXmlNode* Parent()                                                     { return parent; }
00524         const TiXmlNode* Parent() const                         { return parent; }
00525 
00526         const TiXmlNode* FirstChild()   const           { return firstChild; }  
00527         TiXmlNode* FirstChild()                                         { return firstChild; }
00528         const TiXmlNode* FirstChild( const char * value ) const;                        
00529 
00530         TiXmlNode* FirstChild( const char * _value ) {
00531                 // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
00532                 // call the method, cast the return back to non-const.
00533                 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
00534         }
00535         const TiXmlNode* LastChild() const      { return lastChild; }           
00536         TiXmlNode* LastChild()  { return lastChild; }
00537 
00538         const TiXmlNode* LastChild( const char * value ) const;                 
00539         TiXmlNode* LastChild( const char * _value ) {
00540                 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
00541         }
00542 
00543     #ifdef TIXML_USE_STL
00544         const TiXmlNode* FirstChild( const std::string& _value ) const  {       return FirstChild (_value.c_str ());    }       
00545         TiXmlNode* FirstChild( const std::string& _value )                              {       return FirstChild (_value.c_str ());    }       
00546         const TiXmlNode* LastChild( const std::string& _value ) const   {       return LastChild (_value.c_str ());     }       
00547         TiXmlNode* LastChild( const std::string& _value )                               {       return LastChild (_value.c_str ());     }       
00548         #endif
00549 
00566         const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
00567         TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
00568                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
00569         }
00570 
00572         const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
00573         TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
00574                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
00575         }
00576 
00577     #ifdef TIXML_USE_STL
00578         const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const  {       return IterateChildren (_value.c_str (), previous);     }       
00579         TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) {    return IterateChildren (_value.c_str (), previous);     }       
00580         #endif
00581 
00585         TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
00586 
00587 
00597         TiXmlNode* LinkEndChild( TiXmlNode* addThis );
00598 
00602         TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
00603 
00607         TiXmlNode* InsertAfterChild(  TiXmlNode* afterThis, const TiXmlNode& addThis );
00608 
00612         TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
00613 
00615         bool RemoveChild( TiXmlNode* removeThis );
00616 
00618         const TiXmlNode* PreviousSibling() const                        { return prev; }
00619         TiXmlNode* PreviousSibling()                                            { return prev; }
00620 
00622         const TiXmlNode* PreviousSibling( const char * ) const;
00623         TiXmlNode* PreviousSibling( const char *_prev ) {
00624                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
00625         }
00626 
00627     #ifdef TIXML_USE_STL
00628         const TiXmlNode* PreviousSibling( const std::string& _value ) const     {       return PreviousSibling (_value.c_str ());       }       
00629         TiXmlNode* PreviousSibling( const std::string& _value )                         {       return PreviousSibling (_value.c_str ());       }       
00630         const TiXmlNode* NextSibling( const std::string& _value) const          {       return NextSibling (_value.c_str ());   }       
00631         TiXmlNode* NextSibling( const std::string& _value)                                      {       return NextSibling (_value.c_str ());   }       
00632         #endif
00633 
00635         const TiXmlNode* NextSibling() const                            { return next; }
00636         TiXmlNode* NextSibling()                                                        { return next; }
00637 
00639         const TiXmlNode* NextSibling( const char * ) const;
00640         TiXmlNode* NextSibling( const char* _next ) {
00641                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
00642         }
00643 
00648         const TiXmlElement* NextSiblingElement() const;
00649         TiXmlElement* NextSiblingElement() {
00650                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
00651         }
00652 
00657         const TiXmlElement* NextSiblingElement( const char * ) const;
00658         TiXmlElement* NextSiblingElement( const char *_next ) {
00659                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
00660         }
00661 
00662     #ifdef TIXML_USE_STL
00663         const TiXmlElement* NextSiblingElement( const std::string& _value) const        {       return NextSiblingElement (_value.c_str ());    }       
00664         TiXmlElement* NextSiblingElement( const std::string& _value)                            {       return NextSiblingElement (_value.c_str ());    }       
00665         #endif
00666 
00668         const TiXmlElement* FirstChildElement() const;
00669         TiXmlElement* FirstChildElement() {
00670                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
00671         }
00672 
00674         const TiXmlElement* FirstChildElement( const char * _value ) const;
00675         TiXmlElement* FirstChildElement( const char * _value ) {
00676                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
00677         }
00678 
00679     #ifdef TIXML_USE_STL
00680         const TiXmlElement* FirstChildElement( const std::string& _value ) const        {       return FirstChildElement (_value.c_str ());     }       
00681         TiXmlElement* FirstChildElement( const std::string& _value )                            {       return FirstChildElement (_value.c_str ());     }       
00682         #endif
00683 
00688         int Type() const        { return type; }
00689 
00693         const TiXmlDocument* GetDocument() const;
00694         TiXmlDocument* GetDocument() {
00695                 return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
00696         }
00697 
00699         bool NoChildren() const                                         { return !firstChild; }
00700 
00701         virtual const TiXmlDocument*    ToDocument()    const { return 0; } 
00702         virtual const TiXmlElement*     ToElement()     const { return 0; } 
00703         virtual const TiXmlComment*     ToComment()     const { return 0; } 
00704         virtual const TiXmlUnknown*     ToUnknown()     const { return 0; } 
00705         virtual const TiXmlText*        ToText()        const { return 0; } 
00706         virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } 
00707 
00708         virtual TiXmlDocument*          ToDocument()    { return 0; } 
00709         virtual TiXmlElement*           ToElement()         { return 0; } 
00710         virtual TiXmlComment*           ToComment()     { return 0; } 
00711         virtual TiXmlUnknown*           ToUnknown()         { return 0; } 
00712         virtual TiXmlText*                  ToText()        { return 0; } 
00713         virtual TiXmlDeclaration*       ToDeclaration() { return 0; } 
00714 
00718         virtual TiXmlNode* Clone() const = 0;
00719 
00742         virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
00743 
00744 protected:
00745         TiXmlNode( NodeType _type );
00746 
00747         // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
00748         // and the assignment operator.
00749         void CopyTo( TiXmlNode* target ) const;
00750 
00751         #ifdef TIXML_USE_STL
00752             // The real work of the input operator.
00753         virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
00754         #endif
00755 
00756         // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
00757         TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
00758 
00759         TiXmlNode*              parent;
00760         NodeType                type;
00761 
00762         TiXmlNode*              firstChild;
00763         TiXmlNode*              lastChild;
00764 
00765         TIXML_STRING    value;
00766 
00767         TiXmlNode*              prev;
00768         TiXmlNode*              next;
00769 
00770 private:
00771         TiXmlNode( const TiXmlNode& );                          // not implemented.
00772         TiXmlNode& operator=( const TiXmlNode& base );  // not allowed.
00773 };
00774 
00775 
00783 class TiXmlAttribute : public TiXmlBase
00784 {
00785         friend class TiXmlAttributeSet;
00786 
00787 public:
00789         TiXmlAttribute() : TiXmlBase()
00790         {
00791                 document = 0;
00792                 prev = next = 0;
00793         }
00794 
00795         #ifdef TIXML_USE_STL
00796 
00797         TiXmlAttribute( const std::string& _name, const std::string& _value )
00798         {
00799                 name = _name;
00800                 value = _value;
00801                 document = 0;
00802                 prev = next = 0;
00803         }
00804         #endif
00805 
00807         TiXmlAttribute( const char * _name, const char * _value )
00808         {
00809                 name = _name;
00810                 value = _value;
00811                 document = 0;
00812                 prev = next = 0;
00813         }
00814 
00815         const char*             Name()  const           { return name.c_str(); }                
00816         const char*             Value() const           { return value.c_str(); }               
00817         #ifdef TIXML_USE_STL
00818         const std::string& ValueStr() const     { return value; }                               
00819         #endif
00820         int                             IntValue() const;                                                                       
00821         double                  DoubleValue() const;                                                            
00822 
00823         // Get the tinyxml string representation
00824         const TIXML_STRING& NameTStr() const { return name; }
00825 
00835         int QueryIntValue( int* _value ) const;
00837         int QueryDoubleValue( double* _value ) const;
00838 
00839         void SetName( const char* _name )       { name = _name; }                               
00840         void SetValue( const char* _value )     { value = _value; }                             
00841 
00842         void SetIntValue( int _value );                                                                         
00843         void SetDoubleValue( double _value );                                                           
00844 
00845     #ifdef TIXML_USE_STL
00846 
00847         void SetName( const std::string& _name )        { name = _name; }
00849         void SetValue( const std::string& _value )      { value = _value; }
00850         #endif
00851 
00853         const TiXmlAttribute* Next() const;
00854         TiXmlAttribute* Next() {
00855                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
00856         }
00857 
00859         const TiXmlAttribute* Previous() const;
00860         TiXmlAttribute* Previous() {
00861                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
00862         }
00863 
00864         bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
00865         bool operator<( const TiXmlAttribute& rhs )      const { return name < rhs.name; }
00866         bool operator>( const TiXmlAttribute& rhs )  const { return name > rhs.name; }
00867 
00868         /*      Attribute parsing starts: first letter of the name
00869                                                  returns: the next char after the value end quote
00870         */
00871         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
00872 
00873         // Prints this Attribute to a FILE stream.
00874         virtual void Print( FILE* cfile, int depth ) const {
00875                 Print( cfile, depth, 0 );
00876         }
00877         void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
00878 
00879         // [internal use]
00880         // Set the document pointer so the attribute can report errors.
00881         void SetDocument( TiXmlDocument* doc )  { document = doc; }
00882 
00883 private:
00884         TiXmlAttribute( const TiXmlAttribute& );                                // not implemented.
00885         TiXmlAttribute& operator=( const TiXmlAttribute& base );        // not allowed.
00886 
00887         TiXmlDocument*  document;       // A pointer back to a document, for error reporting.
00888         TIXML_STRING name;
00889         TIXML_STRING value;
00890         TiXmlAttribute* prev;
00891         TiXmlAttribute* next;
00892 };
00893 
00894 
00895 /*      A class used to manage a group of attributes.
00896         It is only used internally, both by the ELEMENT and the DECLARATION.
00897 
00898         The set can be changed transparent to the Element and Declaration
00899         classes that use it, but NOT transparent to the Attribute
00900         which has to implement a next() and previous() method. Which makes
00901         it a bit problematic and prevents the use of STL.
00902 
00903         This version is implemented with circular lists because:
00904                 - I like circular lists
00905                 - it demonstrates some independence from the (typical) doubly linked list.
00906 */
00907 class TiXmlAttributeSet
00908 {
00909 public:
00910         TiXmlAttributeSet();
00911         ~TiXmlAttributeSet();
00912 
00913         void Add( TiXmlAttribute* attribute );
00914         void Remove( TiXmlAttribute* attribute );
00915 
00916         const TiXmlAttribute* First()   const   { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00917         TiXmlAttribute* First()                                 { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00918         const TiXmlAttribute* Last() const              { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00919         TiXmlAttribute* Last()                                  { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00920 
00921         const TiXmlAttribute*   Find( const char* _name ) const;
00922         TiXmlAttribute* Find( const char* _name ) {
00923                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
00924         }
00925         #ifdef TIXML_USE_STL
00926         const TiXmlAttribute*   Find( const std::string& _name ) const;
00927         TiXmlAttribute* Find( const std::string& _name ) {
00928                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
00929         }
00930 
00931         #endif
00932 
00933 private:
00934         //*ME:  Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
00935         //*ME:  this class must be also use a hidden/disabled copy-constructor !!!
00936         TiXmlAttributeSet( const TiXmlAttributeSet& );  // not allowed
00937         TiXmlAttributeSet& operator=( const TiXmlAttributeSet& );       // not allowed (as TiXmlAttribute)
00938 
00939         TiXmlAttribute sentinel;
00940 };
00941 
00942 
00947 class TiXmlElement : public TiXmlNode
00948 {
00949 public:
00951         TiXmlElement (const char * in_value);
00952 
00953         #ifdef TIXML_USE_STL
00954 
00955         TiXmlElement( const std::string& _value );
00956         #endif
00957 
00958         TiXmlElement( const TiXmlElement& );
00959 
00960         TiXmlElement& operator=( const TiXmlElement& base );
00961 
00962         virtual ~TiXmlElement();
00963 
00967         const char* Attribute( const char* name ) const;
00968 
00975         const char* Attribute( const char* name, int* i ) const;
00976 
00983         const char* Attribute( const char* name, double* d ) const;
00984 
00992         int QueryIntAttribute( const char* name, int* _value ) const;
00994         int QueryDoubleAttribute( const char* name, double* _value ) const;
00996         int QueryFloatAttribute( const char* name, float* _value ) const {
00997                 double d;
00998                 int result = QueryDoubleAttribute( name, &d );
00999                 if ( result == TIXML_SUCCESS ) {
01000                         *_value = (float)d;
01001                 }
01002                 return result;
01003         }
01004 
01005     #ifdef TIXML_USE_STL
01006 
01014         template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
01015         {
01016                 const TiXmlAttribute* node = attributeSet.Find( name );
01017                 if ( !node )
01018                         return TIXML_NO_ATTRIBUTE;
01019 
01020                 std::stringstream sstream( node->ValueStr() );
01021                 sstream >> *outValue;
01022                 if ( !sstream.fail() )
01023                         return TIXML_SUCCESS;
01024                 return TIXML_WRONG_TYPE;
01025         }
01026         /*
01027          This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
01028          but template specialization is hard to get working cross-compiler. Leaving the bug for now.
01029 
01030         // The above will fail for std::string because the space character is used as a seperator.
01031         // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
01032         template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const
01033         {
01034                 const TiXmlAttribute* node = attributeSet.Find( name );
01035                 if ( !node )
01036                         return TIXML_NO_ATTRIBUTE;
01037                 *outValue = node->ValueStr();
01038                 return TIXML_SUCCESS;
01039         }
01040         */
01041         #endif
01042 
01046         void SetAttribute( const char* name, const char * _value );
01047 
01048     #ifdef TIXML_USE_STL
01049         const std::string* Attribute( const std::string& name ) const;
01050         const std::string* Attribute( const std::string& name, int* i ) const;
01051         const std::string* Attribute( const std::string& name, double* d ) const;
01052         int QueryIntAttribute( const std::string& name, int* _value ) const;
01053         int QueryDoubleAttribute( const std::string& name, double* _value ) const;
01054 
01056         void SetAttribute( const std::string& name, const std::string& _value );
01058         void SetAttribute( const std::string& name, int _value );
01059         #endif
01060 
01064         void SetAttribute( const char * name, int value );
01065 
01069         void SetDoubleAttribute( const char * name, double value );
01070 
01073         void RemoveAttribute( const char * name );
01074     #ifdef TIXML_USE_STL
01075         void RemoveAttribute( const std::string& name ) {       RemoveAttribute (name.c_str ());        }       
01076         #endif
01077 
01078         const TiXmlAttribute* FirstAttribute() const    { return attributeSet.First(); }                
01079         TiXmlAttribute* FirstAttribute()                                { return attributeSet.First(); }
01080         const TiXmlAttribute* LastAttribute()   const   { return attributeSet.Last(); }         
01081         TiXmlAttribute* LastAttribute()                                 { return attributeSet.Last(); }
01082 
01115         const char* GetText() const;
01116 
01118         virtual TiXmlNode* Clone() const;
01119         // Print the Element to a FILE stream.
01120         virtual void Print( FILE* cfile, int depth ) const;
01121 
01122         /*      Attribtue parsing starts: next char past '<'
01123                                                  returns: next char past '>'
01124         */
01125         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01126 
01127         virtual const TiXmlElement*     ToElement()     const { return this; } 
01128         virtual TiXmlElement*           ToElement()               { return this; } 
01129 
01132         virtual bool Accept( TiXmlVisitor* visitor ) const;
01133 
01134 protected:
01135 
01136         void CopyTo( TiXmlElement* target ) const;
01137         void ClearThis();       // like clear, but initializes 'this' object as well
01138 
01139         // Used to be public [internal use]
01140         #ifdef TIXML_USE_STL
01141         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01142         #endif
01143         /*      [internal use]
01144                 Reads the "value" of the element -- another element, or text.
01145                 This should terminate with the current end tag.
01146         */
01147         const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01148 
01149 private:
01150 
01151         TiXmlAttributeSet attributeSet;
01152 };
01153 
01154 
01157 class TiXmlComment : public TiXmlNode
01158 {
01159 public:
01161         TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
01163         TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
01164                 SetValue( _value );
01165         }
01166         TiXmlComment( const TiXmlComment& );
01167         TiXmlComment& operator=( const TiXmlComment& base );
01168 
01169         virtual ~TiXmlComment() {}
01170 
01172         virtual TiXmlNode* Clone() const;
01173         // Write this Comment to a FILE stream.
01174         virtual void Print( FILE* cfile, int depth ) const;
01175 
01176         /*      Attribtue parsing starts: at the ! of the !--
01177                                                  returns: next char past '>'
01178         */
01179         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01180 
01181         virtual const TiXmlComment*  ToComment() const { return this; } 
01182         virtual TiXmlComment*  ToComment() { return this; } 
01183 
01186         virtual bool Accept( TiXmlVisitor* visitor ) const;
01187 
01188 protected:
01189         void CopyTo( TiXmlComment* target ) const;
01190 
01191         // used to be public
01192         #ifdef TIXML_USE_STL
01193         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01194         #endif
01195 //      virtual void StreamOut( TIXML_OSTREAM * out ) const;
01196 
01197 private:
01198 
01199 };
01200 
01201 
01207 class TiXmlText : public TiXmlNode
01208 {
01209         friend class TiXmlElement;
01210 public:
01215         TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
01216         {
01217                 SetValue( initValue );
01218                 cdata = false;
01219         }
01220         virtual ~TiXmlText() {}
01221 
01222         #ifdef TIXML_USE_STL
01223 
01224         TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
01225         {
01226                 SetValue( initValue );
01227                 cdata = false;
01228         }
01229         #endif
01230 
01231         TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT )       { copy.CopyTo( this ); }
01232         TiXmlText& operator=( const TiXmlText& base )   { base.CopyTo( this ); return *this;}
01233 
01234         // Write this text object to a FILE stream.
01235         virtual void Print( FILE* cfile, int depth ) const;
01236 
01238         bool CDATA() const                              { return cdata; }
01240         void SetCDATA( bool _cdata )    { cdata = _cdata; }
01241 
01242         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01243 
01244         virtual const TiXmlText* ToText() const { return this; } 
01245         virtual TiXmlText*       ToText()       { return this; } 
01246 
01249         virtual bool Accept( TiXmlVisitor* content ) const;
01250 
01251 protected :
01253         virtual TiXmlNode* Clone() const;
01254         void CopyTo( TiXmlText* target ) const;
01255 
01256         bool Blank() const;     // returns true if all white space and new lines
01257         // [internal use]
01258         #ifdef TIXML_USE_STL
01259         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01260         #endif
01261 
01262 private:
01263         bool cdata;                     // true if this should be input and output as a CDATA style text element
01264 };
01265 
01266 
01280 class TiXmlDeclaration : public TiXmlNode
01281 {
01282 public:
01284         TiXmlDeclaration()   : TiXmlNode( TiXmlNode::DECLARATION ) {}
01285 
01286 #ifdef TIXML_USE_STL
01287 
01288         TiXmlDeclaration(       const std::string& _version,
01289                                                 const std::string& _encoding,
01290                                                 const std::string& _standalone );
01291 #endif
01292 
01294         TiXmlDeclaration(       const char* _version,
01295                                                 const char* _encoding,
01296                                                 const char* _standalone );
01297 
01298         TiXmlDeclaration( const TiXmlDeclaration& copy );
01299         TiXmlDeclaration& operator=( const TiXmlDeclaration& copy );
01300 
01301         virtual ~TiXmlDeclaration()     {}
01302 
01304         const char *Version() const                     { return version.c_str (); }
01306         const char *Encoding() const            { return encoding.c_str (); }
01308         const char *Standalone() const          { return standalone.c_str (); }
01309 
01311         virtual TiXmlNode* Clone() const;
01312         // Print this declaration to a FILE stream.
01313         virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
01314         virtual void Print( FILE* cfile, int depth ) const {
01315                 Print( cfile, depth, 0 );
01316         }
01317 
01318         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01319 
01320         virtual const TiXmlDeclaration* ToDeclaration() const { return this; } 
01321         virtual TiXmlDeclaration*       ToDeclaration()       { return this; } 
01322 
01325         virtual bool Accept( TiXmlVisitor* visitor ) const;
01326 
01327 protected:
01328         void CopyTo( TiXmlDeclaration* target ) const;
01329         // used to be public
01330         #ifdef TIXML_USE_STL
01331         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01332         #endif
01333 
01334 private:
01335 
01336         TIXML_STRING version;
01337         TIXML_STRING encoding;
01338         TIXML_STRING standalone;
01339 };
01340 
01341 
01349 class TiXmlUnknown : public TiXmlNode
01350 {
01351 public:
01352         TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN )        {}
01353         virtual ~TiXmlUnknown() {}
01354 
01355         TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN )              { copy.CopyTo( this ); }
01356         TiXmlUnknown& operator=( const TiXmlUnknown& copy )                                                                             { copy.CopyTo( this ); return *this;}
01357 
01359         virtual TiXmlNode* Clone() const;
01360         // Print this Unknown to a FILE stream.
01361         virtual void Print( FILE* cfile, int depth ) const;
01362 
01363         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01364 
01365         virtual const TiXmlUnknown*     ToUnknown()     const { return this; } 
01366         virtual TiXmlUnknown*           ToUnknown()         { return this; } 
01367 
01370         virtual bool Accept( TiXmlVisitor* content ) const;
01371 
01372 protected:
01373         void CopyTo( TiXmlUnknown* target ) const;
01374 
01375         #ifdef TIXML_USE_STL
01376         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01377         #endif
01378 
01379 private:
01380 
01381 };
01382 
01383 
01388 class TiXmlDocument : public TiXmlNode
01389 {
01390 public:
01392         TiXmlDocument();
01394         TiXmlDocument( const char * documentName );
01395 
01396         #ifdef TIXML_USE_STL
01397 
01398         TiXmlDocument( const std::string& documentName );
01399         #endif
01400 
01401         TiXmlDocument( const TiXmlDocument& copy );
01402         TiXmlDocument& operator=( const TiXmlDocument& copy );
01403 
01404         virtual ~TiXmlDocument() {}
01405 
01410         bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01412         bool SaveFile() const;
01414         bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01416         bool SaveFile( const char * filename ) const;
01422         bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01424         bool SaveFile( FILE* ) const;
01425 
01426         #ifdef TIXML_USE_STL
01427         bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )                   
01428         {
01429 //              StringToBuffer f( filename );
01430 //              return ( f.buffer && LoadFile( f.buffer, encoding ));
01431                 return LoadFile( filename.c_str(), encoding );
01432         }
01433         bool SaveFile( const std::string& filename ) const              
01434         {
01435 //              StringToBuffer f( filename );
01436 //              return ( f.buffer && SaveFile( f.buffer ));
01437                 return SaveFile( filename.c_str() );
01438         }
01439         #endif
01440 
01445         virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01446 
01451         const TiXmlElement* RootElement() const         { return FirstChildElement(); }
01452         TiXmlElement* RootElement()                                     { return FirstChildElement(); }
01453 
01459         bool Error() const                                              { return error; }
01460 
01462         const char * ErrorDesc() const  { return errorDesc.c_str (); }
01463 
01467         int ErrorId()   const                           { return errorId; }
01468 
01476         int ErrorRow() const    { return errorLocation.row+1; }
01477         int ErrorCol() const    { return errorLocation.col+1; } 
01478 
01503         void SetTabSize( int _tabsize )         { tabsize = _tabsize; }
01504 
01505         int TabSize() const     { return tabsize; }
01506 
01510         void ClearError()                                               {       error = false;
01511                                                                                                 errorId = 0;
01512                                                                                                 errorDesc = "";
01513                                                                                                 errorLocation.row = errorLocation.col = 0;
01514                                                                                                 //errorLocation.last = 0;
01515                                                                                         }
01516 
01518         void Print() const                                              { Print( stdout, 0 ); }
01519 
01520         /* Write the document to a string using formatted printing ("pretty print"). This
01521                 will allocate a character array (new char[]) and return it as a pointer. The
01522                 calling code pust call delete[] on the return char* to avoid a memory leak.
01523         */
01524         //char* PrintToMemory() const;
01525 
01527         virtual void Print( FILE* cfile, int depth = 0 ) const;
01528         // [internal use]
01529         void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01530 
01531         virtual const TiXmlDocument*    ToDocument()    const { return this; } 
01532         virtual TiXmlDocument*          ToDocument()          { return this; } 
01533 
01536         virtual bool Accept( TiXmlVisitor* content ) const;
01537 
01538 protected :
01539         // [internal use]
01540         virtual TiXmlNode* Clone() const;
01541         #ifdef TIXML_USE_STL
01542         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01543         #endif
01544 
01545 private:
01546         void CopyTo( TiXmlDocument* target ) const;
01547 
01548         bool error;
01549         int  errorId;
01550         TIXML_STRING errorDesc;
01551         int tabsize;
01552         TiXmlCursor errorLocation;
01553         bool useMicrosoftBOM;           // the UTF-8 BOM were found when read. Note this, and try to write.
01554 };
01555 
01556 
01637 class TiXmlHandle
01638 {
01639 public:
01641         TiXmlHandle( TiXmlNode* _node )                                 { this->node = _node; }
01643         TiXmlHandle( const TiXmlHandle& ref )                   { this->node = ref.node; }
01644         TiXmlHandle& operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
01645 
01647         TiXmlHandle FirstChild() const;
01649         TiXmlHandle FirstChild( const char * value ) const;
01651         TiXmlHandle FirstChildElement() const;
01653         TiXmlHandle FirstChildElement( const char * value ) const;
01654 
01658         TiXmlHandle Child( const char* value, int index ) const;
01662         TiXmlHandle Child( int index ) const;
01667         TiXmlHandle ChildElement( const char* value, int index ) const;
01672         TiXmlHandle ChildElement( int index ) const;
01673 
01674         #ifdef TIXML_USE_STL
01675         TiXmlHandle FirstChild( const std::string& _value ) const                               { return FirstChild( _value.c_str() ); }
01676         TiXmlHandle FirstChildElement( const std::string& _value ) const                { return FirstChildElement( _value.c_str() ); }
01677 
01678         TiXmlHandle Child( const std::string& _value, int index ) const                 { return Child( _value.c_str(), index ); }
01679         TiXmlHandle ChildElement( const std::string& _value, int index ) const  { return ChildElement( _value.c_str(), index ); }
01680         #endif
01681 
01684         TiXmlNode* ToNode() const                       { return node; }
01687         TiXmlElement* ToElement() const         { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
01690         TiXmlText* ToText() const                       { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
01693         TiXmlUnknown* ToUnknown() const         { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
01694 
01698         TiXmlNode* Node() const                 { return ToNode(); }
01702         TiXmlElement* Element() const   { return ToElement(); }
01706         TiXmlText* Text() const                 { return ToText(); }
01710         TiXmlUnknown* Unknown() const   { return ToUnknown(); }
01711 
01712 private:
01713         TiXmlNode* node;
01714 };
01715 
01716 
01736 class TiXmlPrinter : public TiXmlVisitor
01737 {
01738 public:
01739         TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
01740                                          buffer(), indent( "    " ), lineBreak( "\n" ) {}
01741 
01742         virtual bool VisitEnter( const TiXmlDocument& doc );
01743         virtual bool VisitExit( const TiXmlDocument& doc );
01744 
01745         virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
01746         virtual bool VisitExit( const TiXmlElement& element );
01747 
01748         virtual bool Visit( const TiXmlDeclaration& declaration );
01749         virtual bool Visit( const TiXmlText& text );
01750         virtual bool Visit( const TiXmlComment& comment );
01751         virtual bool Visit( const TiXmlUnknown& unknown );
01752 
01756         void SetIndent( const char* _indent )                   { indent = _indent ? _indent : "" ; }
01758         const char* Indent()                                                    { return indent.c_str(); }
01763         void SetLineBreak( const char* _lineBreak )             { lineBreak = _lineBreak ? _lineBreak : ""; }
01765         const char* LineBreak()                                                 { return lineBreak.c_str(); }
01766 
01770         void SetStreamPrinting()                                                { indent = "";
01771                                                                                                           lineBreak = "";
01772                                                                                                         }
01774         const char* CStr()                                                              { return buffer.c_str(); }
01776         size_t Size()                                                                   { return buffer.size(); }
01777 
01778         #ifdef TIXML_USE_STL
01779 
01780         const std::string& Str()                                                { return buffer; }
01781         #endif
01782 
01783 private:
01784         void DoIndent() {
01785                 for( int i=0; i<depth; ++i )
01786                         buffer += indent;
01787         }
01788         void DoLineBreak() {
01789                 buffer += lineBreak;
01790         }
01791 
01792         int depth;
01793         bool simpleTextPrint;
01794         TIXML_STRING buffer;
01795         TIXML_STRING indent;
01796         TIXML_STRING lineBreak;
01797 };
01798 
01799 
01800 #ifdef _MSC_VER
01801 #pragma warning( pop )
01802 #endif
01803 
01804 #endif
01805