Commit e998da50 authored by Jan Koester's avatar Jan Koester
Browse files

added ultoa and char for assign operator

parent 325c75e3
Loading
Loading
Loading
Loading
+13 −0
Changes for src/html.cpp: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -130,6 +130,19 @@ libhtmlpp::HtmlString &libhtmlpp::HtmlString::operator<<(int src){
    return *this;
}

libhtmlpp::HtmlString &libhtmlpp::HtmlString::operator<<(unsigned long src){
    char *buf=new char[sizeof(int)+1];
    ultoa(src,buf);
    assign(buf);
    delete[] buf;
    return *this;
}

libhtmlpp::HtmlString &libhtmlpp::HtmlString::operator<<(char src){
    push_back(src);
    return *this;
}

const char *libhtmlpp::HtmlString::c_str() {
    Console con;
    HtmlElement *curel=_HtmlRootNode,*nextel=nullptr;
+2 −0
Changes for src/html.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ namespace libhtmlpp {
        
        HtmlString &operator<<(const char *src);
        HtmlString &operator<<(int src);
        HtmlString &operator<<(char src);
        HtmlString &operator<<(unsigned long src);

        const char        *c_str();
        size_t             size();
+10 −0
Changes for src/utils.h: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -66,6 +66,16 @@ namespace libhtmlpp {
        reverse(s);
    }

    inline void ultoa(unsigned long n, char s[]){
        unsigned int i;
        i = 0;
        do {       /* generate digits in reverse order */
            s[i++] = n % 10 + '0';   /* get next digit */
        } while ((n /= 10) > 0);     /* delete it */
        s[i] = '\0';
        reverse(s);
    }
    
    inline bool isdigit(const char src){
        const char numbers[10]={0,1,2,3,4,5,6,7,8,9};
        for(int i=0; i<10; ++i){