From 7e349e2789a633a6014baea63aeb7932e024c917 Mon Sep 17 00:00:00 2001 From: deva Date: Wed, 22 Jul 2009 15:00:29 +0000 Subject: Changed the way the macros are looked up in the filesystem (now they are parsed and indexed using version numbers). Updated all unit tests, to compile and run again. --- server/src/luaquerymapper.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'server/src/luaquerymapper.cc') diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc index bec9640..d6ec531 100644 --- a/server/src/luaquerymapper.cc +++ b/server/src/luaquerymapper.cc @@ -46,7 +46,7 @@ static std::string loadresultstring(QueryResult &res, std::string group = "") std::map< std::string, QueryResult >::iterator g = res.groups.begin(); while(g != res.groups.end()) { - s += group + (*g).first + " = {}\n"; + if(group + (*g).first != "") s += group + (*g).first + " = {}\n"; s += loadresultstring((*g).second, group + (*g).first + "."); g++; } @@ -170,36 +170,33 @@ void LUAQueryMapper::error(std::string message) #ifdef TEST_LUAQUERYMAPPER -#include "queryhandler.h" +#include "queryhandlerpentominos.h" #include "queryparser.h" +#include "tcpsocket.h" int main() { TCPSocket s; s.connect("localhost", 11108); - QueryHandler qh(&s, "2003791613"); + QueryHandlerPentominos qh(&s, "2003791613"); Query q1; q1.attributes["device_id"] = "lensmeter"; q1.attributes["device_type"] = "lensmeter"; - std::string res = qh.exec(); + QueryResult res = qh.exec(q1); - printf("%s\n", res.c_str()); + printf("%s\n", loadresultstring(res).c_str()); - QueryParser e(res); - e.parse(); + LUAQueryMapper mapper; + mapper.addQueryResult(res); - printf("%s\n", loadresultstring(e.result).c_str()); - - LUAQueryMapper mapper(e.result); - - std::string luamap = "return right.sphere, 0"; + std::string luamap = "return status.errstr.value, 0, 0"; Value value = mapper.map(luamap); printf("%s : %s, %lu\n", luamap.c_str(), value.value.c_str(), value.timestamp); - luamap = "return math.sin(right.cyl) * 2, 0"; + luamap = "return math.sin(status.errstr.timestamp) * 2, 0, 0"; value = mapper.map(luamap); printf("%s : %s, %lu\n", luamap.c_str(), value.value.c_str(), value.timestamp); -- cgit v1.2.3