From 26e36b3a9d7b49d46ecfa69b447482251acba8ac Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 24 Jan 2024 16:53:38 +0300 Subject: Turn libodb repository into package for muti-package repository --- libodb/odb/connection.ixx | 131 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 libodb/odb/connection.ixx (limited to 'libodb/odb/connection.ixx') diff --git a/libodb/odb/connection.ixx b/libodb/odb/connection.ixx new file mode 100644 index 0000000..d19390a --- /dev/null +++ b/libodb/odb/connection.ixx @@ -0,0 +1,131 @@ +// file : odb/connection.ixx +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::string +#include + +namespace odb +{ + inline connection:: + connection (connection_factory& f) + : factory_ (f), + tracer_ (0), + results_ (0), + prepared_queries_ (0), + transaction_tracer_ (0) + { + } + + inline connection::database_type& connection:: + database () + { + return factory_.database (); + } + + inline unsigned long long connection:: + execute (const char* st) + { + return execute (st, std::strlen (st)); + } + + inline unsigned long long connection:: + execute (const std::string& st) + { + return execute (st.c_str (), st.size ()); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const char* q) + { + return prepare_query (n, query (q)); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const std::string& q) + { + return prepare_query (n, query (q)); + } + + template + inline prepared_query connection:: + prepare_query (const char* n, const query& q) + { + return query_::call (*this, n, q); + } + + template + inline void connection:: + cache_query (const prepared_query& pq) + { + assert (pq); + cache_query_ (pq.impl_, typeid (T), 0, 0, 0); + } + +#ifdef ODB_CXX11 + template + inline void connection:: + cache_query (const prepared_query& pq, std::unique_ptr

params) + { + assert (pq); + assert (params); + cache_query_ ( + pq.impl_, typeid (T), params.get (), &typeid (P), ¶ms_deleter

); + params.release (); + } +#else + template + inline void connection:: + cache_query (const prepared_query& pq, std::auto_ptr

params) + { + assert (pq); + assert (params.get () != 0); + cache_query_ ( + pq.impl_, typeid (T), params.get (), &typeid (P), ¶ms_deleter

); + params.release (); + } +#endif + + template + inline prepared_query connection:: + lookup_query (const char* name) + { + return prepared_query (lookup_query_ (name, typeid (T), 0, 0)); + } + + template + inline prepared_query connection:: + lookup_query (const char* name, P*& params) + { + return prepared_query ( + lookup_query_ (name, + typeid (T), + reinterpret_cast (¶ms), + &typeid (P))); + } + + inline void connection:: + tracer (tracer_type& t) + { + tracer_ = &t; + } + + inline void connection:: + tracer (tracer_type* t) + { + tracer_ = t; + } + + inline connection::tracer_type* connection:: + tracer () const + { + return tracer_; + } + + inline connection::tracer_type* connection:: + transaction_tracer () const + { + return transaction_tracer_; + } +} -- cgit v1.1