|
||||
File indexing completed on 2025-01-18 09:29:28
0001 // 0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 // Official repository: https://github.com/boostorg/beast 0008 // 0009 0010 #ifndef BOOST_BEAST_READ_SIZE_HELPER_HPP 0011 #define BOOST_BEAST_READ_SIZE_HELPER_HPP 0012 0013 #include <boost/beast/core/detail/config.hpp> 0014 #include <boost/throw_exception.hpp> 0015 0016 namespace boost { 0017 namespace beast { 0018 0019 /** Returns a natural read size. 0020 0021 This function inspects the capacity, size, and maximum 0022 size of the dynamic buffer. Then it computes a natural 0023 read size given the passed-in upper limit. It favors 0024 a read size that does not require a reallocation, subject 0025 to a reasonable minimum to avoid tiny reads. 0026 0027 @param buffer The dynamic buffer to inspect. 0028 0029 @param max_size An upper limit on the returned value. 0030 0031 @note If the buffer is already at its maximum size, zero 0032 is returned. 0033 */ 0034 template<class DynamicBuffer> 0035 std::size_t 0036 read_size(DynamicBuffer& buffer, std::size_t max_size); 0037 0038 /** Returns a natural read size or throw if the buffer is full. 0039 0040 This function inspects the capacity, size, and maximum 0041 size of the dynamic buffer. Then it computes a natural 0042 read size given the passed-in upper limit. It favors 0043 a read size that does not require a reallocation, subject 0044 to a reasonable minimum to avoid tiny reads. 0045 0046 @param buffer The dynamic buffer to inspect. 0047 0048 @param max_size An upper limit on the returned value. 0049 0050 @throws std::length_error if `max_size > 0` and the buffer 0051 is full. 0052 */ 0053 template<class DynamicBuffer> 0054 std::size_t 0055 read_size_or_throw(DynamicBuffer& buffer, 0056 std::size_t max_size); 0057 0058 } // beast 0059 } // boost 0060 0061 #include <boost/beast/core/impl/read_size.hpp> 0062 0063 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |