]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/beast/core/read_size.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / beast / core / read_size.hpp
1 //
2 // Copyright (c) 2016-2019 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 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_READ_SIZE_HELPER_HPP
11 #define BOOST_BEAST_READ_SIZE_HELPER_HPP
12
13 #include <boost/beast/core/detail/config.hpp>
14 #include <boost/throw_exception.hpp>
15
16 namespace boost {
17 namespace beast {
18
19 /** Returns a natural read size.
20
21 This function inspects the capacity, size, and maximum
22 size of the dynamic buffer. Then it computes a natural
23 read size given the passed-in upper limit. It favors
24 a read size that does not require a reallocation, subject
25 to a reasonable minimum to avoid tiny reads.
26
27 @param buffer The dynamic buffer to inspect.
28
29 @param max_size An upper limit on the returned value.
30
31 @note If the buffer is already at its maximum size, zero
32 is returned.
33 */
34 template<class DynamicBuffer>
35 std::size_t
36 read_size(DynamicBuffer& buffer, std::size_t max_size);
37
38 /** Returns a natural read size or throw if the buffer is full.
39
40 This function inspects the capacity, size, and maximum
41 size of the dynamic buffer. Then it computes a natural
42 read size given the passed-in upper limit. It favors
43 a read size that does not require a reallocation, subject
44 to a reasonable minimum to avoid tiny reads.
45
46 @param buffer The dynamic buffer to inspect.
47
48 @param max_size An upper limit on the returned value.
49
50 @throws std::length_error if `max_size > 0` and the buffer
51 is full.
52 */
53 template<class DynamicBuffer>
54 std::size_t
55 read_size_or_throw(DynamicBuffer& buffer,
56 std::size_t max_size);
57
58 } // beast
59 } // boost
60
61 #include <boost/beast/core/impl/read_size.hpp>
62
63 #endif