diff --git a/doc/modules/ROOT/nav.adoc b/doc/modules/ROOT/nav.adoc index 994d9d8..f668924 100644 --- a/doc/modules/ROOT/nav.adoc +++ b/doc/modules/ROOT/nav.adoc @@ -1,4 +1,5 @@ * Concepts ** xref:concepts/ConstBufferSequence.adoc[] ** xref:concepts/MutableBufferSequence.adoc[] +** xref:concepts/DynamicBuffer.adoc[] * xref:reference:boost/buffers.adoc[Reference] diff --git a/doc/modules/ROOT/pages/concepts/ConstBufferSequence.adoc b/doc/modules/ROOT/pages/concepts/ConstBufferSequence.adoc index 34b3e04..af4fe3e 100644 --- a/doc/modules/ROOT/pages/concepts/ConstBufferSequence.adoc +++ b/doc/modules/ROOT/pages/concepts/ConstBufferSequence.adoc @@ -9,3 +9,79 @@ = ConstBufferSequence + +A __ConstBufferSequence__ represents a collection of `const_buffer` s or `mutable_buffer` s. + + +== Related Identifiers + +`is_const_buffer_sequence`. + + +== Requirements + +* `T` denotes a type meeting the requirements of __ConstBufferSequence__. +* `t` denotes a (possibly const) value of type `T`. +* `u` denotes an identifier. + +[cols="1a,1a,3a"] +|=== +// Headers +|Expression|Type|Semantics, Pre/Post-conditions + +// Row 1, Column 1 +|`T::value_type` +// Row 1, Column 2 +|`const_buffer` or `mutable_buffer` +// Row 1, Column 3 +|This type represents a buffer in the sequence. + +// Row 2, Column 1 +|`T::const_iterator` +// Row 2, Column 2 +| +// Row 2, Column 3 +|This type represents an iterator type that satisfies the requirements of `std::bidirectional_iterator`, whose value type is `const_buffer` or `mutable_buffer`. + +// Row 3, Column 1 +|`t.begin()` +// Row 3, Column 2 +|`T::const_iterator` +// Row 3, Column 3 +|Returns an iterator to the first element of the sequence. + +// Row 4, Column 1 +|`t.end()` +// Row 4, Column 2 +|`T::const_iterator` +// Row 4, Column 3 +|Returns an iterator to the element following the last element of the sequence. + +// Row 5, Column 1 +|`T u(t)`; +// Row 5, Column 2 +| +// Row 5, Column 3 +|`T` satisfies the requirements of `std::copyconstructible` and `std::destructible`. + +Post-conditions: +[source,cpp] +---- +assert(std::ranges::size(t) == std::ranges::size(u)); + +for (auto elem : std::views::zip(t, u)) +{ + assert(std::get<0>(elem).data() == std::get<1>(elem).data()); + assert(std::get<0>(elem).size() == std::get<1>(elem).size()); +} +---- + +|=== + + +== Models + +* `const_buffer_span` +* `mutable_buffer_span` +* `const_buffer_pair` +* `mutable_buffer_pair` diff --git a/doc/modules/ROOT/pages/concepts/DynamicBuffer.adoc b/doc/modules/ROOT/pages/concepts/DynamicBuffer.adoc new file mode 100644 index 0000000..5e405bd --- /dev/null +++ b/doc/modules/ROOT/pages/concepts/DynamicBuffer.adoc @@ -0,0 +1,108 @@ +// +// Copyright (c) 2024 Mohammad Nejati +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// Official repository: https://github.com/cppalliance/buffers +// + + += DynamicBuffer + +A __DynamicBuffer__ represents a memory storage that may be automatically resized as required, where the memory is divided into an input sequence followed by an output sequence. These memory regions are internal to the dynamic buffer, but direct access to the elements is provided to permit them to be efficiently used with I/O operations, such as the send or receive operations of a socket. Data written to the output sequence of a dynamic buffer object is appended to the input sequence of the same object. + + +== Related Identifiers + +`is_dynamic_buffer`. + + +== Requirements + +* `D` denotes a dynamic buffer class. +* `a` denotes a value of type `D`. +* `c` denotes a (possibly const) value of type `D`. +* `n` denotes a value of type `std::size_t`. +* `T` denotes a type meeting the requirements for `xref:./ConstBufferSequence.adoc[]`. +* `U` denotes a type meeting the requirements for `xref:./MutableBufferSequence.adoc[]`. + +[cols="1a,1a,3a"] +|=== +// Headers +|Expression|Type|Semantics, Pre/Post-conditions + +// Row 1, Column 1 +|`D::const_buffers_type` +// Row 1, Column 2 +|`T` +// Row 1, Column 3 +|This type represents the memory associated with the input sequence. + +// Row 2, Column 1 +|`D::mutable_buffers_type` +// Row 2, Column 2 +|`U` +// Row 2, Column 3 +|This type represents the memory associated with the output sequence. + +// Row 3, Column 1 +|`c.size()` +// Row 3, Column 2 +|`std::size_t` +// Row 3, Column 3 +|Returns the size, in bytes, of the input sequence. + +// Row 4, Column 1 +|`c.max_size()` +// Row 4, Column 2 +|`std::size_t` +// Row 4, Column 3 +|Returns the permitted maximum of the sum of the sizes of the input sequence and output sequence. + +// Row 5, Column 1 +|`c.capacity()` +// Row 5, Column 2 +|`std::size_t` +// Row 5, Column 3 +|Returns the maximum sum of the sizes of the input sequence and output sequence that the dynamic buffer can hold without requiring reallocation. + +// Row 6, Column 1 +|`c.data()` +// Row 6, Column 2 +|`D::const_buffers_type` +// Row 6, Column 3 +|Returns a constant buffer sequence `u` that represents the memory associated with the input sequence, and where `buffer_size(u) == size()`. + +// Row 7, Column 1 +|`a.prepare(n)` +// Row 7, Column 2 +|`D::mutable_buffers_type` +// Row 7, Column 3 +|Returns a mutable buffer sequence u representing the output sequence, and where `buffer_size(u) == n`. The dynamic buffer reallocates memory as required. All constant or mutable buffer sequences previously obtained using `data()` or `prepare()` are invalidated. + +Throws: `length_error` if `size() + n` exceeds `max_size()`. + +// Row 8, Column 1 +|`a.commit(n)` +// Row 8, Column 2 +| +// Row 8, Column 3 +|Appends `n` bytes from the start of the output sequence to the end of the input sequence. The remainder of the output sequence is discarded. If `n` is greater than the size of the output sequence, the entire output sequence is appended to the input sequence. All constant or mutable buffer sequences previously obtained using `data()` or `prepare()` are invalidated. + +// Row 9, Column 1 +|`a.consume(n)` +// Row 9, Column 2 +| +// Row 9, Column 3 +|Removes `n` bytes from beginning of the input sequence. If `n` is greater than the size of the input sequence, the entire input sequence is removed. All constant or mutable buffer sequences previously obtained using `data()` or `prepare()` are invalidated. + +|=== + + +== Models + +* `any_dynamic_buffer` +* `circular_buffer` +* `flat_buffer` +* `string_buffer` diff --git a/doc/modules/ROOT/pages/concepts/MutableBufferSequence.adoc b/doc/modules/ROOT/pages/concepts/MutableBufferSequence.adoc index 0202f25..1c3fb78 100644 --- a/doc/modules/ROOT/pages/concepts/MutableBufferSequence.adoc +++ b/doc/modules/ROOT/pages/concepts/MutableBufferSequence.adoc @@ -9,3 +9,76 @@ = MutableBufferSequence + +A __MutableBufferSequence__ represents a collection of `mutable_buffer` s. + + +== Related Identifiers + +`is_mutable_buffer_sequence`. + + +== Requirements + +* `T` denotes a type meeting the requirements of __MutableBufferSequence__. +* `t` denotes a (possibly const) value of type `T`. + +[cols="1a,1a,3a"] +|=== +// Headers +|Expression|Type|Semantics, Pre/Post-conditions + +// Row 1, Column 1 +|`T::value_type` +// Row 1, Column 2 +|`mutable_buffer` +// Row 1, Column 3 +|This type represents a mutable buffer in the sequence. + +// Row 2, Column 1 +|`T::const_iterator` +// Row 2, Column 2 +| +// Row 2, Column 3 +|This type represents an iterator type that satisfies the requirements of `std::bidirectional_iterator`, whose value type is `mutable_buffer`. + +// Row 3, Column 1 +|`t.begin()` +// Row 3, Column 2 +|`T::const_iterator` +// Row 3, Column 3 +|Returns an iterator to the first element of the sequence. + +// Row 4, Column 1 +|`t.end()` +// Row 4, Column 2 +|`T::const_iterator` +// Row 4, Column 3 +|Returns an iterator to the element following the last element of the sequence. + +// Row 5, Column 1 +|`T u(t)`; +// Row 5, Column 2 +| +// Row 5, Column 3 +|`T` satisfies the requirements of `std::copyconstructible` and `std::destructible`. + +Post-conditions: +[source,cpp] +---- +assert(std::ranges::size(t) == std::ranges::size(u)); + +for (auto elem : std::views::zip(t, u)) +{ + assert(std::get<0>(elem).data() == std::get<1>(elem).data()); + assert(std::get<0>(elem).size() == std::get<1>(elem).size()); +} +---- + +|=== + + +== Models + +* `mutable_buffer_span` +* `mutable_buffer_pair` diff --git a/doc/modules/ROOT/pages/index.adoc b/doc/modules/ROOT/pages/index.adoc index 6ebcd8b..03053c7 100644 --- a/doc/modules/ROOT/pages/index.adoc +++ b/doc/modules/ROOT/pages/index.adoc @@ -34,7 +34,7 @@ To use the library as header-only; that is, to eliminate the requirement to link a program to a static or dynamic Boost.URL library, simply place the following line in *exactly one* source file in your project. -[source, cpp] +[source,cpp] ---- #include ----