Warning, file /include/boost/redis/adapter/any_adapter.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_REDIS_ANY_ADAPTER_HPP
0008 #define BOOST_REDIS_ANY_ADAPTER_HPP
0009
0010
0011 #include <boost/redis/resp3/node.hpp>
0012 #include <boost/redis/adapter/adapt.hpp>
0013 #include <boost/system/error_code.hpp>
0014 #include <cstddef>
0015 #include <functional>
0016 #include <string_view>
0017 #include <type_traits>
0018
0019 namespace boost::redis {
0020
0021 namespace detail {
0022
0023
0024 template <class Executor>
0025 class basic_connection;
0026
0027 }
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 class any_adapter
0043 {
0044 using fn_type = std::function<void(std::size_t, resp3::basic_node<std::string_view> const&, system::error_code&)>;
0045
0046 struct impl_t {
0047 fn_type adapt_fn;
0048 std::size_t supported_response_size;
0049 } impl_;
0050
0051 template <class T>
0052 static auto create_impl(T& resp) -> impl_t
0053 {
0054 using namespace boost::redis::adapter;
0055 auto adapter = boost_redis_adapt(resp);
0056 std::size_t size = adapter.get_supported_response_size();
0057 return { std::move(adapter), size };
0058 }
0059
0060 template <class Executor>
0061 friend class basic_connection;
0062
0063 public:
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 template <class T, class = std::enable_if_t<!std::is_same_v<T, any_adapter>>>
0075 explicit any_adapter(T& resp) : impl_(create_impl(resp)) {}
0076 };
0077
0078 }
0079
0080 #endif