diff options
author | deva <deva> | 2008-05-26 13:56:30 +0000 |
---|---|---|
committer | deva <deva> | 2008-05-26 13:56:30 +0000 |
commit | 192e0f80bd2da45f1c612411fded2e805ac205de (patch) | |
tree | 95407dd47edc6062a6250382ca345d320b7665be /server/src/luaquerymapper.cc | |
parent | b0be417b31e2d2577c188a563d531889354b7617 (diff) |
Completed the prefilling of the fields, from the db and pentominos, according to their timestamps.
Diffstat (limited to 'server/src/luaquerymapper.cc')
-rw-r--r-- | server/src/luaquerymapper.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/server/src/luaquerymapper.cc b/server/src/luaquerymapper.cc index 67b780d..c99b48b 100644 --- a/server/src/luaquerymapper.cc +++ b/server/src/luaquerymapper.cc @@ -26,13 +26,18 @@ */ #include "luaquerymapper.h" +#include <sstream> + static std::string loadresultstring(QueryResult &res, std::string group = "") { std::string s; + std::stringstream timestamp; timestamp << res.timestamp; std::map< std::string, std::string >::iterator v = res.values.begin(); while(v != res.values.end()) { - s += group + (*v).first + " = \"" + (*v).second + "\"\n"; + s += group + (*v).first + " = {}\n"; + s += group + (*v).first + ".value = \"" + (*v).second + "\"\n"; + s += group + (*v).first + ".timestamp = " + timestamp.str() + "\n"; v++; } @@ -81,7 +86,7 @@ LUAQueryMapper::~LUAQueryMapper() lua_close(L); } -std::string LUAQueryMapper::map(const std::string &mapper) +Value LUAQueryMapper::map(const std::string &mapper) { int s = luaL_loadbuffer(L, mapper.c_str(), mapper.size(), "mapper"); switch(s) { @@ -100,7 +105,14 @@ std::string LUAQueryMapper::map(const std::string &mapper) // Run the loaded code lua_pcall(L, 0, LUA_MULTRET, 0); - return lua_tostring(L, lua_gettop(L)); + Value v; + + v.timestamp = lua_tointeger(L, lua_gettop(L)); + lua_pop(L, 1); + v.value = lua_tostring(L, lua_gettop(L)); + lua_pop(L, 1); + + return v; } #ifdef TEST_LUAQUERYMAPPER |