Loading src/html.cpp +88 −41 Original line number Diff line number Diff line Loading @@ -623,23 +623,25 @@ libhtmlpp::HtmlElement::HtmlElement(const libhtmlpp::HtmlElement* hel) : HtmlEle libhtmlpp::HtmlElement::~HtmlElement(){ if(_prevElement) _prevElement->_nextElement=_nextElement; if(_nextElement) _nextElement->_prevElement=_prevElement; _nextElement=nullptr; Element *cur=this; DELETEELEMENT: if(cur->_Type==HtmlEl){ Attributes *cura=((HtmlElement*)cur)->_firstAttr; _prevElement=nullptr; Attributes *cura=_firstAttr; while(cura){ Attributes *next=cura->_nextAttr; cura->_nextAttr=nullptr; delete cura; cura=next; } } Element *cur=_childElement; DELETEELEMENT: std::stack<Element*> childs; std::stack<Element*> delelm; if(cur->_Type==HtmlEl && ((HtmlElement*)cur)->_childElement){ cur=((HtmlElement*)cur)->_childElement; if(cur && (cur->_Type==HtmlEl && ((HtmlElement*)cur)->_childElement) ){ while(cur){ Element *next=cur->nextElement(); cur->_nextElement=nullptr; Loading @@ -648,7 +650,7 @@ DELETEELEMENT: childs.push(((HtmlElement*)cur)->_childElement); ((HtmlElement*)cur)->_childElement=nullptr; } delete cur; delelm.push(cur); cur=next; } } Loading @@ -656,6 +658,10 @@ DELETEELEMENT: cur=childs.top(); goto DELETEELEMENT; } while(!delelm.empty()){ delete delelm.top(); } } void libhtmlpp::HtmlElement::setTagname(const char* name){ Loading @@ -673,10 +679,17 @@ void libhtmlpp::HtmlElement::insertChild(libhtmlpp::Element* el){ delete _childElement; _childElement=nullptr; } if(el->getType()==HtmlEl) switch(el->getType()){ case HtmlEl: _childElement=new HtmlElement; else if(el->getType()==TextEl) break; case TextEl: _childElement=new TextElement; break; case CommentEl: _childElement=new CommentElement; break; } _copy(_childElement,el); } Loading @@ -688,10 +701,16 @@ void libhtmlpp::HtmlElement::appendChild(libhtmlpp::Element* el){ curel=curel->nextElement(); }while(curel); if(el->getType()==HtmlEl) switch(el->getType()){ case HtmlEl: curel=new HtmlElement; else if(el->getType()==TextEl) break; case TextEl: curel=new TextElement; break; case CommentEl: curel=new CommentElement; } if(prev){ prev->_nextElement=curel; curel->_prevElement=prev; Loading Loading @@ -769,12 +788,20 @@ NEWEL: } if(((libhtmlpp::HtmlElement*)src)->_childElement){ if(((libhtmlpp::HtmlElement*)src)->_childElement->getType()==HtmlEl){ switch(((libhtmlpp::HtmlElement*)src)->_childElement->getType()){ case HtmlEl: ((libhtmlpp::HtmlElement*)dest)->_childElement= new HtmlElement; }else if(((libhtmlpp::HtmlElement*)src)->_childElement->getType()==TextEl){ break; case TextEl: ((libhtmlpp::HtmlElement*)dest)->_childElement = new TextElement; }else if(((libhtmlpp::HtmlElement*)src)->_childElement->getType()==CommentEl){ break; case CommentEl: ((libhtmlpp::HtmlElement*)dest)->_childElement = new CommentElement; break; default: HTMLException ex; ex[HTMLException::Critical] << "Unknown html element found !"; throw ex; } cpyel childel; childel.destin=((libhtmlpp::HtmlElement*)dest)->_childElement;; Loading Loading @@ -819,14 +846,25 @@ NEWEL: }; void libhtmlpp::Element::insertBefore(libhtmlpp::Element* el){ if(el->getType()==HtmlEl){ switch(el->getType()){ case HtmlEl:{ HtmlElement *nel=new HtmlElement(); _copy(nel,el); _prevElement->_nextElement=nel; }else if(el->getType()==TextEl){ break; } case TextEl:{ TextElement *txt= new TextElement; _copy(txt,el); _prevElement->_nextElement=txt; break; } case CommentEl:{ CommentElement *cmt= new CommentElement; _copy(cmt,el); _prevElement->_nextElement=cmt; break; } } Element *nexel=_prevElement->_nextElement,*prev=nullptr; Loading @@ -840,13 +878,21 @@ void libhtmlpp::Element::insertBefore(libhtmlpp::Element* el){ } void libhtmlpp::Element::insertAfter(libhtmlpp::Element* el){ Element *nexel=nullptr,*prev=_nextElement; Element *nexel=nullptr,*prev=nullptr; if(el->getType()==HtmlEl){ _nextElement= new HtmlElement; }else if(el->getType()==TextEl){ switch(el->getType()){ case HtmlEl:{ _nextElement=new HtmlElement(); break; } case TextEl:{ _nextElement=new TextElement; break; } case CommentEl:{ _nextElement=new CommentElement;; break; } } _copy(_nextElement,el); Loading @@ -854,6 +900,7 @@ void libhtmlpp::Element::insertAfter(libhtmlpp::Element* el){ nexel=_nextElement; while(nexel){ prev=nexel; nexel=nexel->nextElement(); } Loading Loading
src/html.cpp +88 −41 Original line number Diff line number Diff line Loading @@ -623,23 +623,25 @@ libhtmlpp::HtmlElement::HtmlElement(const libhtmlpp::HtmlElement* hel) : HtmlEle libhtmlpp::HtmlElement::~HtmlElement(){ if(_prevElement) _prevElement->_nextElement=_nextElement; if(_nextElement) _nextElement->_prevElement=_prevElement; _nextElement=nullptr; Element *cur=this; DELETEELEMENT: if(cur->_Type==HtmlEl){ Attributes *cura=((HtmlElement*)cur)->_firstAttr; _prevElement=nullptr; Attributes *cura=_firstAttr; while(cura){ Attributes *next=cura->_nextAttr; cura->_nextAttr=nullptr; delete cura; cura=next; } } Element *cur=_childElement; DELETEELEMENT: std::stack<Element*> childs; std::stack<Element*> delelm; if(cur->_Type==HtmlEl && ((HtmlElement*)cur)->_childElement){ cur=((HtmlElement*)cur)->_childElement; if(cur && (cur->_Type==HtmlEl && ((HtmlElement*)cur)->_childElement) ){ while(cur){ Element *next=cur->nextElement(); cur->_nextElement=nullptr; Loading @@ -648,7 +650,7 @@ DELETEELEMENT: childs.push(((HtmlElement*)cur)->_childElement); ((HtmlElement*)cur)->_childElement=nullptr; } delete cur; delelm.push(cur); cur=next; } } Loading @@ -656,6 +658,10 @@ DELETEELEMENT: cur=childs.top(); goto DELETEELEMENT; } while(!delelm.empty()){ delete delelm.top(); } } void libhtmlpp::HtmlElement::setTagname(const char* name){ Loading @@ -673,10 +679,17 @@ void libhtmlpp::HtmlElement::insertChild(libhtmlpp::Element* el){ delete _childElement; _childElement=nullptr; } if(el->getType()==HtmlEl) switch(el->getType()){ case HtmlEl: _childElement=new HtmlElement; else if(el->getType()==TextEl) break; case TextEl: _childElement=new TextElement; break; case CommentEl: _childElement=new CommentElement; break; } _copy(_childElement,el); } Loading @@ -688,10 +701,16 @@ void libhtmlpp::HtmlElement::appendChild(libhtmlpp::Element* el){ curel=curel->nextElement(); }while(curel); if(el->getType()==HtmlEl) switch(el->getType()){ case HtmlEl: curel=new HtmlElement; else if(el->getType()==TextEl) break; case TextEl: curel=new TextElement; break; case CommentEl: curel=new CommentElement; } if(prev){ prev->_nextElement=curel; curel->_prevElement=prev; Loading Loading @@ -769,12 +788,20 @@ NEWEL: } if(((libhtmlpp::HtmlElement*)src)->_childElement){ if(((libhtmlpp::HtmlElement*)src)->_childElement->getType()==HtmlEl){ switch(((libhtmlpp::HtmlElement*)src)->_childElement->getType()){ case HtmlEl: ((libhtmlpp::HtmlElement*)dest)->_childElement= new HtmlElement; }else if(((libhtmlpp::HtmlElement*)src)->_childElement->getType()==TextEl){ break; case TextEl: ((libhtmlpp::HtmlElement*)dest)->_childElement = new TextElement; }else if(((libhtmlpp::HtmlElement*)src)->_childElement->getType()==CommentEl){ break; case CommentEl: ((libhtmlpp::HtmlElement*)dest)->_childElement = new CommentElement; break; default: HTMLException ex; ex[HTMLException::Critical] << "Unknown html element found !"; throw ex; } cpyel childel; childel.destin=((libhtmlpp::HtmlElement*)dest)->_childElement;; Loading Loading @@ -819,14 +846,25 @@ NEWEL: }; void libhtmlpp::Element::insertBefore(libhtmlpp::Element* el){ if(el->getType()==HtmlEl){ switch(el->getType()){ case HtmlEl:{ HtmlElement *nel=new HtmlElement(); _copy(nel,el); _prevElement->_nextElement=nel; }else if(el->getType()==TextEl){ break; } case TextEl:{ TextElement *txt= new TextElement; _copy(txt,el); _prevElement->_nextElement=txt; break; } case CommentEl:{ CommentElement *cmt= new CommentElement; _copy(cmt,el); _prevElement->_nextElement=cmt; break; } } Element *nexel=_prevElement->_nextElement,*prev=nullptr; Loading @@ -840,13 +878,21 @@ void libhtmlpp::Element::insertBefore(libhtmlpp::Element* el){ } void libhtmlpp::Element::insertAfter(libhtmlpp::Element* el){ Element *nexel=nullptr,*prev=_nextElement; Element *nexel=nullptr,*prev=nullptr; if(el->getType()==HtmlEl){ _nextElement= new HtmlElement; }else if(el->getType()==TextEl){ switch(el->getType()){ case HtmlEl:{ _nextElement=new HtmlElement(); break; } case TextEl:{ _nextElement=new TextElement; break; } case CommentEl:{ _nextElement=new CommentElement;; break; } } _copy(_nextElement,el); Loading @@ -854,6 +900,7 @@ void libhtmlpp::Element::insertAfter(libhtmlpp::Element* el){ nexel=_nextElement; while(nexel){ prev=nexel; nexel=nexel->nextElement(); } Loading