Loading src/html.cpp +21 −18 Original line number Diff line number Diff line Loading @@ -527,6 +527,7 @@ libhtmlpp::HtmlElement::HtmlElement() : Element(){ _firstAttr=nullptr; _lastAttr=nullptr; _Type=HtmlEl; _TagName=nullptr; } libhtmlpp::HtmlElement::HtmlElement(const libhtmlpp::HtmlElement& hel) : HtmlElement(){ Loading Loading @@ -844,10 +845,10 @@ libhtmlpp::HtmlElement *libhtmlpp::HtmlPage::loadString(HtmlString node){ } void libhtmlpp::HtmlPage::saveFile(const char* path){ std::string data; std::string *data=new std::string;; std::ofstream fs; print(_Page.parse(),nullptr,data); print(_Page.parse(),data); try{ fs.open(path); Loading @@ -859,6 +860,8 @@ void libhtmlpp::HtmlPage::saveFile(const char* path){ fs << data; fs.close(); delete data; } void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ Loading Loading @@ -901,25 +904,25 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element* el, HtmlElement* parent,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 @@ -935,9 +938,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output.append("</"); output.append(*((HtmlElement*) el)->_TagName); output.append(">"); output->append("</"); output->append(*((HtmlElement*) el)->_TagName); output->append(">"); el=el->_nextElement; cpylist->pop(); if(el) Loading @@ -946,7 +949,7 @@ PRINTNEXTEL: }break; case TextEl :{ output.append(*((TextElement*)el)->_Text); output->append(*((TextElement*)el)->_Text); if (el->_nextElement) { el=el->_nextElement; goto PRINTNEXTEL; Loading @@ -954,9 +957,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output.append("</"); output.append(*((HtmlElement*) el)->_TagName); output.append(">"); output->append("</"); output->append(*((HtmlElement*) el)->_TagName); output->append(">"); el=el->_nextElement; cpylist->pop(); if(el) 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, HtmlElement* parent,std::string &output); friend void print(Element* el, std::string *output); friend void _copy(const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -118,7 +118,7 @@ namespace libhtmlpp { friend class HtmlString; friend class HtmlTable; friend void print(Element* el, HtmlElement* parent,std::string &output); friend void print(Element* el, std::string *output); friend void _copy(const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -137,11 +137,11 @@ namespace libhtmlpp { protected: std::string *_Text; friend class HtmlString; friend void print(Element* el, HtmlElement* parent,std::string &output); friend void print(Element* el, std::string *output); friend void _copy(const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; void print(Element* el, HtmlElement* parent,std::string &output); void print(Element* el, std::string *output); class HtmlString { public: Loading test/htmlcopytest.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,10 @@ public: } void printModify(){ std::string html; libhtmlpp::print(&index2,nullptr,html); std::string *html = new std::string; libhtmlpp::print(&index2,html); std::cout << html << std::endl; delete html; } ~HtmlCopy(){ Loading @@ -66,10 +67,10 @@ int main(int arc,char *argv[]){ HtmlCopy cpy(index); std::string html; std::string *html = new std::string; std::cout << "Orginal html:" << std::endl; libhtmlpp::print(index,nullptr,html); libhtmlpp::print(index,html); std::cout << "Modified html:" << std::endl; Loading @@ -78,6 +79,7 @@ int main(int arc,char *argv[]){ std::cout << html << std::endl; std::cout << Green << "Test Passed!" << NOCOLOR << std::endl; delete html; }catch(libhtmlpp::HTMLException &exp){ std::cout << exp.what() << std::endl; std::cout << Red << "Test not Passed!" << NOCOLOR << std::endl; Loading test/htmlpagetest.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -38,10 +38,11 @@ int main(int arc,char *argv[]){ libhtmlpp::HtmlPage page; try{ libhtmlpp::Element *index=page.loadFile(argv[1]); std::string html; libhtmlpp::print(index,nullptr,html); std::string *html = new std::string; libhtmlpp::print(index,html); std::cout << html << std::endl; std::cout << Green << "Test Passed!" << NOCOLOR << std::endl; delete html; }catch(libhtmlpp::HTMLException &exp){ std::cout << exp.what() << std::endl; std::cout << Red << "Test not Passed!" << NOCOLOR << std::endl; Loading Loading
src/html.cpp +21 −18 Original line number Diff line number Diff line Loading @@ -527,6 +527,7 @@ libhtmlpp::HtmlElement::HtmlElement() : Element(){ _firstAttr=nullptr; _lastAttr=nullptr; _Type=HtmlEl; _TagName=nullptr; } libhtmlpp::HtmlElement::HtmlElement(const libhtmlpp::HtmlElement& hel) : HtmlElement(){ Loading Loading @@ -844,10 +845,10 @@ libhtmlpp::HtmlElement *libhtmlpp::HtmlPage::loadString(HtmlString node){ } void libhtmlpp::HtmlPage::saveFile(const char* path){ std::string data; std::string *data=new std::string;; std::ofstream fs; print(_Page.parse(),nullptr,data); print(_Page.parse(),data); try{ fs.open(path); Loading @@ -859,6 +860,8 @@ void libhtmlpp::HtmlPage::saveFile(const char* path){ fs << data; fs.close(); delete data; } void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ Loading Loading @@ -901,25 +904,25 @@ void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){ } void libhtmlpp::print(Element* el, HtmlElement* parent,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 @@ -935,9 +938,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output.append("</"); output.append(*((HtmlElement*) el)->_TagName); output.append(">"); output->append("</"); output->append(*((HtmlElement*) el)->_TagName); output->append(">"); el=el->_nextElement; cpylist->pop(); if(el) Loading @@ -946,7 +949,7 @@ PRINTNEXTEL: }break; case TextEl :{ output.append(*((TextElement*)el)->_Text); output->append(*((TextElement*)el)->_Text); if (el->_nextElement) { el=el->_nextElement; goto PRINTNEXTEL; Loading @@ -954,9 +957,9 @@ PRINTNEXTEL: while(!cpylist->empty()){ el=cpylist->top(); output.append("</"); output.append(*((HtmlElement*) el)->_TagName); output.append(">"); output->append("</"); output->append(*((HtmlElement*) el)->_TagName); output->append(">"); el=el->_nextElement; cpylist->pop(); if(el) 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, HtmlElement* parent,std::string &output); friend void print(Element* el, std::string *output); friend void _copy(const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading Loading @@ -118,7 +118,7 @@ namespace libhtmlpp { friend class HtmlString; friend class HtmlTable; friend void print(Element* el, HtmlElement* parent,std::string &output); friend void print(Element* el, std::string *output); friend void _copy(const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; Loading @@ -137,11 +137,11 @@ namespace libhtmlpp { protected: std::string *_Text; friend class HtmlString; friend void print(Element* el, HtmlElement* parent,std::string &output); friend void print(Element* el, std::string *output); friend void _copy(const libhtmlpp::Element* prev,libhtmlpp::Element *dest,const libhtmlpp::Element *src); }; void print(Element* el, HtmlElement* parent,std::string &output); void print(Element* el, std::string *output); class HtmlString { public: Loading
test/htmlcopytest.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,10 @@ public: } void printModify(){ std::string html; libhtmlpp::print(&index2,nullptr,html); std::string *html = new std::string; libhtmlpp::print(&index2,html); std::cout << html << std::endl; delete html; } ~HtmlCopy(){ Loading @@ -66,10 +67,10 @@ int main(int arc,char *argv[]){ HtmlCopy cpy(index); std::string html; std::string *html = new std::string; std::cout << "Orginal html:" << std::endl; libhtmlpp::print(index,nullptr,html); libhtmlpp::print(index,html); std::cout << "Modified html:" << std::endl; Loading @@ -78,6 +79,7 @@ int main(int arc,char *argv[]){ std::cout << html << std::endl; std::cout << Green << "Test Passed!" << NOCOLOR << std::endl; delete html; }catch(libhtmlpp::HTMLException &exp){ std::cout << exp.what() << std::endl; std::cout << Red << "Test not Passed!" << NOCOLOR << std::endl; Loading
test/htmlpagetest.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -38,10 +38,11 @@ int main(int arc,char *argv[]){ libhtmlpp::HtmlPage page; try{ libhtmlpp::Element *index=page.loadFile(argv[1]); std::string html; libhtmlpp::print(index,nullptr,html); std::string *html = new std::string; libhtmlpp::print(index,html); std::cout << html << std::endl; std::cout << Green << "Test Passed!" << NOCOLOR << std::endl; delete html; }catch(libhtmlpp::HTMLException &exp){ std::cout << exp.what() << std::endl; std::cout << Red << "Test not Passed!" << NOCOLOR << std::endl; Loading