diff options
Diffstat (limited to 'engine.cpp')
-rw-r--r-- | engine.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
@@ -1,10 +1,12 @@ #include "enginedata.h" -#include "Maybe.h" +#include "query.h" #include <iostream> #include <vector> #include <map> #include <list> +#include <utility> #include <cstdlib> +#include <cstring> #include <climits> using namespace std; @@ -13,25 +15,46 @@ using namespace std; map<string,Table> tables; +template <class... T> +void createTable(string name,T&&... args){ + //const Table tbl=Table(forward<T>(args)...); + //tables.emplace(tbl.name,move(tbl)); + tables.emplace(piecewise_construct, + forward_as_tuple(name), + forward_as_tuple(name,forward<T>(args)...)); +} + + int main(int argc,char **argv){ ColHeader *header=new ColHeader[3]; header[0]={RH_INT32,0}; header[1]={RH_UINT32,0}; header[2]={RH_BYTES,10}; - tables.emplace("hoi",Table("hoi",3,header)); + //tables.emplace("hoi",Table("hoi",3,header)); + createTable("hoi",3,header); Table *hoitb=&tables.at("hoi"); Row row(3,hoitb); - 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"); + row.items[0].rh_int32=UINT_MAX; + row.items[1].rh_uint32=UINT_MAX; + row.items[2].rh_bytes=new unsigned char[10]; + strcpy((char*)row.items[2].rh_bytes,"hallo daar"); + // cerr<<row.items[2].rh_bytes<<endl; if(!hoitb->insert(row))cout<<"Failed to insert row!"<<endl; else cout<<"Success."<<endl; if(!hoitb->insert(row))cout<<"Failed to insert row!"<<endl; else cout<<"Success."<<endl; cout<<"hoitb has "<<hoitb->rows.size()<<" row"<<(hoitb->rows.size()==1?"":"s")<<'.'<<endl; - list<Row> found=hoitb->find(serialise((int32_t)-1)); + /*list<Row> found=hoitb->find(serialise((int32_t)-1)); cout<<"Found for key -1:"<<endl; for(Row r : found){ cout<<r<<endl; + }*/ + FindQuery qu; + qu.from="hoi"; + RowItem ri; ri.rh_int32=-1; + qu.where.emplace_back(0,ri); + QueryResult res=qu.execute(tables); + cout<<"Result: "<<res.res<<":"<<endl; + for(const Row &r : res.rows){ + cout<<"- "<<r<<endl; } return 0; } |