• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>DynamicBuffer</title>
5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../index.html" title="Chapter 1. Boost.Beast">
8<link rel="up" href="../concepts.html" title="Concepts">
9<link rel="prev" href="BufferSequence.html" title="BufferSequence">
10<link rel="next" href="Fields.html" title="Fields">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="BufferSequence.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Fields.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="beast.concepts.DynamicBuffer"></a><a class="link" href="DynamicBuffer.html" title="DynamicBuffer">DynamicBuffer</a>
28</h3></div></div></div>
29<p>
30        A dynamic buffer encapsulates memory storage that may be automatically resized
31        as required, where the memory is divided into an input sequence followed
32        by an output sequence. These memory regions are internal to the dynamic buffer,
33        but direct access to the elements is provided to permit them to be efficiently
34        used with I/O operations, such as the send or receive operations of a socket.
35        Data written to the output sequence of a dynamic buffer object is appended
36        to the input sequence of the same object.
37      </p>
38<p>
39        The interface to this concept is intended to permit the following implementation
40        strategies:
41      </p>
42<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
43<li class="listitem">
44            A single contiguous octet array, which is reallocated as necessary to
45            accommodate changes in the size of the octet sequence. This is the implementation
46            approach currently offered by <a class="link" href="../ref/boost__beast__flat_buffer.html" title="flat_buffer"><code class="computeroutput"><span class="identifier">flat_buffer</span></code></a>.
47          </li>
48<li class="listitem">
49            A sequence of one or more octet arrays, where each array is of the same
50            size. Additional octet array objects are appended to the sequence to
51            accommodate changes in the size of the octet sequence.
52          </li>
53<li class="listitem">
54            A sequence of one or more octet arrays of varying sizes. Additional octet
55            array objects are appended to the sequence to accommodate changes in
56            the size of the character sequence. This is the implementation approach
57            currently offered by <a class="link" href="../ref/boost__beast__multi_buffer.html" title="multi_buffer"><code class="computeroutput"><span class="identifier">multi_buffer</span></code></a>.
58          </li>
59</ul></div>
60<h5>
61<a name="beast.concepts.DynamicBuffer.h0"></a>
62        <span class="phrase"><a name="beast.concepts.DynamicBuffer.associated_with"></a></span><a class="link" href="DynamicBuffer.html#beast.concepts.DynamicBuffer.associated_with">Associated
63        With</a>
64      </h5>
65<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
66<li class="listitem">
67            <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">is_dynamic_buffer</span></code>
68          </li>
69<li class="listitem">
70            <a href="../../../../../../doc/html/boost_asio/reference/ConstBufferSequence.html" target="_top"><span class="emphasis"><em>ConstBufferSequence</em></span></a>
71          </li>
72<li class="listitem">
73            <a href="../../../../../../doc/html/boost_asio/reference/MutableBufferSequence.html" target="_top"><span class="emphasis"><em>MutableBufferSequence</em></span></a>
74          </li>
75</ul></div>
76<h5>
77<a name="beast.concepts.DynamicBuffer.h1"></a>
78        <span class="phrase"><a name="beast.concepts.DynamicBuffer.requirements"></a></span><a class="link" href="DynamicBuffer.html#beast.concepts.DynamicBuffer.requirements">Requirements</a>
79      </h5>
80<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
81<li class="listitem">
82            <code class="computeroutput"><span class="identifier">D</span></code> denotes a dynamic buffer
83            class.
84          </li>
85<li class="listitem">
86            <code class="computeroutput"><span class="identifier">a</span></code> denotes a value of
87            type <code class="computeroutput"><span class="identifier">D</span></code>.
88          </li>
89<li class="listitem">
90            <code class="computeroutput"><span class="identifier">c</span></code> denotes a (possibly
91            const) value of type <code class="computeroutput"><span class="identifier">D</span></code>.
92          </li>
93<li class="listitem">
94            <code class="computeroutput"><span class="identifier">n</span></code> denotes a value of
95            type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
96          </li>
97<li class="listitem">
98            <code class="computeroutput"><span class="identifier">T</span></code> denotes a type meeting
99            the requirements for <a href="../../../../../../doc/html/boost_asio/reference/ConstBufferSequence.html" target="_top"><span class="emphasis"><em>ConstBufferSequence</em></span></a>.
100          </li>
101<li class="listitem">
102            <code class="computeroutput"><span class="identifier">U</span></code> denotes a type meeting
103            the requirements for <a href="../../../../../../doc/html/boost_asio/reference/MutableBufferSequence.html" target="_top"><span class="emphasis"><em>MutableBufferSequence</em></span></a>.
104          </li>
105</ul></div>
106<div class="table">
107<a name="beast.concepts.DynamicBuffer.valid_expressions"></a><p class="title"><b>Table 1.40. Valid expressions</b></p>
108<div class="table-contents"><table class="table" summary="Valid expressions">
109<colgroup>
110<col>
111<col>
112<col>
113</colgroup>
114<thead><tr>
115<th>
116                <p>
117                  Expression
118                </p>
119              </th>
120<th>
121                <p>
122                  Type
123                </p>
124              </th>
125<th>
126                <p>
127                  Semantics, Pre/Post-conditions
128                </p>
129              </th>
130</tr></thead>
131<tbody>
132<tr>
133<td>
134                <p>
135                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">const_buffers_type</span></code>
136                </p>
137              </td>
138<td>
139                <p>
140                  <code class="computeroutput"><span class="identifier">T</span></code>
141                </p>
142              </td>
143<td>
144                <p>
145                  This type represents the memory associated with the input sequence.
146                </p>
147              </td>
148</tr>
149<tr>
150<td>
151                <p>
152                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">mutable_buffers_type</span></code>
153                </p>
154              </td>
155<td>
156                <p>
157                  <code class="computeroutput"><span class="identifier">U</span></code>
158                </p>
159              </td>
160<td>
161                <p>
162                  This type represents the memory associated with the output sequence.
163                </p>
164              </td>
165</tr>
166<tr>
167<td>
168                <p>
169                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code>
170                </p>
171              </td>
172<td>
173                <p>
174                  <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>
175                </p>
176              </td>
177<td>
178                <p>
179                  Returns the size, in bytes, of the input sequence.
180                </p>
181              </td>
182</tr>
183<tr>
184<td>
185                <p>
186                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">max_size</span><span class="special">()</span></code>
187                </p>
188              </td>
189<td>
190                <p>
191                  <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>
192                </p>
193              </td>
194<td>
195                <p>
196                  Returns the permitted maximum of the sum of the sizes of the input
197                  sequence and output sequence.
198                </p>
199              </td>
200</tr>
201<tr>
202<td>
203                <p>
204                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">capacity</span><span class="special">()</span></code>
205                </p>
206              </td>
207<td>
208                <p>
209                  <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>
210                </p>
211              </td>
212<td>
213                <p>
214                  Returns the maximum sum of the sizes of the input sequence and
215                  output sequence that the dynamic buffer can hold without requiring
216                  reallocation.
217                </p>
218              </td>
219</tr>
220<tr>
221<td>
222                <p>
223                  <code class="computeroutput"><span class="identifier">c</span><span class="special">.</span><span class="identifier">data</span><span class="special">()</span></code>
224                </p>
225              </td>
226<td>
227                <p>
228                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">const_buffers_type</span></code>
229                </p>
230              </td>
231<td>
232                <p>
233                  Returns a constant buffer sequence u that represents the memory
234                  associated with the input sequence, and where <code class="computeroutput"><span class="identifier">buffer_size</span><span class="special">(</span><span class="identifier">u</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">size</span><span class="special">()</span></code>.
235                </p>
236              </td>
237</tr>
238<tr>
239<td>
240                <p>
241                  <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">prepare</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>
242                </p>
243              </td>
244<td>
245                <p>
246                  <code class="computeroutput"><span class="identifier">D</span><span class="special">::</span><span class="identifier">mutable_buffers_type</span></code>
247                </p>
248              </td>
249<td>
250                <p>
251                  Returns a mutable buffer sequence u representing the output sequence,
252                  and where <code class="computeroutput"><span class="identifier">buffer_size</span><span class="special">(</span><span class="identifier">u</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">n</span></code>. The dynamic buffer reallocates
253                  memory as required. All constant or mutable buffer sequences previously
254                  obtained using <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">prepare</span><span class="special">()</span></code> are invalidated.
255                </p>
256                <p>
257                  Throws: <code class="computeroutput"><span class="identifier">length_error</span></code>
258                  if <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span>
259                  <span class="special">+</span> <span class="identifier">n</span></code>
260                  exceeds <code class="computeroutput"><span class="identifier">max_size</span><span class="special">()</span></code>.
261                </p>
262              </td>
263</tr>
264<tr>
265<td>
266                <p>
267                  <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">commit</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>
268                </p>
269              </td>
270<td>
271              </td>
272<td>
273                <p>
274                  Appends <code class="computeroutput"><span class="identifier">n</span></code> bytes
275                  from the start of the output sequence to the end of the input sequence.
276                  The remainder of the output sequence is discarded. If <code class="computeroutput"><span class="identifier">n</span></code> is greater than the size of
277                  the output sequence, the entire output sequence is appended to
278                  the input sequence. All constant or mutable buffer sequences previously
279                  obtained using <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">prepare</span><span class="special">()</span></code> are invalidated.
280                </p>
281              </td>
282</tr>
283<tr>
284<td>
285                <p>
286                  <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">consume</span><span class="special">(</span><span class="identifier">n</span><span class="special">)</span></code>
287                </p>
288              </td>
289<td>
290              </td>
291<td>
292                <p>
293                  Removes <code class="computeroutput"><span class="identifier">n</span></code> bytes
294                  from beginning of the input sequence. If <code class="computeroutput"><span class="identifier">n</span></code>
295                  is greater than the size of the input sequence, the entire input
296                  sequence is removed. All constant or mutable buffer sequences previously
297                  obtained using <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">prepare</span><span class="special">()</span></code> are invalidated.
298                </p>
299              </td>
300</tr>
301</tbody>
302</table></div>
303</div>
304<br class="table-break"><h5>
305<a name="beast.concepts.DynamicBuffer.h2"></a>
306        <span class="phrase"><a name="beast.concepts.DynamicBuffer.models"></a></span><a class="link" href="DynamicBuffer.html#beast.concepts.DynamicBuffer.models">Models</a>
307      </h5>
308<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
309<li class="listitem">
310            <a class="link" href="../ref/boost__beast__basic_flat_buffer.html" title="basic_flat_buffer"><code class="computeroutput"><span class="identifier">basic_flat_buffer</span></code></a>
311          </li>
312<li class="listitem">
313            <a class="link" href="../ref/boost__beast__basic_multi_buffer.html" title="basic_multi_buffer"><code class="computeroutput"><span class="identifier">basic_multi_buffer</span></code></a>
314          </li>
315<li class="listitem">
316            <a class="link" href="../ref/boost__beast__flat_buffer.html" title="flat_buffer"><code class="computeroutput"><span class="identifier">flat_buffer</span></code></a>
317          </li>
318<li class="listitem">
319            <a class="link" href="../ref/boost__beast__flat_static_buffer.html" title="flat_static_buffer"><code class="computeroutput"><span class="identifier">flat_static_buffer</span></code></a>
320          </li>
321<li class="listitem">
322            <a class="link" href="../ref/boost__beast__flat_static_buffer_base.html" title="flat_static_buffer_base"><code class="computeroutput"><span class="identifier">flat_static_buffer_base</span></code></a>
323          </li>
324<li class="listitem">
325            <a class="link" href="../ref/boost__beast__static_buffer.html" title="static_buffer"><code class="computeroutput"><span class="identifier">static_buffer</span></code></a>
326          </li>
327<li class="listitem">
328            <a class="link" href="../ref/boost__beast__static_buffer_base.html" title="static_buffer_base"><code class="computeroutput"><span class="identifier">static_buffer_base</span></code></a>
329          </li>
330<li class="listitem">
331            <a class="link" href="../ref/boost__beast__multi_buffer.html" title="multi_buffer"><code class="computeroutput"><span class="identifier">multi_buffer</span></code></a>
332          </li>
333</ul></div>
334</div>
335<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
336<td align="left"></td>
337<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie
338      Falco<p>
339        Distributed under the Boost Software License, Version 1.0. (See accompanying
340        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
341      </p>
342</div></td>
343</tr></table>
344<hr>
345<div class="spirit-nav">
346<a accesskey="p" href="BufferSequence.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../concepts.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Fields.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
347</div>
348</body>
349</html>
350