Skip to content

Commit a996ce5

Browse files
committed
Add documentation for concepts
1 parent d5a6330 commit a996ce5

File tree

5 files changed

+259
-1
lines changed

5 files changed

+259
-1
lines changed

doc/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* Concepts
22
** xref:concepts/ConstBufferSequence.adoc[]
33
** xref:concepts/MutableBufferSequence.adoc[]
4+
** xref:concepts/DynamicBuffer.adoc[]
45
* xref:reference:boost/buffers.adoc[Reference]

doc/modules/ROOT/pages/concepts/ConstBufferSequence.adoc

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,79 @@
99

1010

1111
= ConstBufferSequence
12+
13+
A __ConstBufferSequence__ represents a collection of `const_buffer` s or `mutable_buffer` s.
14+
15+
16+
== Related Identifiers
17+
18+
`is_const_buffer_sequence`.
19+
20+
21+
== Requirements
22+
23+
* `T` denotes a type meeting the requirements of __ConstBufferSequence__.
24+
* `t` denotes a (possibly const) value of type `T`.
25+
* `u` denotes an identifier.
26+
27+
[cols="1a,1a,3a"]
28+
|===
29+
// Headers
30+
|Expression|Type|Semantics, Pre/Post-conditions
31+
32+
// Row 1, Column 1
33+
|`T::value_type`
34+
// Row 1, Column 2
35+
|`const_buffer` or `mutable_buffer`
36+
// Row 1, Column 3
37+
|This type represents a buffer in the sequence.
38+
39+
// Row 2, Column 1
40+
|`T::const_iterator`
41+
// Row 2, Column 2
42+
|
43+
// Row 2, Column 3
44+
|This type represents an iterator type that satisfies the requirements of `std::bidirectional_iterator`, whose value type is `const_buffer` or `mutable_buffer`.
45+
46+
// Row 3, Column 1
47+
|`t.begin()`
48+
// Row 3, Column 2
49+
|`T::const_iterator`
50+
// Row 3, Column 3
51+
|Returns an iterator to the first element of the sequence.
52+
53+
// Row 4, Column 1
54+
|`t.end()`
55+
// Row 4, Column 2
56+
|`T::const_iterator`
57+
// Row 4, Column 3
58+
|Returns an iterator to the element following the last element of the sequence.
59+
60+
// Row 5, Column 1
61+
|`T u(t)`;
62+
// Row 5, Column 2
63+
|
64+
// Row 5, Column 3
65+
|`T` satisfies the requirements of `std::copyconstructible` and `std::destructible`.
66+
67+
Post-conditions:
68+
[source,cpp]
69+
----
70+
assert(std::ranges::size(t) == std::ranges::size(u));
71+
72+
for (auto [l, r] : std::views::zip(t, u))
73+
{
74+
assert(l.data() == r.data());
75+
assert(l.size() == r.size());
76+
}
77+
----
78+
79+
|===
80+
81+
82+
== Models
83+
84+
* `const_buffer_span`
85+
* `mutable_buffer_span`
86+
* `const_buffer_pair`
87+
* `mutable_buffer_pair`
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//
2+
// Copyright (c) 2024 Mohammad Nejati
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/cppalliance/buffers
8+
//
9+
10+
11+
= DynamicBuffer
12+
13+
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.
14+
15+
16+
== Related Identifiers
17+
18+
`is_dynamic_buffer`.
19+
20+
21+
== Requirements
22+
23+
* `D` denotes a dynamic buffer class.
24+
* `a` denotes a value of type `D`.
25+
* `c` denotes a (possibly const) value of type `D`.
26+
* `n` denotes a value of type `std::size_t`.
27+
* `T` denotes a type meeting the requirements for `xref:./ConstBufferSequence.adoc[]`.
28+
* `U` denotes a type meeting the requirements for `xref:./MutableBufferSequence.adoc[]`.
29+
30+
[cols="1a,1a,3a"]
31+
|===
32+
// Headers
33+
|Expression|Type|Semantics, Pre/Post-conditions
34+
35+
// Row 1, Column 1
36+
|`D::const_buffers_type`
37+
// Row 1, Column 2
38+
|`T`
39+
// Row 1, Column 3
40+
|This type represents the memory associated with the input sequence.
41+
42+
// Row 2, Column 1
43+
|`D::mutable_buffers_type`
44+
// Row 2, Column 2
45+
|`U`
46+
// Row 2, Column 3
47+
|This type represents the memory associated with the output sequence.
48+
49+
// Row 3, Column 1
50+
|`c.size()`
51+
// Row 3, Column 2
52+
|`std::size_t`
53+
// Row 3, Column 3
54+
|Returns the size, in bytes, of the input sequence.
55+
56+
// Row 4, Column 1
57+
|`c.max_size()`
58+
// Row 4, Column 2
59+
|`std::size_t`
60+
// Row 4, Column 3
61+
|Returns the permitted maximum of the sum of the sizes of the input sequence and output sequence.
62+
63+
// Row 5, Column 1
64+
|`c.capacity()`
65+
// Row 5, Column 2
66+
|`std::size_t`
67+
// Row 5, Column 3
68+
|Returns the maximum sum of the sizes of the input sequence and output sequence that the dynamic buffer can hold without requiring reallocation.
69+
70+
// Row 6, Column 1
71+
|`c.data()`
72+
// Row 6, Column 2
73+
|`D::const_buffers_type`
74+
// Row 6, Column 3
75+
|Returns a constant buffer sequence `u` that represents the memory associated with the input sequence, and where `buffer_size(u) == size()`.
76+
77+
// Row 7, Column 1
78+
|`a.prepare(n)`
79+
// Row 7, Column 2
80+
|`D::mutable_buffers_type`
81+
// Row 7, Column 3
82+
|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.
83+
84+
Throws: `length_error` if `size() + n` exceeds `max_size()`.
85+
86+
// Row 8, Column 1
87+
|`a.commit(n)`
88+
// Row 8, Column 2
89+
|
90+
// Row 8, Column 3
91+
|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.
92+
93+
// Row 9, Column 1
94+
|`a.consume(n)`
95+
// Row 9, Column 2
96+
|
97+
// Row 9, Column 3
98+
|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.
99+
100+
|===
101+
102+
103+
== Models
104+
105+
* `any_dynamic_buffer`
106+
* `circular_buffer`
107+
* `flat_buffer`
108+
* `string_buffer`

