Files
boost_beast/doc/concept/BodyReader.qbk
T

88 lines
3.0 KiB
Plaintext
Raw Normal View History

2017-05-08 12:41:45 -07:00
[/
Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
]
2017-06-04 17:25:55 -07:00
[section:BodyReader BodyReader]
2017-05-08 12:41:45 -07:00
2017-05-28 09:05:29 -07:00
A [*BodyReader] provides an online algorithm to obtain a sequence of zero
2017-05-08 12:41:45 -07:00
or more buffers from a body during serialization. The implementation creates
2017-05-28 09:05:29 -07:00
an instance of this type when needed, and calls into it one or more times to
retrieve buffers holding body octets. The interface of [*BodyReader] is
intended to obtain buffers for these scenarios:
2017-05-08 12:41:45 -07:00
* A body that does not entirely fit in memory.
* A body produced incrementally from coroutine output.
* A body represented by zero or more buffers already in memory.
2017-05-28 09:05:29 -07:00
* A body whose size is not known ahead of time.
* Body data generated dynamically from other threads.
2017-05-08 12:41:45 -07:00
* Body data computed algorithmically.
In this table:
2017-05-28 09:05:29 -07:00
* `X` denotes a type meeting the requirements of [*BodyReader].
* `B` denotes a __Body__ where
`std::is_same<X, B::reader>::value == true`.
2017-05-08 12:41:45 -07:00
* `a` denotes a value of type `X`.
* `m` denotes a value of type `message const&` where
2017-05-28 09:05:29 -07:00
`std::is_same<decltype(m.body), Body::value_type>:value == true`.
2017-05-08 12:41:45 -07:00
2017-06-14 12:03:19 -07:00
* `ec` is a value of type [link beast.ref.beast__error_code `error_code&`].
2017-05-08 12:41:45 -07:00
2017-05-28 09:05:29 -07:00
* `R<T>` is the type `boost::optional<std::pair<T, bool>>`.
2017-05-08 12:41:45 -07:00
2017-05-28 09:05:29 -07:00
[table BodyReader requirements
[[expression] [type] [semantics, pre/post-conditions]]
2017-05-08 12:41:45 -07:00
[
[`X::const_buffers_type`]
[]
[
2017-05-28 09:05:29 -07:00
A type which meets the requirements of __ConstBufferSequence__.
2017-05-08 12:41:45 -07:00
This is the type of buffer returned by `X::get`.
]
2017-06-07 04:36:45 -07:00
][
[`X(m,ec);`]
2017-05-08 12:41:45 -07:00
[]
[
Constructible from `m`. The lifetime of `m` is guaranteed
to end no earlier than after the `X` is destroyed.
2017-06-13 07:08:52 -07:00
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
2017-05-08 12:41:45 -07:00
]
2017-06-07 04:36:45 -07:00
][
2017-05-08 12:41:45 -07:00
[`a.get(ec)`]
2017-05-28 09:05:29 -07:00
[`R<X::const_buffers_type>`]
2017-05-08 12:41:45 -07:00
[
Called repeatedly after `init` succeeds. This function returns
`boost::none` if all buffers representing the body have been
returned in previous calls or if it sets `ec` to indicate an
error. Otherwise, if there are buffers remaining the function
should return a pair with the first element containing a non-zero
length buffer sequence representing the next set of octets in
the body, while the second element is a `bool` meaning `true`
if there may be additional buffers returned on a subsequent call,
or `false` if the buffer returned on this call is the last
buffer representing the body.
2017-06-13 07:08:52 -07:00
The function will ensure that `!ec` is `true` if there was
no error or set to the appropriate error code if there was one.
2017-05-08 12:41:45 -07:00
]
2017-06-07 04:36:45 -07:00
][
2017-05-28 09:05:29 -07:00
[`is_body_reader<B>`]
2017-05-08 12:41:45 -07:00
[`std::true_type`]
[
2017-05-28 09:05:29 -07:00
An alias for `std::true_type` for `B`, otherwise an alias
for `std::false_type`.
2017-05-08 12:41:45 -07:00
]
]
]
2017-06-19 14:35:32 -07:00
[heading Exemplar]
2017-06-20 20:10:47 -07:00
[concept_BodyReader]
2017-05-08 12:41:45 -07:00
[endsect]