Browse Source

remove trailing spaces

Lee Thomason (grinliz) 13 years ago
parent
commit
2f1f6247e0
3 changed files with 139 additions and 139 deletions
  1. 62 62
      tinyxml2.cpp
  2. 51 51
      tinyxml2.h
  3. 26 26
      xmltest.cpp

+ 62 - 62
tinyxml2.cpp

@@ -70,7 +70,7 @@ struct Entity {
 };
 
 static const int NUM_ENTITIES = 5;
-static const Entity entities[NUM_ENTITIES] = 
+static const Entity entities[NUM_ENTITIES] =
 {
 	{ "quot", 4,	DOUBLE_QUOTE },
 	{ "amp", 3,		'&'  },
@@ -123,7 +123,7 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags )
 			return p + length;
 		}
 		++p;
-	}	
+	}
 	return 0;
 }
 
@@ -137,7 +137,7 @@ char* StrPair::ParseName( char* p )
 	}
 
 	while( *p && (
-			   XMLUtil::IsAlphaNum( (unsigned char) *p ) 
+			   XMLUtil::IsAlphaNum( (unsigned char) *p )
 			|| *p == '_'
 			|| *p == ':'
 			|| (*p == '-' && p>start )		// can be in a name, but not lead it.
@@ -166,7 +166,7 @@ void StrPair::CollapseWhitespace()
 		while( *p ) {
 			if ( XMLUtil::IsWhiteSpace( *p )) {
 				p = XMLUtil::SkipWhiteSpace( p );
-				if ( *p == 0 ) 
+				if ( *p == 0 )
 					break;	// don't write to q; this trims the trailing space.
 				*q = ' ';
 				++q;
@@ -231,7 +231,7 @@ const char* StrPair::GetStr()
 						int i=0;
 						for(; i<NUM_ENTITIES; ++i ) {
 							if (    strncmp( p+1, entities[i].pattern, entities[i].length ) == 0
-								 && *(p+entities[i].length+1) == ';' ) 
+								 && *(p+entities[i].length+1) == ';' )
 							{
 								// Found an entity convert;
 								*q = entities[i].value;
@@ -275,9 +275,9 @@ const char* XMLUtil::ReadBOM( const char* p, bool* bom )
 	*bom = false;
 	const unsigned char* pu = reinterpret_cast<const unsigned char*>(p);
 	// Check for BOM:
-	if (    *(pu+0) == TIXML_UTF_LEAD_0 
+	if (    *(pu+0) == TIXML_UTF_LEAD_0
 		 && *(pu+1) == TIXML_UTF_LEAD_1
-		 && *(pu+2) == TIXML_UTF_LEAD_2 ) 
+		 && *(pu+2) == TIXML_UTF_LEAD_2 )
 	{
 		*bom = true;
 		p += 3;
@@ -292,7 +292,7 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
 	const unsigned long BYTE_MARK = 0x80;
 	const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
 
-	if (input < 0x80) 
+	if (input < 0x80)
 		*length = 1;
 	else if ( input < 0x800 )
 		*length = 2;
@@ -306,22 +306,22 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
 	output += *length;
 
 	// Scary scary fall throughs.
-	switch (*length) 
+	switch (*length)
 	{
 		case 4:
-			--output; 
-			*output = (char)((input | BYTE_MARK) & BYTE_MASK); 
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
 			input >>= 6;
 		case 3:
-			--output; 
-			*output = (char)((input | BYTE_MARK) & BYTE_MASK); 
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
 			input >>= 6;
 		case 2:
-			--output; 
-			*output = (char)((input | BYTE_MARK) & BYTE_MASK); 
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
 			input >>= 6;
 		case 1:
-			--output; 
+			--output;
 			*output = (char)(input | FIRST_BYTE_MARK[*length]);
 	}
 }
@@ -359,7 +359,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
 					ucs += mult * (*q - 'a' + 10);
 				else if ( *q >= 'A' && *q <= 'F' )
 					ucs += mult * (*q - 'A' + 10 );
-				else 
+				else
 					return 0;
 				mult *= 16;
 				--q;
@@ -382,7 +382,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
 			{
 				if ( *q >= '0' && *q <= '9' )
 					ucs += mult * (*q - '0');
-				else 
+				else
 					return 0;
 				mult *= 10;
 				--q;
@@ -396,33 +396,33 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
 }
 
 
-void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) 
+void XMLUtil::ToStr( int v, char* buffer, int bufferSize )
 {
-	TIXML_SNPRINTF( buffer, bufferSize, "%d", v );	
+	TIXML_SNPRINTF( buffer, bufferSize, "%d", v );
 }
 
 
 void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize )
 {
-	TIXML_SNPRINTF( buffer, bufferSize, "%u", v );	
+	TIXML_SNPRINTF( buffer, bufferSize, "%u", v );
 }
 
 
 void XMLUtil::ToStr( bool v, char* buffer, int bufferSize )
 {
-	TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 );	
+	TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 );
 }
 
 
 void XMLUtil::ToStr( float v, char* buffer, int bufferSize )
 {
-	TIXML_SNPRINTF( buffer, bufferSize, "%f", v );	
+	TIXML_SNPRINTF( buffer, bufferSize, "%f", v );
 }
 
 
 void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
 {
-	TIXML_SNPRINTF( buffer, bufferSize, "%f", v );	
+	TIXML_SNPRINTF( buffer, bufferSize, "%f", v );
 }
 
 
@@ -476,7 +476,7 @@ bool XMLUtil::ToDouble( const char* str, double* value )
 }
 
 
