]> git.proxmox.com Git - ceph.git/blame - ceph/src/Beast/include/beast/core/to_string.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / include / beast / core / to_string.hpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
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)
6//
7
8#ifndef BEAST_TO_STRING_HPP
9#define BEAST_TO_STRING_HPP
10
11#include <beast/config.hpp>
12#include <beast/core/buffer_concepts.hpp>
13#include <boost/asio/buffer.hpp>
14#include <string>
15
16namespace beast {
17
18/** Convert a @b `ConstBufferSequence` to a `std::string`.
19
20 This function will convert the octets in a buffer sequence to a string.
21 All octets will be inserted into the resulting string, including null
22 or unprintable characters.
23
24 @param buffers The buffer sequence to convert.
25
26 @return A string representing the contents of the input area.
27
28 @note This function participates in overload resolution only if
29 the buffers parameter meets the requirements of @b `ConstBufferSequence`.
30*/
31template<class ConstBufferSequence>
32#if BEAST_DOXYGEN
33std::string
34#else
35typename std::enable_if<
36 is_ConstBufferSequence<ConstBufferSequence>::value,
37 std::string>::type
38#endif
39to_string(ConstBufferSequence const& buffers)
40{
41 using boost::asio::buffer_cast;
42 using boost::asio::buffer_size;
43 std::string s;
44 s.reserve(buffer_size(buffers));
45 for(auto const& buffer : buffers)
46 s.append(buffer_cast<char const*>(buffer),
47 buffer_size(buffer));
48 return s;
49}
50
51} // beast
52
53#endif