5_buffers.qbk 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. [/
  2. Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. Official repository: https://github.com/boostorg/beast
  6. ]
  7. [section Buffer Types]
  8. To facilitate working with instances of the __ConstBufferSequence__ and
  9. __MutableBufferSequence__ concepts introduced in __Asio__, Beast treats
  10. those sequences as a special type of range. The following algorithms and
  11. wrappers are provided which transform these ranges efficiently using lazy
  12. evaluation. No memory allocations are used in the transformations; instead,
  13. they create lightweight iterators over the existing, unmodified memory
  14. buffers. Control of buffers is retained by the caller; ownership is not
  15. transferred.
  16. [table Buffer Algorithms and Types
  17. [[Name][Description]]
  18. [[
  19. [link beast.ref.boost__beast__buffer_bytes `buffer_bytes`]
  20. ][
  21. This is a more reliable version of
  22. [@boost:/doc/html/boost_asio/reference/buffer_size.html `net::buffer_size`]
  23. which is easier to use and also works for types which are convertible
  24. to `net::const_buffer` or `net::mutable_buffer`.
  25. ]]
  26. [[
  27. [link beast.ref.boost__beast__buffers_cat `buffers_cat`]
  28. ][
  29. This functions returns a new buffer sequence which, when iterated,
  30. traverses the sequence which would be formed if all of the input buffer
  31. sequences were concatenated. With this routine, multiple calls to a
  32. stream's `write_some` function may be combined into one, eliminating
  33. expensive system calls.
  34. ]]
  35. [[
  36. [link beast.ref.boost__beast__buffers_cat_view `buffers_cat_view`]
  37. ][
  38. This class represents the buffer sequence formed by concatenating
  39. two or more buffer sequences. This is type of object returned by
  40. [link beast.ref.boost__beast__buffers_cat `buffers_cat`].
  41. ]]
  42. [[
  43. [link beast.ref.boost__beast__buffers_front `buffers_front`]
  44. ][
  45. This function returns the first buffer in a buffer sequence,
  46. or a buffer of size zero if the buffer sequence has no elements.
  47. ]]
  48. [[
  49. [link beast.ref.boost__beast__buffers_prefix `buffers_prefix`]
  50. ][
  51. This function returns a new buffer or buffer sequence which represents
  52. a prefix of the original buffers.
  53. ]]
  54. [[
  55. [link beast.ref.boost__beast__buffers_prefix_view `buffers_prefix_view`]
  56. ][
  57. This class represents the buffer sequence formed from a prefix of
  58. an existing buffer sequence. This is the type of buffer returned by
  59. [link beast.ref.boost__beast__buffers_prefix `buffers_prefix`].
  60. ]]
  61. [[
  62. [link beast.ref.boost__beast__buffers_range `buffers_range`]
  63. [link beast.ref.boost__beast__buffers_range_ref `buffers_range_ref`]
  64. ][
  65. This function returns an iterable range representing the passed
  66. buffer sequence. The values obtained when iterating the range
  67. will always be a constant buffer, unless the underlying buffer
  68. sequence is mutable, in which case the value obtained when iterating
  69. will be a mutable buffer. It is intended as a notational convenience
  70. when writing a ['range-for] statement over a buffer sequence.
  71. The function
  72. [link beast.ref.boost__beast__buffers_range_ref `buffers_range`]
  73. maintains a copy of the buffer sequence, while
  74. [link beast.ref.boost__beast__buffers_range_ref `buffers_range_ref`]
  75. maintains a reference (in this case, the caller must ensure that
  76. the lifetime of the referenced buffer sequence extends until the
  77. range object is destroyed).
  78. ]]
  79. [[
  80. [link beast.ref.boost__beast__buffers_suffix `buffers_suffix`]
  81. ][
  82. This class wraps the underlying memory of an existing buffer sequence
  83. and presents a suffix of the original sequence. The length of the suffix
  84. may be progressively shortened. This lets callers work with sequential
  85. increments of a buffer sequence.
  86. ]]
  87. [[
  88. [link beast.ref.boost__beast__buffers_to_string `buffers_to_string`]
  89. ][
  90. This function converts a buffer sequence to a `std::string`. It can
  91. be used for diagnostic purposes and tests.
  92. ]]
  93. ]
  94. The __DynamicBuffer__ concept introduced in __Asio__ models a buffer
  95. sequence which supports an owning, resizable range. Beast provides this
  96. set of additional implementations of the dynamic buffer concept:
  97. [table Dynamic Buffer Implementations
  98. [[Name][Description]]
  99. [[
  100. [link beast.ref.boost__beast__buffers_adaptor `buffers_adaptor`]
  101. ][
  102. This wrapper adapts any __MutableBufferSequence__ into a
  103. __DynamicBuffer__ with an upper limit on the total size of the input and
  104. output areas equal to the size of the underlying mutable buffer sequence.
  105. The implementation does not perform heap allocations.
  106. ]]
  107. [[
  108. [link beast.ref.boost__beast__flat_buffer `flat_buffer`]
  109. [link beast.ref.boost__beast__basic_flat_buffer `basic_flat_buffer`]
  110. ][
  111. Guarantees that input and output areas are buffer sequences with
  112. length one.
  113. Upon construction an optional upper limit to the total size of the
  114. input and output areas may be set.
  115. The basic container is an
  116. [@https://en.cppreference.com/w/cpp/named_req/AllocatorAwareContainer [*AllocatorAwareContainer]].
  117. ]]
  118. [[
  119. [link beast.ref.boost__beast__multi_buffer `multi_buffer`]
  120. [link beast.ref.boost__beast__basic_multi_buffer `basic_multi_buffer`]
  121. ][
  122. Uses a sequence of one or more character arrays of varying sizes.
  123. Additional character array objects are appended to the sequence to
  124. accommodate changes in the size of the character sequence.
  125. The basic container is an
  126. [@https://en.cppreference.com/w/cpp/named_req/AllocatorAwareContainer [*AllocatorAwareContainer]].
  127. ]]
  128. [[
  129. [link beast.ref.boost__beast__flat_static_buffer `flat_static_buffer`]
  130. [link beast.ref.boost__beast__flat_static_buffer_base `flat_static_buffer_base`]
  131. ][
  132. Guarantees that input and output areas are buffer sequences with
  133. length one.
  134. Provides the facilities of a dynamic buffer, subject to an upper
  135. limit placed on the total size of the input and output areas defined
  136. by a constexpr template parameter. The storage for the sequences are
  137. kept in the class; the implementation does not perform heap allocations.
  138. ]]
  139. [[
  140. [link beast.ref.boost__beast__static_buffer `static_buffer`]
  141. [link beast.ref.boost__beast__static_buffer_base `static_buffer_base`]
  142. ][
  143. Provides the facilities of a circular dynamic buffer. subject to an
  144. upper limit placed on the total size of the input and output areas
  145. defined by a constexpr template parameter.
  146. The implementation never moves memory during buffer operations.
  147. The storage for the sequences are kept in the class; the implementation
  148. does not perform heap allocations.
  149. ]]
  150. ]
  151. These two functions facilitate buffer interoperability with standard
  152. output streams.
  153. [table Buffer Output Streams
  154. [[Name][Description]]
  155. [[
  156. [link beast.ref.boost__beast__make_printable `make_printable`]
  157. ][
  158. This function wraps a __ConstBufferSequence__ so it may be
  159. used with `operator<<` and `std::ostream`.
  160. ]]
  161. [[
  162. [link beast.ref.boost__beast__ostream `ostream`]
  163. ][
  164. This function returns a `std::ostream` which wraps a dynamic buffer.
  165. Characters sent to the stream using `operator<<` are stored in the
  166. dynamic buffer.
  167. ]]
  168. ]
  169. These type traits are provided to facilitate writing compile-time
  170. metafunctions which operate on buffers:
  171. [table Buffer Algorithms and Types
  172. [[Name][Description]]
  173. [[
  174. [link beast.ref.boost__beast__buffers_iterator_type `buffers_iterator_type`]
  175. ][
  176. This metafunction is used to determine the type of iterator
  177. used by a particular buffer sequence.
  178. ]]
  179. [[
  180. [link beast.ref.boost__beast__buffers_type `buffers_type`]
  181. ][
  182. This metafunction is used to determine the underlying buffer type for
  183. a list of buffer sequence. The equivalent type of the alias will vary
  184. depending on the template type argument.
  185. ]]
  186. [[
  187. [link beast.ref.boost__beast__is_const_buffer_sequence `is_const_buffer_sequence`]
  188. ][
  189. This metafunction is used to determine if all of the specified types
  190. meet the requirements of __ConstBufferSequence__. This type alias
  191. will be `std::true_type` if each specified type meets the requirements,
  192. otherwise, this type alias will be `std::false_type`.
  193. ]]
  194. [[
  195. [link beast.ref.boost__beast__is_mutable_buffer_sequence `is_mutable_buffer_sequence`]
  196. ][
  197. This metafunction is used to determine if all of the specified types
  198. meet the requirements of __MutableBufferSequence__. This type alias
  199. will be `std::true_type` if each specified type meets the requirements,
  200. otherwise, this type alias will be `std::false_type`.
  201. ]]
  202. ]
  203. [endsect]