any_execution_request.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_DETAIL_ANY_EXECUTION_REQUEST_HPP
  8. #define BOOST_MYSQL_DETAIL_ANY_EXECUTION_REQUEST_HPP
  9. #include <boost/mysql/field_view.hpp>
  10. #include <boost/mysql/statement.hpp>
  11. #include <boost/mysql/string_view.hpp>
  12. #include <boost/core/span.hpp>
  13. namespace boost {
  14. namespace mysql {
  15. namespace detail {
  16. struct any_execution_request
  17. {
  18. union data_t
  19. {
  20. string_view query;
  21. struct
  22. {
  23. statement stmt;
  24. span<const field_view> params;
  25. } stmt;
  26. data_t(string_view q) noexcept : query(q) {}
  27. data_t(statement s, span<const field_view> params) noexcept : stmt{s, params} {}
  28. } data;
  29. bool is_query;
  30. any_execution_request(string_view q) noexcept : data(q), is_query(true) {}
  31. any_execution_request(statement s, span<const field_view> params) noexcept
  32. : data(s, params), is_query(false)
  33. {
  34. }
  35. };
  36. } // namespace detail
  37. } // namespace mysql
  38. } // namespace boost
  39. #endif