File indexing completed on 2025-01-18 09:29:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_MAKE_PRINTABLE_HPP
0011 #define BOOST_BEAST_MAKE_PRINTABLE_HPP
0012
0013 #include <boost/beast/core/detail/config.hpp>
0014 #include <boost/beast/core/buffer_traits.hpp>
0015 #include <boost/asio/buffer.hpp>
0016 #include <ostream>
0017
0018 namespace boost {
0019 namespace beast {
0020
0021 namespace detail {
0022
0023 template<class Buffers>
0024 class make_printable_adaptor
0025 {
0026 Buffers b_;
0027
0028 public:
0029 explicit
0030 make_printable_adaptor(Buffers const& b)
0031 : b_(b)
0032 {
0033 }
0034
0035 template<class B>
0036 friend
0037 std::ostream&
0038 operator<<(std::ostream& os,
0039 make_printable_adaptor<B> const& v);
0040 };
0041
0042 template<class Buffers>
0043 std::ostream&
0044 operator<<(std::ostream& os,
0045 make_printable_adaptor<Buffers> const& v)
0046 {
0047 for(
0048 auto it = net::buffer_sequence_begin(v.b_),
0049 end = net::buffer_sequence_end(v.b_);
0050 it != end;
0051 ++it)
0052 {
0053 net::const_buffer cb = *it;
0054 os.write(static_cast<char const*>(
0055 cb.data()), cb.size());
0056 }
0057 return os;
0058 }
0059
0060 }
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 template<class ConstBufferSequence>
0090 #if BOOST_BEAST_DOXYGEN
0091 __implementation_defined__
0092 #else
0093 detail::make_printable_adaptor<ConstBufferSequence>
0094 #endif
0095 make_printable(ConstBufferSequence const& buffers)
0096 {
0097 static_assert(net::is_const_buffer_sequence<
0098 ConstBufferSequence>::value,
0099 "ConstBufferSequence type requirements not met");
0100 return detail::make_printable_adaptor<
0101 ConstBufferSequence>{buffers};
0102 }
0103
0104 }
0105 }
0106
0107 #endif