blob: f1e9b2c2cf4abc1a279b47dcc5369b7c9b634808 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#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));
}
//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(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);
}
|