tinystr.h   tinystr.h 
/* /*
www.sourceforge.net/projects/tinyxml www.sourceforge.net/projects/tinyxml
Original file by Yves Berquin.
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
damages arising from the use of this software. damages arising from the use of this software.
Permission is granted to anyone to use this software for any Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions: redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must 1. The origin of this software must not be misrepresented; you must
skipping to change at line 25 skipping to change at line 24
software in a product, an acknowledgment in the product documentation software in a product, an acknowledgment in the product documentation
would be appreciated but is not required. would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and 2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software. must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*/ */
/*
* THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.
*
* - completely rewritten. compact, clean, and fast implementation.
* - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)
* - fixed reserve() to work as per specification.
* - fixed buggy compares operator==(), operator<(), and operator>()
* - fixed operator+=() to take a const ref argument, following spec.
* - added "copy" constructor with length, and most compare operators.
* - added swap(), clear(), size(), capacity(), operator+().
*/
#ifndef TIXML_USE_STL #ifndef TIXML_USE_STL
#ifndef TIXML_STRING_INCLUDED #ifndef TIXML_STRING_INCLUDED
#define TIXML_STRING_INCLUDED #define TIXML_STRING_INCLUDED
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
/* The support for explicit isn't that universal, and it isn't really /* The support for explicit isn't that universal, and it isn't really
required - it is used to check that the TiXmlString class isn't inco rrectly required - it is used to check that the TiXmlString class isn't inco rrectly
skipping to change at line 107 skipping to change at line 94
init(len); init(len);
memcpy(start(), str, len); memcpy(start(), str, len);
} }
// TiXmlString destructor // TiXmlString destructor
~TiXmlString () ~TiXmlString ()
{ {
quit(); quit();
} }
// = operator
TiXmlString& operator = (const char * copy) TiXmlString& operator = (const char * copy)
{ {
return assign( copy, (size_type)strlen(copy)); return assign( copy, (size_type)strlen(copy));
} }
// = operator
TiXmlString& operator = (const TiXmlString & copy) TiXmlString& operator = (const TiXmlString & copy)
{ {
return assign(copy.start(), copy.length()); return assign(copy.start(), copy.length());
} }
// += operator. Maps to append // += operator. Maps to append
TiXmlString& operator += (const char * suffix) TiXmlString& operator += (const char * suffix)
{ {
return append(suffix, static_cast<size_type>( strlen(suffix) )); return append(suffix, static_cast<size_type>( strlen(suffix) ));
} }
 End of changes. 4 change blocks. 
15 lines changed or deleted 0 lines changed or added


 tinyxml.h   tinyxml.h 
/* /*
www.sourceforge.net/projects/tinyxml www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.g rinninglizard.com) Original code by Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
damages arising from the use of this software. damages arising from the use of this software.
Permission is granted to anyone to use this software for any Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions: redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must 1. The origin of this software must not be misrepresented; you must
skipping to change at line 93 skipping to change at line 93
class TiXmlElement; class TiXmlElement;
class TiXmlComment; class TiXmlComment;
class TiXmlUnknown; class TiXmlUnknown;
class TiXmlAttribute; class TiXmlAttribute;
class TiXmlText; class TiXmlText;
class TiXmlDeclaration; class TiXmlDeclaration;
class TiXmlParsingData; class TiXmlParsingData;
const int TIXML_MAJOR_VERSION = 2; const int TIXML_MAJOR_VERSION = 2;
const int TIXML_MINOR_VERSION = 6; const int TIXML_MINOR_VERSION = 6;
const int TIXML_PATCH_VERSION = 1; const int TIXML_PATCH_VERSION = 2;
/* Internal structure for tracking location of items /* Internal structure for tracking location of items
in the XML file. in the XML file.
*/ */
struct TiXmlCursor struct TiXmlCursor
{ {
TiXmlCursor() { Clear(); } TiXmlCursor() { Clear(); }
void Clear() { row = col = -1; } void Clear() { row = col = -1; }
int row; // 0 based. int row; // 0 based.
skipping to change at line 147 skipping to change at line 147
virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXm lAttribute* /*firstAttribute*/ ) { return true; } virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXm lAttribute* /*firstAttribute*/ ) { return true; }
/// Visit an element. /// Visit an element.
virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
/// Visit a declaration /// Visit a declaration
virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { re turn true; } virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { re turn true; }
/// Visit a text node /// Visit a text node
virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
/// Visit a comment node /// Visit a comment node
virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
/// Visit an unknow node /// Visit an unknown node
virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
}; };
// Only used by Attribute::Query functions // Only used by Attribute::Query functions
enum enum
{ {
TIXML_SUCCESS, TIXML_SUCCESS,
TIXML_NO_ATTRIBUTE, TIXML_NO_ATTRIBUTE,
TIXML_WRONG_TYPE TIXML_WRONG_TYPE
}; };
skipping to change at line 676 skipping to change at line 676
TiXmlElement* FirstChildElement( const char * _value ) { TiXmlElement* FirstChildElement( const char * _value ) {
return const_cast< TiXmlElement* >( (const_cast< const TiXml Node* >(this))->FirstChildElement( _value ) ); return const_cast< TiXmlElement* >( (const_cast< const TiXml Node* >(this))->FirstChildElement( _value ) );
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
const TiXmlElement* FirstChildElement( const std::string& _value ) c onst { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. const TiXmlElement* FirstChildElement( const std::string& _value ) c onst { return FirstChildElement (_value.c_str ()); } ///< STL std::string form.
TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form.
#endif #endif
/** Query the type (as an enumerated value, above) of this node. /** Query the type (as an enumerated value, above) of this node.
The possible types are: DOCUMENT, ELEMENT, COMMENT, The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, T
UNKNOWN, TEX INYXML_COMMENT,
T, and DECLARATION. TINYXML_UNKN
OWN, TINYXML_TEXT, and TINYXML_DECLARATION.
*/ */
int Type() const { return type; } int Type() const { return type; }
/** Return a pointer to the Document this node lives in. /** Return a pointer to the Document this node lives in.
Returns null if not in a document. Returns null if not in a document.
*/ */
const TiXmlDocument* GetDocument() const; const TiXmlDocument* GetDocument() const;
TiXmlDocument* GetDocument() { TiXmlDocument* GetDocument() {
return const_cast< TiXmlDocument* >( (const_cast< const TiXm lNode* >(this))->GetDocument() ); return const_cast< TiXmlDocument* >( (const_cast< const TiXm lNode* >(this))->GetDocument() );
} }
skipping to change at line 944 skipping to change at line 944
/// Construct an element. /// Construct an element.
TiXmlElement (const char * in_value); TiXmlElement (const char * in_value);
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/// std::string constructor. /// std::string constructor.
TiXmlElement( const std::string& _value ); TiXmlElement( const std::string& _value );
#endif #endif
TiXmlElement( const TiXmlElement& ); TiXmlElement( const TiXmlElement& );
void operator=( const TiXmlElement& base ); TiXmlElement& operator=( const TiXmlElement& base );
virtual ~TiXmlElement(); virtual ~TiXmlElement();
/** Given an attribute name, Attribute() returns the value /** Given an attribute name, Attribute() returns the value
for the attribute of that name, or null if none exists. for the attribute of that name, or null if none exists.
*/ */
const char* Attribute( const char* name ) const; const char* Attribute( const char* name ) const;
/** Given an attribute name, Attribute() returns the value /** Given an attribute name, Attribute() returns the value
for the attribute of that name, or null if none exists. for the attribute of that name, or null if none exists.
skipping to change at line 977 skipping to change at line 977
const char* Attribute( const char* name, double* d ) const; const char* Attribute( const char* name, double* d ) const;
/** QueryIntAttribute examines the attribute - it is an alternative to the /** QueryIntAttribute examines the attribute - it is an alternative to the
Attribute() method with richer error checking. Attribute() method with richer error checking.
If the attribute is an integer, it is stored in 'value' and If the attribute is an integer, it is stored in 'value' and
the call returns TIXML_SUCCESS. If it is not the call returns TIXML_SUCCESS. If it is not
an integer, it returns TIXML_WRONG_TYPE. If the attribute an integer, it returns TIXML_WRONG_TYPE. If the attribute
does not exist, then TIXML_NO_ATTRIBUTE is returned. does not exist, then TIXML_NO_ATTRIBUTE is returned.
*/ */
int QueryIntAttribute( const char* name, int* _value ) const; int QueryIntAttribute( const char* name, int* _value ) const;
/// QueryUnsignedAttribute examines the attribute - see QueryIntAttr
ibute().
int QueryUnsignedAttribute( const char* name, unsigned* _value ) con
st;
/** QueryBoolAttribute examines the attribute - see QueryIntAttribut
e().
Note that '1', 'true', or 'yes' are considered true, while '
0', 'false'
and 'no' are considered false.
*/
int QueryBoolAttribute( const char* name, bool* _value ) const;
/// QueryDoubleAttribute examines the attribute - see QueryIntAttrib ute(). /// QueryDoubleAttribute examines the attribute - see QueryIntAttrib ute().
int QueryDoubleAttribute( const char* name, double* _value ) const; int QueryDoubleAttribute( const char* name, double* _value ) const;
/// QueryFloatAttribute examines the attribute - see QueryIntAttribu te(). /// QueryFloatAttribute examines the attribute - see QueryIntAttribu te().
int QueryFloatAttribute( const char* name, float* _value ) const { int QueryFloatAttribute( const char* name, float* _value ) const {
double d; double d;
int result = QueryDoubleAttribute( name, &d ); int result = QueryDoubleAttribute( name, &d );
if ( result == TIXML_SUCCESS ) { if ( result == TIXML_SUCCESS ) {
*_value = (float)d; *_value = (float)d;
} }
return result; return result;
skipping to change at line 1155 skipping to change at line 1162
class TiXmlComment : public TiXmlNode class TiXmlComment : public TiXmlNode
{ {
public: public:
/// Constructs an empty comment. /// Constructs an empty comment.
TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
/// Construct a comment from text. /// Construct a comment from text.
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_C OMMENT ) { TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_C OMMENT ) {
SetValue( _value ); SetValue( _value );
} }
TiXmlComment( const TiXmlComment& ); TiXmlComment( const TiXmlComment& );
void operator=( const TiXmlComment& base ); TiXmlComment& operator=( const TiXmlComment& base );
virtual ~TiXmlComment() {} virtual ~TiXmlComment() {}
/// Returns a copy of this Comment. /// Returns a copy of this Comment.
virtual TiXmlNode* Clone() const; virtual TiXmlNode* Clone() const;
// Write this Comment to a FILE stream. // Write this Comment to a FILE stream.
virtual void Print( FILE* cfile, int depth ) const; virtual void Print( FILE* cfile, int depth ) const;
/* Attribtue parsing starts: at the ! of the !-- /* Attribtue parsing starts: at the ! of the !--
returns: next char past '>' returns: next char past '>'
*/ */
virtual const char* Parse( const char* p, TiXmlParsingData* data, Ti XmlEncoding encoding ); virtual const char* Parse( const char* p, TiXmlParsingData* data, Ti XmlEncoding encoding );
virtual const TiXmlComment* ToComment() const { return this; } ///< virtual const TiXmlComment* ToComment() const { return this; } ///
Cast to a more defined type. Will return null not of the requested type. < Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlComment* ToComment() { return this; } ///< Cast to a m virtual TiXmlComment* ToComment() { return thi
ore defined type. Will return null not of the requested type. s; } ///< Cast to a more defined type. Will return null not of the requeste
d type.
/** Walk the XML tree visiting this node and all of its children. /** Walk the XML tree visiting this node and all of its children.
*/ */
virtual bool Accept( TiXmlVisitor* visitor ) const; virtual bool Accept( TiXmlVisitor* visitor ) const;
protected: protected:
void CopyTo( TiXmlComment* target ) const; void CopyTo( TiXmlComment* target ) const;
// used to be public // used to be public
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
skipping to change at line 1219 skipping to change at line 1226
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/// Constructor. /// Constructor.
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TI NYXML_TEXT) TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TI NYXML_TEXT)
{ {
SetValue( initValue ); SetValue( initValue );
cdata = false; cdata = false;
} }
#endif #endif
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_T EXT ) { copy.CopyTo( this ); } TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_T EXT ) { copy.CopyTo( this ); }
void operator=( const TiXmlText& base ) { base.CopyTo( this ); } TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; }
// Write this text object to a FILE stream. // Write this text object to a FILE stream.
virtual void Print( FILE* cfile, int depth ) const; virtual void Print( FILE* cfile, int depth ) const;
/// Queries whether this represents text using a CDATA section. /// Queries whether this represents text using a CDATA section.
bool CDATA() const { return cdata; } bool CDATA() const { return cdata; }
/// Turns on or off a CDATA representation of text. /// Turns on or off a CDATA representation of text.
void SetCDATA( bool _cdata ) { cdata = _cdata; } void SetCDATA( bool _cdata ) { cdata = _cdata; }
virtual const char* Parse( const char* p, TiXmlParsingData* data, Ti XmlEncoding encoding ); virtual const char* Parse( const char* p, TiXmlParsingData* data, Ti XmlEncoding encoding );
skipping to change at line 1285 skipping to change at line 1292
const std::string& _encoding , const std::string& _encoding ,
const std::string& _standalo ne ); const std::string& _standalo ne );
#endif #endif
/// Construct. /// Construct.
TiXmlDeclaration( const char* _version, TiXmlDeclaration( const char* _version,
const char* _encoding, const char* _encoding,
const char* _standalone ); const char* _standalone );
TiXmlDeclaration( const TiXmlDeclaration& copy ); TiXmlDeclaration( const TiXmlDeclaration& copy );
void operator=( const TiXmlDeclaration& copy ); TiXmlDeclaration& operator=( const TiXmlDeclaration& copy );
virtual ~TiXmlDeclaration() {} virtual ~TiXmlDeclaration() {}
/// Version. Will return an empty string if none was found. /// Version. Will return an empty string if none was found.
const char *Version() const { return version.c_s tr (); } const char *Version() const { return version.c_s tr (); }
/// Encoding. Will return an empty string if none was found. /// Encoding. Will return an empty string if none was found.
const char *Encoding() const { return encoding.c_str (); } const char *Encoding() const { return encoding.c_str (); }
/// Is this a standalone document? /// Is this a standalone document?
const char *Standalone() const { return standalone.c_str () ; } const char *Standalone() const { return standalone.c_str () ; }
skipping to change at line 1341 skipping to change at line 1348
DTD tags get thrown into TiXmlUnknowns. DTD tags get thrown into TiXmlUnknowns.
*/ */
class TiXmlUnknown : public TiXmlNode class TiXmlUnknown : public TiXmlNode
{ {
public: public:
TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {}
virtual ~TiXmlUnknown() {} virtual ~TiXmlUnknown() {}
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TIN YXML_UNKNOWN ) { copy.CopyTo( this ); } TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TIN YXML_UNKNOWN ) { copy.CopyTo( this ); }
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; }
/// Creates a copy of this Unknown and returns it. /// Creates a copy of this Unknown and returns it.
virtual TiXmlNode* Clone() const; virtual TiXmlNode* Clone() const;
// Print this Unknown to a FILE stream. // Print this Unknown to a FILE stream.
virtual void Print( FILE* cfile, int depth ) const; virtual void Print( FILE* cfile, int depth ) const;
virtual const char* Parse( const char* p, TiXmlParsingData* data, Ti XmlEncoding encoding ); virtual const char* Parse( const char* p, TiXmlParsingData* data, Ti XmlEncoding encoding );
virtual const TiXmlUnknown* ToUnknown() const { return this; virtual const TiXmlUnknown* ToUnknown() const { return thi
} ///< Cast to a more defined type. Will return null not of the requested s; } ///< Cast to a more defined type. Will return null not of the requeste
type. d type.
virtual TiXmlUnknown* ToUnknown() { return this; } virtual TiXmlUnknown* ToUnknown()
///< Cast to a more defined type. Will return null not of the requested ty { return this; } ///< Cast to a more defined type. Will return null not
pe. of the requested type.
/** Walk the XML tree visiting this node and all of its children. /** Walk the XML tree visiting this node and all of its children.
*/ */
virtual bool Accept( TiXmlVisitor* content ) const; virtual bool Accept( TiXmlVisitor* content ) const;
protected: protected:
void CopyTo( TiXmlUnknown* target ) const; void CopyTo( TiXmlUnknown* target ) const;
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
skipping to change at line 1386 skipping to change at line 1393
TiXmlDocument(); TiXmlDocument();
/// Create a document with a name. The name of the document is also the filename of the xml. /// Create a document with a name. The name of the document is also the filename of the xml.
TiXmlDocument( const char * documentName ); TiXmlDocument( const char * documentName );
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/// Constructor. /// Constructor.
TiXmlDocument( const std::string& documentName ); TiXmlDocument( const std::string& documentName );
#endif #endif
TiXmlDocument( const TiXmlDocument& copy ); TiXmlDocument( const TiXmlDocument& copy );
void operator=( const TiXmlDocument& copy ); TiXmlDocument& operator=( const TiXmlDocument& copy );
virtual ~TiXmlDocument() {} virtual ~TiXmlDocument() {}
/** Load a file using the current document value. /** Load a file using the current document value.
Returns true if successful. Will delete any existing Returns true if successful. Will delete any existing
document data before loading. document data before loading.
*/ */
bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
/// Save a file using the current document value. Returns true if su ccessful. /// Save a file using the current document value. Returns true if su ccessful.
bool SaveFile() const; bool SaveFile() const;
skipping to change at line 1623 skipping to change at line 1630
} }
@endverbatim @endverbatim
*/ */
class TiXmlHandle class TiXmlHandle
{ {
public: public:
/// Create a handle from any node (at any depth of the tree.) This c an be a null pointer. /// Create a handle from any node (at any depth of the tree.) This c an be a null pointer.
TiXmlHandle( TiXmlNode* _node ) { th is->node = _node; } TiXmlHandle( TiXmlNode* _node ) { th is->node = _node; }
/// Copy constructor /// Copy constructor
TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.n ode; return *this; } TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; }
/// Return a handle to the first child node. /// Return a handle to the first child node.
TiXmlHandle FirstChild() const; TiXmlHandle FirstChild() const;
/// Return a handle to the first child node with the given name. /// Return a handle to the first child node with the given name.
TiXmlHandle FirstChild( const char * value ) const; TiXmlHandle FirstChild( const char * value ) const;
/// Return a handle to the first child element. /// Return a handle to the first child element.
TiXmlHandle FirstChildElement() const; TiXmlHandle FirstChildElement() const;
/// Return a handle to the first child element with the given name. /// Return a handle to the first child element with the given name.
TiXmlHandle FirstChildElement( const char * value ) const; TiXmlHandle FirstChildElement( const char * value ) const;
 End of changes. 14 change blocks. 
23 lines changed or deleted 36 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/