Commit d00944c2 authored by jan.koester's avatar jan.koester
Browse files

use stringview

parent 6326d4ef
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <iostream>
#include <cstdarg>
#include <compare>
#include <string_view>

#include <algorithm>
#include <fstream>
@@ -58,7 +59,7 @@

namespace libhtmlpp {

    const char *ContainerTypes[]={
    const std::string_view ContainerTypes[]={
        "div",
        "style",
        "span",
@@ -78,8 +79,7 @@ namespace libhtmlpp {
        "footer",
        "header",
        "main",
        "html",
        nullptr
        "html"
    };

    class DocElements {
@@ -101,9 +101,6 @@ namespace libhtmlpp {
    };
};

libhtmlpp::HtmlString::HtmlString(){
}

libhtmlpp::HtmlString::HtmlString(char str) : HtmlString(){
    _Data.push_back(str);
}
@@ -277,7 +274,7 @@ void libhtmlpp::HtmlString::_buildtreenode(
    Element *prev_el_in_tree = nullptr;

    auto checkContainer = [&](const std::string &tag) {
        for (size_t i = 0; ContainerTypes[i]; ++i) {
        for (size_t i = 0; i<sizeof(ContainerTypes); ++i) {
            if (tag == ContainerTypes[i]) {
                return true;
            }
@@ -1597,8 +1594,8 @@ void libhtmlpp::print(const Element &element, HtmlString &output,bool formated)
    const Element *el=&element;

    auto isContainer = [](const std::string &tagname) {
        for(int i=0; ContainerTypes[i]; ++i){
            if(std::equal(tagname.begin(),tagname.end(),ContainerTypes[i]))
        for(int i=0; i<sizeof(ContainerTypes); ++i){
            if(tagname==ContainerTypes[i])
                return true;
        }
        return false;
+1 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ namespace libhtmlpp {

        using value_type = char;

        HtmlString();
        HtmlString()=default;
        HtmlString(const HtmlString &str);
        HtmlString(char str);
        HtmlString(const std::string &str);