Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // elementvisitor.cpp
- // Andrew Rossow
- // cse335
- // Project 1
- using namespace std;
- #include <iostream>
- #include <string>
- #include <list>
- #include "elementvisitor.h"
- ElementVisitor::~ElementVisitor()
- {
- }
- void ElementVisitor::visitElement( Element* thisele )
- {
- bool emptynodes = false;
- list<Attr*> attrcopy;
- attrcopy = thisele->Copyattrs();
- list<Element*> nodecopy;
- nodecopy = thisele->Copynodes();
- cout << "<" << thisele->getName();
- for (list<Attr*>::iterator i = attrcopy.begin(); i != attrcopy.end(); i++)
- {
- (*i)->Accept(*this);
- }
- if( nodecopy.empty() )
- {
- emptynodes = true;
- }
- if( emptynodes )
- {
- cout << "/>" << endl;
- }
- else
- {
- cout << ">" << endl;
- for ( list<Element*>::iterator n = nodecopy.begin(); n != nodecopy.end(); n++)
- {
- (*n)->Accept(*this);
- }
- cout << "</" << thisele->getName() << ">" << endl;
- }
- }
Add Comment
Please, Sign In to add comment