Commit 756de2d0 authored by Jan Koester's avatar Jan Koester
Browse files

work with new systempp

parent 53ddfb57
Loading
Loading
Loading
Loading
+8 −0
Changes for CMakeLists.txt: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,14 @@ find_package(systempp REQUIRED)
set(LIBV "1.0.0")
set(Upstream_VERSION 1.0.0)

set(CMAKE_CXX_FLAGS 
    "-fPIC\
    ${CMAKE_CXX_FLAGS} \
    -Wall \
    -nostdlib \
    -nodefaultlibs"
)

configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
+4 −7
Changes for src/CMakeLists.txt: 4 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -18,13 +18,10 @@ add_library(htmlpp-static STATIC ${libhtmlSrcs} )

generate_export_header(htmlpp)

IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
  target_link_libraries(htmlpp systempp wsock32 ws2_32)
  target_link_libraries(htmlpp-static systempp wsock32 ws2_32)
ELSE()
  target_link_libraries(htmlpp systempp)
  target_link_libraries(htmlpp-static systempp)    
ENDIF()

target_link_libraries(htmlpp systempp crt1)
target_link_libraries(htmlpp-static systempp crt1)    


SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")

+25 −32
Changes for src/html.cpp: 25 added lines, 32 removed lines.
Original line number Diff line number Diff line
@@ -25,9 +25,8 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <iostream>
#include <fstream>

#include <systempp/sysconsole.h>
#include <systempp/sysfile.h>
#include <systempp/sysutils.h>
#include <systempp/sysexception.h>

@@ -61,7 +60,7 @@ libhtmlpp::HtmlString::~HtmlString(){
}

void libhtmlpp::HtmlString::assign(const char* src, size_t srcsize){
    _Data.insert(_Data.end(),src,src+srcsize);
    _Data.write(src,srcsize);
}

void libhtmlpp::HtmlString::push_back(const char src){
@@ -135,22 +134,16 @@ libhtmlpp::HtmlString &libhtmlpp::HtmlString::operator<<(char src){
}

const char *libhtmlpp::HtmlString::c_str() {
    size_t level=0;
//     _printHtml(_HtmlRootNode,level);
    delete[] _cbuffer;
    _cbuffer = new char[_Data.size()+1];
    sys::scopy(_Data.data(),_Data.data()+_Data.size(),_cbuffer);
    _cbuffer[_Data.size()]='\0';
    return _cbuffer;
    return _Data.c_str();
}

void libhtmlpp::HtmlString::_printHtml(libhtmlpp::HtmlElement* node,size_t &level){
    if(node){
            for(size_t i=0; i<level; ++i){
                std::cout << " ";
                sys::cout << " ";
            }
            std::cout << "<" << node->_Tag << ">"
                                         << std::endl;
            sys::cout << "<" << node->_Tag << ">"
                                         << sys::endl;
            
            if(node->_Child){
                size_t lvl=level+2;
@@ -158,10 +151,10 @@ void libhtmlpp::HtmlString::_printHtml(libhtmlpp::HtmlElement* node,size_t &leve
            }
            
            for(size_t i=0; i<level; ++i){
                std::cout << " ";
                sys::cout << " ";
            }
            std::cout << "</" << node->_Tag << ">" 
                                         << std::endl;
            sys::cout << "</" << node->_Tag << ">" 
                                         << sys::endl;
            if(node->_nextElement)
                _printHtml(node->_nextElement,level);
    }           
@@ -335,7 +328,7 @@ void libhtmlpp::HtmlString::_parseTree(){
int libhtmlpp::HtmlString::_serialzeTags(size_t spos, size_t epos, char **value,size_t &valuesize){
    size_t anpos=0,enpos=0,i=spos;
    int term=-1;
    std::string Doctype;
    sys::array<char> Doctype;
//     while(i<epos){
//         switch(_Data[i]){
//             case('!'):
@@ -430,25 +423,25 @@ const char *libhtmlpp::HtmlPage::printHtml(){
void libhtmlpp::HtmlPage::loadFile(const char* path){
    delete _HtmlDocument;
    _HtmlDocument= new HtmlString();
    std::fstream fs;
    sys::file fs;
    try{
        fs.open(path,std::ios::in);
        fs.open(path,0);
    }catch(sys::SystemException &e){
        HTMLException excp;
        throw excp[HTMLException::Critical] << e.what();
    }
    fs.seekg (0, fs.end);
    int length = fs.tellg();
    fs.seekg (0, fs.beg);
    
    char *buf=new char[length];
    if(fs.read(buf,HTML_BLOCKSIZE)){
        char *dest;
        size_t cdd=sys::cleannewline(buf,length,&dest);
        _HtmlDocument->assign(dest,cdd);
        delete[] dest;
        _HtmlDocument->parse();
    }
//     fs.seekg (0, fs.end);
//     int length = fs.tellg();
//     fs.seekg (0, fs.beg);
//     
//     char *buf=new char[length];
//     if(fs.read(buf,HTML_BLOCKSIZE)){
//         char *dest;
//         size_t cdd=sys::cleannewline(buf,length,&dest);
//         _HtmlDocument->assign(dest,cdd);
//         delete[] dest;
//         _HtmlDocument->parse();
//     }
    HTMLException excp;
    throw excp[HTMLException::Critical] << "Could not read file";
}
+2 −2
Changes for src/html.h: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <vector>
#include <systempp/sysarray.h>

#include <sys/types.h>

@@ -99,7 +99,7 @@ namespace libhtmlpp {
        HtmlElement      *_serialzeElements(HtmlElement *prevnode,ssize_t &pos);
        int               _serialzeTags(size_t spos,size_t epos,char **value,size_t &valuesize);
        void              _printHtml(HtmlElement *node,size_t &level);
        std::vector<char>       _Data;
        sys::array<char>        _Data;
        char                   *_cbuffer;
        ssize_t               **_HTable;
        size_t                  _HTableSize;
+5 −5
Changes for test/csstest.cpp: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <iostream>
#include <systempp/sysconsole.h>

#include "../src/html.h"

@@ -37,18 +37,18 @@ int main(){
    libhtmlpp::HtmlTable table;
    try{
        table.setStyle(":;(),+~'");
        std::cout  << Green << "Test Passed!" << NOCOLOR << std::endl;
        sys::cout  << Green << "Test Passed!" << NOCOLOR << sys::endl;
    }catch(...){
        std::cout   << Red << "Test not Passed!" << NOCOLOR << std::endl;
        sys::cout   << Red << "Test not Passed!" << NOCOLOR << sys::endl;
        return -1;
    }
    
    try{
        table.setStyle("\"");
        std::cout   << Red << "Test not Passed!" << NOCOLOR<< std::endl;
        sys::cout   << Red << "Test not Passed!" << NOCOLOR<< sys::endl;
        return -1;
    }catch(...){
        std::cout   << Green << "Test Passed!" << NOCOLOR << std::endl;
        sys::cout   << Green << "Test Passed!" << NOCOLOR << sys::endl;
    }
    return 0;
}
Loading