2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-14 12:52:17 +00:00

Lowered std requirement to C++11

This commit is contained in:
ruben
2020-06-13 00:40:05 +01:00
parent 3407d818f6
commit 591671bd8d
118 changed files with 2156 additions and 1810 deletions

View File

@@ -44,33 +44,34 @@ public:
template <typename Stream>
class async_callback_errinfo : public network_functions<Stream>
{
template <typename R>
struct handler
{
std::promise<network_result<R>>& prom_;
error_info& output_info_;
handler_call_tracker& call_tracker_;
// For operations with a return type
void operator()(error_code code, R retval)
{
call_tracker_.register_call();
prom_.set_value(network_result<R>(code, std::move(output_info_), std::move(retval)));
}
// For operations without a return type (R=no_result)
void operator()(error_code code)
{
prom_.set_value(network_result<R>(code, std::move(output_info_)));
}
};
template <typename R, typename Callable>
network_result<R> impl(Callable&& cb)
{
struct handler
{
std::promise<network_result<R>>& prom_;
error_info& output_info_;
handler_call_tracker& call_tracker_;
// For operations with a return type
void operator()(error_code code, R retval)
{
call_tracker_.register_call();
prom_.set_value(network_result<R>(code, std::move(output_info_), std::move(retval)));
}
// For operations without a return type (R=no_result)
void operator()(error_code code)
{
prom_.set_value(network_result<R>(code, std::move(output_info_)));
}
};
handler_call_tracker call_tracker;
std::promise<network_result<R>> prom;
error_info info ("error_info not cleared properly");
cb(handler{prom, info, call_tracker}, info);
cb(handler<R>{prom, info, call_tracker}, info);
auto res = prom.get_future().get();
return res;
@@ -91,8 +92,8 @@ public:
const connection_params& params
) override
{
return impl<no_result>([&](auto&& token, error_info& info) {
return conn.async_connect(ep, params, info, std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h, error_info& info) {
return conn.async_connect(ep, params, info, std::move(h));
});
}
network_result<no_result> handshake(
@@ -100,26 +101,27 @@ public:
const connection_params& params
) override
{
return impl<no_result>([&](auto&& token, error_info& info) {
return conn.async_handshake(params, info, std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h, error_info& info) {
return conn.async_handshake(params, info, std::move(h));
});
}
network_result<resultset_type> query(
connection_type& conn,
std::string_view query
boost::string_view query
) override
{
return impl<resultset_type>([&](auto&& token, error_info& info) {
return conn.async_query(query, info, std::forward<decltype(token)>(token));
return impl<resultset_type>([&](handler<resultset_type> h, error_info& info) {
return conn.async_query(query, info, std::move(h));
});
}
network_result<prepared_statement_type> prepare_statement(
connection_type& conn,
std::string_view statement
boost::string_view statement
) override
{
return impl<prepared_statement_type>([&conn, statement](auto&& token, error_info& info) {
return conn.async_prepare_statement(statement, info, std::forward<decltype(token)>(token));
return impl<prepared_statement_type>([&conn, statement](
handler<prepared_statement_type> h, error_info& info) {
return conn.async_prepare_statement(statement, info, std::move(h));
});
}
network_result<resultset_type> execute_statement(
@@ -128,8 +130,8 @@ public:
value_list_it params_last
) override
{
return impl<resultset_type>([&](auto&& token, error_info& info) {
return stmt.async_execute(params_first, params_last, info, std::forward<decltype(token)>(token));
return impl<resultset_type>([&](handler<resultset_type> h, error_info& info) {
return stmt.async_execute(params_first, params_last, info, std::move(h));
});
}
network_result<resultset_type> execute_statement(
@@ -137,24 +139,24 @@ public:
const std::vector<value>& values
) override
{
return impl<resultset_type>([&](auto&& token, error_info& info) {
return stmt.async_execute(values, info, std::forward<decltype(token)>(token));
return impl<resultset_type>([&](handler<resultset_type> h, error_info& info) {
return stmt.async_execute(values, info, std::move(h));
});
}
network_result<no_result> close_statement(
prepared_statement_type& stmt
) override
{
return impl<no_result>([&](auto&& token, error_info& info) {
return stmt.async_close(info, std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h, error_info& info) {
return stmt.async_close(info, std::move(h));
});
}
network_result<const row*> fetch_one(
resultset_type& r
) override
{
return impl<const row*>([&](auto&& token, error_info& info) {
return r.async_fetch_one(info, std::forward<decltype(token)>(token));
return impl<const row*>([&](handler<const row*> h, error_info& info) {
return r.async_fetch_one(info, std::move(h));
});
}
network_result<std::vector<owning_row>> fetch_many(
@@ -162,32 +164,32 @@ public:
std::size_t count
) override
{
return impl<std::vector<owning_row>>([&](auto&& token, error_info& info) {
return r.async_fetch_many(count, info, std::forward<decltype(token)>(token));
return impl<std::vector<owning_row>>([&](handler<std::vector<owning_row>> h, error_info& info) {
return r.async_fetch_many(count, info, std::move(h));
});
}
network_result<std::vector<owning_row>> fetch_all(
resultset_type& r
) override
{
return impl<std::vector<owning_row>>([&](auto&& token, error_info& info) {
return r.async_fetch_all(info, std::forward<decltype(token)>(token));
return impl<std::vector<owning_row>>([&](handler<std::vector<owning_row>> h, error_info& info) {
return r.async_fetch_all(info, std::move(h));
});
}
network_result<no_result> quit(
connection_type& conn
) override
{
return impl<no_result>([&](auto&& token, error_info& info) {
return conn.async_quit(info, std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h, error_info& info) {
return conn.async_quit(info, std::move(h));
});
}
network_result<no_result> close(
connection_type& conn
) override
{
return impl<no_result>([&](auto&& token, error_info& info) {
return conn.async_close(info, std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h, error_info& info) {
return conn.async_close(info, std::move(h));
});
}
};
@@ -195,35 +197,34 @@ public:
template <typename Stream>
class async_callback_noerrinfo : public network_functions<Stream>
{
template <typename R>
struct handler
{
std::promise<network_result<R>>& prom_;
handler_call_tracker& call_tracker_;
// For operations with a return type
void operator()(error_code code, R retval)
{
call_tracker_.register_call();
prom_.set_value(network_result<R>(code, std::move(retval)));
}
// For operations without a return type (R=no_result)
void operator()(error_code code)
{
call_tracker_.register_call();
prom_.set_value(network_result<R>(code));
}
};
template <typename R, typename Callable>
network_result<R> impl(Callable&& cb)
{
struct handler
{
std::promise<network_result<R>>& prom_;
handler_call_tracker& call_tracker_;
// For operations with a return type
void operator()(error_code code, R retval)
{
call_tracker_.register_call();
prom_.set_value(network_result<R>(code, std::move(retval)));
}
// For operations without a return type (R=no_result)
void operator()(error_code code)
{
call_tracker_.register_call();
prom_.set_value(network_result<R>(code));
}
};
handler_call_tracker call_tracker;
std::promise<network_result<R>> prom;
cb(handler{prom, call_tracker});
auto res = prom.get_future().get();
return res;
cb(handler<R>{prom, call_tracker});
return prom.get_future().get();
}
public:
@@ -241,8 +242,8 @@ public:
const connection_params& params
) override
{
return impl<no_result>([&](auto&& token) {
return conn.async_connect(ep, params, std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h) {
return conn.async_connect(ep, params, std::move(h));
});
}
network_result<no_result> handshake(
@@ -250,26 +251,26 @@ public:
const connection_params& params
) override
{
return impl<no_result>([&](auto&& token) {
return conn.async_handshake(params, std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h) {
return conn.async_handshake(params, std::move(h));
});
}
network_result<resultset_type> query(
connection_type& conn,
std::string_view query
boost::string_view query
) override
{
return impl<resultset_type>([&](auto&& token) {
return conn.async_query(query, std::forward<decltype(token)>(token));
return impl<resultset_type>([&](handler<resultset_type> h) {
return conn.async_query(query, std::move(h));
});
}
network_result<prepared_statement_type> prepare_statement(
connection_type& conn,
std::string_view statement
boost::string_view statement
) override
{
return impl<prepared_statement_type>([&conn, statement](auto&& token) {
return conn.async_prepare_statement(statement, std::forward<decltype(token)>(token));
return impl<prepared_statement_type>([&conn, statement](handler<prepared_statement_type> h) {
return conn.async_prepare_statement(statement, std::move(h));
});
}
network_result<resultset_type> execute_statement(
@@ -278,8 +279,8 @@ public:
value_list_it params_last
) override
{
return impl<resultset_type>([&](auto&& token) {
return stmt.async_execute(params_first, params_last, std::forward<decltype(token)>(token));
return impl<resultset_type>([&](handler<resultset_type> h) {
return stmt.async_execute(params_first, params_last, std::move(h));
});
}
network_result<resultset_type> execute_statement(
@@ -287,24 +288,24 @@ public:
const std::vector<value>& values
) override
{
return impl<resultset_type>([&](auto&& token) {
return stmt.async_execute(values, std::forward<decltype(token)>(token));
return impl<resultset_type>([&](handler<resultset_type> h) {
return stmt.async_execute(values, std::move(h));
});
}
network_result<no_result> close_statement(
prepared_statement_type& stmt
) override
{
return impl<no_result>([&](auto&& token) {
return stmt.async_close(std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h) {
return stmt.async_close(std::move(h));
});
}
network_result<const row*> fetch_one(
resultset_type& r
) override
{
return impl<const row*>([&](auto&& token) {
return r.async_fetch_one(std::forward<decltype(token)>(token));
return impl<const row*>([&](handler<const row*> h) {
return r.async_fetch_one(std::move(h));
});
}
network_result<std::vector<owning_row>> fetch_many(
@@ -312,32 +313,32 @@ public:
std::size_t count
) override
{
return impl<std::vector<owning_row>>([&](auto&& token) {
return r.async_fetch_many(count, std::forward<decltype(token)>(token));
return impl<std::vector<owning_row>>([&](handler<std::vector<owning_row>> h) {
return r.async_fetch_many(count, std::move(h));
});
}
network_result<std::vector<owning_row>> fetch_all(
resultset_type& r
) override
{
return impl<std::vector<owning_row>>([&](auto&& token) {
return r.async_fetch_all(std::forward<decltype(token)>(token));
return impl<std::vector<owning_row>>([&](handler<std::vector<owning_row>> h) {
return r.async_fetch_all(std::move(h));
});
}
network_result<no_result> quit(
connection_type& conn
) override
{
return impl<no_result>([&](auto&& token) {
return conn.async_quit(std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h) {
return conn.async_quit(std::move(h));
});
}
network_result<no_result> close(
connection_type& conn
) override
{
return impl<no_result>([&](auto&& token) {
return conn.async_close(std::forward<decltype(token)>(token));
return impl<no_result>([&](handler<no_result> h) {
return conn.async_close(std::move(h));
});
}
};