File indexing completed on 2025-01-18 09:29:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_DETAIL_BUFFER_TRAITS_HPP
0011 #define BOOST_BEAST_DETAIL_BUFFER_TRAITS_HPP
0012
0013 #include <boost/asio/buffer.hpp>
0014 #include <boost/config/workaround.hpp>
0015 #include <boost/type_traits/make_void.hpp>
0016 #include <cstdint>
0017 #include <type_traits>
0018
0019 namespace boost {
0020 namespace beast {
0021 namespace detail {
0022
0023 #if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
0024
0025 template<class T>
0026 struct buffers_iterator_type_helper
0027 {
0028 using type = decltype(
0029 net::buffer_sequence_begin(
0030 std::declval<T const&>()));
0031 };
0032
0033 template<>
0034 struct buffers_iterator_type_helper<
0035 net::const_buffer>
0036 {
0037 using type = net::const_buffer const*;
0038 };
0039
0040 template<>
0041 struct buffers_iterator_type_helper<
0042 net::mutable_buffer>
0043 {
0044 using type = net::mutable_buffer const*;
0045 };
0046
0047 #endif
0048
0049 struct buffer_bytes_impl
0050 {
0051 std::size_t
0052 operator()(net::const_buffer b) const noexcept
0053 {
0054 return net::const_buffer(b).size();
0055 }
0056
0057 std::size_t
0058 operator()(net::mutable_buffer b) const noexcept
0059 {
0060 return net::mutable_buffer(b).size();
0061 }
0062
0063 template<
0064 class B,
0065 class = typename std::enable_if<
0066 net::is_const_buffer_sequence<B>::value>::type>
0067 std::size_t
0068 operator()(B const& b) const noexcept
0069 {
0070 using net::buffer_size;
0071 return buffer_size(b);
0072 }
0073 };
0074
0075
0076
0077
0078
0079 template<class ConstBufferSequence>
0080 bool
0081 buffers_empty(ConstBufferSequence const& buffers)
0082 {
0083 auto it = net::buffer_sequence_begin(buffers);
0084 auto end = net::buffer_sequence_end(buffers);
0085 while(it != end)
0086 {
0087 if(net::const_buffer(*it).size() > 0)
0088 return false;
0089 ++it;
0090 }
0091 return true;
0092 }
0093
0094 }
0095 }
0096 }
0097
0098 #endif