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 ROSPACK_TINYXML_INCLUDED
00027 #define ROSPACK_TINYXML_INCLUDED
00028 
00029 #ifdef _MSC_VER
00030 #pragma warning( push )
00031 #pragma warning( disable : 4530 )
00032 #pragma warning( disable : 4786 )
00033 #endif
00034 
00035 #include <ctype.h>
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <string.h>
00039 #include <assert.h>
00040 
00041 // Help out windows:
00042 #if defined( _DEBUG ) && !defined( DEBUG )
00043 #define DEBUG
00044 #endif
00045 
00046 #ifdef TIXML_USE_STL
00047         #include <string>
00048         #include <iostream>
00049         #include <sstream>
00050         #define TIXML_STRING            std::string
00051 #else
00052         #include "tinystr.h"
00053         #define TIXML_STRING            TiXmlString
00054 #endif
00055 
00056 // Deprecated library function hell. Compilers want to use the
00057 // new safe versions. This probably doesn't fully address the problem,
00058 // but it gets closer. There are too many compilers for me to fully
00059 // test. If you get compilation troubles, undefine TIXML_SAFE
00060 #define TIXML_SAFE
00061 
00062 #ifdef TIXML_SAFE
00063         #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
00064                 // Microsoft visual studio, version 2005 and higher.
00065                 #define TIXML_SNPRINTF _snprintf_s
00066                 #define TIXML_SNSCANF  _snscanf_s
00067                 #define TIXML_SSCANF   sscanf_s
00068         #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
00069                 // Microsoft visual studio, version 6 and higher.
00070                 //#pragma message( "Using _sn* functions." )
00071                 #define TIXML_SNPRINTF _snprintf
00072                 #define TIXML_SNSCANF  _snscanf
00073                 #define TIXML_SSCANF   sscanf
00074         #elif defined(__GNUC__) && (__GNUC__ >= 3 )
00075                 // GCC version 3 and higher.s
00076                 //#warning( "Using sn* functions." )
00077                 #define TIXML_SNPRINTF snprintf
00078                 #define TIXML_SNSCANF  snscanf
00079                 #define TIXML_SSCANF   sscanf
00080         #else
00081                 #define TIXML_SSCANF   sscanf
00082         #endif
00083 #endif  
00084 
00085 #if defined(WIN32)
00086   #if defined(ROS_BUILD_STATIC_LIBS)
00087     #define TINYXML_EXPORT
00088   #elif defined(rospack_EXPORTS) || defined(rosstack_EXPORTS)
00089     #define TINYXML_EXPORT __declspec(dllexport)
00090   #else
00091     #define TINYXML_EXPORT __declspec(dllimport)
00092   #endif
00093 #else
00094   #define TINYXML_EXPORT
00095 #endif
00096 
00097 namespace rospack_tinyxml {
00098 
00099 class TiXmlDocument;
00100 class TiXmlElement;
00101 class TiXmlComment;
00102 class TiXmlUnknown;
00103 class TiXmlAttribute;
00104 class TiXmlText;
00105 class TiXmlDeclaration;
00106 class TiXmlParsingData;
00107 
00108 const int TIXML_MAJOR_VERSION = 2;
00109 const int TIXML_MINOR_VERSION = 5;
00110 const int TIXML_PATCH_VERSION = 3;
00111 
00112 /*      Internal structure for tracking location of items 
00113         in the XML file.
00114 */
00115 struct TiXmlCursor
00116 {
00117         TiXmlCursor()           { Clear(); }
00118         void Clear()            { row = col = -1; }
00119 
00120         int row;        // 0 based.
00121         int col;        // 0 based.
00122 };
00123 
00124 
00143 class TINYXML_EXPORT TiXmlVisitor
00144 {
00145 public:
00146         virtual ~TiXmlVisitor() {}
00147 
00149         virtual bool VisitEnter( const TiXmlDocument& /*doc*/ )                 { return true; }
00151         virtual bool VisitExit( const TiXmlDocument& /*doc*/ )                  { return true; }
00152 
00154         virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ )    { return true; }
00156         virtual bool VisitExit( const TiXmlElement& /*element*/ )               { return true; }
00157 
00159         virtual bool Visit( const TiXmlDeclaration& /*declaration*/ )   { return true; }
00161         virtual bool Visit( const TiXmlText& /*text*/ )                                 { return true; }
00163         virtual bool Visit( const TiXmlComment& /*comment*/ )                   { return true; }
00165         virtual bool Visit( const TiXmlUnknown& /*unknown*/ )                   { return true; }
00166 };
00167 
00168 // Only used by Attribute::Query functions
00169 enum 
00170 { 
00171         TIXML_SUCCESS,
00172         TIXML_NO_ATTRIBUTE,
00173         TIXML_WRONG_TYPE
00174 };
00175 
00176 
00177 // Used by the parsing routines.
00178 enum TiXmlEncoding
00179 {
00180         TIXML_ENCODING_UNKNOWN,
00181         TIXML_ENCODING_UTF8,
00182         TIXML_ENCODING_LEGACY
00183 };
00184 
00185 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
00186 
00209 class TINYXML_EXPORT TiXmlBase
00210 {
00211         friend class TiXmlNode;
00212         friend class TiXmlElement;
00213         friend class TiXmlDocument;
00214 
00215 public:
00216         TiXmlBase()     :       userData(0)             {}
00217         virtual ~TiXmlBase()                    {}
00218 
00228         virtual void Print( FILE* cfile, int depth ) const = 0;
00229 
00236         static void SetCondenseWhiteSpace( bool condense )              { condenseWhiteSpace = condense; }
00237 
00239         static bool IsWhiteSpaceCondensed()                                             { return condenseWhiteSpace; }
00240 
00259         int Row() const                 { return location.row + 1; }
00260         int Column() const              { return location.col + 1; }    
00261 
00262         void  SetUserData( void* user )                 { userData = user; }    
00263         void* GetUserData()                                             { return userData; }    
00264         const void* GetUserData() const                 { return userData; }    
00265 
00266         // Table that returns, for a given lead byte, the total number of bytes
00267         // in the UTF-8 sequence.
00268         static const int utf8ByteTable[256];
00269 
00270         virtual const char* Parse(      const char* p, 
00271                                                                 TiXmlParsingData* data, 
00272                                                                 TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
00273 
00277         static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
00278 
00279         enum
00280         {
00281                 TIXML_NO_ERROR = 0,
00282                 TIXML_ERROR,
00283                 TIXML_ERROR_OPENING_FILE,
00284                 TIXML_ERROR_OUT_OF_MEMORY,
00285                 TIXML_ERROR_PARSING_ELEMENT,
00286                 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00287                 TIXML_ERROR_READING_ELEMENT_VALUE,
00288                 TIXML_ERROR_READING_ATTRIBUTES,
00289                 TIXML_ERROR_PARSING_EMPTY,
00290                 TIXML_ERROR_READING_END_TAG,
00291                 TIXML_ERROR_PARSING_UNKNOWN,
00292                 TIXML_ERROR_PARSING_COMMENT,
00293                 TIXML_ERROR_PARSING_DECLARATION,
00294                 TIXML_ERROR_DOCUMENT_EMPTY,
00295                 TIXML_ERROR_EMBEDDED_NULL,
00296                 TIXML_ERROR_PARSING_CDATA,
00297                 TIXML_ERROR_DOCUMENT_TOP_ONLY,
00298 
00299                 TIXML_ERROR_STRING_COUNT
00300         };
00301 
00302 protected:
00303 
00304         static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
00305         inline static bool IsWhiteSpace( char c )               
00306         { 
00307                 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 
00308         }
00309         inline static bool IsWhiteSpace( int c )
00310         {
00311                 if ( c < 256 )
00312                         return IsWhiteSpace( (char) c );
00313                 return false;   // Again, only truly correct for English/Latin...but usually works.
00314         }
00315 
00316         #ifdef TIXML_USE_STL
00317         static bool     StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
00318         static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
00319         #endif
00320 
00321         /*      Reads an XML name into the string provided. Returns
00322                 a pointer just past the last character of the name,
00323                 or 0 if the function has an error.
00324         */
00325         static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
00326 
00327         /*      Reads text. Returns a pointer past the given end tag.
00328                 Wickedly complex options, but it keeps the (sensitive) code in one place.
00329         */
00330         static const char* ReadText(    const char* in,                         // where to start
00331                                                                         TIXML_STRING* text,                     // the string read
00332                                                                         bool ignoreWhiteSpace,          // whether to keep the white space
00333                                                                         const char* endTag,                     // what ends this text
00334                                                                         bool ignoreCase,                        // whether to ignore case in the end tag
00335                                                                         TiXmlEncoding encoding );       // the current encoding
00336 
00337         // If an entity has been found, transform it into a character.
00338         static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
00339 
00340         // Get a character, while interpreting entities.
00341         // The length can be from 0 to 4 bytes.
00342         inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
00343         {
00344                 assert( p );
00345                 if ( encoding == TIXML_ENCODING_UTF8 )
00346                 {
00347                         *length = utf8ByteTable[ *((const unsigned char*)p) ];
00348                         assert( *length >= 0 && *length < 5 );
00349                 }
00350                 else
00351                 {
00352                         *length = 1;
00353                 }
00354 
00355                 if ( *length == 1 )
00356                 {
00357                         if ( *p == '&' )
00358                                 return GetEntity( p, _value, length, encoding );
00359                         *_value = *p;
00360                         return p+1;
00361                 }
00362                 else if ( *length )
00363                 {
00364                         //strncpy( _value, p, *length );        // lots of compilers don't like this function (unsafe),
00365                                                                                                 // and the null terminator isn't needed
00366                         for( int i=0; p[i] && i<*length; ++i ) {
00367                                 _value[i] = p[i];
00368                         }
00369                         return p + (*length);
00370                 }
00371                 else
00372                 {
00373                         // Not valid text.
00374                         return 0;
00375                 }
00376         }
00377 
00378         // Return true if the next characters in the stream are any of the endTag sequences.
00379         // Ignore case only works for english, and should only be relied on when comparing
00380         // to English words: StringEqual( p, "version", true ) is fine.
00381         static bool StringEqual(        const char* p,
00382                                                                 const char* endTag,
00383                                                                 bool ignoreCase,
00384                                                                 TiXmlEncoding encoding );
00385 
00386         static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00387 
00388         TiXmlCursor location;
00389 
00391         void*                   userData;
00392         
00393         // None of these methods are reliable for any language except English.
00394         // Good for approximation, not great for accuracy.
00395         static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
00396         static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
00397         inline static int ToLower( int v, TiXmlEncoding encoding )
00398         {
00399                 if ( encoding == TIXML_ENCODING_UTF8 )
00400                 {
00401                         if ( v < 128 ) return tolower( v );
00402                         return v;
00403                 }
00404                 else
00405                 {
00406                         return tolower( v );
00407                 }
00408         }
00409         static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
00410 
00411 private:
00412         TiXmlBase( const TiXmlBase& );                          // not implemented.
00413         void operator=( const TiXmlBase& base );        // not allowed.
00414 
00415         struct Entity
00416         {
00417                 const char*     str;
00418                 unsigned int    strLength;
00419                 char                chr;
00420         };
00421         enum
00422         {
00423                 NUM_ENTITY = 5,
00424                 MAX_ENTITY_LENGTH = 6
00425 
00426         };
00427         static Entity entity[ NUM_ENTITY ];
00428         static bool condenseWhiteSpace;
00429 };
00430 
00431 
00438 class TINYXML_EXPORT TiXmlNode : public TiXmlBase
00439 {
00440         friend class TiXmlDocument;
00441         friend class TiXmlElement;
00442 
00443 public:
00444         #ifdef TIXML_USE_STL    
00445 
00449             friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
00450 
00467             friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
00468 
00470                 friend std::string& operator<< (std::string& out, const TiXmlNode& base );
00471 
00472         #endif
00473 
00477         enum NodeType
00478         {
00479                 DOCUMENT,
00480                 ELEMENT,
00481                 COMMENT,
00482                 UNKNOWN,
00483                 TEXT,
00484                 DECLARATION,
00485                 TYPECOUNT
00486         };
00487 
00488         virtual ~TiXmlNode();
00489 
00502         const char *Value() const { return value.c_str (); }
00503 
00504     #ifdef TIXML_USE_STL
00505 
00509         const std::string& ValueStr() const { return value; }
00510         #endif
00511 
00512         const TIXML_STRING& ValueTStr() const { return value; }
00513 
00523         void SetValue(const char * _value) { value = _value;}
00524 
00525     #ifdef TIXML_USE_STL
00526 
00527         void SetValue( const std::string& _value )      { value = _value; }
00528         #endif
00529 
00531         void Clear();
00532 
00534         TiXmlNode* Parent()                                                     { return parent; }
00535         const TiXmlNode* Parent() const                         { return parent; }
00536 
00537         const TiXmlNode* FirstChild()   const           { return firstChild; }  
00538         TiXmlNode* FirstChild()                                         { return firstChild; }
00539         const TiXmlNode* FirstChild( const char * value ) const;                        
00540 
00541         TiXmlNode* FirstChild( const char * _value ) {
00542                 // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
00543                 // call the method, cast the return back to non-const.
00544                 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
00545         }
00546         const TiXmlNode* LastChild() const      { return lastChild; }           
00547         TiXmlNode* LastChild()  { return lastChild; }
00548         
00549         const TiXmlNode* LastChild( const char * value ) const;                 
00550         TiXmlNode* LastChild( const char * _value ) {
00551                 return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
00552         }
00553 
00554     #ifdef TIXML_USE_STL
00555         const TiXmlNode* FirstChild( const std::string& _value ) const  {       return FirstChild (_value.c_str ());    }       
00556         TiXmlNode* FirstChild( const std::string& _value )                              {       return FirstChild (_value.c_str ());    }       
00557         const TiXmlNode* LastChild( const std::string& _value ) const   {       return LastChild (_value.c_str ());     }       
00558         TiXmlNode* LastChild( const std::string& _value )                               {       return LastChild (_value.c_str ());     }       
00559         #endif
00560 
00577         const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
00578         TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
00579                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
00580         }
00581 
00583         const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
00584         TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
00585                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
00586         }
00587 
00588     #ifdef TIXML_USE_STL
00589         const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const  {       return IterateChildren (_value.c_str (), previous);     }       
00590         TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) {    return IterateChildren (_value.c_str (), previous);     }       
00591         #endif
00592 
00596         TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
00597 
00598 
00608         TiXmlNode* LinkEndChild( TiXmlNode* addThis );
00609 
00613         TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
00614 
00618         TiXmlNode* InsertAfterChild(  TiXmlNode* afterThis, const TiXmlNode& addThis );
00619 
00623         TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
00624 
00626         bool RemoveChild( TiXmlNode* removeThis );
00627 
00629         const TiXmlNode* PreviousSibling() const                        { return prev; }
00630         TiXmlNode* PreviousSibling()                                            { return prev; }
00631 
00633         const TiXmlNode* PreviousSibling( const char * ) const;
00634         TiXmlNode* PreviousSibling( const char *_prev ) {
00635                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
00636         }
00637 
00638     #ifdef TIXML_USE_STL
00639         const TiXmlNode* PreviousSibling( const std::string& _value ) const     {       return PreviousSibling (_value.c_str ());       }       
00640         TiXmlNode* PreviousSibling( const std::string& _value )                         {       return PreviousSibling (_value.c_str ());       }       
00641         const TiXmlNode* NextSibling( const std::string& _value) const          {       return NextSibling (_value.c_str ());   }       
00642         TiXmlNode* NextSibling( const std::string& _value)                                      {       return NextSibling (_value.c_str ());   }       
00643         #endif
00644 
00646         const TiXmlNode* NextSibling() const                            { return next; }
00647         TiXmlNode* NextSibling()                                                        { return next; }
00648 
00650         const TiXmlNode* NextSibling( const char * ) const;
00651         TiXmlNode* NextSibling( const char* _next ) {
00652                 return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
00653         }
00654 
00659         const TiXmlElement* NextSiblingElement() const;
00660         TiXmlElement* NextSiblingElement() {
00661                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
00662         }
00663 
00668         const TiXmlElement* NextSiblingElement( const char * ) const;
00669         TiXmlElement* NextSiblingElement( const char *_next ) {
00670                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
00671         }
00672 
00673     #ifdef TIXML_USE_STL
00674         const TiXmlElement* NextSiblingElement( const std::string& _value) const        {       return NextSiblingElement (_value.c_str ());    }       
00675         TiXmlElement* NextSiblingElement( const std::string& _value)                            {       return NextSiblingElement (_value.c_str ());    }       
00676         #endif
00677 
00679         const TiXmlElement* FirstChildElement() const;
00680         TiXmlElement* FirstChildElement() {
00681                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
00682         }
00683 
00685         const TiXmlElement* FirstChildElement( const char * _value ) const;
00686         TiXmlElement* FirstChildElement( const char * _value ) {
00687                 return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
00688         }
00689 
00690     #ifdef TIXML_USE_STL
00691         const TiXmlElement* FirstChildElement( const std::string& _value ) const        {       return FirstChildElement (_value.c_str ());     }       
00692         TiXmlElement* FirstChildElement( const std::string& _value )                            {       return FirstChildElement (_value.c_str ());     }       
00693         #endif
00694 
00699         int Type() const        { return type; }
00700 
00704         const TiXmlDocument* GetDocument() const;
00705         TiXmlDocument* GetDocument() {
00706                 return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
00707         }
00708 
00710         bool NoChildren() const                                         { return !firstChild; }
00711 
00712         virtual const TiXmlDocument*    ToDocument()    const { return 0; } 
00713         virtual const TiXmlElement*     ToElement()     const { return 0; } 
00714         virtual const TiXmlComment*     ToComment()     const { return 0; } 
00715         virtual const TiXmlUnknown*     ToUnknown()     const { return 0; } 
00716         virtual const TiXmlText*        ToText()        const { return 0; } 
00717         virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } 
00718 
00719         virtual TiXmlDocument*          ToDocument()    { return 0; } 
00720         virtual TiXmlElement*           ToElement()         { return 0; } 
00721         virtual TiXmlComment*           ToComment()     { return 0; } 
00722         virtual TiXmlUnknown*           ToUnknown()         { return 0; } 
00723         virtual TiXmlText*                  ToText()        { return 0; } 
00724         virtual TiXmlDeclaration*       ToDeclaration() { return 0; } 
00725 
00729         virtual TiXmlNode* Clone() const = 0;
00730 
00753         virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
00754 
00755 protected:
00756         TiXmlNode( NodeType _type );
00757 
00758         // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
00759         // and the assignment operator.
00760         void CopyTo( TiXmlNode* target ) const;
00761 
00762         #ifdef TIXML_USE_STL
00763             // The real work of the input operator.
00764         virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
00765         #endif
00766 
00767         // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
00768         TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
00769 
00770         TiXmlNode*              parent;
00771         NodeType                type;
00772 
00773         TiXmlNode*              firstChild;
00774         TiXmlNode*              lastChild;
00775 
00776         TIXML_STRING    value;
00777 
00778         TiXmlNode*              prev;
00779         TiXmlNode*              next;
00780 
00781 private:
00782         TiXmlNode( const TiXmlNode& );                          // not implemented.
00783         void operator=( const TiXmlNode& base );        // not allowed.
00784 };
00785 
00786 
00794 class TINYXML_EXPORT TiXmlAttribute : public TiXmlBase
00795 {
00796         friend class TiXmlAttributeSet;
00797 
00798 public:
00800         TiXmlAttribute() : TiXmlBase()
00801         {
00802                 document = 0;
00803                 prev = next = 0;
00804         }
00805 
00806         #ifdef TIXML_USE_STL
00807 
00808         TiXmlAttribute( const std::string& _name, const std::string& _value )
00809         {
00810                 name = _name;
00811                 value = _value;
00812                 document = 0;
00813                 prev = next = 0;
00814         }
00815         #endif
00816 
00818         TiXmlAttribute( const char * _name, const char * _value )
00819         {
00820                 name = _name;
00821                 value = _value;
00822                 document = 0;
00823                 prev = next = 0;
00824         }
00825 
00826         const char*             Name()  const           { return name.c_str(); }                
00827         const char*             Value() const           { return value.c_str(); }               
00828         #ifdef TIXML_USE_STL
00829         const std::string& ValueStr() const     { return value; }                               
00830         #endif
00831         int                             IntValue() const;                                                                       
00832         double                  DoubleValue() const;                                                            
00833 
00834         // Get the tinyxml string representation
00835         const TIXML_STRING& NameTStr() const { return name; }
00836 
00846         int QueryIntValue( int* _value ) const;
00848         int QueryDoubleValue( double* _value ) const;
00849 
00850         void SetName( const char* _name )       { name = _name; }                               
00851         void SetValue( const char* _value )     { value = _value; }                             
00852 
00853         void SetIntValue( int _value );                                                                         
00854         void SetDoubleValue( double _value );                                                           
00855 
00856     #ifdef TIXML_USE_STL
00857 
00858         void SetName( const std::string& _name )        { name = _name; }       
00860         void SetValue( const std::string& _value )      { value = _value; }
00861         #endif
00862 
00864         const TiXmlAttribute* Next() const;
00865         TiXmlAttribute* Next() {
00866                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); 
00867         }
00868 
00870         const TiXmlAttribute* Previous() const;
00871         TiXmlAttribute* Previous() {
00872                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); 
00873         }
00874 
00875         bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
00876         bool operator<( const TiXmlAttribute& rhs )      const { return name < rhs.name; }
00877         bool operator>( const TiXmlAttribute& rhs )  const { return name > rhs.name; }
00878 
00879         /*      Attribute parsing starts: first letter of the name
00880                                                  returns: the next char after the value end quote
00881         */
00882         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
00883 
00884         // Prints this Attribute to a FILE stream.
00885         virtual void Print( FILE* cfile, int depth ) const {
00886                 Print( cfile, depth, 0 );
00887         }
00888         void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
00889 
00890         // [internal use]
00891         // Set the document pointer so the attribute can report errors.
00892         void SetDocument( TiXmlDocument* doc )  { document = doc; }
00893 
00894 private:
00895         TiXmlAttribute( const TiXmlAttribute& );                                // not implemented.
00896         void operator=( const TiXmlAttribute& base );   // not allowed.
00897 
00898         TiXmlDocument*  document;       // A pointer back to a document, for error reporting.
00899         TIXML_STRING name;
00900         TIXML_STRING value;
00901         TiXmlAttribute* prev;
00902         TiXmlAttribute* next;
00903 };
00904 
00905 
00906 /*      A class used to manage a group of attributes.
00907         It is only used internally, both by the ELEMENT and the DECLARATION.
00908         
00909         The set can be changed transparent to the Element and Declaration
00910         classes that use it, but NOT transparent to the Attribute
00911         which has to implement a next() and previous() method. Which makes
00912         it a bit problematic and prevents the use of STL.
00913 
00914         This version is implemented with circular lists because:
00915                 - I like circular lists
00916                 - it demonstrates some independence from the (typical) doubly linked list.
00917 */
00918 class TINYXML_EXPORT TiXmlAttributeSet
00919 {
00920 public:
00921         TiXmlAttributeSet();
00922         ~TiXmlAttributeSet();
00923 
00924         void Add( TiXmlAttribute* attribute );
00925         void Remove( TiXmlAttribute* attribute );
00926 
00927         const TiXmlAttribute* First()   const   { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00928         TiXmlAttribute* First()                                 { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
00929         const TiXmlAttribute* Last() const              { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00930         TiXmlAttribute* Last()                                  { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
00931 
00932         const TiXmlAttribute*   Find( const char* _name ) const;
00933         TiXmlAttribute* Find( const char* _name ) {
00934                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
00935         }
00936         #ifdef TIXML_USE_STL
00937         const TiXmlAttribute*   Find( const std::string& _name ) const;
00938         TiXmlAttribute* Find( const std::string& _name ) {
00939                 return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
00940         }
00941 
00942         #endif
00943 
00944 private:
00945         //*ME:  Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
00946         //*ME:  this class must be also use a hidden/disabled copy-constructor !!!
00947         TiXmlAttributeSet( const TiXmlAttributeSet& );  // not allowed
00948         void operator=( const TiXmlAttributeSet& );     // not allowed (as TiXmlAttribute)
00949 
00950         TiXmlAttribute sentinel;
00951 };
00952 
00953 
00958 class TINYXML_EXPORT TiXmlElement : public TiXmlNode
00959 {
00960 public:
00962         TiXmlElement (const char * in_value);
00963 
00964         #ifdef TIXML_USE_STL
00965 
00966         TiXmlElement( const std::string& _value );
00967         #endif
00968 
00969         TiXmlElement( const TiXmlElement& );
00970 
00971         void operator=( const TiXmlElement& base );
00972 
00973         virtual ~TiXmlElement();
00974 
00978         const char* Attribute( const char* name ) const;
00979 
00986         const char* Attribute( const char* name, int* i ) const;
00987 
00994         const char* Attribute( const char* name, double* d ) const;
00995 
01003         int QueryIntAttribute( const char* name, int* _value ) const;
01005         int QueryDoubleAttribute( const char* name, double* _value ) const;
01007         int QueryFloatAttribute( const char* name, float* _value ) const {
01008                 double d;
01009                 int result = QueryDoubleAttribute( name, &d );
01010                 if ( result == TIXML_SUCCESS ) {
01011                         *_value = (float)d;
01012                 }
01013                 return result;
01014         }
01015 
01016     #ifdef TIXML_USE_STL
01017 
01025         template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
01026         {
01027                 const TiXmlAttribute* node = attributeSet.Find( name );
01028                 if ( !node )
01029                         return TIXML_NO_ATTRIBUTE;
01030 
01031                 std::stringstream sstream( node->ValueStr() );
01032                 sstream >> *outValue;
01033                 if ( !sstream.fail() )
01034                         return TIXML_SUCCESS;
01035                 return TIXML_WRONG_TYPE;
01036         }
01037         /*
01038          This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
01039          but template specialization is hard to get working cross-compiler. Leaving the bug for now.
01040          
01041         // The above will fail for std::string because the space character is used as a seperator.
01042         // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
01043         template<> 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         */
01052         #endif
01053 
01057         void SetAttribute( const char* name, const char * _value );
01058 
01059     #ifdef TIXML_USE_STL
01060         const std::string* Attribute( const std::string& name ) const;
01061         const std::string* Attribute( const std::string& name, int* i ) const;
01062         const std::string* Attribute( const std::string& name, double* d ) const;
01063         int QueryIntAttribute( const std::string& name, int* _value ) const;
01064         int QueryDoubleAttribute( const std::string& name, double* _value ) const;
01065 
01067         void SetAttribute( const std::string& name, const std::string& _value );
01069         void SetAttribute( const std::string& name, int _value );
01070         #endif
01071 
01075         void SetAttribute( const char * name, int value );
01076 
01080         void SetDoubleAttribute( const char * name, double value );
01081 
01084         void RemoveAttribute( const char * name );
01085     #ifdef TIXML_USE_STL
01086         void RemoveAttribute( const std::string& name ) {       RemoveAttribute (name.c_str ());        }       
01087         #endif
01088 
01089         const TiXmlAttribute* FirstAttribute() const    { return attributeSet.First(); }                
01090         TiXmlAttribute* FirstAttribute()                                { return attributeSet.First(); }
01091         const TiXmlAttribute* LastAttribute()   const   { return attributeSet.Last(); }         
01092         TiXmlAttribute* LastAttribute()                                 { return attributeSet.Last(); }
01093 
01126         const char* GetText() const;
01127 
01129         virtual TiXmlNode* Clone() const;
01130         // Print the Element to a FILE stream.
01131         virtual void Print( FILE* cfile, int depth ) const;
01132 
01133         /*      Attribtue parsing starts: next char past '<'
01134                                                  returns: next char past '>'
01135         */
01136         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
01137 
01138         virtual const TiXmlElement*     ToElement()     const { return this; } 
01139         virtual TiXmlElement*           ToElement()               { return this; } 
01140 
01143         virtual bool Accept( TiXmlVisitor* visitor ) const;
01144 
01145 protected:
01146 
01147         void CopyTo( TiXmlElement* target ) const;
01148         void ClearThis();       // like clear, but initializes 'this' object as well
01149 
01150         // Used to be public [internal use]
01151         #ifdef TIXML_USE_STL
01152         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01153         #endif
01154         /*      [internal use]
01155                 Reads the "value" of the element -- another element, or text.
01156                 This should terminate with the current end tag.
01157         */
01158         const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01159 
01160 private:
01161 
01162         TiXmlAttributeSet attributeSet;
01163 };
01164 
01165 
01168 class TINYXML_EXPORT TiXmlComment : public TiXmlNode
01169 {
01170 public:
01172         TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
01174         TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
01175                 SetValue( _value );
01176         }
01177         TiXmlComment( const TiXmlComment& );
01178         void 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_EXPORT TiXmlText : public TiXmlNode
01219 {
01220         friend class TiXmlElement;
01221 public:
01226         TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::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::TEXT)
01236         {
01237                 SetValue( initValue );
01238                 cdata = false;
01239         }
01240         #endif
01241 
01242         TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT )       { copy.CopyTo( this ); }
01243         void operator=( const TiXmlText& base )                                                         { base.CopyTo( 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_EXPORT TiXmlDeclaration : public TiXmlNode
01292 {
01293 public:
01295         TiXmlDeclaration()   : TiXmlNode( TiXmlNode::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         void 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_EXPORT TiXmlUnknown : public TiXmlNode
01361 {
01362 public:
01363         TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN )        {}
01364         virtual ~TiXmlUnknown() {}
01365 
01366         TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN )              { copy.CopyTo( this ); }
01367         void operator=( const TiXmlUnknown& copy )                                                                              { copy.CopyTo( 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_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         void 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 //              StringToBuffer f( filename );
01441 //              return ( f.buffer && LoadFile( f.buffer, encoding ));
01442                 return LoadFile( filename.c_str(), encoding );
01443         }
01444         bool SaveFile( const std::string& filename ) const              
01445         {
01446 //              StringToBuffer f( filename );
01447 //              return ( f.buffer && SaveFile( f.buffer ));
01448                 return SaveFile( filename.c_str() );
01449         }
01450         #endif
01451 
01456         virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
01457 
01462         const TiXmlElement* RootElement() const         { return FirstChildElement(); }
01463         TiXmlElement* RootElement()                                     { return FirstChildElement(); }
01464 
01470         bool Error() const                                              { return error; }
01471 
01473         const char * ErrorDesc() const  { return errorDesc.c_str (); }
01474 
01478         int ErrorId()   const                           { return errorId; }
01479 
01487         int ErrorRow() const    { return errorLocation.row+1; }
01488         int ErrorCol() const    { return errorLocation.col+1; } 
01489 
01514         void SetTabSize( int _tabsize )         { tabsize = _tabsize; }
01515 
01516         int TabSize() const     { return tabsize; }
01517 
01521         void ClearError()                                               {       error = false; 
01522                                                                                                 errorId = 0; 
01523                                                                                                 errorDesc = ""; 
01524                                                                                                 errorLocation.row = errorLocation.col = 0; 
01525                                                                                                 //errorLocation.last = 0; 
01526                                                                                         }
01527 
01529         void Print() const                                              { Print( stdout, 0 ); }
01530 
01531         /* Write the document to a string using formatted printing ("pretty print"). This
01532                 will allocate a character array (new char[]) and return it as a pointer. The
01533                 calling code pust call delete[] on the return char* to avoid a memory leak.
01534         */
01535         //char* PrintToMemory() const; 
01536 
01538         virtual void Print( FILE* cfile, int depth = 0 ) const;
01539         // [internal use]
01540         void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
01541 
01542         virtual const TiXmlDocument*    ToDocument()    const { return this; } 
01543         virtual TiXmlDocument*          ToDocument()          { return this; } 
01544 
01547         virtual bool Accept( TiXmlVisitor* content ) const;
01548 
01549 protected :
01550         // [internal use]
01551         virtual TiXmlNode* Clone() const;
01552         #ifdef TIXML_USE_STL
01553         virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
01554         #endif
01555 
01556 private:
01557         void CopyTo( TiXmlDocument* target ) const;
01558 
01559         bool error;
01560         int  errorId;
01561         TIXML_STRING errorDesc;
01562         int tabsize;
01563         TiXmlCursor errorLocation;
01564         bool useMicrosoftBOM;           // the UTF-8 BOM were found when read. Note this, and try to write.
01565 };
01566 
01567 
01648 class TINYXML_EXPORT TiXmlHandle
01649 {
01650 public:
01652         TiXmlHandle( TiXmlNode* _node )                                 { this->node = _node; }
01654         TiXmlHandle( const TiXmlHandle& ref )                   { this->node = ref.node; }
01655         TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
01656 
01658         TiXmlHandle FirstChild() const;
01660         TiXmlHandle FirstChild( const char * value ) const;
01662         TiXmlHandle FirstChildElement() const;
01664         TiXmlHandle FirstChildElement( const char * value ) const;
01665 
01669         TiXmlHandle Child( const char* value, int index ) const;
01673         TiXmlHandle Child( int index ) const;
01678         TiXmlHandle ChildElement( const char* value, int index ) const;
01683         TiXmlHandle ChildElement( int index ) const;
01684 
01685         #ifdef TIXML_USE_STL
01686         TiXmlHandle FirstChild( const std::string& _value ) const                               { return FirstChild( _value.c_str() ); }
01687         TiXmlHandle FirstChildElement( const std::string& _value ) const                { return FirstChildElement( _value.c_str() ); }
01688 
01689         TiXmlHandle Child( const std::string& _value, int index ) const                 { return Child( _value.c_str(), index ); }
01690         TiXmlHandle ChildElement( const std::string& _value, int index ) const  { return ChildElement( _value.c_str(), index ); }
01691         #endif
01692 
01695         TiXmlNode* ToNode() const                       { return node; } 
01698         TiXmlElement* ToElement() const         { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
01701         TiXmlText* ToText() const                       { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
01704         TiXmlUnknown* ToUnknown() const         { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
01705 
01709         TiXmlNode* Node() const                 { return ToNode(); } 
01713         TiXmlElement* Element() const   { return ToElement(); }
01717         TiXmlText* Text() const                 { return ToText(); }
01721         TiXmlUnknown* Unknown() const   { return ToUnknown(); }
01722 
01723 private:
01724         TiXmlNode* node;
01725 };
01726 
01727 
01747 class TINYXML_EXPORT TiXmlPrinter : public TiXmlVisitor
01748 {
01749 public:
01750         TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
01751                                          buffer(), indent( "    " ), lineBreak( "\n" ) {}
01752 
01753         virtual bool VisitEnter( const TiXmlDocument& doc );
01754         virtual bool VisitExit( const TiXmlDocument& doc );
01755 
01756         virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
01757         virtual bool VisitExit( const TiXmlElement& element );
01758 
01759         virtual bool Visit( const TiXmlDeclaration& declaration );
01760         virtual bool Visit( const TiXmlText& text );
01761         virtual bool Visit( const TiXmlComment& comment );
01762         virtual bool Visit( const TiXmlUnknown& unknown );
01763 
01767         void SetIndent( const char* _indent )                   { indent = _indent ? _indent : "" ; }
01769         const char* Indent()                                                    { return indent.c_str(); }
01774         void SetLineBreak( const char* _lineBreak )             { lineBreak = _lineBreak ? _lineBreak : ""; }
01776         const char* LineBreak()                                                 { return lineBreak.c_str(); }
01777 
01781         void SetStreamPrinting()                                                { indent = "";
01782                                                                                                           lineBreak = "";
01783                                                                                                         }       
01785         const char* CStr()                                                              { return buffer.c_str(); }
01787         size_t Size()                                                                   { return buffer.size(); }
01788 
01789         #ifdef TIXML_USE_STL
01790 
01791         const std::string& Str()                                                { return buffer; }
01792         #endif
01793 
01794 private:
01795         void DoIndent() {
01796                 for( int i=0; i<depth; ++i )
01797                         buffer += indent;
01798         }
01799         void DoLineBreak() {
01800                 buffer += lineBreak;
01801         }
01802 
01803         int depth;
01804         bool simpleTextPrint;
01805         TIXML_STRING buffer;
01806         TIXML_STRING indent;
01807         TIXML_STRING lineBreak;
01808 };
01809 
01810 }
01811 
01812 #ifdef _MSC_VER
01813 #pragma warning( pop )
01814 #endif
01815 
01816 #endif
01817 


rospack
Author(s): Brian Gerkey/gerkey@willowgarage.com, Morgan Quigley/mquigley@cs.stanford.edu
autogenerated on Fri Jan 3 2014 11:51:40