Loading src/html.cpp +43 −64 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ void libhtmlpp::HtmlString::_buildtreenode(libhtmlpp::DocElements *firstel,libht auto checkterminator = [](DocElements *termel, DocElements *end){ int i=0; if(termel->element->getType()!=HtmlEl) if(((Element*)(termel->element))->getType()!=HtmlEl) return (DocElements*) nullptr; for (DocElements* curcel=termel->nextel; curcel; curcel=curcel->nextel) { Loading Loading @@ -681,6 +681,10 @@ DELETEELEMENT: delelm.pop(); } delete _nextElement; delete _prevElement; delete _childElement; delete _firstElement; } int libhtmlpp::Element::getType() const{ Loading @@ -699,8 +703,7 @@ const char* libhtmlpp::HtmlElement::getTagname(){ void libhtmlpp::HtmlElement::insertChild(libhtmlpp::Element* el){ if(_childElement){ delete _childElement; _childElement=nullptr; remove(_childElement); } switch(el->getType()){ case HtmlEl: Loading Loading @@ -1021,6 +1024,9 @@ libhtmlpp::Element::~Element(){ delete curel; curel=next; } delete _firstElement; delete _prevElement; delete _nextElement; }; void libhtmlpp::Element::remove(libhtmlpp::Element* el){ Loading Loading @@ -1219,29 +1225,30 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element* el, HtmlString &output,bool formated) { std::stack<libhtmlpp::Element*> cpylist; auto printag = [](Element *el,HtmlString &tag){ tag.append("<"); tag.append(((HtmlElement*) el)->getTagname()); PRINTNEXTEL: switch(el->getType()){ case HtmlEl:{ output.append("<"); output.append(((HtmlElement*) el)->getTagname()); for (HtmlElement::Attributes* curattr = ((HtmlElement*) el)->_firstAttr; curattr; curattr = curattr->_nextAttr) { tag.append(" "); tag.append(curattr->_Key.data(),curattr->_Key.size()); output.append(" "); output.append(curattr->_Key.data(),curattr->_Key.size()); if(!curattr->_Value.empty()){ tag.append("=\""); tag.append(curattr->_Value.data(),curattr->_Value.size()); tag.append("\""); output.append("=\""); output.append(curattr->_Value.data(),curattr->_Value.size()); output.append("\""); } } tag.append(">"); }; PRINTNEXTEL: switch(el->getType()){ case HtmlEl:{ printag(el,output); if(((HtmlElement*) el)->_childElement || el->_nextElement ){ output.append(">"); }else{ output.append("</"); output.append(((HtmlElement*) el)->_TagName.data(),((HtmlElement*) el)->_TagName.size()); output.append(">"); } if (((HtmlElement*) el)->_childElement) { cpylist.push(el); el=((HtmlElement*) el)->_childElement; Loading @@ -1252,20 +1259,6 @@ PRINTNEXTEL: el=el->_nextElement; goto PRINTNEXTEL; } while(!cpylist.empty()){ el=cpylist.top(); output.append("</"); output.append(((HtmlElement*) el)->getTagname()); output.append(">"); cpylist.pop(); if(el->_nextElement){ el=el->_nextElement; goto PRINTNEXTEL; } } }break; case TextEl :{ Loading @@ -1276,19 +1269,6 @@ PRINTNEXTEL: goto PRINTNEXTEL; } while(!cpylist.empty()){ el=cpylist.top(); output.append("</"); output.append(((HtmlElement*) el)->_TagName.data(),((HtmlElement*) el)->_TagName.size()); output.append(">"); cpylist.pop(); if(el->_nextElement){ el=el->_nextElement; goto PRINTNEXTEL; } } }break; case CommentEl: { output.append("<!--"); Loading @@ -1299,7 +1279,13 @@ PRINTNEXTEL: el=el->_nextElement; goto PRINTNEXTEL; } }break; default: HTMLException excp; excp[HTMLException::Error] << "Unkown Elementtype"; throw excp; break; } while(!cpylist.empty()){ el=cpylist.top(); Loading @@ -1313,13 +1299,6 @@ PRINTNEXTEL: goto PRINTNEXTEL; } } }break; default: HTMLException excp; excp[HTMLException::Error] << "Unkown Elementtype"; throw excp; break; } } libhtmlpp::HtmlElement *libhtmlpp::HtmlElement::getElementbyID(const char *id) const{ Loading Loading
src/html.cpp +43 −64 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ void libhtmlpp::HtmlString::_buildtreenode(libhtmlpp::DocElements *firstel,libht auto checkterminator = [](DocElements *termel, DocElements *end){ int i=0; if(termel->element->getType()!=HtmlEl) if(((Element*)(termel->element))->getType()!=HtmlEl) return (DocElements*) nullptr; for (DocElements* curcel=termel->nextel; curcel; curcel=curcel->nextel) { Loading Loading @@ -681,6 +681,10 @@ DELETEELEMENT: delelm.pop(); } delete _nextElement; delete _prevElement; delete _childElement; delete _firstElement; } int libhtmlpp::Element::getType() const{ Loading @@ -699,8 +703,7 @@ const char* libhtmlpp::HtmlElement::getTagname(){ void libhtmlpp::HtmlElement::insertChild(libhtmlpp::Element* el){ if(_childElement){ delete _childElement; _childElement=nullptr; remove(_childElement); } switch(el->getType()){ case HtmlEl: Loading Loading @@ -1021,6 +1024,9 @@ libhtmlpp::Element::~Element(){ delete curel; curel=next; } delete _firstElement; delete _prevElement; delete _nextElement; }; void libhtmlpp::Element::remove(libhtmlpp::Element* el){ Loading Loading @@ -1219,29 +1225,30 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element* el, HtmlString &output,bool formated) { std::stack<libhtmlpp::Element*> cpylist; auto printag = [](Element *el,HtmlString &tag){ tag.append("<"); tag.append(((HtmlElement*) el)->getTagname()); PRINTNEXTEL: switch(el->getType()){ case HtmlEl:{ output.append("<"); output.append(((HtmlElement*) el)->getTagname()); for (HtmlElement::Attributes* curattr = ((HtmlElement*) el)->_firstAttr; curattr; curattr = curattr->_nextAttr) { tag.append(" "); tag.append(curattr->_Key.data(),curattr->_Key.size()); output.append(" "); output.append(curattr->_Key.data(),curattr->_Key.size()); if(!curattr->_Value.empty()){ tag.append("=\""); tag.append(curattr->_Value.data(),curattr->_Value.size()); tag.append("\""); output.append("=\""); output.append(curattr->_Value.data(),curattr->_Value.size()); output.append("\""); } } tag.append(">"); }; PRINTNEXTEL: switch(el->getType()){ case HtmlEl:{ printag(el,output); if(((HtmlElement*) el)->_childElement || el->_nextElement ){ output.append(">"); }else{ output.append("</"); output.append(((HtmlElement*) el)->_TagName.data(),((HtmlElement*) el)->_TagName.size()); output.append(">"); } if (((HtmlElement*) el)->_childElement) { cpylist.push(el); el=((HtmlElement*) el)->_childElement; Loading @@ -1252,20 +1259,6 @@ PRINTNEXTEL: el=el->_nextElement; goto PRINTNEXTEL; } while(!cpylist.empty()){ el=cpylist.top(); output.append("</"); output.append(((HtmlElement*) el)->getTagname()); output.append(">"); cpylist.pop(); if(el->_nextElement){ el=el->_nextElement; goto PRINTNEXTEL; } } }break; case TextEl :{ Loading @@ -1276,19 +1269,6 @@ PRINTNEXTEL: goto PRINTNEXTEL; } while(!cpylist.empty()){ el=cpylist.top(); output.append("</"); output.append(((HtmlElement*) el)->_TagName.data(),((HtmlElement*) el)->_TagName.size()); output.append(">"); cpylist.pop(); if(el->_nextElement){ el=el->_nextElement; goto PRINTNEXTEL; } } }break; case CommentEl: { output.append("<!--"); Loading @@ -1299,7 +1279,13 @@ PRINTNEXTEL: el=el->_nextElement; goto PRINTNEXTEL; } }break; default: HTMLException excp; excp[HTMLException::Error] << "Unkown Elementtype"; throw excp; break; } while(!cpylist.empty()){ el=cpylist.top(); Loading @@ -1313,13 +1299,6 @@ PRINTNEXTEL: goto PRINTNEXTEL; } } }break; default: HTMLException excp; excp[HTMLException::Error] << "Unkown Elementtype"; throw excp; break; } } libhtmlpp::HtmlElement *libhtmlpp::HtmlElement::getElementbyID(const char *id) const{ Loading