Skip to content

Commit

Permalink
Updated TinyXml to 2.6.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
acaudwell committed Mar 16, 2014
1 parent a004408 commit 1e66a59
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 58 deletions.
5 changes: 0 additions & 5 deletions src/tinyxml/tinystr.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
www.sourceforge.net/projects/tinyxml
Original file by Yves Berquin.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
Expand All @@ -22,10 +21,6 @@ must not be misrepresented as being the original software.
distribution.
*/

/*
* THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
*/


#ifndef TIXML_USE_STL

Expand Down
14 changes: 0 additions & 14 deletions src/tinyxml/tinystr.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
www.sourceforge.net/projects/tinyxml
Original file by Yves Berquin.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
Expand All @@ -22,17 +21,6 @@ must not be misrepresented as being the original software.
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

Expand Down Expand Up @@ -106,13 +94,11 @@ class TiXmlString
quit();
}

// = operator
TiXmlString& operator = (const char * copy)
{
return assign( copy, (size_type)strlen(copy));
}

// = operator
TiXmlString& operator = (const TiXmlString & copy)
{
return assign(copy.start(), copy.length());
Expand Down
69 changes: 58 additions & 11 deletions src/tinyxml/tinyxml.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
Original code by Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
Expand Down Expand Up @@ -191,7 +191,8 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT )
{
delete node;
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
if ( GetDocument() )
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0;
}

Expand All @@ -214,7 +215,8 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
{
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
{
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
if ( GetDocument() )
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0;
}
TiXmlNode* node = addThis.Clone();
Expand All @@ -232,7 +234,8 @@ TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode&
}
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
{
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
if ( GetDocument() )
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0;
}

Expand Down Expand Up @@ -264,7 +267,8 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a
}
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
{
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
if ( GetDocument() )
GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0;
}

Expand Down Expand Up @@ -544,10 +548,11 @@ TiXmlElement::TiXmlElement( const TiXmlElement& copy)
}


void TiXmlElement::operator=( const TiXmlElement& base )
TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base )
{
ClearThis();
base.CopyTo( this );
return *this;
}


Expand Down Expand Up @@ -662,6 +667,45 @@ int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
}


int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const
{
const TiXmlAttribute* node = attributeSet.Find( name );
if ( !node )
return TIXML_NO_ATTRIBUTE;

int ival = 0;
int result = node->QueryIntValue( &ival );
*value = (unsigned)ival;
return result;
}


int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const
{
const TiXmlAttribute* node = attributeSet.Find( name );
if ( !node )
return TIXML_NO_ATTRIBUTE;

int result = TIXML_WRONG_TYPE;
if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN )
|| StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN )
|| StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) )
{
*bval = true;
result = TIXML_SUCCESS;
}
else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN )
|| StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN )
|| StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) )
{
*bval = false;
result = TIXML_SUCCESS;
}
return result;
}



#ifdef TIXML_USE_STL
int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
{
Expand Down Expand Up @@ -899,10 +943,11 @@ TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode
}


void TiXmlDocument::operator=( const TiXmlDocument& copy )
TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy )
{
Clear();
copy.CopyTo( this );
return *this;
}


Expand Down Expand Up @@ -1171,15 +1216,15 @@ void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) cons

if (value.find ('\"') == TIXML_STRING::npos) {
if ( cfile ) {
fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
}
if ( str ) {
(*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
}
}
else {
if ( cfile ) {
fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
}
if ( str ) {
(*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
Expand Down Expand Up @@ -1241,10 +1286,11 @@ TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::T
}


void TiXmlComment::operator=( const TiXmlComment& base )
TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base )
{
Clear();
base.CopyTo( this );
return *this;
}


Expand Down Expand Up @@ -1361,10 +1407,11 @@ TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
}


void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
{
Clear();
copy.CopyTo( this );
return *this;
}


Expand Down
40 changes: 23 additions & 17 deletions src/tinyxml/tinyxml.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
Original code by Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
Expand Down Expand Up @@ -91,7 +91,7 @@ class TiXmlParsingData;

const int TIXML_MAJOR_VERSION = 2;
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
in the XML file.
Expand Down Expand Up @@ -146,7 +146,7 @@ class TiXmlVisitor
virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
/// Visit a comment node
virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
/// Visit an unknow node
/// Visit an unknown node
virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
};

