Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:39

0001 //
0002 // Copyright (c) 2019-2023 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_EXECUTION_CONCEPTS_HPP
0009 #define BOOST_MYSQL_DETAIL_EXECUTION_CONCEPTS_HPP
0010 
0011 #include <boost/mysql/statement.hpp>
0012 #include <boost/mysql/string_view.hpp>
0013 
0014 #include <boost/mysql/detail/config.hpp>
0015 
0016 #include <type_traits>
0017 
0018 #ifdef BOOST_MYSQL_HAS_CONCEPTS
0019 
0020 namespace boost {
0021 namespace mysql {
0022 
0023 // Forward decls
0024 template <class... StaticRow>
0025 class static_execution_state;
0026 
0027 template <class... StaticRow>
0028 class static_results;
0029 
0030 class execution_state;
0031 class results;
0032 
0033 namespace detail {
0034 
0035 // Execution state
0036 template <class T>
0037 struct is_static_execution_state : std::false_type
0038 {
0039 };
0040 
0041 template <class... T>
0042 struct is_static_execution_state<static_execution_state<T...>> : std::true_type
0043 {
0044 };
0045 
0046 template <class T>
0047 concept execution_state_type = std::is_same_v<T, execution_state> || is_static_execution_state<T>::value;
0048 
0049 // Results
0050 template <class T>
0051 struct is_static_results : std::false_type
0052 {
0053 };
0054 
0055 template <class... T>
0056 struct is_static_results<static_results<T...>> : std::true_type
0057 {
0058 };
0059 
0060 template <class T>
0061 concept results_type = std::is_same_v<T, results> || is_static_results<T>::value;
0062 
0063 // Execution request
0064 template <class T>
0065 struct is_bound_statement_tuple : std::false_type
0066 {
0067 };
0068 
0069 template <class T>
0070 struct is_bound_statement_tuple<bound_statement_tuple<T>> : std::true_type
0071 {
0072 };
0073 
0074 template <class T>
0075 struct is_bound_statement_range : std::false_type
0076 {
0077 };
0078 
0079 template <class T>
0080 struct is_bound_statement_range<bound_statement_iterator_range<T>> : std::true_type
0081 {
0082 };
0083 
0084 template <class T>
0085 struct is_execution_request
0086 {
0087     using without_cvref = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
0088     static constexpr bool value = std::is_convertible<T, string_view>::value ||
0089                                   is_bound_statement_tuple<without_cvref>::value ||
0090                                   is_bound_statement_range<without_cvref>::value;
0091 };
0092 
0093 template <class T>
0094 concept execution_request = is_execution_request<T>::value;
0095 
0096 }  // namespace detail
0097 }  // namespace mysql
0098 }  // namespace boost
0099 
0100 #define BOOST_MYSQL_EXECUTION_STATE_TYPE ::boost::mysql::detail::execution_state_type
0101 #define BOOST_MYSQL_RESULTS_TYPE ::boost::mysql::detail::results_type
0102 #define BOOST_MYSQL_EXECUTION_REQUEST ::boost::mysql::detail::execution_request
0103 
0104 #else
0105 
0106 #define BOOST_MYSQL_EXECUTION_STATE_TYPE class
0107 #define BOOST_MYSQL_RESULTS_TYPE class
0108 #define BOOST_MYSQL_EXECUTION_REQUEST class
0109 
0110 #endif
0111 
0112 #endif