Loading src/html.cpp +50 −27 Original line number Diff line number Diff line Loading @@ -345,7 +345,7 @@ NEXTDOCEL: goto NEXTDOCEL; } } #include <iostream> libhtmlpp::Element *libhtmlpp::HtmlString::_buildTree() { DocElements *firstEl = nullptr, *lastEl = nullptr; Loading Loading @@ -411,9 +411,9 @@ libhtmlpp::Element *libhtmlpp::HtmlString::_buildTree() { if(open!=std::string::npos && close !=std::string::npos && starttag!=std::string::npos){ addelement(&firstEl,&lastEl,new HtmlElement()); if(terminate!=std::string::npos) if(terminate!=std::string::npos){ lastEl->terminator=true; } std::vector<char> tel; ++close; Loading Loading @@ -495,7 +495,7 @@ ENDCOMMANDTAGDOUND: } } Element *first = firstEl->element; HtmlElement *first = (HtmlElement*)firstEl->element; _buildtreenode(firstEl,lastEl); Loading Loading @@ -638,37 +638,40 @@ libhtmlpp::HtmlElement::~HtmlElement(){ cura=next; } Element *cur=_childElement; Element *cur=_firstElement; std::stack<Element*> childs; std::stack<HtmlElement*> parents; std::stack<Element*> delelm; DELETEELEMENT: while(cur){ Element *next=cur->_nextElement; if(cur->getType()==HtmlEl){ if(((HtmlElement*)cur)->_childElement){ childs.push(((HtmlElement*)cur)->_childElement); ((HtmlElement*)cur)->_childElement=nullptr; parents.push((HtmlElement*)cur); cur=((HtmlElement*)cur)->_childElement; } } Element *next=cur->_nextElement; cur->_firstElement=nullptr; cur->_prevElement=nullptr; cur->_nextElement=nullptr; delelm.push(cur); cur=next; } if(!childs.empty()){ cur=childs.top(); childs.pop(); if(!parents.empty()){ cur=parents.top(); ((HtmlElement*)cur)->_childElement=nullptr; parents.pop(); goto DELETEELEMENT; } while(!delelm.empty()){ if(delelm.top()!=this) delete delelm.top(); delelm.pop(); } }; } Loading Loading @@ -773,31 +776,43 @@ libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Html void libhtmlpp::HtmlElement::remove(libhtmlpp::Element* el){ Element *cur=_firstElement; std::stack<Element*> childs,dels; std::stack<Element*> parents; DELETEELEMENT: while(cur){ Element *next=cur->_nextElement; if(cur->_firstElement==el) cur->_firstElement=el->_nextElement; if(cur->getType()==HtmlEl){ if(((HtmlElement*)cur)->_childElement){ childs.push(((HtmlElement*)cur)->_childElement); dels.push(((HtmlElement*)cur)->_childElement); parents.push(cur); cur=((HtmlElement*)cur)->_childElement; } } if(cur==el){ if(cur->_prevElement) cur->_prevElement->_nextElement=cur->_nextElement; if(cur->_nextElement) cur->_nextElement->_prevElement=cur->_prevElement; cur->_nextElement=nullptr; cur->_prevElement=nullptr; cur->_firstElement=nullptr; delete cur; return; } Element *next=cur->_nextElement; cur=next; } if(!childs.empty()){ cur=childs.top(); childs.pop(); if(!parents.empty()){ cur=parents.top()->nextElement(); parents.pop(); if(cur!=el) goto DELETEELEMENT; } while(!dels.empty()){ Element::remove(dels.top()); dels.pop(); } } Loading Loading @@ -1048,6 +1063,10 @@ libhtmlpp::TextElement::TextElement(const TextElement &texel) : TextElement(){ _copy(this,&texel); } libhtmlpp::TextElement::~TextElement(){ } libhtmlpp::TextElement & libhtmlpp::TextElement::operator=(const libhtmlpp::Element& hel){ _copy(this,&hel); return *this; Loading Loading @@ -1081,6 +1100,10 @@ libhtmlpp::CommentElement::CommentElement(const CommentElement &comel) : Element _copy(this,&comel); } libhtmlpp::CommentElement::~CommentElement(){ } libhtmlpp::CommentElement & libhtmlpp::CommentElement::operator=(const libhtmlpp::Element& hel){ _copy(this,&hel); return *this; Loading src/html.h +2 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ namespace libhtmlpp { public: TextElement(); TextElement(const TextElement &texel); ~TextElement(); TextElement& operator=(const Element &hel); TextElement& operator=(const Element *hel); Loading @@ -164,6 +165,7 @@ namespace libhtmlpp { public: CommentElement(); CommentElement(const CommentElement &comel); ~CommentElement(); CommentElement& operator=(const Element &hel); CommentElement& operator=(const Element *hel); Loading Loading
src/html.cpp +50 −27 Original line number Diff line number Diff line Loading @@ -345,7 +345,7 @@ NEXTDOCEL: goto NEXTDOCEL; } } #include <iostream> libhtmlpp::Element *libhtmlpp::HtmlString::_buildTree() { DocElements *firstEl = nullptr, *lastEl = nullptr; Loading Loading @@ -411,9 +411,9 @@ libhtmlpp::Element *libhtmlpp::HtmlString::_buildTree() { if(open!=std::string::npos && close !=std::string::npos && starttag!=std::string::npos){ addelement(&firstEl,&lastEl,new HtmlElement()); if(terminate!=std::string::npos) if(terminate!=std::string::npos){ lastEl->terminator=true; } std::vector<char> tel; ++close; Loading Loading @@ -495,7 +495,7 @@ ENDCOMMANDTAGDOUND: } } Element *first = firstEl->element; HtmlElement *first = (HtmlElement*)firstEl->element; _buildtreenode(firstEl,lastEl); Loading Loading @@ -638,37 +638,40 @@ libhtmlpp::HtmlElement::~HtmlElement(){ cura=next; } Element *cur=_childElement; Element *cur=_firstElement; std::stack<Element*> childs; std::stack<HtmlElement*> parents; std::stack<Element*> delelm; DELETEELEMENT: while(cur){ Element *next=cur->_nextElement; if(cur->getType()==HtmlEl){ if(((HtmlElement*)cur)->_childElement){ childs.push(((HtmlElement*)cur)->_childElement); ((HtmlElement*)cur)->_childElement=nullptr; parents.push((HtmlElement*)cur); cur=((HtmlElement*)cur)->_childElement; } } Element *next=cur->_nextElement; cur->_firstElement=nullptr; cur->_prevElement=nullptr; cur->_nextElement=nullptr; delelm.push(cur); cur=next; } if(!childs.empty()){ cur=childs.top(); childs.pop(); if(!parents.empty()){ cur=parents.top(); ((HtmlElement*)cur)->_childElement=nullptr; parents.pop(); goto DELETEELEMENT; } while(!delelm.empty()){ if(delelm.top()!=this) delete delelm.top(); delelm.pop(); } }; } Loading Loading @@ -773,31 +776,43 @@ libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Html void libhtmlpp::HtmlElement::remove(libhtmlpp::Element* el){ Element *cur=_firstElement; std::stack<Element*> childs,dels; std::stack<Element*> parents; DELETEELEMENT: while(cur){ Element *next=cur->_nextElement; if(cur->_firstElement==el) cur->_firstElement=el->_nextElement; if(cur->getType()==HtmlEl){ if(((HtmlElement*)cur)->_childElement){ childs.push(((HtmlElement*)cur)->_childElement); dels.push(((HtmlElement*)cur)->_childElement); parents.push(cur); cur=((HtmlElement*)cur)->_childElement; } } if(cur==el){ if(cur->_prevElement) cur->_prevElement->_nextElement=cur->_nextElement; if(cur->_nextElement) cur->_nextElement->_prevElement=cur->_prevElement; cur->_nextElement=nullptr; cur->_prevElement=nullptr; cur->_firstElement=nullptr; delete cur; return; } Element *next=cur->_nextElement; cur=next; } if(!childs.empty()){ cur=childs.top(); childs.pop(); if(!parents.empty()){ cur=parents.top()->nextElement(); parents.pop(); if(cur!=el) goto DELETEELEMENT; } while(!dels.empty()){ Element::remove(dels.top()); dels.pop(); } } Loading Loading @@ -1048,6 +1063,10 @@ libhtmlpp::TextElement::TextElement(const TextElement &texel) : TextElement(){ _copy(this,&texel); } libhtmlpp::TextElement::~TextElement(){ } libhtmlpp::TextElement & libhtmlpp::TextElement::operator=(const libhtmlpp::Element& hel){ _copy(this,&hel); return *this; Loading Loading @@ -1081,6 +1100,10 @@ libhtmlpp::CommentElement::CommentElement(const CommentElement &comel) : Element _copy(this,&comel); } libhtmlpp::CommentElement::~CommentElement(){ } libhtmlpp::CommentElement & libhtmlpp::CommentElement::operator=(const libhtmlpp::Element& hel){ _copy(this,&hel); return *this; Loading
src/html.h +2 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ namespace libhtmlpp { public: TextElement(); TextElement(const TextElement &texel); ~TextElement(); TextElement& operator=(const Element &hel); TextElement& operator=(const Element *hel); Loading @@ -164,6 +165,7 @@ namespace libhtmlpp { public: CommentElement(); CommentElement(const CommentElement &comel); ~CommentElement(); CommentElement& operator=(const Element &hel); CommentElement& operator=(const Element *hel); Loading