-char* XMLDocument::Identify( char* p, XMLNode** node ) 
+char* XMLDocument::Identify( char* p, XMLNode** node )
 {
 	XMLNode* returnNode = 0;
 	char* start = p;
@@ -486,7 +486,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node )
 		return p;
 	}
 
-	// What is this thing? 
+	// What is this thing?
 	// - Elements start with a letter or underscore, but xml is reserved.
 	// - Comments: <!--
 	// - Decleration: <?
@@ -600,7 +600,7 @@ void XMLNode::DeleteChildren()
 	while( firstChild ) {
 		XMLNode* node = firstChild;
 		Unlink( node );
-		
+
 		DELETE_NODE( node );
 	}
 	firstChild = lastChild = 0;
@@ -610,9 +610,9 @@ void XMLNode::DeleteChildren()
 void XMLNode::Unlink( XMLNode* child )
 {
 	TIXMLASSERT( child->parent == this );
-	if ( child == firstChild ) 
+	if ( child == firstChild )
 		firstChild = firstChild->next;
-	if ( child == lastChild ) 
+	if ( child == lastChild )
 		lastChild = lastChild->prev;
 
 	if ( child->prev ) {
@@ -731,8 +731,8 @@ const XMLElement* XMLNode::LastChildElement( const char* value ) const
 const XMLElement* XMLNode::NextSiblingElement( const char* value ) const
 {
 	for( XMLNode* element=this->next; element; element = element->next ) {
-		if (    element->ToElement() 
-			 && (!value || XMLUtil::StringEqual( value, element->Value() ))) 
+		if (    element->ToElement()
+			 && (!value || XMLUtil::StringEqual( value, element->Value() )))
 		{
 			return element->ToElement();
 		}
@@ -745,7 +745,7 @@ const XMLElement* XMLNode::PreviousSiblingElement( const char* value ) const
 {
 	for( XMLNode* element=this->prev; element; element = element->prev ) {
 		if (    element->ToElement()
-			 && (!value || XMLUtil::StringEqual( value, element->Value() ))) 
+			 && (!value || XMLUtil::StringEqual( value, element->Value() )))
 		{
 			return element->ToElement();
 		}
@@ -765,11 +765,11 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
 	//		<foo>
 	//		</foo>
 	//		<!-- comment -->
-	//		
+	//
 	// Where the closing element (/foo) *must* be the next thing after the opening
 	// element, and the names must match. BUT the tricky bit is that the closing
 	// element will be read by the child.
-	// 
+	//
 	// 'endTag' is the end tag for this node, it is returned by a call to a child.
 	// 'parentEnd' is the end tag for the parent, which is filled in and returned.
 
@@ -814,7 +814,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
 				p = 0;
 			}
 			else if ( !endTag.Empty() ) {
-				if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) { 
+				if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
 					document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
 					p = 0;
 				}
@@ -1177,10 +1177,10 @@ const XMLAttribute* XMLElement::FindAttribute( const char* name ) const
 
 
 const char* XMLElement::Attribute( const char* name, const char* value ) const
-{ 
-	const XMLAttribute* a = FindAttribute( name ); 
-	if ( !a ) 
-		return 0; 
+{
+	const XMLAttribute* a = FindAttribute( name );
+	if ( !a )
+		return 0;
 	if ( !value || XMLUtil::StringEqual( a->Value(), value ))
 		return a->Value();
 	return 0;
@@ -1269,7 +1269,7 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
 	for( attrib = rootAttribute;
 		 attrib;
 		 last = attrib, attrib = attrib->next )
-	{		 
+	{
 		if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
 			break;
 		}
@@ -1337,12 +1337,12 @@ char* XMLElement::ParseAttributes( char* p )
 			// attribute will be doubly added. However, tracking the 'prevAttribute'
 			// avoids re-scanning the attribute list. Preferring performance for
 			// now, may reconsider in the future.
-			if ( prevAttribute ) { 
+			if ( prevAttribute ) {
 				prevAttribute->next = attrib;
 			}
 			else {
 				rootAttribute = attrib;
-			}	
+			}
 			prevAttribute = attrib;
 		}
 		// end of the tag
@@ -1386,7 +1386,7 @@ char* XMLElement::ParseDeep( char* p, StrPair* strPair )
 	if ( value.Empty() ) return 0;
 
 	p = ParseAttributes( p );
-	if ( !p || !*p || closingType ) 
+	if ( !p || !*p || closingType )
 		return p;
 
 	p = XMLNode::ParseDeep( p, strPair );
@@ -1422,7 +1422,7 @@ bool XMLElement::ShallowEqual( const XMLNode* compare ) const
 			}
 			a = a->Next();
 			b = b->Next();
-		}	
+		}
 		if ( a || b ) {
 			// different count
 			return false;
@@ -1435,7 +1435,7 @@ bool XMLElement::ShallowEqual( const XMLNode* compare ) const
 
 bool XMLElement::Accept( XMLVisitor* visitor ) const
 {
-	if ( visitor->VisitEnter( *this, rootAttribute ) ) 
+	if ( visitor->VisitEnter( *this, rootAttribute ) )
 	{
 		for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
 		{
@@ -1560,7 +1560,7 @@ int XMLDocument::LoadFile( const char* filename )
 }
 
 
-int XMLDocument::LoadFile( FILE* fp ) 
+int XMLDocument::LoadFile( FILE* fp )
 {
 	DeleteChildren();
 	InitDocument();
@@ -1579,7 +1579,7 @@ int XMLDocument::LoadFile( FILE* fp )
 		SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
 		return errorID;
 	}
-	
+
 	charBuffer[size] = 0;
 
 	const char* p = charBuffer;
@@ -1642,13 +1642,13 @@ int XMLDocument::Parse( const char* p )
 	charBuffer = new char[ len+1 ];
 	memcpy( charBuffer, p, len+1 );
 
-	
+
 	ParseDeep( charBuffer, 0 );
 	return errorID;
 }
 
 
-void XMLDocument::Print( XMLPrinter* streamer ) 
+void XMLDocument::Print( XMLPrinter* streamer )
 {
 	XMLPrinter stdStreamer( stdout );
 	if ( !streamer )
@@ -1665,13 +1665,13 @@ void XMLDocument::SetError( int error, const char* str1, const char* str2 )
 }
 
 
-void XMLDocument::PrintError() const 
+void XMLDocument::PrintError() const
 {
 	if ( errorID ) {
 		static const int LEN = 20;
 		char buf1[LEN] = { 0 };
 		char buf2[LEN] = { 0 };
-		
+
 		if ( errorStr1 ) {
 			TIXML_SNPRINTF( buf1, LEN, "%s", errorStr1 );
 		}
@@ -1685,11 +1685,11 @@ void XMLDocument::PrintError() const
 }
 
 
-XMLPrinter::XMLPrinter( FILE* file, bool compact ) : 
-	elementJustOpened( false ), 
+XMLPrinter::XMLPrinter( FILE* file, bool compact ) :
+	elementJustOpened( false ),
 	firstElement( true ),
-	fp( file ), 
-	depth( 0 ), 
+	fp( file ),
+	depth( 0 ),
 	textDepth( -1 ),
 	processEntities( true ),
 	compactMode( compact )
@@ -1738,7 +1738,7 @@ void XMLPrinter::Print( const char* format, ... )
 			int len = vsnprintf( 0, 0, format, va );
 			// Close out and re-start the va-args
 			va_end( va );
-			va_start( va, format );		
+			va_start( va, format );
 			char* p = buffer.PushArr( len ) - 1;
 			vsnprintf( p, len+1, format, va );
 		#endif
@@ -1766,7 +1766,7 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
 			// Remember, char is sometimes signed. (How many times has that bitten me?)
 			if ( *q > 0 && *q < ENTITY_RANGE ) {
 				// Check for entities. If one is found, flush
-				// the stream up until the entity, write the 
+				// the stream up until the entity, write the
 				// entity, and keep looking.
 				if ( flag[(unsigned)(*q)] ) {
 					while ( p < q ) {
@@ -1913,7 +1913,7 @@ void XMLPrinter::PushText( const char* text, bool cdata )
 	}
 }
 
-void XMLPrinter::PushText( int value ) 
+void XMLPrinter::PushText( int value )
 {
 	char buf[BUF_SIZE];
 	XMLUtil::ToStr( value, buf, BUF_SIZE );
@@ -1921,7 +1921,7 @@ void XMLPrinter::PushText( int value )
 }
 
 
-void XMLPrinter::PushText( unsigned value ) 
+void XMLPrinter::PushText( unsigned value )
 {
 	char buf[BUF_SIZE];
 	XMLUtil::ToStr( value, buf, BUF_SIZE );
@@ -1929,7 +1929,7 @@ void XMLPrinter::PushText( unsigned value )
 }
 
 
-void XMLPrinter::PushText( bool value ) 
+void XMLPrinter::PushText( bool value )
 {
 	char buf[BUF_SIZE];
 	XMLUtil::ToStr( value, buf, BUF_SIZE );
@@ -1937,7 +1937,7 @@ void XMLPrinter::PushText( bool value )
 }
 
 
-void XMLPrinter::PushText( float value ) 
+void XMLPrinter::PushText( float value )
 {
 	char buf[BUF_SIZE];
 	XMLUtil::ToStr( value, buf, BUF_SIZE );
@@ -1945,7 +1945,7 @@ void XMLPrinter::PushText( float value )
 }
 
 
-void XMLPrinter::PushText( double value ) 
+void XMLPrinter::PushText( double value )
 {
 	char buf[BUF_SIZE];
 	XMLUtil::ToStr( value, buf, BUF_SIZE );

+ 51 - 51
tinyxml2.h

@@ -40,7 +40,7 @@ distribution.
 	#include <cstdarg>
 #endif
 
-/* 
+/*
    TODO: intern strings instead of allocation.
 */
 /*
@@ -74,9 +74,9 @@ distribution.
 	/*int _snprintf_s(
 	   char *buffer,
 	   size_t sizeOfBuffer,
-	   size_t count,	
+	   size_t count,
 	   const char *format [,
-		  argument] ... 
+		  argument] ...
 	);*/
 	inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) {
 	    va_list va;
@@ -145,7 +145,7 @@ public:
 	void SetInternedStr( const char* str ) { Reset(); this->start = const_cast<char*>(str); }
 	void SetStr( const char* str, int flags=0 );
 
-	char* ParseText( char* in, const char* endTag, int strFlags );	
+	char* ParseText( char* in, const char* endTag, int strFlags );
 	char* ParseName( char* in );
 
 
@@ -160,7 +160,7 @@ private:
 
 	// After parsing, if *end != 0, it can be set to zero.
 	int flags;
-	char* start;	
+	char* start;
 	char* end;
 };
 
@@ -174,7 +174,7 @@ template <class T, int INIT>
 class DynArray
 {
 public:
-	DynArray< T, INIT >() 
+	DynArray< T, INIT >()
 	{
 		mem = pool;
 		allocated = INIT;
@@ -202,7 +202,7 @@ public:
 	T Pop() {
 		return mem[--size];
 	}
-	void PopArr( int count ) 
+	void PopArr( int count )
 	{
 		TIXMLASSERT( size >= count );
 		size -= count;
@@ -248,7 +248,7 @@ public:
 
 	virtual int ItemSize() const = 0;
 	virtual void* Alloc() = 0;
-	virtual void Free( void* ) = 0; 
+	virtual void Free( void* ) = 0;
 };
 
 
@@ -334,7 +334,7 @@ private:
 	If you return 'true' from a Visit method, recursive parsing will continue. If you return
 	false, <b>no children of this node or its sibilings</b> will be visited.
 
-	All flavors of Visit methods have a default implementation that returns 'true' (continue 
+	All flavors of Visit methods have a default implementation that returns 'true' (continue
 	visiting). You need to only override methods that are interesting to you.
 
 	Generally Accept() is called on the TiXmlDocument, although all nodes support visiting.
@@ -375,7 +375,7 @@ public:
 class XMLUtil
 {
 public:
-	// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't 
+	// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
 	// correct, but simple, and usually works.
 	static const char* SkipWhiteSpace( const char* p )	{ while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) { ++p; } return p; }
 	static char* SkipWhiteSpace( char* p )				{ while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) )		{ ++p; } return p; }
@@ -424,7 +424,7 @@ public:
 	XML Document Object Model (DOM), except XMLAttributes.
 	Nodes have siblings, a parent, and children which can
 	be navigated. A node is always in a XMLDocument.
-	The type of a XMLNode can be queried, and it can 
+	The type of a XMLNode can be queried, and it can
 	be cast to its more defined type.
 
 	A XMLDocument allocates memory for all its Nodes.
@@ -510,7 +510,7 @@ public:
 	*/
 	const XMLElement* LastChildElement( const char* value=0 ) const;
 	XMLElement* LastChildElement( const char* _value=0 )	{ return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(_value) ); }
-	
+
 	/// Get the previous (left) sibling node of this node.
 	const XMLNode*	PreviousSibling() const					{ return prev; }
 	XMLNode*	PreviousSibling()							{ return prev; }
@@ -518,11 +518,11 @@ public:
 	/// Get the previous (left) sibling element of this node, with an opitionally supplied name.
 	const XMLElement*	PreviousSiblingElement( const char* value=0 ) const ;
 	XMLElement*	PreviousSiblingElement( const char* _value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( _value ) ); }
-	
+
 	/// Get the next (right) sibling node of this node.
 	const XMLNode*	NextSibling() const						{ return next; }
 	XMLNode*	NextSibling()								{ return next; }
-		
+
 	/// Get the next (right) sibling element of this node, with an opitionally supplied name.
 	const XMLElement*	NextSiblingElement( const char* value=0 ) const;
  	XMLElement*	NextSiblingElement( const char* _value=0 )	{ return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( _value ) ); }
@@ -541,7 +541,7 @@ public:
 		Add a node after the specified child node.
 	*/
 	XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
-	
+
 	/**
 		Delete all the children of this node.
 	*/
@@ -555,7 +555,7 @@ public:
 	/**
 		Make a copy of this node, but not its children.
 		You may pass in a Document pointer that will be
-		the owner of the new Node. If the 'document' is 
+		the owner of the new Node. If the 'document' is
 		null, then the node returned will be allocated
 		from the current Document. (this->GetDocument())
 
@@ -571,7 +571,7 @@ public:
 	*/
 	virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
 
-	/** Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the 
+	/** Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the
 		XML tree will be conditionally visited and the host will be called back
 		via the TiXmlVisitor interface.
 
@@ -582,7 +582,7 @@ public:
 		The interface has been based on ideas from:
 
 		- http://www.saxproject.org/
-		- http://c2.com/cgi/wiki?HierarchicalVisitorPattern 
+		- http://c2.com/cgi/wiki?HierarchicalVisitorPattern
 
 		Which are both good references for "visiting".
 
@@ -603,7 +603,7 @@ protected:
 	virtual ~XMLNode();
 	XMLNode( const XMLNode& );	// not supported
 	XMLNode& operator=( const XMLNode& );	// not supported
-	
+
 	XMLDocument*	document;
 	XMLNode*		parent;
 	mutable StrPair	value;
@@ -627,9 +627,9 @@ private:
 	<root>This is <b>bold</b></root>
 	@endverbatim
 
-	A text node can have 2 ways to output the next. "normal" output 
+	A text node can have 2 ways to output the next. "normal" output
 	and CDATA. It will default to the mode it was parsed from the XML file and
-	you generally want to leave it alone, but you can change the output mode with 
+	you generally want to leave it alone, but you can change the output mode with
 	SetCDATA() and query it with CDATA().
 */
 class XMLText : public XMLNode
@@ -867,15 +867,15 @@ public:
 	virtual bool Accept( XMLVisitor* visitor ) const;
 
 	/** Given an attribute name, Attribute() returns the value
-		for the attribute of that name, or null if none 
+		for the attribute of that name, or null if none
 		exists. For example:
 
 		@verbatim
 		const char* value = ele->Attribute( "foo" );
 		@endverbatim
 
-		The 'value' parameter is normally null. However, if specified, 
-		the attribute will only be returned if the 'name' and 'value' 
+		The 'value' parameter is normally null. However, if specified,
+		the attribute will only be returned if the 'name' and 'value'
 		match. This allow you to write code:
 
 		@verbatim
@@ -893,7 +893,7 @@ public:
 
 	/** Given an attribute name, IntAttribute() returns the value
 		of the attribute interpreted as an integer. 0 will be
-		returned if there is an error. For a method with error 
+		returned if there is an error. For a method with error
 		checking, see QueryIntAttribute()
 	*/
 	int		 IntAttribute( const char* name ) const		{ int i=0;		QueryIntAttribute( name, &i );		return i; }
@@ -906,7 +906,7 @@ public:
 	/// See IntAttribute()
 	float	 FloatAttribute( const char* name ) const	{ float f=0;	QueryFloatAttribute( name, &f );	return f; }
 
-	/** Given an attribute name, QueryIntAttribute() returns 
+	/** Given an attribute name, QueryIntAttribute() returns
 		XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
 		can't be performed, or XML_NO_ATTRIBUTE if the attribute
 		doesn't exist. If successful, the result of the conversion
@@ -919,7 +919,7 @@ public:
 		QueryIntAttribute( "foo", &value );		// if "foo" isn't found, value will still be 10
 		@endverbatim
 	*/
-	int QueryIntAttribute( const char* name, int* _value ) const				{ const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryIntValue( _value ); } 
+	int QueryIntAttribute( const char* name, int* _value ) const				{ const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryIntValue( _value ); }
 	/// See QueryIntAttribute()
 	int QueryUnsignedAttribute( const char* name, unsigned int* _value ) const	{ const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryUnsignedValue( _value ); }
 	/// See QueryIntAttribute()
@@ -953,7 +953,7 @@ public:
 	/** Convenience function for easy access to the text inside an element. Although easy
 		and concise, GetText() is limited compared to getting the TiXmlText child
 		and accessing it directly.
-	
+
 		If the first child of 'this' is a TiXmlText, the GetText()
 		returns the character string of the Text node, else null is returned.
 
@@ -963,24 +963,24 @@ public:
 			const char* str = fooElement->GetText();
 		@endverbatim
 
-		'str' will be a pointer to "This is text". 
-		
+		'str' will be a pointer to "This is text".
+
 		Note that this function can be misleading. If the element foo was created from
 		this XML:
 		@verbatim
-			<foo><b>This is text</b></foo> 
+			<foo><b>This is text</b></foo>
 		@endverbatim
 
 		then the value of str would be null. The first child node isn't a text node, it is
 		another element. From this XML:
 		@verbatim
-			<foo>This is <b>text</b></foo> 
+			<foo>This is <b>text</b></foo>
 		@endverbatim
 		GetText() will return "This is ".
 	*/
 	const char* GetText() const;
 
-	/** 
+	/**
 		Convenience method to query the value of a child text node. This is probably best
 		shown by example. Given you have a document is this form:
 		@verbatim
@@ -1004,7 +1004,7 @@ public:
 
 		@returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted
 				 to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.
-			
+
 	*/
 	int QueryIntText( int* _value ) const;
 	/// See QueryIntText()
@@ -1049,10 +1049,10 @@ private:
 enum Whitespace {
 	PRESERVE_WHITESPACE,
 	COLLAPSE_WHITESPACE
-};	   
+};
+
 
-	
-/** A Document binds together all the functionality. 
+/** A Document binds together all the functionality.
 	It can be saved, loaded, and printed to the screen.
 	All Nodes are connected and allocated to a Document.
 	If the Document is deleted, all its Nodes are also deleted.
@@ -1062,7 +1062,7 @@ class XMLDocument : public XMLNode
 	friend class XMLElement;
 public:
 	/// constructor
-	XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); 
+	XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
 	~XMLDocument();
 
 	virtual XMLDocument* ToDocument()				{ return this; }
@@ -1074,23 +1074,23 @@ public:
 		an errorID.
 	*/
 	int Parse( const char* xml );
-	
+
 	/**
 		Load an XML file from disk.
 		Returns XML_NO_ERROR (0) on success, or
 		an errorID.
-	*/	
+	*/
 	int LoadFile( const char* filename );
-	
+
 	/**
 		Load an XML file from disk. You are responsible
 		for providing and closing the FILE*.
 
 		Returns XML_NO_ERROR (0) on success, or
 		an errorID.
-	*/	
+	*/
 	int LoadFile( FILE* );
-	
+
 	/**
 		Save the XML file to disk.
 		Returns XML_NO_ERROR (0) on success, or
@@ -1185,7 +1185,7 @@ public:
 	void DeleteNode( XMLNode* node )	{ node->parent->DeleteChild( node ); }
 
 	void SetError( int error, const char* str1, const char* str2 );
-	
+
 	/// Return true if there was an error parsing the document.
 	bool Error() const { return errorID != XML_NO_ERROR; }
 	/// Return the errorID.
@@ -1238,7 +1238,7 @@ private:
 	</Document>
 	@endverbatim
 
-	Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very 
+	Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
 	easy to write a *lot* of code that looks like:
 
 	@verbatim
@@ -1258,7 +1258,7 @@ private:
 	@endverbatim
 
 	And that doesn't even cover "else" cases. XMLHandle addresses the verbosity
-	of such code. A XMLHandle checks for null pointers so it is perfectly safe 
+	of such code. A XMLHandle checks for null pointers so it is perfectly safe
 	and correct to use:
 
 	@verbatim
@@ -1303,12 +1303,12 @@ public:
 	/// Get the previous sibling element of this handle.
 	XMLHandle PreviousSiblingElement( const char* _value=0 )				{ return XMLHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); }
 	/// Get the next sibling of this handle.
-	XMLHandle NextSibling()													{ return XMLHandle( node ? node->NextSibling() : 0 ); }		
+	XMLHandle NextSibling()													{ return XMLHandle( node ? node->NextSibling() : 0 ); }
 	/// Get the next sibling element of this handle.
 	XMLHandle NextSiblingElement( const char* _value=0 )					{ return XMLHandle( node ? node->NextSiblingElement( _value ) : 0 ); }
 
 	/// Safe cast to XMLNode. This can return null.
-	XMLNode* ToNode()							{ return node; } 
+	XMLNode* ToNode()							{ return node; }
 	/// Safe cast to XMLElement. This can return null.
 	XMLElement* ToElement() 					{ return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
 	/// Safe cast to XMLText. This can return null.
@@ -1346,7 +1346,7 @@ public:
 	const XMLConstHandle NextSiblingElement( const char* _value=0 ) const			{ return XMLConstHandle( node ? node->NextSiblingElement( _value ) : 0 ); }
 
 
-	const XMLNode* ToNode() const				{ return node; } 
+	const XMLNode* ToNode() const				{ return node; }
 	const XMLElement* ToElement() const			{ return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
 	const XMLText* ToText() const				{ return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
 	const XMLUnknown* ToUnknown() const			{ return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
@@ -1375,7 +1375,7 @@ private:
 	@endverbatim
 
 	Print to a File
-	
+
 	You provide the file pointer.
 	@verbatim
 	XMLPrinter printer( fp );
@@ -1462,7 +1462,7 @@ public:
 	*/
 	const char* CStr() const { return buffer.Mem(); }
 	/**
-   		If in print to memory mode, return the size 
+   		If in print to memory mode, return the size
 		of the XML file in memory. (Note the size returned
 		includes the terminating null.)
   	*/

+ 26 - 26
xmltest.cpp

@@ -97,7 +97,7 @@ int example_2()
 
 int example_3()
 {
-	static const char* xml = 
+	static const char* xml =
 		"<?xml version=\"1.0\"?>"
 		"<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
 		"<PLAY>"
@@ -110,7 +110,7 @@ int example_3()
 	XMLElement* titleElement = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" );
 	const char* title = titleElement->GetText();
 	printf( "Name of play (1): %s\n", title );
-		
+
 	XMLText* textNode = titleElement->FirstChild()->ToText();
 	title = textNode->Value();
 	printf( "Name of play (2): %s\n", title );
@@ -128,7 +128,7 @@ bool example_4()
 		"		<v>2</v>"
 		"	</textApproach>"
 		"</information>";
-	
+
 	XMLDocument doc;
 	doc.Parse( xml );
 
@@ -151,7 +151,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 {
 	#if defined( _MSC_VER ) && defined( DEBUG )
 		_CrtMemCheckpoint( &startMemState );
-	#endif	
+	#endif
 
 	#if defined(_MSC_VER)
 	#pragma warning ( push )
@@ -187,7 +187,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 	XMLTest( "Example-3", 0, example_3() );
 	XMLTest( "Example-4", true, example_4() );
 
-	/* ------ Example 2: Lookup information. ---- */	
+	/* ------ Example 2: Lookup information. ---- */
 
 	{
 		static const char* test[] = {	"<element />",
@@ -268,7 +268,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		XMLTest( "Programmatic DOM", "comment", doc->FirstChildElement( "element" )->FirstChild()->Value() );
 		XMLTest( "Programmatic DOM", "0", doc->FirstChildElement( "element" )->FirstChildElement()->Attribute( "attrib" ) );
 		XMLTest( "Programmatic DOM", 2, doc->FirstChildElement()->LastChildElement( "sub" )->IntAttribute( "attrib" ) );
-		XMLTest( "Programmatic DOM", "& Text!", 
+		XMLTest( "Programmatic DOM", "& Text!",
 				 doc->FirstChildElement()->LastChildElement( "sub" )->FirstChild()->ToText()->Value() );
 
 		// And now deletion:
@@ -402,7 +402,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 
 		// Get the attribute "value" from the "Russian" element and check it.
 		XMLElement* element = doc.FirstChildElement( "document" )->FirstChildElement( "Russian" );
-		const unsigned char correctValue[] = {	0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU, 
+		const unsigned char correctValue[] = {	0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
 												0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
 
 		XMLTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ) );
@@ -491,7 +491,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		doc.Parse( str );
 		doc.Print();
 
-		XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(), 
+		XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
 								 "I am > the rules!\n...since I make symbolic puns",
 								 false );
 	}
@@ -508,7 +508,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		doc.Parse( str );
 		doc.Print();
 
-		XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(), 
+		XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
 								 "<b>I am > the rules!</b>\n...since I make symbolic puns",
 								 false );
 	}
@@ -590,11 +590,11 @@ int main( int /*argc*/, const char ** /*argv*/ )
 			"<passages count=\"006\" formatversion=\"20020620\">"
 				"<psg context=\"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;.\">Crazy &ttk;</psg>"
 			"</passages>";
-		
+
 		XMLDocument doc( false );
 		doc.Parse( passages );
 
-		XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ), 
+		XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ),
 				 "Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;." );
 		XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(),
 				 "Crazy &ttk;" );
@@ -625,7 +625,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 
 	{
 		// DOCTYPE not preserved (950171)
-		// 
+		//
 		const char* doctype =
 			"<?xml version=\"1.0\" ?>"
 			"<!DOCTYPE PLAY SYSTEM 'play.dtd'>"
@@ -639,7 +639,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		doc.DeleteChild( doc.RootElement() );
 		doc.LoadFile( "resources/out/test7.xml" );
 		doc.Print();
-		
+
 		const XMLUnknown* decl = doc.FirstChild()->NextSibling()->ToUnknown();
 		XMLTest( "Correct value of unknown.", "DOCTYPE PLAY SYSTEM 'play.dtd'", decl->Value() );
 
@@ -647,7 +647,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 
 	{
 		// Comments do not stream out correctly.
-		const char* doctype = 
+		const char* doctype =
 			"<!-- Somewhat<evil> -->";
 		XMLDocument doc;
 		doc.Parse( doctype );
@@ -662,7 +662,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 
 		XMLDocument doc;
 		doc.Parse( doctype );
-		
+
 		XMLTest( "Parsing repeated attributes.", (int)XML_ERROR_PARSING_ATTRIBUTE, doc.ErrorID() );	// is an  error to tinyxml (didn't use to be, but caused issues)
 		doc.PrintError();
 	}
@@ -709,7 +709,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		XMLTest("Missing end tag with trailing whitespace", xml.Error(), true);
 		xml.Parse("<x></y>");
 		XMLTest("Mismatched tags", xml.ErrorID(), (int)XML_ERROR_MISMATCHED_ELEMENT);
-	} 
+	}
 
 
 	{
@@ -756,7 +756,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 
 		XMLDocument doc;
 		doc.Parse( (const char*)buf);
-	} 
+	}
 
 
 	{
@@ -806,14 +806,14 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		}
 		XMLTest( "Error in snprinf handling.", true, doc.Error() );
 	}
