1[/ 2 / Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff 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[section:DynamicBuffer_v1 Dynamic buffer requirements (version 1)] 9 10A dynamic buffer encapsulates memory storage that may be automatically resized 11as required, where the memory is divided into an input sequence followed by an 12output sequence. These memory regions are internal to the dynamic buffer 13sequence, but direct access to the elements is provided to permit them to be 14efficiently used with I/O operations, such as the `send` or `receive` 15operations of a socket. Data written to the output sequence of a dynamic buffer 16sequence object is appended to the input sequence of the same object. 17 18A dynamic buffer type `X` shall satisfy the requirements of `MoveConstructible` 19(C++ Std, [moveconstructible]) types in addition to those listed below. 20 21In the table below, `X` denotes a dynamic buffer class, `x` denotes a 22value of type `X&`, `x1` denotes values of type `const X&`, and `n` denotes a 23value of type `size_t`, and `u` denotes an identifier. 24 25[table DynamicBuffer_v1 requirements 26 [[expression] [type] [assertion/note[br]pre/post-conditions]] 27 [ 28 [`X::const_buffers_type`] 29 [type meeting [link boost_asio.reference.ConstBufferSequence ConstBufferSequence] 30 requirements.] 31 [This type represents the memory associated with the input sequence.] 32 ] 33 [ 34 [`X::mutable_buffers_type`] 35 [type meeting [link boost_asio.reference.MutableBufferSequence MutableBufferSequence] 36 requirements.] 37 [This type represents the memory associated with the output sequence.] 38 ] 39 [ 40 [`x1.size()`] 41 [`size_t`] 42 [Returns the size, in bytes, of the input sequence.] 43 ] 44 [ 45 [`x1.max_size()`] 46 [`size_t`] 47 [Returns the permitted maximum of the sum of the sizes of the input 48 sequence and output sequence.] 49 ] 50 [ 51 [`x1.capacity()`] 52 [`size_t`] 53 [Returns the maximum sum of the sizes of the input sequence and output 54 sequence that the dynamic buffer can hold without requiring reallocation.] 55 ] 56 [ 57 [`x1.data()`] 58 [`X::const_buffers_type`] 59 [Returns a constant buffer sequence `u` that represents the memory 60 associated with the input sequence, and where `buffer_size(u) == size()`.] 61 ] 62 [ 63 [`x.prepare(n)`] 64 [`X::mutable_buffers_type`] 65 [Requires: `size() + n <= max_size()`.[br] 66 [br] 67 Returns a mutable buffer sequence `u` representing the output sequence, and 68 where `buffer_size(u) == n`. The dynamic buffer reallocates memory as 69 required. All constant or mutable buffer sequences previously obtained 70 using `data()` or `prepare()` are invalidated.[br] 71 [br] 72 Throws: `length_error` if `size() + n > max_size()`.] 73 ] 74 [ 75 [`x.commit(n)`] 76 [] 77 [Appends `n` bytes from the start of the output sequence to the end of the 78 input sequence. The remainder of the output sequence is discarded. If `n` 79 is greater than the size of the output sequence, the entire output sequence 80 is appended to the input sequence. All constant or mutable buffer sequences 81 previously obtained using `data()` or `prepare()` are invalidated.] 82 ] 83 [ 84 [`x.consume(n)`] 85 [] 86 [Removes `n` bytes from beginning of the input sequence. If `n` is greater 87 than the size of the input sequence, the entire input sequence is removed. 88 All constant or mutable buffer sequences previously obtained using `data()` 89 or `prepare()` are invalidated.] 90 ] 91] 92 93[endsect] 94