32 #ifndef SOCI_PROXY_H_INCLUDED 33 #define SOCI_PROXY_H_INCLUDED 36 #ifndef SOCI_PROXY_DECL 37 # define SOCI_PROXY_DECL 40 #include <soci-backend.h> 41 #include <api/DatabaseEngine.hpp> 42 #include <api/DatabaseConnectionPool.hpp> 43 #include <api/DatabaseConnection.hpp> 44 #include <api/DatabaseStatement.hpp> 45 #include <api/DatabaseError.hpp> 46 #include <api/DatabaseBlob.hpp> 47 #include <api/DatabaseResultSet.hpp> 48 #include <api/DatabaseValueType.hpp> 49 #include <api/DatabaseColumn.hpp> 50 #include <api/DatabaseResultRow.hpp> 54 #include <unordered_map> 55 #include <utils/Either.hpp> 59 # define SOCI_OVERRIDE override 62 #ifdef SOCI_PROXY_DEBUG 63 #define SP_PRINT(p) std::cout << p << std::endl; 76 struct proxy_statement_backend;
84 void define_by_pos(
int& position,
void* data, details::exchange_type type) SOCI_OVERRIDE;
86 void pre_fetch() SOCI_OVERRIDE;
87 void post_fetch(
bool gotData,
bool calledFromFetch, indicator* ind) SOCI_OVERRIDE;
89 void clean_up() SOCI_OVERRIDE;
94 details::exchange_type _type;
100 : statement_(st), _position(-1)
103 void bind_by_pos(
int& position,
void* data, details::exchange_type type,
bool readOnly) SOCI_OVERRIDE;
104 void bind_by_name(std::string
const& name,
void* data, details::exchange_type type,
bool readOnly) SOCI_OVERRIDE;
106 void pre_use(indicator
const* ind) SOCI_OVERRIDE;
107 void post_use(
bool gotData, indicator* ind) SOCI_OVERRIDE;
109 void clean_up() SOCI_OVERRIDE;
114 details::exchange_type _type;
122 void alloc() SOCI_OVERRIDE;
123 void clean_up() SOCI_OVERRIDE;
124 void prepare(std::string
const& query, details::statement_type eType) SOCI_OVERRIDE;
126 exec_fetch_result execute(
int number) SOCI_OVERRIDE;
127 exec_fetch_result fetch(
int number) SOCI_OVERRIDE;
129 exec_fetch_result batch_fetch(
int number);
130 exec_fetch_result single_row_fetch();
132 long long get_affected_rows() SOCI_OVERRIDE;
133 int get_number_of_rows() SOCI_OVERRIDE;
134 std::string get_parameter_name(
int index)
const;
136 std::string rewrite_for_procedure_call(std::string
const& query) SOCI_OVERRIDE;
138 int prepare_for_describe() SOCI_OVERRIDE;
139 void describe_column(
int colNum, data_type& dtype, std::string& columnName) SOCI_OVERRIDE;
143 details::vector_into_type_backend* make_vector_into_type_backend() SOCI_OVERRIDE;
144 details::vector_use_type_backend* make_vector_use_type_backend() SOCI_OVERRIDE;
146 bool reset_if_necessary();
149 std::shared_ptr<ledger::core::api::DatabaseStatement> _stmt;
150 std::shared_ptr<ledger::core::api::DatabaseResultSet> _results;
151 std::shared_ptr<ledger::core::api::DatabaseResultRow> _lastRow;
164 proxy_blob_backend(
const std::shared_ptr<ledger::core::api::DatabaseBlob>& backend) : _backend(backend) {};
168 std::size_t get_len() SOCI_OVERRIDE;
169 std::size_t read(std::size_t offset,
char* buf, std::size_t toRead) SOCI_OVERRIDE;
170 std::size_t write(std::size_t offset,
char const* buf, std::size_t toWrite) SOCI_OVERRIDE;
171 std::size_t append(
char const* buf, std::size_t toWrite) SOCI_OVERRIDE;
172 const std::shared_ptr<ledger::core::api::DatabaseBlob> getBlob()
const {
return _backend; };
173 void setBlob(
const std::shared_ptr<ledger::core::api::DatabaseBlob>& blob) {
176 void trim(std::size_t newLen) SOCI_OVERRIDE;
178 std::shared_ptr<ledger::core::api::DatabaseBlob> _backend;
188 void begin() SOCI_OVERRIDE;
189 void commit() SOCI_OVERRIDE;
190 void rollback() SOCI_OVERRIDE;
192 std::string get_dummy_from_table()
const {
return std::string(); }
194 std::string get_backend_name()
const SOCI_OVERRIDE {
return "proxy"; }
195 std::shared_ptr<ledger::core::api::DatabaseConnection> get_connection()
const {
return _conn; };
203 std::shared_ptr<ledger::core::api::DatabaseConnection> _conn;
208 proxy_backend_factory(
const std::shared_ptr<ledger::core::api::DatabaseEngine>& engine) : _engine(engine) {}
210 const std::shared_ptr<ledger::core::api::DatabaseEngine>& getEngine()
const;
211 ~proxy_backend_factory();
215 std::shared_ptr<ledger::core::api::DatabaseConnectionPool> get_pool(connection_parameters
const& parameters)
const;
217 std::shared_ptr<ledger::core::api::DatabaseEngine> _engine;
218 mutable std::unordered_map<std::string, std::shared_ptr<ledger::core::api::DatabaseConnectionPool>> _pools;
223 SOCI_PROXY_DECL backend_factory
const* factory_proxy(
const std::shared_ptr<ledger::core::api::DatabaseEngine>& engine);
224 SOCI_PROXY_DECL
void register_factory_proxy();
229 #endif // SOCI_PROXY_H_INCLUDED
Definition: soci-proxy.h:182
Definition: soci-proxy.h:78
Definition: soci-proxy.h:162
Definition: soci-proxy.h:206
Definition: soci-proxy.h:154
Definition: soci-proxy.h:118
Definition: soci-proxy.h:73
Definition: soci-proxy.h:97