From 95c5eb96cf65019131a97e93031d4cdf38eca3c2 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 11 May 2015 10:00:29 +0200 Subject: Initial --- enginedata.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 enginedata.cpp (limited to 'enginedata.cpp') diff --git a/enginedata.cpp b/enginedata.cpp new file mode 100644 index 0000000..c4d5e27 --- /dev/null +++ b/enginedata.cpp @@ -0,0 +1,27 @@ +#include "enginedata.h" + +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(Row &&other):table(other.table),items(other.items){ //move constr + other.table=NULL; + other.items=NULL; +} +Row::Row(const Row &other):table(other.table){ //copy constr + items=new RowItem[table->nc]; + memcpy(items,other.items,table->nc*sizeof(RowItem)); +} + + +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 + header=new ColHeader[nc]; + memcpy(header,_hd,nc*sizeof(ColHeader)); +} +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);} -- cgit v1.2.3-54-g00ecf