doc/modules/ROOT/pages/concepts/MutableBufferSequence.adoc

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,76 @@
99

1010

1111
= MutableBufferSequence
12+
13+
A __MutableBufferSequence__ represents a collection of `mutable_buffer` s.
14+
15+
16+
== Related Identifiers
17+
18+
`is_mutable_buffer_sequence`.
19+
20+
21+
== Requirements
22+
23+
* `T` denotes a type meeting the requirements of __MutableBufferSequence__.
24+
* `t` denotes a (possibly const) value of type `T`.
25+
26+
[cols="1a,1a,3a"]
27+
|===
28+
// Headers
29+
|Expression|Type|Semantics, Pre/Post-conditions
30+
31+
// Row 1, Column 1
32+
|`T::value_type`
33+
// Row 1, Column 2
34+
|`mutable_buffer`
35+
// Row 1, Column 3
36+
|This type represents a mutable buffer in the sequence.
37+
38+
// Row 2, Column 1
39+
|`T::const_iterator`
40+
// Row 2, Column 2
41+
|
42+
// Row 2, Column 3
43+
|This type represents an iterator type that satisfies the requirements of `std::bidirectional_iterator`, whose value type is `mutable_buffer`.
44+
45+
// Row 3, Column 1
46+
|`t.begin()`
47+
// Row 3, Column 2
48+
|`T::const_iterator`
49+
// Row 3, Column 3
50+
|Returns an iterator to the first element of the sequence.
51+
52+
// Row 4, Column 1
53+
|`t.end()`
54+
// Row 4, Column 2
55+
|`T::const_iterator`
56+
// Row 4, Column 3
57+
|Returns an iterator to the element following the last element of the sequence.
58+
59+
// Row 5, Column 1
60+
|`T u(t)`;
61+
// Row 5, Column 2
62+
|
63+
// Row 5, Column 3
64+
|`T` satisfies the requirements of `std::copyconstructible` and `std::destructible`.
65+
66+
Post-conditions:
67+
[source,cpp]
68+
----
69+
assert(std::ranges::size(t) == std::ranges::size(u));
70+
71+
for (auto [l, r] : std::views::zip(t, u))
72+
{
73+
assert(l.data() == r.data());
74+
assert(l.size() == r.size());
75+
}
76+
----
77+
78+
|===
79+
80+
81+
== Models
82+
83+
* `mutable_buffer_span`
84+
* `mutable_buffer_pair`

doc/modules/ROOT/pages/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ To use the library as header-only; that is, to eliminate the requirement
3434
to link a program to a static or dynamic Boost.URL library, simply place
3535
the following line in *exactly one* source file in your project.
3636

37-
[source, cpp]
37+
[source,cpp]
3838
----
3939
#include <boost/buffers/src.hpp>
4040
----

0 commit comments

Comments
 (0)