#pragma once #include #include #include #include "Maybe.h" using namespace std; struct RowItem; 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! int32_t rh_int32; uint32_t rh_uint32; unsigned char *rh_bytes; } u; }; enum ColHeaderType{ RH_INT32, RH_UINT32, RH_BYTES //takes length argument }; struct ColHeader{ ColHeaderType type; int arg; }; 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(void); 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; map rows; //map key is serialised version of the first column Table(const string &_n,const int _nc,const ColHeader *const _hd); ~Table(void); Table(Table &&other); bool insert(Row &&row); bool insert(Row &row); list find(const string &key); };