aboutsummaryrefslogtreecommitdiff
path: root/enginedata.h
diff options
context:
space:
mode:
authortomsmeding <hallo@tomsmeding.nl>2015-05-11 18:39:56 +0200
committertomsmeding <hallo@tomsmeding.nl>2015-05-11 18:40:08 +0200
commit82407c1c4c9526e7dc408e936478c8619ded8c66 (patch)
treeb7ab24326c72e58d915ad1afec5adebef51c0689 /enginedata.h
parent6f27f2e53179f476cfb80e634a59bfd3d584db6b (diff)
Fix up makefile and add functional insert and find implementation
Diffstat (limited to 'enginedata.h')
-rw-r--r--enginedata.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/enginedata.h b/enginedata.h
index 29550f6..1b9feb4 100644
--- a/enginedata.h
+++ b/enginedata.h
@@ -1,5 +1,6 @@
#include <string>
-#include <vector>
+#include <map>
+#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<Row> rows;
+ map<string,Row> 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<Row> find(const string &key);
};