aboutsummaryrefslogtreecommitdiff
path: root/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engine.cpp')
-rw-r--r--engine.cpp48
1 files changed, 30 insertions, 18 deletions
diff --git a/engine.cpp b/engine.cpp
index 098a55e..608d641 100644
--- a/engine.cpp
+++ b/engine.cpp
@@ -30,31 +30,43 @@ int main(int argc,char **argv){
header[0]={RH_INT32,0};
header[1]={RH_UINT32,0};
header[2]={RH_BYTES,10};
- //tables.emplace("hoi",Table("hoi",3,header));
- createTable("hoi",3,header);
+
+ CreateQuery cqu;
+ cqu.tablename="hoi";
+ cqu.nc=3;
+ cqu.setHeader(header);
+ QueryResult res=cqu.execute(tables);
+
+ cout<<"Create, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ for(const Row &r : res.rows)cout<<"- "<<r<<endl;
+
Table *hoitb=&tables.at("hoi");
+
Row row(3,hoitb);
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;
+
+ InsertQuery iqu(move(row));
+ iqu.tablename="hoi";
+
+ res=iqu.execute(tables);
+
+ cout<<"Insert, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ for(const Row &r : res.rows)cout<<"- "<<r<<endl;
+
cout<<"hoitb has "<<hoitb->rows.size()<<" row"<<(hoitb->rows.size()==1?"":"s")<<'.'<<endl;
- /*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";
+
+ FindQuery fqu;
+ fqu.tablename="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;
- }
+ fqu.where.emplace_back(0,ri);
+
+ res=fqu.execute(tables);
+
+ cout<<"Find, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ for(const Row &r : res.rows)cout<<"- "<<r<<endl;
+
return 0;
}