summaryrefslogtreecommitdiff
path: root/server/src/luaquerymapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/luaquerymapper.cc')
-rw-r--r--server/src/luaquerymapper.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc
index f4f6f20..be18742 100644
--- a/server/src/luaquerymapper.cc
+++ b/server/src/luaquerymapper.cc
@@ -105,28 +105,33 @@ std::string LUAQueryMapper::map(const std::string &mapper)
#ifdef TEST_LUAQUERYMAPPER
+#include "queryhandler.h"
+#include "queryparser.h"
+
int main()
{
- QueryResult res;
+ TCPSocket s;
+ s.connect("localhost", 11108);
+
+ QueryHandler qh(&s, "2003791613");
- QueryResult group1;
- group1.values["dims"] = "42";
+ Query q1("lensmeter", "lensmeter");
+ qh.addQuery(q1);
- QueryResult group2;
- group2.values["foo"] = "bar";
- group2.values["bar"] = "foo";
- group2.groups["fnuller"] = group1;
+ std::string res = qh.exec();
+
+ printf("%s\n", res.c_str());
- res.values["dims"] = "42";
- res.groups["dimmer"] = group2;
+ QueryParser e(res);
+ e.parse();
- LUAQueryMapper mapper(res);
+ LUAQueryMapper mapper(e.result);
- std::string luamap = "return dimmer.fnuller.dims * 2 + dims";
- printf("%s\n", mapper.map(luamap).c_str());
+ std::string luamap = "return right.sphere";
+ printf("%s : %s\n", luamap.c_str(), mapper.map(luamap).c_str());
- luamap = "return math.sin(dimmer.fnuller.dims * 2 + dims)";
- printf("%s\n", mapper.map(luamap).c_str());
+ luamap = "return math.sin(right.cyl) * 2";
+ printf("%s : %s\n", luamap.c_str(), mapper.map(luamap).c_str());
return 0;
}