@@ -42,6 +42,24 @@ namespace GLua = GarrysMod::Lua;
4242 int name##__Imp([[maybe_unused]] GarrysMod::Lua::ILuaInterface* lua)
4343
4444namespace 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+
4563 struct SocketStatus {
4664 bool read_ready = false ;
4765 bool write_ready = false ;
@@ -54,7 +72,7 @@ namespace async_postgres {
5472
5573 struct ParameterizedCommand {
5674 std::string command;
57- std::vector<std::string> values ;
75+ ParamValues param ;
5876 };
5977
6078 struct Query {
@@ -108,5 +126,7 @@ namespace async_postgres {
108126 // util.cpp
109127 std::string_view get_string (GLua::ILuaInterface* lua, int index = -1 );
110128 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);
111131 SocketStatus check_socket_status (PGconn* conn);
112132}; // namespace async_postgres
0 commit comments