File indexing completed on 2025-09-17 08:39:19
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_IMPL_WITH_PARAMS_HPP
0009 #define BOOST_MYSQL_IMPL_WITH_PARAMS_HPP
0010
0011 #pragma once
0012
0013 #include <boost/mysql/constant_string_view.hpp>
0014 #include <boost/mysql/field_view.hpp>
0015 #include <boost/mysql/format_sql.hpp>
0016 #include <boost/mysql/with_params.hpp>
0017
0018 #include <boost/mysql/detail/any_execution_request.hpp>
0019
0020 #include <boost/core/ignore_unused.hpp>
0021 #include <boost/core/span.hpp>
0022 #include <boost/mp11/integer_sequence.hpp>
0023
0024
0025 namespace boost {
0026 namespace mysql {
0027 namespace detail {
0028
0029 template <std::size_t N>
0030 struct with_params_proxy
0031 {
0032 constant_string_view query;
0033 std::array<format_arg, N> args;
0034
0035 operator detail::any_execution_request() const { return any_execution_request({query, args}); }
0036 };
0037
0038 template <class... T>
0039 struct execution_request_traits<with_params_t<T...>>
0040 {
0041 template <class WithParamsType, std::size_t... I>
0042 static with_params_proxy<sizeof...(T)> make_request_impl(WithParamsType&& input, mp11::index_sequence<I...>)
0043 {
0044 boost::ignore_unused(input);
0045
0046 return {
0047 input.query,
0048 {{
0049 {
0050 string_view(),
0051 formattable_ref(std::get<I>(std::forward<WithParamsType>(input).args))
0052 }...
0053 }}
0054 };
0055
0056 }
0057
0058
0059 template <class WithParamsType>
0060 static with_params_proxy<sizeof...(T)> make_request(WithParamsType&& input, std::vector<field_view>&)
0061 {
0062 return make_request_impl(
0063 std::forward<WithParamsType>(input),
0064 mp11::make_index_sequence<sizeof...(T)>()
0065 );
0066 }
0067 };
0068
0069
0070 template <>
0071 struct execution_request_traits<with_params_t<>>
0072 {
0073 static any_execution_request make_request(with_params_t<> input, std::vector<field_view>&)
0074 {
0075 return any_execution_request({input.query, span<format_arg>{}});
0076 }
0077 };
0078
0079 }
0080 }
0081 }
0082
0083 #endif