interreality.org [VOS]
[Home] [About]
[Screenshots]
[Download]
[News]
[Community]
[Documentation] [Manual]
[Bugs & Requests] [Wiki]

/home/tetron/hack/vos/libs/vos/vutil/tinyxml.hh

Go to the documentation of this file.
00001 /*
00002  TinyXML, modified for inclusion in VOS source tree
00003 
00004 www.sourceforge.net/projects/tinyxml
00005 Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
00006 
00007 This software is provided 'as-is', without any express or implied
00008 warranty. In no event will the authors be held liable for any
00009 damages arising from the use of this software.
00010 
00011 Permission is granted to anyone to use this software for any
00012 purpose, including commercial applications, and to alter it and
00013 redistribute it freely, subject to the following restrictions:
00014 
00015 1. The origin of this software must not be misrepresented; you must
00016 not claim that you wrote the original software. If you use this
00017 software in a product, an acknowledgment in the product documentation
00018 would be appreciated but is not required.
00019 
00020 2. Altered source versions must be plainly marked as such, and
00021 must not be misrepresented as being the original software.
00022 
00023 3. This notice may not be removed or altered from any source
00024 distribution.
00025 */
00026 
00027 // modified for VOS, added this line to use the STL by default
00028 #define TIXML_USE_STL 1
00029 
00030 #ifndef TINYXML_INCLUDED
00031 #define TINYXML_INCLUDED
00032 
00033 #include <vos/vutil/vutildefs.hh>
00034 
00035 #ifdef _MSC_VER
00036 #pragma warning( push )
00037 #pragma warning( disable : 4530 )
00038 #pragma warning( disable : 4786 )
00039 #endif
00040 
00041 #include <ctype.h>
00042 #include <stdio.h>
00043 #include <stdlib.h>
00044 #include <string.h>
00045 #include <assert.h>
00046 
00047 // Help out windows:
00048 #if defined( _DEBUG ) && !defined( DEBUG )
00049 #define DEBUG
00050 #endif
00051 
00052 #if defined( DEBUG ) && defined( _MSC_VER )
00053 #include <windows.h>
00054 #define TIXML_LOG OutputDebugString
00055 #else
00056 #define TIXML_LOG printf
00057 #endif
00058 
00059 #ifdef TIXML_USE_STL
00060         #include <string>
00061         #include <iostream>
00062         #define TIXML_STRING    std::string
00063         #define TIXML_ISTREAM   std::istream
00064         #define TIXML_OSTREAM   std::ostream
00065 #else
00066         #define TIXML_STRING    TiXmlString
00067         #define TIXML_OSTREAM   TiXmlOutStream
00068 #endif
00069 
00070 // Deprecated library function hell. Compilers want to use the
00071 // new safe versions. This probably doesn't fully address the problem,
00072 // but it gets closer. There are too many compilers for me to fully
00073 // test. If you get compilation troubles, undefine TIXML_SAFE
00074 
00075 #define TIXML_SAFE              // TinyXml isn't fully buffer overrun protected, safe code. This is work in progress.
00076 #ifdef TIXML_SAFE
00077         #if defined(_MSC_VER) && (_MSC_VER >= 1200 )
00078                 // Microsoft visual studio, version 6 and higher.
00079                 //#pragma message( "Using _sn* functions." )
00080                 #define TIXML_SNPRINTF _snprintf
00081                 #define TIXML_SNSCANF  _snscanf
00082         #elif defined(__GNUC__) && (__GNUC__ >= 3 )
00083                 // GCC version 3 and higher.s
00084                 //#warning( "Using sn* functions." )
00085                 #define TIXML_SNPRINTF snprintf
00086                 #define TIXML_SNSCANF  snscanf
00087         #endif
00088 #endif
00089 
00090 class TiXmlDocument;
00091 class TiXmlElement;
00092 class TiXmlComment;
00093 class TiXmlUnknown;
00094 class TiXmlAttribute;
00095 class TiXmlText;
00096 class TiXmlDeclaration;
00097 class TiXmlParsingData;
00098 
00099 const int TIXML_MAJOR_VERSION = 2;
00100 const int TIXML_MINOR_VERSION = 4;
00101 const int TIXML_PATCH_VERSION = 2;
00102 
00103 /*      Internal structure for tracking location of items
00104         in the XML file.
00105 */
00106 struct VUTIL_API TiXmlCursor
00107 {
00108         TiXmlCursor()           { Clear(); }
00109         void Clear()            { row = col = -1; }
00110 
00111         int row;        // 0 based.
00112         int col;        // 0 based.
00113 };
00114 
00115 
00116 // Only used by Attribute::Query functions
00117 enum
00118 {
00119         TIXML_SUCCESS,
00120         TIXML_NO_ATTRIBUTE,
00121         TIXML_WRONG_TYPE
00122 };
00123 
00124 
00125 // Used by the parsing routines.
00126 enum TiXmlEncoding
00127 {
00128         TIXML_ENCODING_UNKNOWN,
00129         TIXML_ENCODING_UTF8,
00130         TIXML_ENCODING_LEGACY
00131 };
00132 
00133 const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
00134 
00135 /** TiXmlBase is a base class for every class in TinyXml.
00136         It does little except to establish that TinyXml classes
00137         can be printed and provide some utility functions.
00138 
00139         In XML, the document and elements can contain
00140         other elements and other types of nodes.
00141 
00142         @verbatim
00143         A Document can contain: Element (container or leaf)
00144                                                         Comment (leaf)
00145                                                         Unknown (leaf)
00146                                                         Declaration( leaf )
00147 
00148         An Element can contain: Element (container or leaf)
00149                                                         Text    (leaf)
00150                                                         Attributes (not on tree)
00151                                                         Comment (leaf)
00152                                                         Unknown (leaf)
00153 
00154         A Decleration contains: Attributes (not on tree)
00155         @endverbatim
00156 */
00157 class VUTIL_API TiXmlBase
00158 {
00159         friend class TiXmlNode;
00160         friend class TiXmlElement;
00161         friend class TiXmlDocument;
00162 
00163 public:
00164         TiXmlBase()     :       userData(0) {}
00165         virtual ~TiXmlBase()                                    {}
00166 
00167         /**     All TinyXml classes can print themselves to a filestream.
00168                 This is a formatted print, and will insert tabs and newlines.
00169 
00170                 (For an unformatted stream, use the << operator.)
00171         */
00172         virtual void Print( FILE* cfile, int depth ) const = 0;
00173 
00174         /**     The world does not agree on whether white space should be kept or
00175                 not. In order to make everyone happy, these global, static functions
00176                 are provided to set whether or not TinyXml will condense all white space
00177                 into a single space or not. The default is to condense. Note changing this
00178                 values is not thread safe.
00179         */
00180         static void SetCondenseWhiteSpace( bool condense )              { condenseWhiteSpace = condense; }
00181 
00182         /// Return the current white space setting.
00183         static bool IsWhiteSpaceCondensed()                                             { return condenseWhiteSpace; }
00184 
00185         /** Return the position, in the original source file, of this node or attribute.
00186                 The row and column are 1-based. (That is the first row and first column is
00187                 1,1). If the returns values are 0 or less, then the parser does not have
00188                 a row and column value.
00189 
00190                 Generally, the row and column value will be set when the TiXmlDocument::Load(),
00191                 TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set
00192                 when the DOM was created from operator>>.
00193 
00194                 The values reflect the initial load. Once the DOM is modified programmatically
00195                 (by adding or changing nodes and attributes) the new values will NOT update to
00196                 reflect changes in the document.
00197 
00198                 There is a minor performance cost to computing the row and column. Computation
00199                 can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.
00200 
00201                 @sa TiXmlDocument::SetTabSize()
00202         */
00203         int Row() const                 { return location.row + 1; }
00204         int Column() const              { return location.col + 1; }    ///< See Row()
00205 
00206         void  SetUserData( void* user )                 { userData = user; }
00207         void* GetUserData()                                             { return userData; }
00208 
00209         // Table that returs, for a given lead byte, the total number of bytes
00210         // in the UTF-8 sequence.
00211         static const int utf8ByteTable[256];
00212 
00213         virtual const char* Parse(      const char* p,
00214                                                                 TiXmlParsingData* data,
00215                                                                 TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
00216 
00217         enum
00218         {
00219                 TIXML_NO_ERROR = 0,
00220                 TIXML_ERROR,
00221                 TIXML_ERROR_OPENING_FILE,
00222                 TIXML_ERROR_OUT_OF_MEMORY,
00223                 TIXML_ERROR_PARSING_ELEMENT,
00224                 TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
00225                 TIXML_ERROR_READING_ELEMENT_VALUE,
00226                 TIXML_ERROR_READING_ATTRIBUTES,
00227                 TIXML_ERROR_PARSING_EMPTY,
00228                 TIXML_ERROR_READING_END_TAG,
00229                 TIXML_ERROR_PARSING_UNKNOWN,
00230                 TIXML_ERROR_PARSING_COMMENT,
00231                 TIXML_ERROR_PARSING_DECLARATION,
00232                 TIXML_ERROR_DOCUMENT_EMPTY,
00233                 TIXML_ERROR_EMBEDDED_NULL,
00234                 TIXML_ERROR_PARSING_CDATA,
00235 
00236                 TIXML_ERROR_STRING_COUNT
00237         };
00238 
00239 protected:
00240 
00241         // See STL_STRING_BUG
00242         // Utility class to overcome a bug.
00243         class VUTIL_API StringToBuffer
00244         {
00245           public:
00246                 StringToBuffer( const TIXML_STRING& str );
00247                 ~StringToBuffer();
00248                 char* buffer;
00249         };
00250 
00251         static const char*      SkipWhiteSpace( const char*, TiXmlEncoding encoding );
00252         inline static bool      IsWhiteSpace( char c )
00253         {
00254                 return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
00255         }
00256 
00257         virtual void StreamOut (TIXML_OSTREAM *, int depth) const = 0;
00258 
00259         #ifdef TIXML_USE_STL
00260             static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag );
00261             static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag );
00262         #endif
00263 
00264         /*      Reads an XML name into the string provided. Returns
00265                 a pointer just past the last character of the name,
00266                 or 0 if the function has an error.
00267         */
00268         static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
00269 
00270         /*      Reads text. Returns a pointer past the given end tag.
00271                 Wickedly complex options, but it keeps the (sensitive) code in one place.
00272         */
00273         static const char* ReadText(    const char* in,                         // where to start
00274                                                                         TIXML_STRING* text,                     // the string read
00275                                                                         bool ignoreWhiteSpace,          // whether to keep the white space
00276                                                                         const char* endTag,                     // what ends this text
00277                                                                         bool ignoreCase,                        // whether to ignore case in the end tag
00278                                                                         TiXmlEncoding encoding );       // the current encoding
00279 
00280         // If an entity has been found, transform it into a character.
00281         static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
00282 
00283         // Get a character, while interpreting entities.
00284         // The length can be from 0 to 4 bytes.
00285         inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
00286         {
00287                 assert( p );
00288                 if ( encoding == TIXML_ENCODING_UTF8 )
00289                 {
00290                         *length = utf8ByteTable[ *((unsigned char*)p) ];
00291                         assert( *length >= 0 && *length < 5 );
00292                 }
00293                 else
00294                 {
00295                         *length = 1;
00296                 }
00297 
00298                 if ( *length == 1 )
00299                 {
00300                         if ( *p == '&' )
00301                                 return GetEntity( p, _value, length, encoding );
00302                         *_value = *p;
00303                         return p+1;
00304                 }
00305                 else if ( *length )
00306                 {
00307                         //strncpy( _value, p, *length );        // lots of compilers don't like this function (unsafe),
00308                                                                                                 // and the null terminator isn't needed
00309                         for( int i=0; p[i] && i<*length; ++i ) {
00310                                 _value[i] = p[i];
00311                         }
00312                         return p + (*length);
00313                 }
00314                 else
00315                 {
00316                         // Not valid text.
00317                         return 0;
00318                 }
00319         }
00320 
00321         // Puts a string to a stream, expanding entities as it goes.
00322         // Note this should not contian the '<', '>', etc, or they will be transformed into entities!
00323         static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out );
00324 
00325         static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
00326 
00327         // Return true if the next characters in the stream are any of the endTag sequences.
00328         // Ignore case only works for english, and should only be relied on when comparing
00329         // to English words: StringEqual( p, "version", true ) is fine.
00330         static bool StringEqual(        const char* p,
00331                                                                 const char* endTag,
00332                                                                 bool ignoreCase,
00333                                                                 TiXmlEncoding encoding );
00334 
00335         static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
00336 
00337         TiXmlCursor location;
00338 
00339     /// Field containing a generic user pointer
00340         void*                   userData;
00341 
00342         // None of these methods are reliable for any language except English.
00343         // Good for approximation, not great for accuracy.
00344         static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
00345         static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
00346         inline static int ToLower( int v, TiXmlEncoding encoding )
00347         {
00348                 if ( encoding == TIXML_ENCODING_UTF8 )
00349                 {
00350                         if ( v < 128 ) return tolower( v );
00351                         return v;
00352                 }
00353                 else
00354                 {
00355                         return tolower( v );
00356                 }
00357         }
00358         static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
00359 
00360 private:
00361         TiXmlBase( const TiXmlBase& );                          // not implemented.
00362         void operator=( const TiXmlBase& base );        // not allowed.
00363 
00364         struct Entity
00365         {
00366                 const char*     str;
00367                 unsigned int    strLength;
00368                 char                chr;
00369         };
00370         enum
00371         {
00372                 NUM_ENTITY = 5,
00373                 MAX_ENTITY_LENGTH = 6
00374 
00375         };
00376         static Entity entity[ NUM_ENTITY ];
00377         static bool condenseWhiteSpace;
00378 };
00379 
00380 
00381 /** The parent class for everything in the Document Object Model.
00382         (Except for attributes).
00383         Nodes have siblings, a parent, and children. A node can be
00384         in a document, or stand on its own. The type of a TiXmlNode
00385         can be queried, and it can be cast to its more defined type.
00386 */
00387 class VUTIL_API TiXmlNode : public TiXmlBase
00388 {
00389         friend class TiXmlDocument;
00390         friend class TiXmlElement;
00391 
00392 public:
00393         #ifdef TIXML_USE_STL
00394 
00395             /** An input stream operator, for every class. Tolerant of newlines and
00396                     formatting, but doesn't expect them.
00397             */
00398             friend VUTIL_API std::istream& operator >> (std::istream& in, TiXmlNode& base);
00399 
00400             /** An output stream operator, for every class. Note that this outputs
00401                     without any newlines or formatting, as opposed to Print(), which
00402                     includes tabs and new lines.
00403 
00404                     The operator<< and operator>> are not completely symmetric. Writing
00405                     a node to a stream is very well defined. You'll get a nice stream
00406                     of output, without any extra whitespace or newlines.
00407 
00408                     But reading is not as well defined. (As it always is.) If you create
00409                     a TiXmlElement (for example) and read that from an input stream,
00410                     the text needs to define an element or junk will result. This is
00411                     true of all input streams, but it's worth keeping in mind.
00412 
00413                     A TiXmlDocument will read nodes until it reads a root element, and
00414                         all the children of that root element.
00415             */
00416             VUTIL_API friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
00417 
00418                 /// Appends the XML node or attribute to a std::string.
00419                 VUTIL_API friend std::string& operator<< (std::string& out, const TiXmlNode& base );
00420 
00421         #else
00422             // Used internally, not part of the public API.
00423             friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base);
00424         #endif
00425 
00426         /** The types of XML nodes supported by TinyXml. (All the
00427                         unsupported types are picked up by UNKNOWN.)
00428         */
00429         enum NodeType
00430         {
00431                 DOCUMENT,
00432                 ELEMENT,
00433                 COMMENT,
00434                 UNKNOWN,
00435                 TEXT,
00436                 DECLARATION,
00437                 TYPECOUNT
00438         };
00439 
00440         virtual ~TiXmlNode();
00441 
00442         /** The meaning of 'value' changes for the specific type of
00443                 TiXmlNode.
00444                 @verbatim
00445                 Document:       filename of the xml file
00446                 Element:        name of the element
00447                 Comment:        the comment text
00448                 Unknown:        the tag contents
00449                 Text:           the text string
00450                 @endverbatim
00451 
00452                 The subclasses will wrap this function.
00453         */
00454         const char *Value() const { return value.c_str (); }
00455 
00456     #ifdef TIXML_USE_STL
00457         /** Return Value() as a std::string. If you only use STL,
00458             this is more efficient than calling Value().
00459                 Only available in STL mode.
00460         */
00461         const std::string& ValueStr() const { return value; }
00462         #endif
00463 
00464         /** Changes the value of the node. Defined as:
00465                 @verbatim
00466                 Document:       filename of the xml file
00467                 Element:        name of the element
00468                 Comment:        the comment text
00469                 Unknown:        the tag contents
00470                 Text:           the text string
00471                 @endverbatim
00472         */
00473         void SetValue(const char * _value) { value = _value;}
00474 
00475     #ifdef TIXML_USE_STL
00476         /// STL std::string form.
00477         void SetValue( const std::string& _value )
00478         {
00479                 StringToBuffer buf( _value );
00480                 SetValue( buf.buffer ? buf.buffer : "" );
00481         }
00482         #endif
00483 
00484         /// Delete all the children of this node. Does not affect 'this'.
00485         void Clear();
00486 
00487         /// One step up the DOM.
00488         TiXmlNode* Parent()                                                     { return parent; }
00489         const TiXmlNode* Parent() const                         { return parent; }
00490 
00491         const TiXmlNode* FirstChild()   const   { return firstChild; }          ///< The first child of this node. Will be null if there are no children.
00492         TiXmlNode* FirstChild()                                 { return firstChild; }
00493         const TiXmlNode* FirstChild( const char * value ) const;                        ///< The first child of this node with the matching 'value'. Will be null if none found.
00494         TiXmlNode* FirstChild( const char * value );                                            ///< The first child of this node with the matching 'value'. Will be null if none found.
00495 
00496         const TiXmlNode* LastChild() const      { return lastChild; }           /// The last child of this node. Will be null if there are no children.
00497         TiXmlNode* LastChild()  { return lastChild; }
00498         const TiXmlNode* LastChild( const char * value ) const;                 /// The last child of this node matching 'value'. Will be null if there are no children.
00499         TiXmlNode* LastChild( const char * value );
00500 
00501     #ifdef TIXML_USE_STL
00502         const TiXmlNode* FirstChild( const std::string& _value ) const  {       return FirstChild (_value.c_str ());    }       ///< STL std::string form.
00503         TiXmlNode* FirstChild( const std::string& _value )                              {       return FirstChild (_value.c_str ());    }       ///< STL std::string form.
00504         const TiXmlNode* LastChild( const std::string& _value ) const   {       return LastChild (_value.c_str ());     }       ///< STL std::string form.
00505         TiXmlNode* LastChild( const std::string& _value )                               {       return LastChild (_value.c_str ());     }       ///< STL std::string form.
00506         #endif
00507 
00508         /** An alternate way to walk the children of a node.
00509                 One way to iterate over nodes is:
00510                 @verbatim
00511                         for( child = parent->FirstChild(); child; child = child->NextSibling() )
00512                 @endverbatim
00513 
00514                 IterateChildren does the same thing with the syntax:
00515                 @verbatim
00516                         child = 0;
00517                         while( child = parent->IterateChildren( child ) )
00518                 @endverbatim
00519 
00520                 IterateChildren takes the previous child as input and finds
00521                 the next one. If the previous child is null, it returns the
00522                 first. IterateChildren will return null when done.
00523         */
00524         const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
00525         TiXmlNode* IterateChildren( TiXmlNode* previous );
00526 
00527         /// This flavor of IterateChildren searches for children with a particular 'value'
00528         const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
00529         TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous );
00530 
00531     #ifdef TIXML_USE_STL
00532         const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const  {       return IterateChildren (_value.c_str (), previous);     }       ///< STL std::string form.
00533         TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) {  return IterateChildren (_value.c_str (), previous);     }       ///< STL std::string form.
00534         #endif
00535 
00536         /** Add a new node related to this. Adds a child past the LastChild.
00537                 Returns a pointer to the new object or NULL if an error occured.
00538         */
00539         TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
00540 
00541 
00542         /** Add a new node related to this. Adds a child past the LastChild.
00543 
00544                 NOTE: the node to be added is passed by pointer, and will be
00545                 henceforth owned (and deleted) by tinyXml. This method is efficient
00546                 and avoids an extra copy, but should be used with care as it
00547                 uses a different memory model than the other insert functions.
00548 
00549                 @sa InsertEndChild
00550         */
00551         TiXmlNode* LinkEndChild( TiXmlNode* addThis );
00552 
00553         /** Add a new node related to this. Adds a child before the specified child.
00554                 Returns a pointer to the new object or NULL if an error occured.
00555         */
00556         TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
00557 
00558         /** Add a new node related to this. Adds a child after the specified child.
00559                 Returns a pointer to the new object or NULL if an error occured.
00560         */
00561         TiXmlNode* InsertAfterChild(  TiXmlNode* afterThis, const TiXmlNode& addThis );
00562 
00563         /** Replace a child of this node.
00564                 Returns a pointer to the new object or NULL if an error occured.
00565         */
00566         TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
00567 
00568         /// Delete a child of this node.
00569         bool RemoveChild( TiXmlNode* removeThis );
00570 
00571         /// Navigate to a sibling node.
00572         const TiXmlNode* PreviousSibling() const                        { return prev; }
00573         TiXmlNode* PreviousSibling()                                            { return prev; }
00574 
00575         /// Navigate to a sibling node.
00576         const TiXmlNode* PreviousSibling( const char * ) const;
00577         TiXmlNode* PreviousSibling( const char * );
00578 
00579     #ifdef TIXML_USE_STL
00580         const TiXmlNode* PreviousSibling( const std::string& _value ) const     {       return PreviousSibling (_value.c_str ());       }       ///< STL std::string form.
00581         TiXmlNode* PreviousSibling( const std::string& _value )                         {       return PreviousSibling (_value.c_str ());       }       ///< STL std::string form.
00582         const TiXmlNode* NextSibling( const std::string& _value) const          {       return NextSibling (_value.c_str ());   }       ///< STL std::string form.
00583         TiXmlNode* NextSibling( const std::string& _value)                                      {       return NextSibling (_value.c_str ());   }       ///< STL std::string form.
00584         #endif
00585 
00586         /// Navigate to a sibling node.
00587         const TiXmlNode* NextSibling() const                            { return next; }
00588         TiXmlNode* NextSibling()                                                        { return next; }
00589 
00590         /// Navigate to a sibling node with the given 'value'.
00591         const TiXmlNode* NextSibling( const char * ) const;
00592         TiXmlNode* NextSibling( const char * );
00593 
00594         /** Convenience function to get through elements.
00595                 Calls NextSibling and ToElement. Will skip all non-Element
00596                 nodes. Returns 0 if there is not another element.
00597         */
00598         const TiXmlElement* NextSiblingElement() const;
00599         TiXmlElement* NextSiblingElement();
00600 
00601         /** Convenience function to get through elements.
00602                 Calls NextSibling and ToElement. Will skip all non-Element
00603                 nodes. Returns 0 if there is not another element.
00604         */
00605         const TiXmlElement* NextSiblingElement( const char * ) const;
00606         TiXmlElement* NextSiblingElement( const char * );
00607 
00608     #ifdef TIXML_USE_STL
00609         const TiXmlElement* NextSiblingElement( const std::string& _value) const        {       return NextSiblingElement (_value.c_str ());    }       ///< STL std::string form.
00610         TiXmlElement* NextSiblingElement( const std::string& _value)                            {       return NextSiblingElement (_value.c_str ());    }       ///< STL std::string form.
00611         #endif
00612 
00613         /// Convenience function to get through elements.
00614         const TiXmlElement* FirstChildElement() const;
00615         TiXmlElement* FirstChildElement();
00616 
00617         /// Convenience function to get through elements.
00618         const TiXmlElement* FirstChildElement( const char * value ) const;
00619         TiXmlElement* FirstChildElement( const char * value );
00620 
00621     #ifdef TIXML_USE_STL
00622         const TiXmlElement* FirstChildElement( const std::string& _value ) const        {       return FirstChildElement (_value.c_str ());     }       ///< STL std::string form.
00623         TiXmlElement* FirstChildElement( const std::string& _value )                            {       return FirstChildElement (_value.c_str ());     }       ///< STL std::string form.
00624         #endif
00625 
00626         /** Query the type (as an enumerated value, above) of this node.
00627                 The possible types are: DOCUMENT, ELEMENT, COMMENT,
00628                                                                 UNKNOWN, TEXT, and DECLARATION.
00629         */
00630         int Type() const        { return type; }
00631 
00632         /** Return a pointer to the Document this node lives in.
00633                 Returns null if not in a document.
00634         */
00635         const TiXmlDocument* GetDocument() const;
00636         TiXmlDocument* GetDocument();
00637 
00638         /// Returns true if this node has no children.
00639         bool NoChildren() const                                         { return !firstChild; }
00640 
00641         const TiXmlDocument* ToDocument()       const           { return ( this && type == DOCUMENT ) ? (const TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00642         const TiXmlElement*  ToElement() const                  { return ( this && type == ELEMENT  ) ? (const TiXmlElement*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00643         const TiXmlComment*  ToComment() const                  { return ( this && type == COMMENT  ) ? (const TiXmlComment*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00644         const TiXmlUnknown*  ToUnknown() const                  { return ( this && type == UNKNOWN  ) ? (const TiXmlUnknown*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00645         const TiXmlText*           ToText()    const            { return ( this && type == TEXT     ) ? (const TiXmlText*)     this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00646         const TiXmlDeclaration* ToDeclaration() const   { return ( this && type == DECLARATION ) ? (const TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00647 
00648         TiXmlDocument* ToDocument()                     { return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00649         TiXmlElement*  ToElement()                      { return ( this && type == ELEMENT  ) ? (TiXmlElement*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00650         TiXmlComment*  ToComment()                      { return ( this && type == COMMENT  ) ? (TiXmlComment*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00651         TiXmlUnknown*  ToUnknown()                      { return ( this && type == UNKNOWN  ) ? (TiXmlUnknown*)  this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00652         TiXmlText*         ToText()                     { return ( this && type == TEXT     ) ? (TiXmlText*)     this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00653         TiXmlDeclaration* ToDeclaration()       { return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
00654 
00655         /** Create an exact duplicate of this node and return it. The memory must be deleted
00656                 by the caller.
00657         */
00658         virtual TiXmlNode* Clone() const = 0;
00659 
00660 protected:
00661         TiXmlNode( NodeType _type );
00662 
00663         // Copy to the allocated object. Shared functionality between Clone, Copy constructor,
00664         // and the assignment operator.
00665         void CopyTo( TiXmlNode* target ) const;
00666 
00667         #ifdef TIXML_USE_STL
00668             // The real work of the input operator.
00669             virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0;
00670         #endif
00671 
00672         // Figure out what is at *p, and parse it. Returns null if it is not an xml node.
00673         TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
00674 
00675         TiXmlNode*              parent;
00676         NodeType                type;
00677 
00678         TiXmlNode*              firstChild;
00679         TiXmlNode*              lastChild;
00680 
00681         TIXML_STRING    value;
00682 
00683         TiXmlNode*              prev;
00684         TiXmlNode*              next;
00685 
00686 private:
00687         TiXmlNode( const TiXmlNode& );                          // not implemented.
00688         void operator=( const TiXmlNode& base );        // not allowed.
00689 };
00690 
00691 
00692 /** An attribute is a name-value pair. Elements have an arbitrary
00693         number of attributes, each with a unique name.
00694 
00695         @note The attributes are not TiXmlNodes, since they are not
00696                   part of the tinyXML document object model. There are other
00697                   suggested ways to look at this problem.
00698 */
00699 class VUTIL_API TiXmlAttribute : public TiXmlBase
00700 {
00701         friend class TiXmlAttributeSet;
00702 
00703 public:
00704         /// Construct an empty attribute.
00705         TiXmlAttribute() : TiXmlBase()
00706         {
00707                 document = 0;
00708                 prev = next = 0;
00709         }
00710 
00711         #ifdef TIXML_USE_STL
00712         /// std::string constructor.
00713         TiXmlAttribute( const std::string& _name, const std::string& _value )
00714         {
00715                 name = _name;
00716                 value = _value;
00717                 document = 0;
00718                 prev = next = 0;
00719         }
00720         #endif
00721 
00722         /// Construct an attribute with a name and value.
00723         TiXmlAttribute( const char * _name, const char * _value )
00724         {
00725                 name = _name;
00726                 value = _value;
00727                 document = 0;
00728                 prev = next = 0;
00729         }
00730 
00731         const char*             Name()  const           { return name.c_str (); }               ///< Return the name of this attribute.
00732         const char*             Value() const           { return value.c_str (); }              ///< Return the value of this attribute.
00733         int                             IntValue() const;                                                                       ///< Return the value of this attribute, converted to an integer.
00734         double                  DoubleValue() const;                                                            ///< Return the value of this attribute, converted to a double.
00735 
00736         /** QueryIntValue examines the value string. It is an alternative to the
00737                 IntValue() method with richer error checking.
00738                 If the value is an integer, it is stored in 'value' and
00739                 the call returns TIXML_SUCCESS. If it is not
00740                 an integer, it returns TIXML_WRONG_TYPE.
00741 
00742                 A specialized but useful call. Note that for success it returns 0,
00743                 which is the opposite of almost all other TinyXml calls.
00744         */
00745         int QueryIntValue( int* _value ) const;
00746         /// QueryDoubleValue examines the value string. See QueryIntValue().
00747         int QueryDoubleValue( double* _value ) const;
00748 
00749         void SetName( const char* _name )       { name = _name; }                               ///< Set the name of this attribute.
00750         void SetValue( const char* _value )     { value = _value; }                             ///< Set the value.
00751 
00752         void SetIntValue( int _value );                                                                         ///< Set the value from an integer.
00753         void SetDoubleValue( double _value );                                                           ///< Set the value from a double.
00754 
00755     #ifdef TIXML_USE_STL
00756         /// STL std::string form.
00757         void SetName( const std::string& _name )
00758         {
00759                 StringToBuffer buf( _name );
00760                 SetName ( buf.buffer ? buf.buffer : "error" );
00761         }
00762         /// STL std::string form.
00763         void SetValue( const std::string& _value )
00764         {
00765                 StringToBuffer buf( _value );
00766                 SetValue( buf.buffer ? buf.buffer : "error" );
00767         }
00768         #endif
00769 
00770         /// Get the next sibling attribute in the DOM. Returns null at end.
00771         const TiXmlAttribute* Next() const;
00772         TiXmlAttribute* Next();
00773         /// Get the previous sibling attribute in the DOM. Returns null at beginning.
00774         const TiXmlAttribute* Previous() const;
00775         TiXmlAttribute* Previous();
00776 
00777         bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
00778         bool operator<( const TiXmlAttribute& rhs )      const { return name < rhs.name; }
00779         bool operator>( const TiXmlAttribute& rhs )  const { return name > rhs.name; }
00780 
00781         /*      Attribute parsing starts: first letter of the name
00782                                                  returns: the next char after the value end quote
00783         */
00784         virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
00785 
00786         // Prints this Attribute to a FILE stream.
00787         virtual void Print( FILE* cfile, int depth ) const;
00788 
00789         virtual