// // Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_MYSQL_IMPL_STATEMENT_HPP #define BOOST_MYSQL_IMPL_STATEMENT_HPP #pragma once #include #include #include #include #include #include #include #include #include template class boost::mysql::bound_statement_tuple { friend class statement; friend struct detail::access; struct impl { statement stmt; WritableFieldTuple params; } impl_; template bound_statement_tuple(const statement& stmt, TupleType&& t) : impl_{stmt, std::forward(t)} { } }; template class boost::mysql::bound_statement_iterator_range { friend class statement; friend struct detail::access; struct impl { statement stmt; FieldViewFwdIterator first; FieldViewFwdIterator last; } impl_; bound_statement_iterator_range( const statement& stmt, FieldViewFwdIterator first, FieldViewFwdIterator last ) : impl_{stmt, first, last} { } }; template boost::mysql::bound_statement_tuple::type> boost::mysql::statement:: bind(WritableFieldTuple&& args) const { BOOST_ASSERT(valid()); return bound_statement_tuple::type>( *this, std::forward(args) ); } template boost::mysql::bound_statement_iterator_range boost::mysql::statement::bind( FieldViewFwdIterator first, FieldViewFwdIterator last ) const { BOOST_ASSERT(valid()); return bound_statement_iterator_range(*this, first, last); } // Execution request traits namespace boost { namespace mysql { namespace detail { // Tuple template struct stmt_tuple_request_proxy { statement stmt; std::array params; operator any_execution_request() const { return any_execution_request({stmt.id(), static_cast(stmt.num_params()), params}); } }; template struct execution_request_traits>> { template static std::array tuple_to_array(const std::tuple& t, mp11::index_sequence) { boost::ignore_unused(t); // MSVC gets confused if sizeof...(T) == 0 return {{to_field(std::get(t))...}}; } static stmt_tuple_request_proxy make_request(const bound_statement_tuple>& input, std::vector&) { auto& impl = access::get_impl(input); return {impl.stmt, tuple_to_array(impl.params, mp11::make_index_sequence())}; } }; // Iterator range template struct execution_request_traits> { static any_execution_request make_request( const bound_statement_iterator_range& input, std::vector& shared_fields ) { auto& impl = access::get_impl(input); shared_fields.assign(impl.first, impl.last); return any_execution_request( {impl.stmt.id(), static_cast(impl.stmt.num_params()), shared_fields} ); } }; } // namespace detail } // namespace mysql } // namespace boost #endif