Loading src/html.cpp +34 −12 Changes for src/html.cpp: 34 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -183,8 +183,6 @@ libhtmlpp::HtmlElement* libhtmlpp::HtmlString::_buildTree(ssize_t& pos) { }*firstEl = nullptr, * lastEl = nullptr, * before = nullptr; int startpos = 0; for (int i = 0; i < _HTableSize; ++i) { if (!firstEl) { firstEl = new el; Loading Loading @@ -230,7 +228,8 @@ libhtmlpp::HtmlElement* libhtmlpp::HtmlString::_buildTree(ssize_t& pos) { if (curel->terminator) { for (el* parent = lastEl; parent; parent = parent->prevel) { if (parent->elhtml->_TagName == curel->elhtml->_TagName){ parent->elhtml->_Child = parent->elhtml->_nextElement; HtmlElement::Elements* cel = parent->elhtml->_addElement(); cel->_Child = parent->elhtml->_nextElement; if (parent->elhtml->_nextElement) parent->elhtml->_nextElement->_prevElement = nullptr; parent->elhtml->_nextElement = nullptr; Loading @@ -244,7 +243,6 @@ libhtmlpp::HtmlElement* libhtmlpp::HtmlString::_buildTree(ssize_t& pos) { } endcur = endcur->nextel; } } } } Loading Loading @@ -397,15 +395,16 @@ void libhtmlpp::HtmlString::_parseTree(){ libhtmlpp::HtmlElement::HtmlElement(const char *tagname){ _nextElement=nullptr; _prevElement=nullptr; _Child=nullptr; _firstAttr = nullptr; _lastAttr = nullptr; _TagName = tagname; _firstElement = nullptr; _lastElement = nullptr; } libhtmlpp::HtmlElement::~HtmlElement(){ delete _firstAttr; delete _Child; delete _firstElement; delete _nextElement; } Loading Loading @@ -454,7 +453,6 @@ void libhtmlpp::HtmlPage::loadFile(const char* path){ void libhtmlpp::HtmlElement::_print(HtmlElement* child) { for (HtmlElement* cur = child; cur; cur = cur->_nextElement) { if (!cur->_TagName.empty() && _Text.empty()) { _Cstr.append("<"); _Cstr.append(cur->_TagName.c_str()); for (HtmlElement::HtmlAttributes* curattr = cur->_firstAttr; curattr; curattr = curattr->_nextAttr) { Loading @@ -465,17 +463,20 @@ void libhtmlpp::HtmlElement::_print(HtmlElement* child) { _Cstr.append("\""); } _Cstr.append(">"); if (cur->_Child) _print(cur->_Child); for (HtmlElement::Elements* cel = cur->_firstElement; cel; cel=cel->_nextElement) { if (cel->_Child) { _print(cel->_Child); } else if (!cel->_Text.empty()) { _Cstr.append(cel->_Text.c_str()); } } _Cstr.append("</"); _Cstr.append(cur->_TagName.c_str()); _Cstr.append(">"); } else { _Cstr.append(_Text.c_str()); } } } const char* libhtmlpp::HtmlElement::printHtmlElement() { _Cstr.clear(); _print(this); Loading Loading @@ -527,6 +528,27 @@ libhtmlpp::HtmlElement::HtmlAttributes::~HtmlAttributes() { delete _nextAttr; } libhtmlpp::HtmlElement::Elements* libhtmlpp::HtmlElement::_addElement() { if (_firstElement) { _lastElement->_nextElement = new HtmlElement::Elements(); _lastElement = _lastElement->_nextElement; } else { _firstElement = new HtmlElement::Elements(); _lastElement = _firstElement; } return _lastElement; } libhtmlpp::HtmlElement::Elements::Elements() { _nextElement = nullptr; } libhtmlpp::HtmlElement::Elements::~Elements() { delete _Child; delete _nextElement; } libhtmlpp::HtmlTable::HtmlTable() : HtmlElement("table") { } Loading src/html.h +12 −4 Changes for src/html.h: 12 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ namespace libhtmlpp { protected: void _print(HtmlElement* child); HtmlElement* _Child; HtmlElement* _prevElement; HtmlElement* _nextElement; Loading @@ -65,6 +64,14 @@ namespace libhtmlpp { HtmlAttributes* _nextAttr; }; struct Elements { Elements(); ~Elements(); HtmlElement *_Child; sys::array<char> _Text; Elements *_nextElement; }; private: sys::array<char> _TagName; sys::array<char> _Cstr; Loading @@ -73,11 +80,12 @@ namespace libhtmlpp { HtmlAttributes* _firstAttr; HtmlAttributes* _lastAttr; friend class HtmlString; }; Elements *_addElement(); class HtmlText : public HtmlElement { Elements *_firstElement; Elements *_lastElement; friend class HtmlString; }; class HtmlDivLayer : public HtmlElement { Loading test/htmlfiles/right.html +2 −1 Changes for test/htmlfiles/right.html: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,8 +8,9 @@ </head> <body> <!-- body content --> <span>test text</span> <span>text 1</span> <!-- page content --> <span>text 2</span> weiterer text </body> </html> Loading
src/html.cpp +34 −12 Changes for src/html.cpp: 34 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -183,8 +183,6 @@ libhtmlpp::HtmlElement* libhtmlpp::HtmlString::_buildTree(ssize_t& pos) { }*firstEl = nullptr, * lastEl = nullptr, * before = nullptr; int startpos = 0; for (int i = 0; i < _HTableSize; ++i) { if (!firstEl) { firstEl = new el; Loading Loading @@ -230,7 +228,8 @@ libhtmlpp::HtmlElement* libhtmlpp::HtmlString::_buildTree(ssize_t& pos) { if (curel->terminator) { for (el* parent = lastEl; parent; parent = parent->prevel) { if (parent->elhtml->_TagName == curel->elhtml->_TagName){ parent->elhtml->_Child = parent->elhtml->_nextElement; HtmlElement::Elements* cel = parent->elhtml->_addElement(); cel->_Child = parent->elhtml->_nextElement; if (parent->elhtml->_nextElement) parent->elhtml->_nextElement->_prevElement = nullptr; parent->elhtml->_nextElement = nullptr; Loading @@ -244,7 +243,6 @@ libhtmlpp::HtmlElement* libhtmlpp::HtmlString::_buildTree(ssize_t& pos) { } endcur = endcur->nextel; } } } } Loading Loading @@ -397,15 +395,16 @@ void libhtmlpp::HtmlString::_parseTree(){ libhtmlpp::HtmlElement::HtmlElement(const char *tagname){ _nextElement=nullptr; _prevElement=nullptr; _Child=nullptr; _firstAttr = nullptr; _lastAttr = nullptr; _TagName = tagname; _firstElement = nullptr; _lastElement = nullptr; } libhtmlpp::HtmlElement::~HtmlElement(){ delete _firstAttr; delete _Child; delete _firstElement; delete _nextElement; } Loading Loading @@ -454,7 +453,6 @@ void libhtmlpp::HtmlPage::loadFile(const char* path){ void libhtmlpp::HtmlElement::_print(HtmlElement* child) { for (HtmlElement* cur = child; cur; cur = cur->_nextElement) { if (!cur->_TagName.empty() && _Text.empty()) { _Cstr.append("<"); _Cstr.append(cur->_TagName.c_str()); for (HtmlElement::HtmlAttributes* curattr = cur->_firstAttr; curattr; curattr = curattr->_nextAttr) { Loading @@ -465,17 +463,20 @@ void libhtmlpp::HtmlElement::_print(HtmlElement* child) { _Cstr.append("\""); } _Cstr.append(">"); if (cur->_Child) _print(cur->_Child); for (HtmlElement::Elements* cel = cur->_firstElement; cel; cel=cel->_nextElement) { if (cel->_Child) { _print(cel->_Child); } else if (!cel->_Text.empty()) { _Cstr.append(cel->_Text.c_str()); } } _Cstr.append("</"); _Cstr.append(cur->_TagName.c_str()); _Cstr.append(">"); } else { _Cstr.append(_Text.c_str()); } } } const char* libhtmlpp::HtmlElement::printHtmlElement() { _Cstr.clear(); _print(this); Loading Loading @@ -527,6 +528,27 @@ libhtmlpp::HtmlElement::HtmlAttributes::~HtmlAttributes() { delete _nextAttr; } libhtmlpp::HtmlElement::Elements* libhtmlpp::HtmlElement::_addElement() { if (_firstElement) { _lastElement->_nextElement = new HtmlElement::Elements(); _lastElement = _lastElement->_nextElement; } else { _firstElement = new HtmlElement::Elements(); _lastElement = _firstElement; } return _lastElement; } libhtmlpp::HtmlElement::Elements::Elements() { _nextElement = nullptr; } libhtmlpp::HtmlElement::Elements::~Elements() { delete _Child; delete _nextElement; } libhtmlpp::HtmlTable::HtmlTable() : HtmlElement("table") { } Loading
src/html.h +12 −4 Changes for src/html.h: 12 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ namespace libhtmlpp { protected: void _print(HtmlElement* child); HtmlElement* _Child; HtmlElement* _prevElement; HtmlElement* _nextElement; Loading @@ -65,6 +64,14 @@ namespace libhtmlpp { HtmlAttributes* _nextAttr; }; struct Elements { Elements(); ~Elements(); HtmlElement *_Child; sys::array<char> _Text; Elements *_nextElement; }; private: sys::array<char> _TagName; sys::array<char> _Cstr; Loading @@ -73,11 +80,12 @@ namespace libhtmlpp { HtmlAttributes* _firstAttr; HtmlAttributes* _lastAttr; friend class HtmlString; }; Elements *_addElement(); class HtmlText : public HtmlElement { Elements *_firstElement; Elements *_lastElement; friend class HtmlString; }; class HtmlDivLayer : public HtmlElement { Loading
test/htmlfiles/right.html +2 −1 Changes for test/htmlfiles/right.html: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,8 +8,9 @@ </head> <body> <!-- body content --> <span>test text</span> <span>text 1</span> <!-- page content --> <span>text 2</span> weiterer text </body> </html>