2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
8 #ifndef BEAST_WEBSOCKET_DETAIL_DEBUG_HPP
9 #define BEAST_WEBSOCKET_DETAIL_DEBUG_HPP
11 #include <boost/asio/buffer.hpp>
20 template<class = void>
22 to_hex(boost::asio::const_buffer b)
24 using namespace boost::asio;
26 auto p = buffer_cast<std::uint8_t const*>(b);
27 auto n = buffer_size(b);
33 std::hex << int(*p++) << " ";
38 template<class Buffers>
40 to_hex(Buffers const& bs)
43 for(auto const& b : bs)
44 s.append(to_hex(boost::asio::const_buffer(b)));
48 template<class Buffers>
50 buffers_to_string(Buffers const& bs)
52 using namespace boost::asio;
54 s.reserve(buffer_size(bs));
55 for(auto const& b : bs)
56 s.append(buffer_cast<char const*>(b),
61 template<class = void>
66 for(int n = w*(s.size()/w); n>0; n-=w)