|
2 | 2 |
|
3 | 3 | #include <deque> |
4 | 4 | #include <thread> |
5 | | -#include <rapidjson/document.h> |
6 | | -#include <rapidjson/writer.h> |
7 | | -#include <rapidjson/stringbuffer.h> |
| 5 | + |
| 6 | +#include <vector> |
| 7 | +#include <map> |
8 | 8 |
|
9 | 9 | std::string FetchPluginName(lua_State* state); |
10 | 10 | #define FetchPluginByState(state) g_pluginManager->FetchPlugin(FetchPluginName(state)) |
@@ -39,45 +39,16 @@ void DatabaseQueryThread() |
39 | 39 | if (queue.plugin->GetKind() == PluginKind_t::Lua) |
40 | 40 | { |
41 | 41 | lua_State* state = ((LuaPlugin*)queue.plugin)->GetState(); |
42 | | - luabridge::LuaRef tbl = luabridge::LuaRef::newTable(state); |
| 42 | + std::vector<std::map<std::string, luabridge::LuaRef>> tbl; |
| 43 | + |
43 | 44 | for (uint32_t i = 0; i < queryResult.size(); i++) |
44 | 45 | { |
45 | | - luabridge::LuaRef rowTbl = luabridge::LuaRef::newTable(state); |
| 46 | + std::map<std::string, luabridge::LuaRef> rowTbl; |
46 | 47 |
|
47 | 48 | for (std::map<const char*, std::any>::iterator it = queryResult[i].begin(); it != queryResult[i].end(); ++it) |
48 | | - { |
49 | | - const char* key = it->first; |
50 | | - std::any value = it->second; |
51 | | - |
52 | | - if (value.type() == typeid(const char*)) |
53 | | - rowTbl[key] = std::string(std::any_cast<const char*>(value)); |
54 | | - else if (value.type() == typeid(std::string)) |
55 | | - rowTbl[key] = std::any_cast<std::string>(value); |
56 | | - else if (value.type() == typeid(uint64)) |
57 | | - rowTbl[key] = std::any_cast<uint64>(value); |
58 | | - else if (value.type() == typeid(uint32)) |
59 | | - rowTbl[key] = std::any_cast<uint32>(value); |
60 | | - else if (value.type() == typeid(uint16)) |
61 | | - rowTbl[key] = std::any_cast<uint16>(value); |
62 | | - else if (value.type() == typeid(uint8)) |
63 | | - rowTbl[key] = std::any_cast<uint8>(value); |
64 | | - else if (value.type() == typeid(int64)) |
65 | | - rowTbl[key] = std::any_cast<int64>(value); |
66 | | - else if (value.type() == typeid(int32)) |
67 | | - rowTbl[key] = std::any_cast<int32>(value); |
68 | | - else if (value.type() == typeid(int16)) |
69 | | - rowTbl[key] = std::any_cast<int16>(value); |
70 | | - else if (value.type() == typeid(int8)) |
71 | | - rowTbl[key] = std::any_cast<int8>(value); |
72 | | - else if (value.type() == typeid(bool)) |
73 | | - rowTbl[key] = std::any_cast<bool>(value); |
74 | | - else if (value.type() == typeid(float)) |
75 | | - rowTbl[key] = std::any_cast<float>(value); |
76 | | - else if (value.type() == typeid(double)) |
77 | | - rowTbl[key] = std::any_cast<double>(value); |
78 | | - } |
| 49 | + rowTbl.insert({ it->first, LuaSerializeData(it->second, state) }); |
79 | 50 |
|
80 | | - if (rowTbl.isTable()) tbl.append(rowTbl); |
| 51 | + tbl.push_back(rowTbl); |
81 | 52 | } |
82 | 53 |
|
83 | 54 | luabridge::LuaRef ref = *(luabridge::LuaRef*)queue.callback; |
|
0 commit comments