diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 83bafb3..63b8707 100644 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -58,7 +58,7 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) lastChild = addThis; addThis->parent = this; - addThis->next = null; + addThis->next = 0; } else { TIXMLASSERT( firstChild == 0 ); @@ -66,7 +66,16 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) addThis->parent = this; addThis->prev = 0; - addThis->next = null; + addThis->next = 0; + } + return addThis; +} + + +void XMLNode::Print( FILE* fp, int depth ) +{ + for( int i=0; i\n", value ); +} + + +char* XMLComment::ParseDeep( char* p ) { // Comment parses as text. value = ParseText( p, "-->", &p ); @@ -135,21 +151,22 @@ XMLDocument::~XMLDocument() bool XMLDocument::Parse( const char* p ) { - charBuffer = CharBuffer.Construct( p ); + charBuffer = CharBuffer::Construct( p ); XMLNode* node = 0; - Identify( charBuffer., node ); - node->Parse( p ); + char* q = Identify( charBuffer->mem, &node ); + node->ParseDeep( q ); + return true; } -XMLComment* XMLDocument::newComment( XMLNode* parent ) +void XMLDocument::Print( FILE* fp, int depth ) { - + for( XMLNode* node = root->firstChild; node; node=node->next ) { + node->Print( fp, depth ); + } } - - char* XMLDocument::Identify( char* p, XMLNode** node ) { XMLNode* returnNode = 0; @@ -173,7 +190,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node ) const char* cdataHeader = { " +#include +#include #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) #ifndef DEBUG @@ -27,7 +29,7 @@ namespace tinyxml2 { -class XMLDocument*; +class XMLDocument; // internal - move to separate namespace struct CharBuffer @@ -45,7 +47,8 @@ class XMLNode friend class XMLDocument; public: - static XMLNode* Identify( const char* p ); + XMLNode* InsertEndChild( XMLNode* addThis ); + void Print( FILE* cfile, int depth ); // prints leading spaces. protected: XMLNode( XMLDocument* ); @@ -97,8 +100,13 @@ public: XMLComment( XMLDocument* doc ); virtual ~XMLComment(); + void Print( FILE* cfile, int depth ); + +protected: + char* ParseDeep( char* ); + private: - char* value; + const char* value; }; @@ -109,26 +117,20 @@ public: ~XMLDocument(); bool Parse( const char* ); + void Print( FILE* cfile=stdout, int depth=0 ); XMLNode* Root() { return root; } XMLNode* RootElement(); - XMLNode* InsertEndChild( XMLNode* addThis ); - private: XMLDocument( const XMLDocument& ); // intentionally not implemented - - virtual char* ParseDeep( char* ); + char* Identify( char* p, XMLNode** node ); XMLNode* root; CharBuffer* charBuffer; }; - - - - }; // tinyxml2 diff --git a/tinyxml2.suo b/tinyxml2.suo index fb3b44e..e447d8f 100644 Binary files a/tinyxml2.suo and b/tinyxml2.suo differ