| | |
| | | #ifndef _QTL_ASIO_H_ |
| | | #define _QTL_ASIO_H_ |
| | | |
| | | #include <qtl_async.hpp> |
| | | #include "qtl_async.hpp" |
| | | #include <asio/version.hpp> |
| | | #define ASIO_STANDALONE |
| | | #if ASIO_VERSION < 101200 |
| | |
| | | else |
| | | handler(qtl::event::ef_exception); |
| | | _busying = false; |
| | | _timer.cancel(); |
| | | })); |
| | | _busying = true; |
| | | } |
| | |
| | | handler(qtl::event::ef_timeout); |
| | | else |
| | | handler(qtl::event::ef_exception); |
| | | _timer.cancel(); |
| | | _busying = false; |
| | | })); |
| | | _busying = true; |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(OpenHandler, void(typename Connection::exception_type)) |
| | | async_open(service& service, Connection& db, OpenHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<OpenHandler, |
| | | void(typename Connection::exception_type)> init(std::forward<OpenHandler>(handler)); |
| | | #else |
| | | async_init_type<OpenHandler, |
| | | void(typename Connection::exception_type)> init(handler); |
| | | #endif |
| | | |
| | | db.open(service, get_async_handler(init), std::forward<Args>(args)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(CloseHandler, void()) |
| | | async_close(Connection& db, CloseHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<CloseHandler, |
| | | void()> init(std::forward<CloseHandler>(std::forward<CloseHandler>(handler))); |
| | | #else |
| | | async_init_type<CloseHandler, |
| | | void()> init(std::forward<CloseHandler>(handler)); |
| | | #endif |
| | | |
| | | db.close(get_async_handler(init), std::forward<Args>(args)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(ExecuteHandler, void(typename Connection::exception_type, uint64_t)) |
| | | async_execute(Connection& db, ExecuteHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(std::forward<ExecuteHandler>(handler)); |
| | | #else |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(handler); |
| | | #endif |
| | | |
| | | db.execute(get_async_handler(init), std::forward<Args>(args)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(ExecuteHandler, void(typename Connection::exception_type, uint64_t)) |
| | | async_execute_direct(Connection& db, ExecuteHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(std::forward<ExecuteHandler>(handler)); |
| | | #else |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(handler); |
| | | #endif |
| | | |
| | | db.execute_direct(get_async_handler(init), std::forward<Args>(args)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(ExecuteHandler, void(typename Connection::exception_type, uint64_t)) |
| | | async_insert(Connection& db, ExecuteHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(std::forward<ExecuteHandler>(handler)); |
| | | #else |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(handler); |
| | | #endif |
| | | |
| | | db.insert(get_async_handler(init), std::forward<Args>(args)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(ExecuteHandler, void(typename Connection::exception_type, uint64_t)) |
| | | async_insert_direct(Connection& db, ExecuteHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(std::forward<ExecuteHandler>(handler)); |
| | | #else |
| | | async_init_type<ExecuteHandler, |
| | | void(typename Connection::exception_type, uint64_t)> init(handler); |
| | | #endif |
| | | |
| | | db.insert_direct(get_async_handler(init), std::forward<Args>(args)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(FinishHandler, void(typename Connection::exception_type)) |
| | | async_query(Connection& db, FinishHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(std::forward<FinishHandler>(handler)); |
| | | #else |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(handler); |
| | | #endif |
| | | |
| | | db.query(std::forward<Args>(args)..., get_async_handler(init)); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(FinishHandler, void(typename Connection::exception_type)) |
| | | async_query_explicit(Connection& db, FinishHandler&& handler, Args&&... args) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(std::forward<FinishHandler>(handler)); |
| | | #else |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(handler); |
| | | #endif |
| | | |
| | | db.query_explicit(std::forward<Args>(args)..., get_async_handler(init)); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(FinishHandler, void(typename Connection::exception_type)) |
| | | async_query_multi_with_params(Connection& db, A1&& a1, A2&& a2, FinishHandler&& handler, RowHandlers&&... row_handlers) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(std::forward<FinishHandler>(handler)); |
| | | #else |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(handler); |
| | | #endif |
| | | |
| | | db.query_multi_with_params(std::forward<A1>(a1), std::forward<A2>(a2), get_async_handler(init), std::forward<RowHandlers>(row_handlers)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(FinishHandler, void(typename Connection::exception_type)) |
| | | async_query_multi_with_params(Connection& db, A1&& a1, FinishHandler&& handler, RowHandlers&&... row_handlers) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(std::forward<FinishHandler>(handler)); |
| | | #else |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(handler); |
| | | #endif |
| | | |
| | | db.query_multi_with_params(std::forward<A1>(a1), get_async_handler(init), std::forward<RowHandlers>(row_handlers)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(FinishHandler, void(typename Connection::exception_type)) |
| | | async_query_multi(Connection& db, A1&& a1, A2&& a2, FinishHandler&& handler, RowHandlers&&... row_handlers) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(std::forward<FinishHandler>(handler)); |
| | | #else |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(handler); |
| | | #endif |
| | | |
| | | db.query_multi(std::forward<A1>(a1), std::forward<A2>(a2), get_async_handler(init), std::forward<RowHandlers>(row_handlers)...); |
| | | return init.result.get(); |
| | | } |
| | |
| | | inline ASIO_INITFN_RESULT_TYPE(FinishHandler, void(typename Connection::exception_type)) |
| | | async_query_multi(Connection& db, A1&& a1, FinishHandler&& handler, RowHandlers&&... row_handlers) |
| | | { |
| | | #if ASIO_VERSION < 101200 |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(std::forward<FinishHandler>(handler)); |
| | | #else |
| | | async_init_type<FinishHandler, |
| | | void(typename Connection::exception_type)> init(handler); |
| | | #endif |
| | | |
| | | db.query_multi(std::forward<A1>(a1), get_async_handler(init), std::forward<RowHandlers>(row_handlers)...); |
| | | return init.result.get(); |
| | | } |