aboutsummaryrefslogtreecommitdiff
path: root/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engine.cpp')
-rw-r--r--engine.cpp74
1 files changed, 60 insertions, 14 deletions
diff --git a/engine.cpp b/engine.cpp
index 568245b..ea81602 100644
--- a/engine.cpp
+++ b/engine.cpp
@@ -44,6 +44,20 @@ int main(int argc,char **argv){
Table *hoitb=&tables.at("hoi");
+
+
+ //Shitty. Works.
+#define FINDQUERYEVERYTHING(PAR_tnm) \
+ { \
+ FindQuery fqu; \
+ fqu.tablename= PAR_tnm ; \
+ QueryResult res=fqu.execute(tables); \
+ cout<<"Find in \"" PAR_tnm "\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; \
+ for(const Row &r : res.rows)cout<<"- "<<r<<endl; \
+ }
+
+
+
{
Row row(3,hoitb);
row.items[0].v.rh_int32=UINT_MAX;
@@ -56,7 +70,7 @@ int main(int argc,char **argv){
QueryResult res=iqu.execute(tables);
- cout<<"Insert [-1 uint_max \"hallo daar\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ cout<<"Insert [UINT_MAX UINT_MAX \"hallo daar\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
for(const Row &r : res.rows)cout<<"- "<<r<<endl;
}
@@ -72,22 +86,52 @@ int main(int argc,char **argv){
QueryResult res=iqu.execute(tables);
- cout<<"Insert [42 uint_max \"doei\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ cout<<"Insert [42 UINT_MAX \"doei\"] into \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
for(const Row &r : res.rows)cout<<"- "<<r<<endl;
}
+ FINDQUERYEVERYTHING("hoi")
+
{
- FindQuery fqu;
- fqu.tablename="hoi";
- RowItem ri; ri.v.rh_uint32=UINT_MAX;
- fqu.where.emplace_back(1,ri);
+ UpdateQuery uqu;
+ uqu.tablename="hoi";
+
+ RowItem ri;
+ ri.v.rh_bytes=new unsigned char[10];
+ memcpy(ri.v.rh_bytes,"hallo daar",10);
+ uqu.where.push_back({2,ri});
+
+ delete[] ri.v.rh_bytes;
+ ri.v.rh_int32=20;
+ uqu.updates.push_back({0,ri});
- QueryResult res=fqu.execute(tables);
+ QueryResult res=uqu.execute(tables);
- cout<<"Find in \"hoi\" where {1}=uint_max, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ cout<<"Update in \"hoi\" where {2}=\"hallo daar\" {0}->20, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
for(const Row &r : res.rows)cout<<"- "<<r<<endl;
}
+ FINDQUERYEVERYTHING("hoi")
+
+ {
+ UpdateQuery uqu;
+ uqu.tablename="hoi";
+
+ RowItem ri;
+ ri.v.rh_uint32=UINT_MAX;
+ uqu.where.push_back({1,ri});
+
+ ri.v.rh_uint32=12345;
+ uqu.updates.push_back({1,ri});
+
+ QueryResult res=uqu.execute(tables);
+
+ cout<<"Update in \"hoi\" where {1}=UINT_MAX {1}->12345, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ for(const Row &r : res.rows)cout<<"- "<<r<<endl;
+ }
+
+ FINDQUERYEVERYTHING("hoi")
+
{
DeleteQuery dqu;
dqu.tablename="hoi";
@@ -100,17 +144,19 @@ int main(int argc,char **argv){
for(const Row &r : res.rows)cout<<"- "<<r<<endl;
}
+ FINDQUERYEVERYTHING("hoi")
+
{
- FindQuery fqu;
- fqu.tablename="hoi";
- RowItem ri; ri.v.rh_uint32=UINT_MAX;
- fqu.where.emplace_back(1,ri);
+ DropQuery drqu;
+ drqu.tablename="hoi";
- QueryResult res=fqu.execute(tables);
+ QueryResult res=drqu.execute(tables);
- cout<<"Find in \"hoi\" where {1}=uint_max, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
+ cout<<"Drop table \"hoi\", Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl;
for(const Row &r : res.rows)cout<<"- "<<r<<endl;
}
+ FINDQUERYEVERYTHING("hoi")
+
return 0;
}