daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // elementvisitor.cpp
  2.  
  3. // Andrew Rossow
  4. // cse335
  5. // Project 1
  6.  
  7. using namespace std;
  8.  
  9. #include <iostream>
  10. #include <string>
  11. #include <list>
  12. #include "elementvisitor.h"
  13.  
  14. ElementVisitor::~ElementVisitor()
  15. {
  16. }
  17.  
  18. void ElementVisitor::visitElement( Element* thisele )
  19. {
  20.     bool emptynodes = false;
  21.     list<Attr*> attrcopy;
  22.     attrcopy = thisele->Copyattrs();
  23.     list<Element*> nodecopy;
  24.     nodecopy = thisele->Copynodes();
  25.     cout << "<" << thisele->getName();
  26.  
  27.     for (list<Attr*>::iterator i = attrcopy.begin(); i != attrcopy.end(); i++)
  28.     {
  29.         (*i)->Accept(*this);
  30.     }
  31.  
  32.     if( nodecopy.empty() )
  33.     {
  34.         emptynodes = true;
  35.     }
  36.     if( emptynodes )
  37.     {
  38.         cout << "/>" << endl;
  39.     }
  40.     else
  41.     {
  42.         cout << ">" << endl;
  43.    
  44.         for ( list<Element*>::iterator n = nodecopy.begin(); n != nodecopy.end(); n++)
  45.         {
  46.             (*n)->Accept(*this);
  47.         }
  48.  
  49.         cout << "</" << thisele->getName() << ">" << endl;
  50.  
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top