#pragma once #include #include #include using namespace std; struct RowItem; struct Row; struct ColHeader; struct Table; struct RowItem{ union{ int32_t rh_int32; uint32_t rh_uint32; unsigned char *rh_bytes; } v; RowItem copy(const ColHeader&); }; enum ColHeaderType{ RH_INT32, RH_UINT32, RH_BYTES //takes length argument }; struct ColHeader{ ColHeaderType type; int arg; }; struct Row{ int nc; Table *table; //pointer to the parent table; don't delete! RowItem *items; Row(void); Row(const int _nc,Table *_t); ~Row(void); Row(Row &&other); //move constr Row(const Row &other); //copy constr Row& operator=(const Row &other); //copy assignment 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); //copies from _hd, so you can freely delete or edit the passed colheader array ~Table(void); Table(const Table &other); Table(Table &&other); }; 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); int riCompare(const ColHeader &header,const RowItem &ri1,const RowItem &ri2); int riCompare(int32_t v1,int32_t v2); int riCompare(uint32_t v1,uint32_t v2); int riCompare(unsigned char *v1,unsigned char *v2,int len);