Loading src/html.cpp +74 −10 Changes for src/html.cpp: 74 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <fstream> #include "utils.h" Loading Loading @@ -724,12 +726,61 @@ libhtmlpp::HtmlTable::HtmlTable(){ libhtmlpp::HtmlTable::~HtmlTable(){ } libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::operator<<(const libhtmlpp::HtmlTable::Row row){ if(_firstRow){ _lastRow->_nextRow=new Row(row); _lastRow=_lastRow->_nextRow; }else{ _firstRow= new Row(row); _lastRow=_firstRow; } ++_count; return *_lastRow; } libhtmlpp::HtmlTable::Row & libhtmlpp::HtmlTable::operator[](size_t pos){ if(!_firstRow || _count<pos){ libhtmlpp::HTMLException exp; exp[HTMLException::Error] << "HtmlTable: Row at this position won't exists !"; throw exp; } size_t cpos=0; Row *curel=nullptr; for(curel=_firstRow; curel; curel=curel->_nextRow){ if(cpos==pos) return *curel; ++cpos; } return *curel; } void libhtmlpp::HtmlTable::insert(libhtmlpp::Element* element){ } void libhtmlpp::HtmlTable::parse(libhtmlpp::Element* element){ } void libhtmlpp::HtmlTable::setHeader(int count,...){ va_list args; va_start(args,count); for (int i = 0; i < count; ++i) { _header << va_arg(args, const char*); } } void libhtmlpp::HtmlTable::deleteRow(size_t pos){ Row *drow=&(*this)[pos]; try{ Row *prev=&(*this)[pos-1]; prev->_nextRow=drow->_nextRow; }catch(...){} drow->_nextRow=nullptr; --_count; delete drow; } libhtmlpp::HtmlTable::Column::Column(){ _nextColumn=nullptr; } Loading @@ -755,6 +806,12 @@ libhtmlpp::HtmlTable::Row::~Row(){ delete _nextRow; } libhtmlpp::HtmlTable::Row::Row(const libhtmlpp::HtmlTable::Row& row){ for(Column *curel=row._firstColumn; curel; curel=curel->_nextColumn){ *this << curel->Data; } } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(libhtmlpp::HtmlString value){ if(_firstColumn){ _lastColumn->_nextColumn=new Column; Loading @@ -781,14 +838,10 @@ libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(int 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){ libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator[](size_t pos){ if(!_firstColumn || _count<pos){ libhtmlpp::HTMLException exp; exp[HTMLException::Error] << "HtmlTable: Row at this position won't exists !"; exp[HTMLException::Error] << "HtmlTable: Column at this position won't exists !"; throw exp; } size_t cpos=0; Loading @@ -801,9 +854,20 @@ libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator[](int pos){ return *curel; } void libhtmlpp::HtmlTable::Row::setHeader(const libhtmlpp::HtmlTable::Column col){ _header = col; void libhtmlpp::HtmlTable::Row::delColumn(size_t pos){ Column *dcol=&(*this)[pos]; try{ Column *prev=&(*this)[pos-1]; prev->_nextColumn=dcol->_nextColumn; }catch(...){} dcol->_nextColumn=nullptr; --_count; delete dcol; } void libhtmlpp::HtmlTable::Row::clear(){ delete _firstColumn; _firstColumn = nullptr; _lastColumn = nullptr; _count = 0; } src/html.h +11 −4 Changes for src/html.h: 11 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -198,30 +198,37 @@ namespace libhtmlpp { class Row { public: Row(); Row(const Row &row); ~Row(); Column& operator<<(HtmlString value); Column& operator<<(const char* value); Column& operator<<(int value); Column& operator[](int pos); Column& operator[](size_t pos); void setHeader(const Column col); void delColumn(size_t pos); void clear(); private: Column *_firstColumn; Column *_lastColumn; Column _header; Row *_nextRow; size_t _count; friend class HtmlTable; }; Row& operator<<(const Column col); Row& operator<<(const Row row); Row& operator[](size_t pos); void insert(Element *element); void parse(Element *element); void setHeader(int count,...); void deleteRow(size_t pos); private: Row *_firstRow; Row *_lastRow; Row _header; size_t _count; }; }; Loading
src/html.cpp +74 −10 Changes for src/html.cpp: 74 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <fstream> #include "utils.h" Loading Loading @@ -724,12 +726,61 @@ libhtmlpp::HtmlTable::HtmlTable(){ libhtmlpp::HtmlTable::~HtmlTable(){ } libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::operator<<(const libhtmlpp::HtmlTable::Row row){ if(_firstRow){ _lastRow->_nextRow=new Row(row); _lastRow=_lastRow->_nextRow; }else{ _firstRow= new Row(row); _lastRow=_firstRow; } ++_count; return *_lastRow; } libhtmlpp::HtmlTable::Row & libhtmlpp::HtmlTable::operator[](size_t pos){ if(!_firstRow || _count<pos){ libhtmlpp::HTMLException exp; exp[HTMLException::Error] << "HtmlTable: Row at this position won't exists !"; throw exp; } size_t cpos=0; Row *curel=nullptr; for(curel=_firstRow; curel; curel=curel->_nextRow){ if(cpos==pos) return *curel; ++cpos; } return *curel; } void libhtmlpp::HtmlTable::insert(libhtmlpp::Element* element){ } void libhtmlpp::HtmlTable::parse(libhtmlpp::Element* element){ } void libhtmlpp::HtmlTable::setHeader(int count,...){ va_list args; va_start(args,count); for (int i = 0; i < count; ++i) { _header << va_arg(args, const char*); } } void libhtmlpp::HtmlTable::deleteRow(size_t pos){ Row *drow=&(*this)[pos]; try{ Row *prev=&(*this)[pos-1]; prev->_nextRow=drow->_nextRow; }catch(...){} drow->_nextRow=nullptr; --_count; delete drow; } libhtmlpp::HtmlTable::Column::Column(){ _nextColumn=nullptr; } Loading @@ -755,6 +806,12 @@ libhtmlpp::HtmlTable::Row::~Row(){ delete _nextRow; } libhtmlpp::HtmlTable::Row::Row(const libhtmlpp::HtmlTable::Row& row){ for(Column *curel=row._firstColumn; curel; curel=curel->_nextColumn){ *this << curel->Data; } } libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(libhtmlpp::HtmlString value){ if(_firstColumn){ _lastColumn->_nextColumn=new Column; Loading @@ -781,14 +838,10 @@ libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator<<(int 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){ libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator[](size_t pos){ if(!_firstColumn || _count<pos){ libhtmlpp::HTMLException exp; exp[HTMLException::Error] << "HtmlTable: Row at this position won't exists !"; exp[HTMLException::Error] << "HtmlTable: Column at this position won't exists !"; throw exp; } size_t cpos=0; Loading @@ -801,9 +854,20 @@ libhtmlpp::HtmlTable::Column & libhtmlpp::HtmlTable::Row::operator[](int pos){ return *curel; } void libhtmlpp::HtmlTable::Row::setHeader(const libhtmlpp::HtmlTable::Column col){ _header = col; void libhtmlpp::HtmlTable::Row::delColumn(size_t pos){ Column *dcol=&(*this)[pos]; try{ Column *prev=&(*this)[pos-1]; prev->_nextColumn=dcol->_nextColumn; }catch(...){} dcol->_nextColumn=nullptr; --_count; delete dcol; } void libhtmlpp::HtmlTable::Row::clear(){ delete _firstColumn; _firstColumn = nullptr; _lastColumn = nullptr; _count = 0; }
src/html.h +11 −4 Changes for src/html.h: 11 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -198,30 +198,37 @@ namespace libhtmlpp { class Row { public: Row(); Row(const Row &row); ~Row(); Column& operator<<(HtmlString value); Column& operator<<(const char* value); Column& operator<<(int value); Column& operator[](int pos); Column& operator[](size_t pos); void setHeader(const Column col); void delColumn(size_t pos); void clear(); private: Column *_firstColumn; Column *_lastColumn; Column _header; Row *_nextRow; size_t _count; friend class HtmlTable; }; Row& operator<<(const Column col); Row& operator<<(const Row row); Row& operator[](size_t pos); void insert(Element *element); void parse(Element *element); void setHeader(int count,...); void deleteRow(size_t pos); private: Row *_firstRow; Row *_lastRow; Row _header; size_t _count; }; };