diff --git a/alib2/src/regexp/RegExpToXMLPrinter.cpp b/alib2/src/regexp/RegExpToXMLPrinter.cpp index aaa76d058f770d97b9bb3b2439af165d5e3edab6..39e33625a05dede34a33fef7b2abb545fabec820 100644 --- a/alib2/src/regexp/RegExpToXMLPrinter.cpp +++ b/alib2/src/regexp/RegExpToXMLPrinter.cpp @@ -15,26 +15,20 @@ RegExpToXMLPrinter::RegExpToXMLPrinter(ostream& out) : m_Out(out) { } -void RegExpToXMLPrinter::Visit(const std::elementAux<RegExp::visitor_type>& regexp) { +void RegExpToXMLPrinter::Visit(const RegExp::element_type& regexp) { m_Out << "<regexp>" << endl; regexp.Accept(*this); m_Out << "</regexp>" << endl; } -void RegExpToXMLPrinter::Visit(const std::elementAux<RegExpElement::visitor_type>& element) { +void RegExpToXMLPrinter::Visit(const RegExpElement::element_type& element) { element.Accept(*this); } -void RegExpToXMLPrinter::Visit(const list<std::elementAux<RegExpElement::visitor_type>*>& content) { - for (auto element : content) { - element->Accept(*this); - } -} - void RegExpToXMLPrinter::Visit(const Alternation& alternation) { m_Out << "<alternation>" << endl; for (auto element : alternation.getElements()) { - std::elementAux<RegExpElement::visitor_type>& object = static_cast<std::elementAux<RegExpElement::visitor_type>&>(*element); + const RegExpElement::element_type& object = static_cast<const RegExpElement::element_type&>(*element); object.Accept(*this); } m_Out << "</alternation>" << endl; @@ -43,7 +37,7 @@ void RegExpToXMLPrinter::Visit(const Alternation& alternation) { void RegExpToXMLPrinter::Visit(const Concatenation& concatenation) { m_Out <<"<concatenation>" << endl; for (auto element : concatenation.getElements()) { - std::elementAux<RegExpElement::visitor_type>& object = static_cast<std::elementAux<RegExpElement::visitor_type>&>(*element); + const RegExpElement::element_type& object = static_cast<const RegExpElement::element_type&>(*element); object.Accept(*this); } m_Out <<"</concatenation>" << endl; @@ -52,7 +46,7 @@ void RegExpToXMLPrinter::Visit(const Concatenation& concatenation) { void RegExpToXMLPrinter::Visit(const Iteration& iteration) { m_Out << "<iteration>" << endl; - const std::elementAux<RegExpElement::visitor_type>& object = static_cast<const std::elementAux<RegExpElement::visitor_type>&>(*iteration.getElement()); + const RegExpElement::element_type& object = static_cast<const RegExpElement::element_type&>(*iteration.getElement()); object.Accept(*this); m_Out << "</iteration>" << endl; } diff --git a/alib2/src/regexp/RegExpToXMLPrinter.h b/alib2/src/regexp/RegExpToXMLPrinter.h index c2e634c3b49ff21f6bdc56335a1bb81de10b504f..880f455fc85fab93fb49d447c9f40f6e461d299c 100644 --- a/alib2/src/regexp/RegExpToXMLPrinter.h +++ b/alib2/src/regexp/RegExpToXMLPrinter.h @@ -23,8 +23,6 @@ using namespace std; class RegExpToXMLPrinter : public RegExp::visitor_type, public RegExpElement::visitor_type { static const string c_Indentation; - void Visit(const list<std::elementAux<RegExpElement::visitor_type>*>& content); - ostream& m_Out; public: @@ -44,8 +42,9 @@ public: * @param regexp RegExp to print * @param out output stream to which print the RegExp */ - void Visit(const std::elementAux<RegExp::visitor_type>& regexp); - void Visit(const std::elementAux<RegExpElement::visitor_type>& element); + void Visit(const RegExp::element_type& regexp); + + void Visit(const RegExpElement::element_type& element); }; } /* namespace regexp */ diff --git a/alib2/src/std/visitor.hpp b/alib2/src/std/visitor.hpp index f2764c984334b3c8082537827ed3340358db5270..103b04335ab36e20f9f330ef9c5f0e31824e20fe 100644 --- a/alib2/src/std/visitor.hpp +++ b/alib2/src/std/visitor.hpp @@ -37,7 +37,8 @@ template<typename VisitorType> class elementAux { public: typedef VisitorType visitor_type; - + typedef elementAux element_type; + virtual void Accept(VisitorType& visitor) const = 0; };