Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:39:14

0001 //
0002 // Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MYSQL_DETAIL_ANY_EXECUTION_REQUEST_HPP
0009 #define BOOST_MYSQL_DETAIL_ANY_EXECUTION_REQUEST_HPP
0010 
0011 #include <boost/mysql/constant_string_view.hpp>
0012 #include <boost/mysql/string_view.hpp>
0013 
0014 #include <boost/core/span.hpp>
0015 
0016 #include <cstdint>
0017 #include <type_traits>
0018 #include <vector>
0019 
0020 namespace boost {
0021 namespace mysql {
0022 
0023 class field_view;
0024 class format_arg;
0025 
0026 namespace detail {
0027 
0028 struct any_execution_request
0029 {
0030     enum class type_t
0031     {
0032         query,
0033         query_with_params,
0034         stmt
0035     };
0036 
0037     union data_t
0038     {
0039         string_view query;
0040         struct query_with_params_t
0041         {
0042             constant_string_view query;
0043             span<const format_arg> args;
0044         } query_with_params;
0045         struct stmt_t
0046         {
0047             std::uint32_t stmt_id;
0048             std::uint16_t num_params;
0049             span<const field_view> params;
0050         } stmt;
0051 
0052         data_t(string_view q) noexcept : query(q) {}
0053         data_t(query_with_params_t v) noexcept : query_with_params(v) {}
0054         data_t(stmt_t v) noexcept : stmt(v) {}
0055     };
0056 
0057     type_t type;
0058     data_t data;
0059 
0060     any_execution_request(string_view q) noexcept : type(type_t::query), data(q) {}
0061     any_execution_request(data_t::query_with_params_t v) noexcept : type(type_t::query_with_params), data(v)
0062     {
0063     }
0064     any_execution_request(data_t::stmt_t v) noexcept : type(type_t::stmt), data(v) {}
0065 };
0066 
0067 struct no_execution_request_traits
0068 {
0069 };
0070 
0071 template <class T, class = void>
0072 struct execution_request_traits : no_execution_request_traits
0073 {
0074 };
0075 
0076 template <class T>
0077 struct execution_request_traits<T, typename std::enable_if<std::is_convertible<T, string_view>::value>::type>
0078 {
0079     static any_execution_request make_request(string_view input, std::vector<field_view>&) { return input; }
0080 };
0081 
0082 }  // namespace detail
0083 }  // namespace mysql
0084 }  // namespace boost
0085 
0086 #endif