From 82407c1c4c9526e7dc408e936478c8619ded8c66 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 11 May 2015 18:39:56 +0200 Subject: Fix up makefile and add functional insert and find implementation --- enginedata.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'enginedata.h') diff --git a/enginedata.h b/enginedata.h index 29550f6..1b9feb4 100644 --- a/enginedata.h +++ b/enginedata.h @@ -1,5 +1,6 @@ #include -#include +#include +#include "Maybe.h" using namespace std; @@ -8,11 +9,16 @@ struct Row; struct ColHeader; struct Table; +string serialise(const ColHeader &header,const RowItem &rowitem); +string serialise(int32_t v); +string serialise(uint32_t v); +string serialise(unsigned char *v,int len); + struct RowItem{ union { //watch the pointerness or not-pointerness of the attributes! - int rh_int32; - unsigned int rh_uint32; + int32_t rh_int32; + uint32_t rh_uint32; unsigned char *rh_bytes; } u; }; @@ -28,20 +34,23 @@ struct ColHeader{ }; struct Row{ + const int nc; const Table *table; //pointer to the parent table; don't delete! RowItem *items; - Row(const int nc,const Table *const _t); + Row(const int _nc,const Table *const _t); ~Row(void); - Row(Row &&other); - Row(const Row &other); + Row(Row &&other); //move constr + Row(const Row &other); //copy constr + + friend ostream& operator<<(ostream &os,const Row &r); }; struct Table{ const string name; const int nc; ColHeader *header; - vector rows; + map rows; //map key is serialised version of the first column Table(const string &_n,const int _nc,const ColHeader *const _hd); ~Table(void); @@ -49,4 +58,5 @@ struct Table{ void insert(Row &&row); void insert(Row &row); + Maybe find(const string &key); }; -- cgit v1.2.3-54-g00ecf