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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#pragma once
#include <string>
#include <map>
#include <list>
using namespace std;
struct RowItem;
struct Row;
struct ColHeader;
struct Table;
struct RowItem{
int32_t rh_int32;
uint32_t rh_uint32;
unsigned char *rh_bytes;
};
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(void);
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<string,Row> 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);
|