Commit 3e781f77 authored by jan.koester's avatar jan.koester
Browse files

some fixes

parent e5e60db1
Loading
Loading
Loading
Loading
+45 −36
Original line number Diff line number Diff line
@@ -298,9 +298,6 @@ void libhtmlpp::HtmlString::_buildtreenode(const libhtmlpp::DocElements *firstel
    auto checkterminator = [](const DocElements *termel, const DocElements *end){
        int i=0;

        if(((Element*)(termel->element))->getType()!=HtmlEl)
            return (DocElements*) nullptr;

        for (DocElements* curcel=termel->nextel; curcel; curcel=curcel->nextel) {

            if (curcel->element && curcel->element->getType()==HtmlEl && !curcel->terminator &&
@@ -367,7 +364,7 @@ NEXTDOCEL:
        goto NEXTDOCEL;
    }
}
#include <iostream>

libhtmlpp::Element *libhtmlpp::HtmlString::_buildTree() {
    DocElements *firstEl = nullptr, *lastEl = nullptr;

@@ -517,7 +514,7 @@ ENDCOMMANDTAGDOUND:
        }
    }

    HtmlElement *first = (HtmlElement*)firstEl->element;
    Element *first = firstEl->element;

    _buildtreenode(firstEl,lastEl);

@@ -719,28 +716,34 @@ void libhtmlpp::HtmlElement::insertChild(const libhtmlpp::Element* el){
    if(_childElement){
        remove(_childElement);
    }
    switch(el->getType()){

    Element *curel=_childElement;

    for(const Element *nextel=el; nextel; nextel=nextel->nextElement()){
            switch(nextel->getType()){
                case HtmlEl:
            _childElement=new HtmlElement;
                    curel=new HtmlElement;
                    break;
                case TextEl:
            _childElement=new TextElement;
                    curel=new TextElement;
                    break;
                case CommentEl:
            _childElement=new CommentElement;
            break;
                    curel=new CommentElement;
                default:
                    HTMLException ex;
            ex[HTMLException::Critical] << "insertChild: Unknown html element found !";
                    ex[HTMLException::Critical] << "appendChild: Unknown html element found: "<< el->getType() << " !";
                    throw ex;
            }
    _copy(_childElement,el);
            _copy(curel,nextel);
            if(nextel->nextElement())
                curel=curel->_nextElement;
    }
}

void libhtmlpp::HtmlElement::insertChild(const Element& el){
    insertChild(&el);
}

#include <iostream>
void libhtmlpp::HtmlElement::appendChild(const libhtmlpp::Element* el){
    if(_childElement){
        Element *curel=_childElement,*prev=nullptr;
@@ -749,7 +752,10 @@ void libhtmlpp::HtmlElement::appendChild(const libhtmlpp::Element* el){
            curel=curel->nextElement();
        }while(curel);

        switch(el->getType()){
        std::cout << el->getType() << std::endl;

        for(const Element *nextel=el; nextel; nextel=nextel->nextElement()){
            switch(nextel->getType()){
                case HtmlEl:
                    curel=new HtmlElement;
                    break;
@@ -758,13 +764,16 @@ void libhtmlpp::HtmlElement::appendChild(const libhtmlpp::Element* el){
                    break;
                case CommentEl:
                    curel=new CommentElement;
                    break;
                default:
                    HTMLException ex;
                    ex[HTMLException::Critical] << "appendChild: Unknown html element found: "<< el->getType() << " !";
                    throw ex;
            }

        _copy(curel,el);
            _copy(curel,nextel);
            if(nextel->nextElement())
                curel=curel->_nextElement;
        }

        if(prev){
            prev->_nextElement=curel;