adding a bunch of the api (which isn't yet hooked up.)
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 72f9db8..c860c07 100644
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -235,18 +235,18 @@
}
-bool XMLDocument::Accept( XMLVisitor* visitor ) const
-{
- if ( visitor->VisitEnter( *this ) )
- {
- for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
- {
- if ( !node->Accept( visitor ) )
- break;
- }
- }
- return visitor->VisitExit( *this );
-}
+bool XMLDocument::Accept( XMLVisitor* visitor ) const
+{
+ if ( visitor->VisitEnter( *this ) )
+ {
+ for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
+ {
+ if ( !node->Accept( visitor ) )
+ break;
+ }
+ }
+ return visitor->VisitExit( *this );
+}
// --------- XMLNode ----------- //
@@ -363,12 +363,13 @@
}
-void XMLNode::Print( XMLStreamer* streamer )
+/*void XMLNode::Print( XMLStreamer* streamer )
{
for( XMLNode* node = firstChild; node; node=node->next ) {
node->Print( streamer );
}
}
+*/
char* XMLNode::ParseDeep( char* p )
@@ -401,11 +402,13 @@
}
+/*
void XMLText::Print( XMLStreamer* streamer )
{
const char* v = value.GetStr();
streamer->PushText( v );
}
+*/
bool XMLText::Accept( XMLVisitor* visitor ) const
@@ -427,12 +430,14 @@
}
+/*
void XMLComment::Print( XMLStreamer* streamer )
{
// XMLNode::Print( fp, depth );
// fprintf( fp, "<!--%s-->\n", value.GetStr() );
streamer->PushComment( value.GetStr() );
}
+*/
char* XMLComment::ParseDeep( char* p )
@@ -442,10 +447,10 @@
}
-bool XMLComment::Accept( XMLVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
+bool XMLComment::Accept( XMLVisitor* visitor ) const
+{
+ return visitor->Visit( *this );
+}
// --------- XMLAttribute ---------- //
@@ -462,13 +467,14 @@
}
+/*
void XMLAttribute::Print( XMLStreamer* streamer )
{
// fixme: sort out single vs. double quote
//fprintf( cfile, "%s=\"%s\"", name.GetStr(), value.GetStr() );
streamer->PushAttribute( name.GetStr(), value.GetStr() );
}
-
+*/
// --------- XMLElement ---------- //
XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ),
@@ -580,6 +586,7 @@
}
+/*
void XMLElement::Print( XMLStreamer* streamer )
{
//if ( !parent || !parent->IsTextParent() ) {
@@ -599,21 +606,22 @@
}
streamer->CloseElement();
}
+*/
-bool XMLElement::Accept( XMLVisitor* visitor ) const
-{
- if ( visitor->VisitEnter( *this, rootAttribute ) )
- {
- for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
- {
- if ( !node->Accept( visitor ) )
- break;
- }
- }
- return visitor->VisitExit( *this );
-
-}
+bool XMLElement::Accept( XMLVisitor* visitor ) const
+{
+ if ( visitor->VisitEnter( *this, rootAttribute ) )
+ {
+ for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() )
+ {
+ if ( !node->Accept( visitor ) )
+ break;
+ }
+ }
+ return visitor->VisitExit( *this );
+
+}
// --------- XMLDocument ----------- //
@@ -687,9 +695,10 @@
XMLStreamer stdStreamer( stdout );
if ( !streamer )
streamer = &stdStreamer;
- for( XMLNode* node = firstChild; node; node=node->next ) {
- node->Print( streamer );
- }
+ //for( XMLNode* node = firstChild; node; node=node->next ) {
+ // node->Print( streamer );
+ //}
+ Accept( streamer );
}
@@ -872,3 +881,35 @@
PrintSpace( depth );
fprintf( fp, "<!--%s-->\n", comment );
}
+
+
+bool XMLStreamer::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
+{
+ OpenElement( element.Name() );
+ while ( attribute ) {
+ PushAttribute( attribute->Name(), attribute->Value() );
+ attribute = attribute->Next();
+ }
+ return true;
+}
+
+
+bool XMLStreamer::VisitExit( const XMLElement& element )
+{
+ CloseElement();
+ return true;
+}
+
+
+bool XMLStreamer::Visit( const XMLText& text )
+{
+ PushText( text.Value() );
+ return true;
+}
+
+
+bool XMLStreamer::Visit( const XMLComment& comment )
+{
+ PushComment( comment.Value() );
+ return true;
+}