Commit 820a1ec7 authored by jan.koester's avatar jan.koester
Browse files

warning api change !

parent 10e7a958
Loading
Loading
Loading
Loading
+21 −18
Original line number Diff line number Diff line
@@ -527,6 +527,7 @@ libhtmlpp::HtmlElement::HtmlElement() : Element(){
    _firstAttr=nullptr;
    _lastAttr=nullptr;
    _Type=HtmlEl;
    _TagName=nullptr;
}

libhtmlpp::HtmlElement::HtmlElement(const libhtmlpp::HtmlElement& hel) : HtmlElement(){
@@ -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);
@@ -859,6 +860,8 @@ void libhtmlpp::HtmlPage::saveFile(const char* path){
    fs << data;

    fs.close();

    delete data;
}

void libhtmlpp::HtmlPage::_CheckHeader(const HtmlString &page){
@@ -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);
@@ -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)
@@ -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;
@@ -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)
+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, 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);
    };

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

@@ -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:
+6 −4
Original line number Diff line number Diff line
@@ -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(){
@@ -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;

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