11#pragma once
22#include < intercept.hpp>
33#include < mariadb++/result_set.hpp>
4+ #include < future>
45using namespace intercept ;
56using namespace intercept ::types;
67
@@ -11,20 +12,22 @@ class Result {
1112
1213 static game_value cmd_affectedRows (uintptr_t , game_value_parameter right);
1314 static game_value cmd_lastInsertId (uintptr_t , game_value_parameter right);
14- static game_value cmd_toArray (uintptr_t , game_value_parameter right);
15-
16-
17-
15+ static game_value cmd_toArray (uintptr_t , game_value_parameter right);
16+ static game_value cmd_bindCallback (uintptr_t , game_value_parameter left, game_value_parameter right);
1817
1918 static void initCommands ();
2019 static inline sqf_script_type GameDataDBResult_type;
2120 static inline game_data_type GameDataDBResult_typeE;
21+ static inline sqf_script_type GameDataDBAsyncResult_type;
22+ static inline game_data_type GameDataDBAsyncResult_typeE;
2223
2324 static inline types::registered_sqf_function handle_cmd_affectedRows;
2425 static inline types::registered_sqf_function handle_cmd_lastInsertId;
25- static inline types::registered_sqf_function handle_cmd_toArray;
26+ static inline types::registered_sqf_function handle_cmd_toArray;
27+ static inline types::registered_sqf_function handle_cmd_bindCallback;
2628};
2729
30+
2831class GameDataDBResult : public game_data {
2932
3033public:
@@ -36,10 +39,10 @@ class GameDataDBResult : public game_data {
3639 bool get_as_bool () const override { return true ; }
3740 float get_as_number () const override { return 0 .f ; }
3841 const r_string& get_as_string () const override { static r_string nm (" TODO" sv); return nm; }
39- game_data* copy () const override { return new GameDataDBResult (*this ); } // #TODO can't do that dave
42+ game_data* copy () const override { return new GameDataDBResult (*this ); }
4043 r_string to_string () const override { return r_string (" TODO" sv); }
4144 // virtual bool equals(const game_data*) const override; //#TODO isEqualTo on hashMaps would be quite nice I guess?
42- const char * type_as_string () const override { return " databaseQuery " ; }
45+ const char * type_as_string () const override { return " databaseResult " ; }
4346 bool is_nil () const override { return false ; }
4447 bool can_serialize () override { return true ; }// Setting this to false causes a fail in scheduled and global vars
4548
@@ -63,4 +66,52 @@ class GameDataDBResult : public game_data {
6366 }
6467
6568 mariadb::result_set_ref res;
69+ };
70+
71+ class GameDataDBAsyncResult : public game_data {
72+
73+ public:
74+ GameDataDBAsyncResult () {}
75+ void lastRefDeleted () const override { delete this ; }
76+ const sqf_script_type& type () const override { return Result::GameDataDBAsyncResult_type; }
77+ ~GameDataDBAsyncResult () override {};
78+
79+ bool get_as_bool () const override { return true ; }
80+ float get_as_number () const override { return 0 .f ; }
81+ const r_string& get_as_string () const override { static r_string nm (" TODO" sv); return nm; }
82+ game_data* copy () const override {
83+ return new GameDataDBAsyncResult (*this );
84+ } // #TODO can't do that dave
85+ r_string to_string () const override { return r_string (" TODO" sv); }
86+ // virtual bool equals(const game_data*) const override; //#TODO isEqualTo on hashMaps would be quite nice I guess?
87+ const char * type_as_string () const override { return " databaseResultAsync" ; }
88+ bool is_nil () const override { return false ; }
89+ bool can_serialize () override { return false ; }// Setting this to false causes a fail in scheduled and global vars
90+
91+ serialization_return serialize(param_archive& ar) override {
92+ game_data::serialize (ar);
93+ // size_t entryCount;
94+ // if (ar._isExporting) entryCount = map.size();
95+ // ar.serialize("entryCount"sv, entryCount, 1);
96+ // #TODO add array serialization functions
97+ // ar._p1->add_array_entry()
98+ // if (!ar._isExporting) {
99+ //
100+ // for (int i = 0; i < entryCount; ++i) {
101+ // s
102+ // }
103+ //
104+ //
105+ //
106+ // }
107+ return serialization_return::no_error;
108+ }
109+ struct dataT {
110+ std::future<mariadb::result_set_ref> res;
111+ game_value callback;
112+ game_value callbackArgs;
113+ };
114+ std::shared_ptr<dataT> data;
115+
116+
66117};
0 commit comments