-	
+
 	{
 		// Attribute ordering.
 		static const char* xml = "<element attrib1=\"1\" attrib2=\"2\" attrib3=\"3\" />";
 		XMLDocument doc;
 		doc.Parse( xml );
 		XMLElement* ele = doc.FirstChildElement();
-		
+
 		const XMLAttribute* a = ele->FirstAttribute();
 		XMLTest( "Attribute order", "1", a->Value() );
 		a = a->Next();
@@ -821,13 +821,13 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		a = a->Next();
 		XMLTest( "Attribute order", "3", a->Value() );
 		XMLTest( "Attribute order", "attrib3", a->Name() );
-		
+
 		ele->DeleteAttribute( "attrib2" );
 		a = ele->FirstAttribute();
 		XMLTest( "Attribute order", "1", a->Value() );
 		a = a->Next();
 		XMLTest( "Attribute order", "3", a->Value() );
-		
+
 		ele->DeleteAttribute( "attrib1" );
 		ele->DeleteAttribute( "attrib3" );
 		XMLTest( "Attribute order (empty)", false, ele->FirstAttribute() ? true : false );
@@ -879,7 +879,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement();
 		XMLTest( "Handle, dne, mutable", false, ele != 0 );
 	}
-	
+
 	{
 		static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
 		XMLDocument doc;
@@ -897,7 +897,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		XMLDocument doc;
 		doc.InsertEndChild( doc.NewDeclaration() );
 		doc.SetBOM( true );
-		
+
 		XMLPrinter printer;
 		doc.Print( &printer );
 
@@ -972,7 +972,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 		doc.Parse( xml );
 		XMLTest( "Whitespace  all space", true, 0 == doc.FirstChildElement()->FirstChild() );
 	}
-	
+
 	// ----------- Performance tracking --------------
 	{
 #if defined( _MSC_VER )
@@ -1015,7 +1015,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 
 		delete [] mem;
 
-		static const char* note = 
+		static const char* note =
 #ifdef DEBUG
 			"DEBUG";
 #else
@@ -1030,7 +1030,7 @@ int main( int /*argc*/, const char ** /*argv*/ )
 	}
 
 	#if defined( _MSC_VER ) &&  defined( DEBUG )
-		_CrtMemCheckpoint( &endMemState );  
+		_CrtMemCheckpoint( &endMemState );
 		//_CrtMemDumpStatistics( &endMemState );
 
 		_CrtMemState diffMemState;