aboutsummaryrefslogtreecommitdiff
path: root/engine.cpp
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 /engine.cpp
parent6f27f2e53179f476cfb80e634a59bfd3d584db6b (diff)
Fix up makefile and add functional insert and find implementation
Diffstat (limited to 'engine.cpp')
-rw-r--r--engine.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/engine.cpp b/engine.cpp
index dd0f5f4..bc4165a 100644
--- a/engine.cpp
+++ b/engine.cpp
@@ -2,7 +2,9 @@
#include <vector>
#include <map>
#include <cstdlib>
+#include <climits>
#include "enginedata.h"
+#include "Maybe.h"
using namespace std;
@@ -18,11 +20,14 @@ int main(int argc,char **argv){
tables.emplace("hoi",Table("hoi",3,header));
Table *hoitb=&tables.at("hoi");
Row row(3,hoitb);
- row.items[0].u.rh_int32=42;
- row.items[1].u.rh_uint32=42;
+ row.items[0].u.rh_int32=UINT_MAX;
+ row.items[1].u.rh_uint32=UINT_MAX;
row.items[2].u.rh_bytes=new unsigned char[10];
strcpy((char*)row.items[2].u.rh_bytes,"hallo daar");
hoitb->insert(row);
- cout<<"hoitb has "<<hoitb->rows.size()<<" row"<<(hoitb->rows.size()==1?"":"s")<<endl;
+ Maybe<Row> found=hoitb->find(serialise((int32_t)-1));
+ cout<<"hoitb has "<<hoitb->rows.size()<<" row"<<(hoitb->rows.size()==1?"":"s")<<'.'<<endl;
+ if(found)cout<<found.value()<<endl;
+ else cout<<"No row with key -1 found"<<endl;
return 0;
}