Commit d2f2829a authored by jan.koester's avatar jan.koester
Browse files

api change backwards

parent 89815063
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -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);
@@ -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);
@@ -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){
@@ -1011,7 +1011,7 @@ PRINTNEXTEL:
        }break;

        case TextEl :{
            (*output)->append(*((TextElement*)el)->_Text);
            output->append(*((TextElement*)el)->_Text);

            if (el->_nextElement) {
                el=el->_nextElement;
@@ -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){
+4 −4
Original line number Diff line number Diff line
@@ -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);
    };

@@ -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);
    };

@@ -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:
+2 −2
Original line number Diff line number Diff line
@@ -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;
    }
@@ -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;

+1 −1
Original line number Diff line number Diff line
@@ -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;