Commit 25e365a0 authored by jan.koester's avatar jan.koester
Browse files

htmltable insert method finished

parent 6e829704
Loading
Loading
Loading
Loading
+22 −7
Changes for src/html.cpp: 22 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -448,6 +448,14 @@ libhtmlpp::HtmlElement::~HtmlElement(){
    }
}

void libhtmlpp::HtmlElement::setTagname(const char* name){
    _TagName=name;
}

const char* libhtmlpp::HtmlElement::getTagname(){
    return _TagName.c_str();
}

void libhtmlpp::HtmlElement::insertChild(libhtmlpp::Element* el){
    if(_childElement){
        delete _childElement;
@@ -640,11 +648,6 @@ libhtmlpp::HtmlElement * libhtmlpp::getRootNode(libhtmlpp::Element* el){
    return nullptr;
}

const char * libhtmlpp::HtmlElement::getTagname(){
    return _TagName.c_str();
}


libhtmlpp::HtmlElement *libhtmlpp::HtmlElement::getElementbyID(const char *id){
    for(Element *curel=this; curel; curel=curel->nextElement()){
        if(curel->getType()==HtmlEl){
@@ -754,10 +757,22 @@ libhtmlpp::HtmlTable::Row & libhtmlpp::HtmlTable::operator[](size_t pos){
    return *curel;
}

void libhtmlpp::HtmlTable::insert(libhtmlpp::Element* element){
void libhtmlpp::HtmlTable::insert(libhtmlpp::HtmlElement* element){
    element->setTagname("table");
    for(Row *crow=_firstRow; crow; crow=crow->_nextRow){
        HtmlElement *hrow= new HtmlElement("tr");

        for(Column *ccol=crow->_firstColumn; ccol; ccol=ccol->_nextColumn ){
            HtmlElement *hcol= new HtmlElement("td");
            hcol->appendChild(ccol->Data.parse());
            hrow->appendChild(hcol);
        }

        element->appendChild(hrow);
    }
}

void libhtmlpp::HtmlTable::parse(libhtmlpp::Element* element){
void libhtmlpp::HtmlTable::parse(libhtmlpp::HtmlElement* element){
}

void libhtmlpp::HtmlTable::setHeader(int count,...){
+3 −2
Changes for src/html.h: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ namespace libhtmlpp {
        void         insertChild(Element* el);
        void         appendChild(Element* el);

        void         setTagname(const char *name);
        const char  *getTagname();

        HtmlElement *getElementbyID(const char *id);
@@ -220,8 +221,8 @@ namespace libhtmlpp {
        Row& operator<<(const Row row);
        Row& operator[](size_t pos);

        void insert(Element *element);
        void parse(Element *element);
        void insert(HtmlElement *element);
        void parse(HtmlElement *element);

        void setHeader(int count,...);
        void deleteRow(size_t pos);