Loading src/html.cpp +18 −18 Original line number Diff line number Diff line Loading @@ -657,7 +657,7 @@ libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Elem namespace libhtmlpp { void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src){ const libhtmlpp::Element* prev; const libhtmlpp::Element* prev=nullptr; if(!src || !dest) return; struct cpyel { Loading Loading @@ -908,7 +908,7 @@ void libhtmlpp::HtmlPage::saveFile(const char* path){ std::string *data=new std::string;; std::ofstream fs; print(_Page->parse(),data); print(_Page->parse(),&data); try{ fs.open(path); Loading Loading @@ -964,25 +964,25 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element* el, std::string *output) { void libhtmlpp::print(Element* el, std::string **output) { std::stack<libhtmlpp::Element*> *cpylist = new std::stack<libhtmlpp::Element*>; PRINTNEXTEL: switch(el->_Type){ case HtmlEl:{ output->append("<"); output->append(*((HtmlElement*) el)->_TagName); (*output)->append("<"); (*output)->append(*((HtmlElement*) el)->_TagName); for (HtmlElement::Attributes* curattr = ((HtmlElement*) el)->_firstAttr; curattr; curattr = curattr->_nextAttr) { output->append(" "); output->append(curattr->_Key); (*output)->append(" "); (*output)->append(curattr->_Key); if(!curattr->_Value.empty()){ output->append("=\""); output->append(curattr->_Value); output->append("\""); (*output)->append("=\""); (*output)->append(curattr->_Value); (*output)->append("\""); } } output->append(">"); (*output)->append(">"); if (((HtmlElement*) el)->_childElement) { cpylist->push(el); Loading @@ -998,9 +998,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output->append("</"); output->append(((HtmlElement*) el)->getTagname()); output->append(">"); (*output)->append("</"); (*output)->append(((HtmlElement*) el)->getTagname()); (*output)->append(">"); cpylist->pop(); if(el->_nextElement){ Loading @@ -1011,7 +1011,7 @@ PRINTNEXTEL: }break; case TextEl :{ output->append(*((TextElement*)el)->_Text); (*output)->append(*((TextElement*)el)->_Text); if (el->_nextElement) { el=el->_nextElement; Loading @@ -1021,9 +1021,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output->append("</"); output->append(((HtmlElement*) el)->getTagname()); output->append(">"); (*output)->append("</"); (*output)->append(((HtmlElement*) el)->getTagname()); (*output)->append(">"); cpylist->pop(); if(el->_nextElement){ Loading src/html.h +4 −4 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ namespace libhtmlpp { friend class HtmlElement; friend class TextElement; friend class HtmlString; friend void print(Element* el, std::string *output); friend void print(Element* el, std::string **output); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -119,7 +119,7 @@ namespace libhtmlpp { friend class HtmlString; friend class HtmlTable; friend void print(Element* el, std::string *output); friend void print(Element* el, std::string **output); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -138,11 +138,11 @@ namespace libhtmlpp { protected: std::string *_Text; friend class HtmlString; friend void print(Element* el, std::string *output); friend void print(Element* el, std::string **output); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; void print(Element* el, std::string *output); void print(Element* el, std::string **output); class HtmlString { public: Loading test/htmlcopytest.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ public: void printModify(){ std::string *html = new std::string; libhtmlpp::print(&index2,html); libhtmlpp::print(&index2,&html); std::cout << html << std::endl; delete html; } Loading @@ -70,7 +70,7 @@ int main(int arc,char *argv[]){ std::string *html = new std::string; std::cout << "Orginal html:" << std::endl; libhtmlpp::print(index,html); libhtmlpp::print(index,&html); std::cout << "Modified html:" << std::endl; Loading test/htmlpagetest.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ int main(int arc,char *argv[]){ try{ libhtmlpp::Element *index=page.loadFile(argv[1]); std::string *html = new std::string; libhtmlpp::print(index,html); libhtmlpp::print(index,&html); std::cout << html << std::endl; std::cout << Green << "Test Passed!" << NOCOLOR << std::endl; delete html; Loading Loading
src/html.cpp +18 −18 Original line number Diff line number Diff line Loading @@ -657,7 +657,7 @@ libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Elem namespace libhtmlpp { void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src){ const libhtmlpp::Element* prev; const libhtmlpp::Element* prev=nullptr; if(!src || !dest) return; struct cpyel { Loading Loading @@ -908,7 +908,7 @@ void libhtmlpp::HtmlPage::saveFile(const char* path){ std::string *data=new std::string;; std::ofstream fs; print(_Page->parse(),data); print(_Page->parse(),&data); try{ fs.open(path); Loading Loading @@ -964,25 +964,25 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element* el, std::string *output) { void libhtmlpp::print(Element* el, std::string **output) { std::stack<libhtmlpp::Element*> *cpylist = new std::stack<libhtmlpp::Element*>; PRINTNEXTEL: switch(el->_Type){ case HtmlEl:{ output->append("<"); output->append(*((HtmlElement*) el)->_TagName); (*output)->append("<"); (*output)->append(*((HtmlElement*) el)->_TagName); for (HtmlElement::Attributes* curattr = ((HtmlElement*) el)->_firstAttr; curattr; curattr = curattr->_nextAttr) { output->append(" "); output->append(curattr->_Key); (*output)->append(" "); (*output)->append(curattr->_Key); if(!curattr->_Value.empty()){ output->append("=\""); output->append(curattr->_Value); output->append("\""); (*output)->append("=\""); (*output)->append(curattr->_Value); (*output)->append("\""); } } output->append(">"); (*output)->append(">"); if (((HtmlElement*) el)->_childElement) { cpylist->push(el); Loading @@ -998,9 +998,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output->append("</"); output->append(((HtmlElement*) el)->getTagname()); output->append(">"); (*output)->append("</"); (*output)->append(((HtmlElement*) el)->getTagname()); (*output)->append(">"); cpylist->pop(); if(el->_nextElement){ Loading @@ -1011,7 +1011,7 @@ PRINTNEXTEL: }break; case TextEl :{ output->append(*((TextElement*)el)->_Text); (*output)->append(*((TextElement*)el)->_Text); if (el->_nextElement) { el=el->_nextElement; Loading @@ -1021,9 +1021,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output->append("</"); output->append(((HtmlElement*) el)->getTagname()); output->append(">"); (*output)->append("</"); (*output)->append(((HtmlElement*) el)->getTagname()); (*output)->append(">"); cpylist->pop(); if(el->_nextElement){ Loading
src/html.h +4 −4 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ namespace libhtmlpp { friend class HtmlElement; friend class TextElement; friend class HtmlString; friend void print(Element* el, std::string *output); friend void print(Element* el, std::string **output); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -119,7 +119,7 @@ namespace libhtmlpp { friend class HtmlString; friend class HtmlTable; friend void print(Element* el, std::string *output); friend void print(Element* el, std::string **output); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -138,11 +138,11 @@ namespace libhtmlpp { protected: std::string *_Text; friend class HtmlString; friend void print(Element* el, std::string *output); friend void print(Element* el, std::string **output); friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; void print(Element* el, std::string *output); void print(Element* el, std::string **output); class HtmlString { public: Loading
test/htmlcopytest.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ public: void printModify(){ std::string *html = new std::string; libhtmlpp::print(&index2,html); libhtmlpp::print(&index2,&html); std::cout << html << std::endl; delete html; } Loading @@ -70,7 +70,7 @@ int main(int arc,char *argv[]){ std::string *html = new std::string; std::cout << "Orginal html:" << std::endl; libhtmlpp::print(index,html); libhtmlpp::print(index,&html); std::cout << "Modified html:" << std::endl; Loading
test/htmlpagetest.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ int main(int arc,char *argv[]){ try{ libhtmlpp::Element *index=page.loadFile(argv[1]); std::string *html = new std::string; libhtmlpp::print(index,html); libhtmlpp::print(index,&html); std::cout << html << std::endl; std::cout << Green << "Test Passed!" << NOCOLOR << std::endl; delete html; Loading