Commit 9c3ad78d authored by jan.koester's avatar jan.koester
Browse files

test

parent 73629440
Loading
Loading
Loading
Loading
+14 −19
Original line number Diff line number Diff line
@@ -239,25 +239,27 @@ void libhtmlpp::HtmlString::parse(HtmlElement &dest) {
    HTMLException excp;
    _parseTree();
    long pos = 0;
    dest=(HtmlElement*)_buildTree(pos);
    HtmlElement *buf;
    _buildTree(&buf,pos);
    dest=buf;
    delete buf;
}

bool libhtmlpp::HtmlString::validate(std::string *err){
    try{
        _parseTree();
        long pos = 0;
        HtmlElement *el=(HtmlElement*)_buildTree(pos);
        if(el){
            delete el;
        HtmlElement *buf;
        _buildTree(&buf,pos);
        delete buf;
        return true;
        }
    }catch(HTMLException &e){
        *err=e.what();
    }
    return false;
}

libhtmlpp::Element* libhtmlpp::HtmlString::_buildtreenode(libhtmlpp::DocElements *firstel,libhtmlpp::DocElements *lastel){
void libhtmlpp::HtmlString::_buildtreenode(libhtmlpp::DocElements *firstel,libhtmlpp::DocElements *lastel){

    struct cpyel {
        cpyel(){
@@ -280,8 +282,6 @@ libhtmlpp::Element* libhtmlpp::HtmlString::_buildtreenode(libhtmlpp::DocElements
    DocElements *next=firstel->nextel;
    DocElements *end=lastel;

    Element* first=start->element;

    auto checkterminator = [](DocElements *termel, DocElements *end){
        int i=0;

@@ -367,11 +367,9 @@ NEXTDOCEL:
    }

    lastel=nullptr;

    return first;
}

libhtmlpp::Element* libhtmlpp::HtmlString::_buildTree(long& pos) {
void libhtmlpp::HtmlString::_buildTree(HtmlElement **html,long& pos) {
    DocElements *firstEl = nullptr, *lastEl = nullptr;

    auto addelement = [](DocElements **first,DocElements **last){
@@ -449,6 +447,8 @@ libhtmlpp::Element* libhtmlpp::HtmlString::_buildTree(long& pos) {
        }
    }

    *html=(HtmlElement*)firstEl->element;

    return _buildtreenode(firstEl,lastEl);
}

@@ -751,17 +751,12 @@ bool libhtmlpp::HtmlElement::operator==(const HtmlElement &hel){
    return false;
}

libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Element hel){
    _copy(this,&hel);
    return *this;
}

libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Element& hel){
libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::HtmlElement& hel){
    _copy(this,&hel);
    return *this;
}

libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::Element* hel){
libhtmlpp::HtmlElement & libhtmlpp::HtmlElement::operator=(const libhtmlpp::HtmlElement* hel){
    _copy(this,hel);
    return *this;
}
+4 −5
Original line number Diff line number Diff line
@@ -83,9 +83,8 @@ namespace libhtmlpp {
        HtmlElement(const HtmlElement *hel);
        ~HtmlElement();

        HtmlElement& operator=(const Element  hel);
        HtmlElement& operator=(const Element &hel);
        HtmlElement& operator=(const Element *hel);
        HtmlElement& operator=(const HtmlElement &hel);
        HtmlElement& operator=(const HtmlElement *hel);

        bool operator==(const HtmlElement *hel);
        bool operator==(const HtmlElement &hel);
@@ -219,8 +218,8 @@ namespace libhtmlpp {
    private:
        void               _parseTree();
        void               _serialelize(std::vector<char> in, HtmlElement* out);
        Element*           _buildTree(long& pos);
        Element*           _buildtreenode(DocElements *firstel,DocElements *lastel);
        void               _buildTree(HtmlElement **html,long& pos);
        void               _buildtreenode(DocElements *firstel,DocElements *lastel);
        std::vector<char>  _Data;
        std::vector<char>  _CStr;
        long**             _HTable;
+2 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class HtmlCopy{
public:
    HtmlCopy(libhtmlpp::Element *index){
    HtmlCopy(libhtmlpp::HtmlElement &index){
        index2=index;
        libhtmlpp::HtmlElement  el("span");
        el.setAttribute("id","txt3");
@@ -65,7 +65,7 @@ int main(int arc,char *argv[]){

        page.loadFile(index,argv[1]);

        HtmlCopy cpy(&index);
        HtmlCopy cpy(index);


        libhtmlpp::HtmlString html;