From db4b20dea8278579ef8e02e528595178c7b500d0 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 11 May 2015 10:16:25 +0200 Subject: Bit of cleanup --- enginedata.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'enginedata.cpp') diff --git a/enginedata.cpp b/enginedata.cpp index c4d5e27..f1e9b2c 100644 --- a/enginedata.cpp +++ b/enginedata.cpp @@ -2,8 +2,12 @@ using namespace std; -Row::Row(const int nc,const Table *const _t):table(_t){items=new RowItem[nc];} -Row::~Row(void){if(items)delete[] items;} +Row::Row(const int nc,const Table *const _t):table(_t){ + items=new RowItem[nc]; +} +Row::~Row(void){ + if(items)delete[] items; +} Row::Row(Row &&other):table(other.table),items(other.items){ //move constr other.table=NULL; other.items=NULL; @@ -14,14 +18,21 @@ Row::Row(const Row &other):table(other.table){ //copy constr } -Table::Table(const string &_n,const int _nc,const ColHeader *const _hd):name(_n),nc(_nc){ //copies from _hd, so you can freely delete it or whatever +//copies from _hd, so you can freely delete or edit the passed colheader array +Table::Table(const string &_n,const int _nc,const ColHeader *const _hd):name(_n),nc(_nc){ header=new ColHeader[nc]; memcpy(header,_hd,nc*sizeof(ColHeader)); } -Table::~Table(void){if(header)delete[] header;} +Table::~Table(void){ + if(header)delete[] header; +} Table::Table(Table &&other):name(move(other.name)),nc(other.nc),header(other.header),rows(move(other.rows)){ other.header=NULL; } -void Table::insert(Row &&row){rows.push_back(move(row));} -void Table::insert(Row &row){rows.emplace_back(row);} +void Table::insert(Row &&row){ + rows.push_back(move(row)); +} +void Table::insert(Row &row){ + rows.emplace_back(row); +} -- cgit v1.2.3-54-g00ecf