Loading src/html.cpp +94 −9 Changes for src/html.cpp: 94 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -76,6 +76,11 @@ libhtmlpp::HtmlString::~HtmlString(){ clear(); } libhtmlpp::HtmlString::HtmlString(const libhtmlpp::HtmlString& str){ _Data=str._Data; } void libhtmlpp::HtmlString::append(const char* src, size_t srcsize){ _Data.append(src,srcsize); } Loading Loading @@ -704,21 +709,101 @@ libhtmlpp::HtmlElement::Attributes::~Attributes() { delete _nextAttr; } libhtmlpp::HtmlTable::HtmlTable(HtmlElement *element){ _Element=element; if(_Element->_TagName!="table"){ HTMLException exp; exp[HTMLException::Critical] << "Element ist not table Aborting!"; throw exp; libhtmlpp::TextElement::TextElement(){ _Type=TextEl; } libhtmlpp::TextElement::~TextElement(){ } libhtmlpp::HtmlTable::HtmlTable(){ _firstRow=nullptr; _lastRow=nullptr; } libhtmlpp::HtmlTable::~HtmlTable(){ } libhtmlpp::TextElement::TextElement(){ _Type=TextEl; void libhtmlpp::HtmlTable::insert(libhtmlpp::Element* element){ } libhtmlpp::TextElement::~TextElement(){ void libhtmlpp::HtmlTable::parse(libhtmlpp::Element* element){ } libhtmlpp::HtmlTable::Column::Column(){ _nextColumn=nullptr; } libhtmlpp::HtmlTable::Column::~Column(){ delete _nextColumn; } libhtmlpp::HtmlTable::Column::Column(const libhtmlpp::HtmlTable::Column& col){ Data = col.Data; } libhtmlpp::HtmlTable::Row::Row(){ _firstColumn=nullptr; _lastColumn=nullptr; _nextRow=nullptr; _count=0; } libhtmlpp::HtmlTable::Row::~Row(){ delete _firstColumn; delete _nextRow; } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(libhtmlpp::HtmlString value){ if(_firstColumn){ _lastColumn->_nextColumn=new Column; _lastColumn=_lastColumn->_nextColumn; }else{ _firstColumn= new Column; _lastColumn=_firstColumn; } _lastColumn->Data=value; ++_count; return *_lastColumn; } libhtmlpp::HtmlTable::Column &libhtmlpp::HtmlTable::Row::operator<<(const char* value){ HtmlString buf; buf << value; return *this << buf; } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(int value){ char buf[255]; snprintf(buf,255,"%d",value); return *this << buf; } libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::operator<<(const libhtmlpp::HtmlTable::Column col){ return *_lastRow; } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator[](int pos){ if(!_firstColumn || _count<pos){ libhtmlpp::HTMLException exp; exp[HTMLException::Error] << "HtmlTable: Row at this position won't exists !"; throw exp; } size_t cpos=0; Column *curel=nullptr; for(curel=_firstColumn; curel; curel=curel->_nextColumn){ if(cpos==pos) return *curel; ++cpos; } return *curel; } void libhtmlpp::HtmlTable::Row::setHeader(const libhtmlpp::HtmlTable::Column col){ _header = col; } src/html.h +48 −17 Changes for src/html.h: 48 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -124,26 +124,10 @@ namespace libhtmlpp { HtmlElement *getRootNode(Element* el); class HtmlTable { public: HtmlTable(HtmlElement *element); ~HtmlTable(); class Row { public: Row& operator<<(const char* value); Row& operator<<(int value); private: Row(); ~Row(); Row* _nextRow; }; private: HtmlElement *_Element; }; class HtmlString { public: HtmlString(); HtmlString(const HtmlString &str); ~HtmlString(); void append(const char* src, size_t srcsize); Loading Loading @@ -193,4 +177,51 @@ namespace libhtmlpp { void _CheckHeader(); HtmlString _Page; }; class HtmlTable { public: HtmlTable(); ~HtmlTable(); class Column { public: HtmlString Data; private: Column(); Column(const Column &col); ~Column(); Column *_nextColumn; friend class HtmlTable; }; class Row { public: Row(); ~Row(); Column& operator<<(HtmlString value); Column& operator<<(const char* value); Column& operator<<(int value); Column& operator[](int pos); void setHeader(const Column col); private: Column *_firstColumn; Column *_lastColumn; Column _header; Row *_nextRow; size_t _count; friend class HtmlTable; }; Row& operator<<(const Column col); void insert(Element *element); void parse(Element *element); private: Row *_firstRow; Row *_lastRow; }; }; Loading
src/html.cpp +94 −9 Changes for src/html.cpp: 94 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -76,6 +76,11 @@ libhtmlpp::HtmlString::~HtmlString(){ clear(); } libhtmlpp::HtmlString::HtmlString(const libhtmlpp::HtmlString& str){ _Data=str._Data; } void libhtmlpp::HtmlString::append(const char* src, size_t srcsize){ _Data.append(src,srcsize); } Loading Loading @@ -704,21 +709,101 @@ libhtmlpp::HtmlElement::Attributes::~Attributes() { delete _nextAttr; } libhtmlpp::HtmlTable::HtmlTable(HtmlElement *element){ _Element=element; if(_Element->_TagName!="table"){ HTMLException exp; exp[HTMLException::Critical] << "Element ist not table Aborting!"; throw exp; libhtmlpp::TextElement::TextElement(){ _Type=TextEl; } libhtmlpp::TextElement::~TextElement(){ } libhtmlpp::HtmlTable::HtmlTable(){ _firstRow=nullptr; _lastRow=nullptr; } libhtmlpp::HtmlTable::~HtmlTable(){ } libhtmlpp::TextElement::TextElement(){ _Type=TextEl; void libhtmlpp::HtmlTable::insert(libhtmlpp::Element* element){ } libhtmlpp::TextElement::~TextElement(){ void libhtmlpp::HtmlTable::parse(libhtmlpp::Element* element){ } libhtmlpp::HtmlTable::Column::Column(){ _nextColumn=nullptr; } libhtmlpp::HtmlTable::Column::~Column(){ delete _nextColumn; } libhtmlpp::HtmlTable::Column::Column(const libhtmlpp::HtmlTable::Column& col){ Data = col.Data; } libhtmlpp::HtmlTable::Row::Row(){ _firstColumn=nullptr; _lastColumn=nullptr; _nextRow=nullptr; _count=0; } libhtmlpp::HtmlTable::Row::~Row(){ delete _firstColumn; delete _nextRow; } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(libhtmlpp::HtmlString value){ if(_firstColumn){ _lastColumn->_nextColumn=new Column; _lastColumn=_lastColumn->_nextColumn; }else{ _firstColumn= new Column; _lastColumn=_firstColumn; } _lastColumn->Data=value; ++_count; return *_lastColumn; } libhtmlpp::HtmlTable::Column &libhtmlpp::HtmlTable::Row::operator<<(const char* value){ HtmlString buf; buf << value; return *this << buf; } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(int value){ char buf[255]; snprintf(buf,255,"%d",value); return *this << buf; } libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::operator<<(const libhtmlpp::HtmlTable::Column col){ return *_lastRow; } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator[](int pos){ if(!_firstColumn || _count<pos){ libhtmlpp::HTMLException exp; exp[HTMLException::Error] << "HtmlTable: Row at this position won't exists !"; throw exp; } size_t cpos=0; Column *curel=nullptr; for(curel=_firstColumn; curel; curel=curel->_nextColumn){ if(cpos==pos) return *curel; ++cpos; } return *curel; } void libhtmlpp::HtmlTable::Row::setHeader(const libhtmlpp::HtmlTable::Column col){ _header = col; }
src/html.h +48 −17 Changes for src/html.h: 48 added lines, 17 removed lines. Original line number Diff line number Diff line Loading @@ -124,26 +124,10 @@ namespace libhtmlpp { HtmlElement *getRootNode(Element* el); class HtmlTable { public: HtmlTable(HtmlElement *element); ~HtmlTable(); class Row { public: Row& operator<<(const char* value); Row& operator<<(int value); private: Row(); ~Row(); Row* _nextRow; }; private: HtmlElement *_Element; }; class HtmlString { public: HtmlString(); HtmlString(const HtmlString &str); ~HtmlString(); void append(const char* src, size_t srcsize); Loading Loading @@ -193,4 +177,51 @@ namespace libhtmlpp { void _CheckHeader(); HtmlString _Page; }; class HtmlTable { public: HtmlTable(); ~HtmlTable(); class Column { public: HtmlString Data; private: Column(); Column(const Column &col); ~Column(); Column *_nextColumn; friend class HtmlTable; }; class Row { public: Row(); ~Row(); Column& operator<<(HtmlString value); Column& operator<<(const char* value); Column& operator<<(int value); Column& operator[](int pos); void setHeader(const Column col); private: Column *_firstColumn; Column *_lastColumn; Column _header; Row *_nextRow; size_t _count; friend class HtmlTable; }; Row& operator<<(const Column col); void insert(Element *element); void parse(Element *element); private: Row *_firstRow; Row *_lastRow; }; };