Loading src/html.cpp +38 −37 Original line number Diff line number Diff line Loading @@ -1384,7 +1384,10 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { void libhtmlpp::print(const Element &element, HtmlString &output,bool formated) { const Element *el=&element; auto isContainer = [](const std::string &tagname) { for(int i=0; ContainerTypes[i]; ++i){ if(std::equal(tagname.begin(),tagname.end(),ContainerTypes[i])) Loading @@ -1393,7 +1396,7 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { return false; }; std::stack<libhtmlpp::Element*> cpylist; std::stack<const libhtmlpp::Element*> cpylist; int lvl=0; Loading @@ -1407,12 +1410,11 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { } } switch(el.getType()){ switch(el->getType()){ case HtmlEl:{ HtmlElement* htmlel = dynamic_cast<HtmlElement*>(&el); output.append("<"); output.append(htmlel->getTagname()); for (HtmlElement::Attributes* curattr = htmlel->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(reinterpret_cast<const HtmlElement*>(el)->getTagname()); for (HtmlElement::Attributes* curattr = reinterpret_cast<const HtmlElement*>(el)->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(" "); std::copy( curattr->_Key.begin(), Loading @@ -1437,21 +1439,21 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { virgin=false; } if (htmlel->_childElement) { if (reinterpret_cast<const HtmlElement*>(el)->_childElement) { if(formated) output.append("\r\n"); cpylist.push(&el); el=htmlel->_childElement.get(); cpylist.push(el); el=reinterpret_cast<const HtmlElement*>(el)->_childElement.get(); ++lvl; goto PRINTNEXTEL; } //Container must be always terminated fuck html5 if(isContainer(htmlel->getTagname())){ if(isContainer(reinterpret_cast<const HtmlElement*>(el)->getTagname())){ output.append("</"); std::copy( htmlel->_TagName.begin(), htmlel->_TagName.end(), reinterpret_cast<const HtmlElement*>(el)->_TagName.begin(), reinterpret_cast<const HtmlElement*>(el)->_TagName.end(), std::back_inserter(output) ); output.append(">"); Loading @@ -1460,46 +1462,46 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { if(formated) output.append("\r\n"); if (htmlel->_nextElement) { el=htmlel->_nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; case TextEl :{ std::copy( ((TextElement*)&el)->_Text.begin(), ((TextElement*)&el)->_Text.end(), ((TextElement*)el)->_Text.begin(), ((TextElement*)el)->_Text.end(), std::back_inserter(output) ); if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; case CommentEl: { output.append("<!--"); std::copy( ((CommentElement*)&el)->_Comment.begin(), ((CommentElement*)&el)->_Comment.end(), ((CommentElement*)el)->_Comment.begin(), ((CommentElement*)el)->_Comment.end(), std::back_inserter(output) ); output.append("-->"); if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; case ScriptEL:{ output.append("<"); output.append(((ScriptElement*) &el)->getTagname()); for (ScriptElement::Attributes* curattr = ((ScriptElement*) &el)->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(((ScriptElement*) el)->getTagname()); for (ScriptElement::Attributes* curattr = ((ScriptElement*) el)->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(" "); std::copy( curattr->_Key.begin(), Loading @@ -1525,8 +1527,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { } } std::copy( ((ScriptElement*)&el)->_Script.begin(), ((ScriptElement*)&el)->_Script.end(), ((ScriptElement*)el)->_Script.begin(), ((ScriptElement*)el)->_Script.end(), std::back_inserter(output) ); if(formated){ Loading @@ -1541,8 +1543,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; Loading Loading @@ -1575,8 +1577,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { } } std::copy( ((SvgElement*)&el)->_Svg.begin(), ((SvgElement*)&el)->_Svg.end(), ((SvgElement*)el)->_Svg.begin(), ((SvgElement*)el)->_Svg.end(), std::back_inserter(output) ); if(formated){ Loading @@ -1591,8 +1593,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; Loading @@ -1616,8 +1618,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { output.append("</"); std::copy( ((HtmlElement*) &el)->_TagName.begin(), ((HtmlElement*) &el)->_TagName.end(), ((HtmlElement*) el)->_TagName.begin(), ((HtmlElement*) el)->_TagName.end(), std::back_inserter(output) ); output.append(">"); Loading @@ -1626,12 +1628,11 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { output.append("\r\n"); cpylist.pop(); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } } } libhtmlpp::HtmlElement *libhtmlpp::HtmlElement::getElementbyID(const std::string &id) const{ Loading src/html.h +7 −7 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ namespace libhtmlpp { friend class HtmlElement; friend class TextElement; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -137,7 +137,7 @@ namespace libhtmlpp { friend class HtmlString; friend class HtmlTable; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -158,7 +158,7 @@ namespace libhtmlpp { protected: std::vector<char> _Text; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -178,7 +178,7 @@ namespace libhtmlpp { protected: std::vector<char> _Comment; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -207,7 +207,7 @@ namespace libhtmlpp { std::vector<char> _Script; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -236,11 +236,11 @@ namespace libhtmlpp { std::vector<char> _Svg; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; void print(Element& el, HtmlString &output,bool formated=false); void print(const Element& element, HtmlString &output,bool formated=false); class HtmlString { public: Loading Loading
src/html.cpp +38 −37 Original line number Diff line number Diff line Loading @@ -1384,7 +1384,10 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { void libhtmlpp::print(const Element &element, HtmlString &output,bool formated) { const Element *el=&element; auto isContainer = [](const std::string &tagname) { for(int i=0; ContainerTypes[i]; ++i){ if(std::equal(tagname.begin(),tagname.end(),ContainerTypes[i])) Loading @@ -1393,7 +1396,7 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { return false; }; std::stack<libhtmlpp::Element*> cpylist; std::stack<const libhtmlpp::Element*> cpylist; int lvl=0; Loading @@ -1407,12 +1410,11 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { } } switch(el.getType()){ switch(el->getType()){ case HtmlEl:{ HtmlElement* htmlel = dynamic_cast<HtmlElement*>(&el); output.append("<"); output.append(htmlel->getTagname()); for (HtmlElement::Attributes* curattr = htmlel->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(reinterpret_cast<const HtmlElement*>(el)->getTagname()); for (HtmlElement::Attributes* curattr = reinterpret_cast<const HtmlElement*>(el)->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(" "); std::copy( curattr->_Key.begin(), Loading @@ -1437,21 +1439,21 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { virgin=false; } if (htmlel->_childElement) { if (reinterpret_cast<const HtmlElement*>(el)->_childElement) { if(formated) output.append("\r\n"); cpylist.push(&el); el=htmlel->_childElement.get(); cpylist.push(el); el=reinterpret_cast<const HtmlElement*>(el)->_childElement.get(); ++lvl; goto PRINTNEXTEL; } //Container must be always terminated fuck html5 if(isContainer(htmlel->getTagname())){ if(isContainer(reinterpret_cast<const HtmlElement*>(el)->getTagname())){ output.append("</"); std::copy( htmlel->_TagName.begin(), htmlel->_TagName.end(), reinterpret_cast<const HtmlElement*>(el)->_TagName.begin(), reinterpret_cast<const HtmlElement*>(el)->_TagName.end(), std::back_inserter(output) ); output.append(">"); Loading @@ -1460,46 +1462,46 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { if(formated) output.append("\r\n"); if (htmlel->_nextElement) { el=htmlel->_nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; case TextEl :{ std::copy( ((TextElement*)&el)->_Text.begin(), ((TextElement*)&el)->_Text.end(), ((TextElement*)el)->_Text.begin(), ((TextElement*)el)->_Text.end(), std::back_inserter(output) ); if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; case CommentEl: { output.append("<!--"); std::copy( ((CommentElement*)&el)->_Comment.begin(), ((CommentElement*)&el)->_Comment.end(), ((CommentElement*)el)->_Comment.begin(), ((CommentElement*)el)->_Comment.end(), std::back_inserter(output) ); output.append("-->"); if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; case ScriptEL:{ output.append("<"); output.append(((ScriptElement*) &el)->getTagname()); for (ScriptElement::Attributes* curattr = ((ScriptElement*) &el)->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(((ScriptElement*) el)->getTagname()); for (ScriptElement::Attributes* curattr = ((ScriptElement*) el)->_firstAttr.get(); curattr; curattr = curattr->_nextAttr.get()) { output.append(" "); std::copy( curattr->_Key.begin(), Loading @@ -1525,8 +1527,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { } } std::copy( ((ScriptElement*)&el)->_Script.begin(), ((ScriptElement*)&el)->_Script.end(), ((ScriptElement*)el)->_Script.begin(), ((ScriptElement*)el)->_Script.end(), std::back_inserter(output) ); if(formated){ Loading @@ -1541,8 +1543,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; Loading Loading @@ -1575,8 +1577,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { } } std::copy( ((SvgElement*)&el)->_Svg.begin(), ((SvgElement*)&el)->_Svg.end(), ((SvgElement*)el)->_Svg.begin(), ((SvgElement*)el)->_Svg.end(), std::back_inserter(output) ); if(formated){ Loading @@ -1591,8 +1593,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { if(formated) output.append("\r\n"); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } }break; Loading @@ -1616,8 +1618,8 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { output.append("</"); std::copy( ((HtmlElement*) &el)->_TagName.begin(), ((HtmlElement*) &el)->_TagName.end(), ((HtmlElement*) el)->_TagName.begin(), ((HtmlElement*) el)->_TagName.end(), std::back_inserter(output) ); output.append(">"); Loading @@ -1626,12 +1628,11 @@ void libhtmlpp::print(Element &el, HtmlString &output,bool formated) { output.append("\r\n"); cpylist.pop(); if (el._nextElement) { el=el._nextElement.get(); if (el->_nextElement) { el=el->_nextElement.get(); goto PRINTNEXTEL; } } } libhtmlpp::HtmlElement *libhtmlpp::HtmlElement::getElementbyID(const std::string &id) const{ Loading
src/html.h +7 −7 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ namespace libhtmlpp { friend class HtmlElement; friend class TextElement; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -137,7 +137,7 @@ namespace libhtmlpp { friend class HtmlString; friend class HtmlTable; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -158,7 +158,7 @@ namespace libhtmlpp { protected: std::vector<char> _Text; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -178,7 +178,7 @@ namespace libhtmlpp { protected: std::vector<char> _Comment; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -207,7 +207,7 @@ namespace libhtmlpp { std::vector<char> _Script; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -236,11 +236,11 @@ namespace libhtmlpp { std::vector<char> _Svg; friend class HtmlString; friend void print(Element& el, HtmlString &output,bool formated); friend void print(const Element& element, HtmlString &output,bool formated); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; void print(Element& el, HtmlString &output,bool formated=false); void print(const Element& element, HtmlString &output,bool formated=false); class HtmlString { public: Loading