Expand Down Expand Up @@ -678,8 +678,8 @@ class TiXmlNode : public TiXmlBase
#endif

/** Query the type (as an enumerated value, above) of this node.
The possible types are: DOCUMENT, ELEMENT, COMMENT,
UNKNOWN, TEXT, and DECLARATION.
The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT,
TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION.
*/
int Type() const { return type; }

Expand Down Expand Up @@ -950,7 +950,7 @@ class TiXmlElement : public TiXmlNode

TiXmlElement( const TiXmlElement& );

void operator=( const TiXmlElement& base );
TiXmlElement& operator=( const TiXmlElement& base );

virtual ~TiXmlElement();

Expand Down Expand Up @@ -983,6 +983,13 @@ class TiXmlElement : public TiXmlNode
does not exist, then TIXML_NO_ATTRIBUTE is returned.
*/
int QueryIntAttribute( const char* name, int* _value ) const;
/// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute().
int QueryUnsignedAttribute( const char* name, unsigned* _value ) const;
/** QueryBoolAttribute examines the attribute - see QueryIntAttribute().
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 QueryIntAttribute().
int QueryDoubleAttribute( const char* name, double* _value ) const;
/// QueryFloatAttribute examines the attribute - see QueryIntAttribute().
Expand Down Expand Up @@ -1162,7 +1169,7 @@ class TiXmlComment : public TiXmlNode
SetValue( _value );
}
TiXmlComment( const TiXmlComment& );
void operator=( const TiXmlComment& base );
TiXmlComment& operator=( const TiXmlComment& base );

virtual ~TiXmlComment() {}

Expand All @@ -1176,8 +1183,8 @@ class TiXmlComment : public TiXmlNode
*/
virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );

virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.

/** Walk the XML tree visiting this node and all of its children.
*/
Expand Down Expand Up @@ -1227,7 +1234,7 @@ class TiXmlText : public TiXmlNode
#endif

TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { 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.
virtual void Print( FILE* cfile, int depth ) const;
Expand Down Expand Up @@ -1294,7 +1301,7 @@ class TiXmlDeclaration : public TiXmlNode
const char* _standalone );

TiXmlDeclaration( const TiXmlDeclaration& copy );
void operator=( const TiXmlDeclaration& copy );
TiXmlDeclaration& operator=( const TiXmlDeclaration& copy );

virtual ~TiXmlDeclaration() {}

Expand Down Expand Up @@ -1351,7 +1358,7 @@ class TiXmlUnknown : public TiXmlNode
virtual ~TiXmlUnknown() {}

TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_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.
virtual TiXmlNode* Clone() const;
Expand All @@ -1360,8 +1367,8 @@ class TiXmlUnknown : public TiXmlNode

virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );

virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.

/** Walk the XML tree visiting this node and all of its children.
*/
Expand Down Expand Up @@ -1397,7 +1404,7 @@ class TiXmlDocument : public TiXmlNode
#endif

TiXmlDocument( const TiXmlDocument& copy );
void operator=( const TiXmlDocument& copy );
TiXmlDocument& operator=( const TiXmlDocument& copy );

virtual ~TiXmlDocument() {}

Expand Down Expand Up @@ -1635,7 +1642,7 @@ class TiXmlHandle
TiXmlHandle( TiXmlNode* _node ) { this->node = _node; }
/// Copy constructor
TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; }

/// Return a handle to the first child node.
TiXmlHandle FirstChild() const;
Expand Down Expand Up @@ -1796,4 +1803,3 @@ class TiXmlPrinter : public TiXmlVisitor
#endif

#endif

2 changes: 1 addition & 1 deletion src/tinyxml/tinyxmlerror.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ distribution.
// It also cleans up the code a bit.
//

const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
Expand Down
Loading

0 comments on commit 1e66a59

Please sign in to comment.