@@ -42,6 +42,24 @@ namespace GLua = GarrysMod::Lua;
42
42
int name##__Imp([[maybe_unused]] GarrysMod::Lua::ILuaInterface* lua)
43
43
44
44
namespace async_postgres {
45
+ typedef std::variant<std::nullptr_t , std::string, double , bool > ParamValue;
46
+
47
+ struct ParamValues {
48
+ ParamValues (int n_params)
49
+ : strings(n_params),
50
+ values (n_params),
51
+ lengths(n_params, 0 ),
52
+ formats(n_params, 0 ) {}
53
+
54
+ inline int length () const { return strings.size (); }
55
+
56
+ std::vector<std::string> strings;
57
+ // vectors below are used in PQexecParams-like functions
58
+ std::vector<const char *> values;
59
+ std::vector<int > lengths;
60
+ std::vector<int > formats;
61
+ };
62
+
45
63
struct SocketStatus {
46
64
bool read_ready = false ;
47
65
bool write_ready = false ;
@@ -54,7 +72,7 @@ namespace async_postgres {
54
72
55
73
struct ParameterizedCommand {
56
74
std::string command;
57
- std::vector<std::string> values ;
75
+ ParamValues param ;
58
76
};
59
77
60
78
struct Query {
@@ -108,5 +126,7 @@ namespace async_postgres {
108
126
// util.cpp
109
127
std::string_view get_string (GLua::ILuaInterface* lua, int index = -1 );
110
128
void pcall (GLua::ILuaInterface* lua, int nargs, int nresults);
129
+ // Converts a lua array at given index to a ParamValues
130
+ ParamValues array_to_params (GLua::ILuaInterface* lua, int index);
111
131
SocketStatus check_socket_status (PGconn* conn);
112
132
}; // namespace async_postgres
0 commit comments