Merge pull request #312 from Dmitry-Me/newDocumentMustBeEmpty

Document must be initially empty
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 567b9f0..e8dd32b 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -796,8 +796,8 @@
 

 const XMLElement* XMLNode::FirstChildElement( const char* value ) const

 {

-    for( XMLNode* node=_firstChild; node; node=node->_next ) {

-        XMLElement* element = node->ToElement();

+    for( const XMLNode* node = _firstChild; node; node = node->_next ) {

+        const XMLElement* element = node->ToElement();

         if ( element ) {

             if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {

                 return element;

@@ -810,8 +810,8 @@
 

 const XMLElement* XMLNode::LastChildElement( const char* value ) const

 {

-    for( XMLNode* node=_lastChild; node; node=node->_prev ) {

-        XMLElement* element = node->ToElement();

+    for( const XMLNode* node = _lastChild; node; node = node->_prev ) {

+        const XMLElement* element = node->ToElement();

         if ( element ) {

             if ( !value || XMLUtil::StringEqual( element->Name(), value ) ) {

                 return element;

@@ -824,7 +824,7 @@
 

 const XMLElement* XMLNode::NextSiblingElement( const char* value ) const

 {

-    for( XMLNode* node=this->_next; node; node = node->_next ) {

+    for( const XMLNode* node = _next; node; node = node->_next ) {

         const XMLElement* element = node->ToElement();

         if ( element

                 && (!value || XMLUtil::StringEqual( value, node->Value() ))) {

@@ -837,7 +837,7 @@
 

 const XMLElement* XMLNode::PreviousSiblingElement( const char* value ) const

 {

-    for( XMLNode* node=_prev; node; node = node->_prev ) {

+    for( const XMLNode* node = _prev; node; node = node->_prev ) {

         const XMLElement* element = node->ToElement();

         if ( element

                 && (!value || XMLUtil::StringEqual( value, node->Value() ))) {

diff --git a/tinyxml2.h b/tinyxml2.h
index d3d0b0a..d0620cc 100755
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -211,13 +211,13 @@
 	Has a small initial memory pool, so that low or no usage will not

 	cause a call to new/delete

 */

-template <class T, int INIT>

+template <class T, int INITIAL_SIZE>

 class DynArray

 {

 public:

     DynArray() {

         _mem = _pool;

-        _allocated = INIT;

+        _allocated = INITIAL_SIZE;

         _size = 0;

     }

 

@@ -312,7 +312,7 @@
     }

 

     T*  _mem;

-    T   _pool[INIT];

+    T   _pool[INITIAL_SIZE];

     int _allocated;		// objects allocated

     int _size;			// number objects in use

 };

@@ -887,13 +887,12 @@
     */

     virtual bool Accept( XMLVisitor* visitor ) const = 0;

 

-    // internal

-    virtual char* ParseDeep( char*, StrPair* );

-

 protected:

     XMLNode( XMLDocument* );

     virtual ~XMLNode();

 

+    virtual char* ParseDeep( char*, StrPair* );

+

     XMLDocument*	_document;

     XMLNode*		_parent;

     mutable StrPair	_value;

@@ -950,7 +949,6 @@
         return _isCData;

     }

 

-    char* ParseDeep( char*, StrPair* endTag );

     virtual XMLNode* ShallowClone( XMLDocument* document ) const;

     virtual bool ShallowEqual( const XMLNode* compare ) const;

 

@@ -958,6 +956,8 @@
     XMLText( XMLDocument* doc )	: XMLNode( doc ), _isCData( false )	{}

     virtual ~XMLText()												{}

 

+    char* ParseDeep( char*, StrPair* endTag );

+

 private:

     bool _isCData;

 

@@ -980,7 +980,6 @@
 

     virtual bool Accept( XMLVisitor* visitor ) const;

 

-    char* ParseDeep( char*, StrPair* endTag );

     virtual XMLNode* ShallowClone( XMLDocument* document ) const;

     virtual bool ShallowEqual( const XMLNode* compare ) const;

 

@@ -988,6 +987,8 @@
     XMLComment( XMLDocument* doc );

     virtual ~XMLComment();

 

+    char* ParseDeep( char*, StrPair* endTag );

+

 private:

     XMLComment( const XMLComment& );	// not supported

     XMLComment& operator=( const XMLComment& );	// not supported

@@ -1018,7 +1019,6 @@
 

     virtual bool Accept( XMLVisitor* visitor ) const;

 

-    char* ParseDeep( char*, StrPair* endTag );

     virtual XMLNode* ShallowClone( XMLDocument* document ) const;

     virtual bool ShallowEqual( const XMLNode* compare ) const;

 

@@ -1026,6 +1026,8 @@
     XMLDeclaration( XMLDocument* doc );

     virtual ~XMLDeclaration();

 

+    char* ParseDeep( char*, StrPair* endTag );

+

 private:

     XMLDeclaration( const XMLDeclaration& );	// not supported

     XMLDeclaration& operator=( const XMLDeclaration& );	// not supported

@@ -1052,7 +1054,6 @@
 

     virtual bool Accept( XMLVisitor* visitor ) const;

 

-    char* ParseDeep( char*, StrPair* endTag );

     virtual XMLNode* ShallowClone( XMLDocument* document ) const;

     virtual bool ShallowEqual( const XMLNode* compare ) const;

 

@@ -1060,6 +1061,8 @@
     XMLUnknown( XMLDocument* doc );

     virtual ~XMLUnknown();

 

+    char* ParseDeep( char*, StrPair* endTag );

+

 private:

     XMLUnknown( const XMLUnknown& );	// not supported

     XMLUnknown& operator=( const XMLUnknown& );	// not supported

@@ -1509,10 +1512,12 @@
     int ClosingType() const {

         return _closingType;

     }

-    char* ParseDeep( char* p, StrPair* endTag );

     virtual XMLNode* ShallowClone( XMLDocument* document ) const;

     virtual bool ShallowEqual( const XMLNode* compare ) const;

 

+protected:

+    char* ParseDeep( char* p, StrPair* endTag );

+

 private:

     XMLElement( XMLDocument* doc );

     virtual ~XMLElement();