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

exceptions out of html.h

parent b871a13a
Loading
Loading
Loading
Loading
+18 −12
Changes for src/html.cpp: 18 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -74,9 +74,10 @@ void libhtmlpp::HtmlString::assign(const char* src) {
}

void libhtmlpp::HtmlString::insert(size_t pos, char src){
    HTMLException excp;
    if(pos < _DataSize){
        _HTMLException[HTMLException::Critical] << "HtmlString: out of String";
        throw _HTMLException;
        excp[HTMLException::Critical] << "HtmlString: out of String";
        throw excp;
    }
    _Data[pos]=src;
}
@@ -172,9 +173,10 @@ bool libhtmlpp::HtmlString::validate(){
}

void libhtmlpp::HtmlString::parse(){
    HTMLException excp;
    if(!validate()){
        _HTMLException[HTMLException::Critical] << "HtmlString: " << "parseTree parse Error html not validate !";
        throw _HTMLException;
        excp[HTMLException::Critical] << "HtmlString: " << "parseTree parse Error html not validate !";
        throw excp;
    }
    _parseTree();
    size_t tpos=(_HTableSize-1),spos=0;
@@ -191,6 +193,7 @@ void libhtmlpp::HtmlString::_InitString(){
}

void libhtmlpp::HtmlString::_parseTree(){
    HTMLException excp;
    if(_HTable){
        for(size_t i=0; i<_HTableSize; ++i){
            delete[] _HTable[i];
@@ -219,8 +222,8 @@ void libhtmlpp::HtmlString::_parseTree(){
                break;
            case HTMLTAG_CLOSE:
                if(!open){
                    _HTMLException[HTMLException::Error] << "HtmlString: parseTree parse Error couldn't fid opentag";
                    throw _HTMLException;
                    excp[HTMLException::Error] << "HtmlString: parseTree parse Error couldn't fid opentag";
                    throw excp;
                }
                _HTable[ip][2]=ii;
                ++ip;
@@ -339,23 +342,26 @@ READFILE:
}

void libhtmlpp::HtmlElement::setID(const char *id){
    HTMLException excp;
    if(!setter(id,getlen(id),&_ID)){
        _HTMLException[HTMLException::Error] << "HtmlTable can't id: " << id;
        throw _HTMLException;        
        excp[HTMLException::Error] << "HtmlTable can't id: " << id;
        throw excp;        
    }
}

void libhtmlpp::HtmlElement::setClass(const char *cname){
    HTMLException excp;
    if(!setter(cname,getlen(cname),&_Class)){
        _HTMLException[HTMLException::Error] << "HtmlTable can't class name: " << cname;
        throw _HTMLException;          
        excp[HTMLException::Error] << "HtmlTable can't class name: " << cname;
        throw excp;          
    }
}

void libhtmlpp::HtmlElement::setStyle(const char *css){
    HTMLException excp;
    if(!setter(css,getlen(css),&_Style,":;(),+~'")){
        _HTMLException[HTMLException::Error] << "HtmlTable can't set Style: " << css;
        throw _HTMLException;          
        excp[HTMLException::Error] << "HtmlTable can't set Style: " << css;
        throw excp;          
    }
}

+0 −6
Changes for src/html.h: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <sys/types.h>

#include "htmlpp/exception.h"

#ifndef HTML_H
#define HTML_H

@@ -61,7 +59,6 @@ namespace libhtmlpp {
        char          *_ID;
        char          *_Class;
        char          *_Style;
        HTMLException  _HTMLException;
        friend class HtmlString;
    };
        
@@ -99,7 +96,6 @@ namespace libhtmlpp {
        ssize_t         **_HTable;
        size_t            _HTableSize;
        HtmlElement      *_HtmlRootNode;
        HTMLException     _HTMLException;
    };

    class HtmlPage {
@@ -116,7 +112,6 @@ namespace libhtmlpp {
        const char *printHtml();
    private:
        HtmlString    *_HtmlDocument;
        HTMLException  _HTMLException;
    }; 
    
    class HtmlTable : public HtmlElement{
@@ -134,7 +129,6 @@ namespace libhtmlpp {
            friend class HtmlTable;
        };
    private:
        HTMLException  _HTMLException;
    };
};