Commit 518b82bf authored by jan.koester's avatar jan.koester
Browse files

test

parent 554bc947
Loading
Loading
Loading
Loading
+36 −11
Original line number Diff line number Diff line
@@ -1762,7 +1762,7 @@ int libhtmlpp::HtmlElement::getType() const{


libhtmlpp::HtmlTable::HtmlTable(){
    _firstRow=std::make_unique<Row>();
    _firstRow=nullptr;
    _lastRow=nullptr;
    _count = 0;
}
@@ -1770,19 +1770,43 @@ libhtmlpp::HtmlTable::HtmlTable(){
libhtmlpp::HtmlTable::~HtmlTable(){
}

libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::operator<<(const libhtmlpp::HtmlTable::Row row){
    std::unique_ptr<Row> ptr=std::make_unique<Row> (row);
    if(_firstRow){
        _lastRow->_nextRow=std::move(ptr);
        _lastRow=_lastRow->_nextRow.get();
libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::operator<<(const Row& row){
    // Creates a new, owning smart pointer for the destination row.
    std::unique_ptr<Row> newRow = std::make_unique<Row>();

    // Deep Copy of Columns (Correct: iterates source, creates new unique_ptr destination chain)
    for(Column *curco=row._firstColumn.get(); curco; curco=curco->_nextColumn.get()){

        auto newColumn = std::make_unique<Column>(); // New unique_ptr column
        newColumn->Data = curco->Data;

        if(!newRow->_firstColumn){
            // First element: takes ownership
            newRow->_firstColumn = std::move(newColumn);
            newRow->_lastColumn = newRow->_firstColumn.get();
        }else{
        _firstRow= std::move(ptr);
            // Subsequent elements: links to the last raw pointer's unique_ptr member
            newRow->_lastColumn->_nextColumn = std::move(newColumn);
            newRow->_lastColumn = newRow->_lastColumn->_nextColumn.get();
        }
    }
    newRow->_count = row._count;

    // Transfer Row Ownership (Correct: moves unique_ptr into unique_ptr members)
    if (!_firstRow) {
        _firstRow = std::move(newRow); // Assuming _firstRow is std::unique_ptr<Row>
        _lastRow = _firstRow.get();
    } else {
        _lastRow->_nextRow = std::move(newRow); // Assuming Row::_nextRow is std::unique_ptr<Row>
        _lastRow = _lastRow->_nextRow.get();
    }

    ++_count;
    return *_lastRow;
}



libhtmlpp::HtmlTable::Row & libhtmlpp::HtmlTable::operator[](size_t pos){
    if(!_firstRow || _count<pos){
        libhtmlpp::HTMLException exp;
@@ -1877,8 +1901,9 @@ libhtmlpp::HtmlTable::Row::Row(const libhtmlpp::HtmlTable::Row& row){
    }
}

libhtmlpp::HtmlTable::Row& libhtmlpp::HtmlTable::Row::operator<<(Column &col){
libhtmlpp::HtmlTable::Row& libhtmlpp::HtmlTable::Row::operator<<(const Column &col){
    std::unique_ptr<Column> ptr=std::make_unique<Column>(col);

    if(_firstColumn){
        _lastColumn->_nextColumn=std::move(ptr);
        _lastColumn=_lastColumn->_nextColumn.get();
@@ -1890,7 +1915,7 @@ libhtmlpp::HtmlTable::Row& libhtmlpp::HtmlTable::Row::operator<<(Column &col){
    return *this;
}

libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::Row::operator<<(libhtmlpp::HtmlString value){
libhtmlpp::HtmlTable::Row &libhtmlpp::HtmlTable::Row::operator<<(const libhtmlpp::HtmlString value){
    Column col(value);
    *this << col;
    return *this;
+5 −6
Original line number Diff line number Diff line
@@ -325,10 +325,9 @@ namespace libhtmlpp {
            HtmlString  Data;
             ~Column();
             Column(const Column &col);
        private:
             Column();
            Column(const HtmlString &data);

        private:
            std::unique_ptr<Column> _nextColumn;
            friend class HtmlTable;
        };
@@ -339,8 +338,8 @@ namespace libhtmlpp {
            Row(const Row &row);
            ~Row();

            Row& operator<<(Column &col);
            Row& operator<<(HtmlString  value);
            Row& operator<<(const Column &col);
            Row& operator<<(const HtmlString  value);
            Row& operator<<(const char* value);
            Row& operator<<(int value);

@@ -356,7 +355,7 @@ namespace libhtmlpp {
            friend class HtmlTable;
        };

        Row& operator<<(const Row row);
        Row& operator<<(const Row &row);
        Row& operator[](size_t pos);

        void insert(HtmlElement *element);