DynamicBuffer.qbk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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:DynamicBuffer DynamicBuffer]
  8. A dynamic buffer encapsulates memory storage that may be automatically resized
  9. as required, where the memory is divided into an input sequence followed by an
  10. output sequence. These memory regions are internal to the dynamic buffer, but
  11. direct access to the elements is provided to permit them to be efficiently used
  12. with I/O operations, such as the send or receive operations of a socket. Data
  13. written to the output sequence of a dynamic buffer object is appended to the
  14. input sequence of the same object.
  15. The interface to this concept is intended to permit the following
  16. implementation strategies:
  17. * A single contiguous octet array, which is reallocated as necessary to
  18. accommodate changes in the size of the octet sequence. This is the
  19. implementation approach currently offered by __flat_buffer__.
  20. * A sequence of one or more octet arrays, where each array is of the same
  21. size. Additional octet array objects are appended to the sequence to
  22. accommodate changes in the size of the octet sequence.
  23. * A sequence of one or more octet arrays of varying sizes. Additional octet
  24. array objects are appended to the sequence to accommodate changes in the
  25. size of the character sequence. This is the implementation approach
  26. currently offered by __multi_buffer__.
  27. [heading Associated With]
  28. * `boost::asio::is_dynamic_buffer`
  29. * __ConstBufferSequence__
  30. * __MutableBufferSequence__
  31. [heading Requirements]
  32. * `D` denotes a dynamic buffer class.
  33. * `a` denotes a value of type `D`.
  34. * `c` denotes a (possibly const) value of type `D`.
  35. * `n` denotes a value of type `std::size_t`.
  36. * `T` denotes a type meeting the requirements for __ConstBufferSequence__.
  37. * `U` denotes a type meeting the requirements for __MutableBufferSequence__.
  38. [table Valid expressions
  39. [[Expression] [Type] [Semantics, Pre/Post-conditions]]
  40. [
  41. [`D::const_buffers_type`]
  42. [`T`]
  43. [
  44. This type represents the memory associated with the input sequence.
  45. ]
  46. ][
  47. [`D::mutable_buffers_type`]
  48. [`U`]
  49. [
  50. This type represents the memory associated with the output sequence.
  51. ]
  52. ][
  53. [`c.size()`]
  54. [`std::size_t`]
  55. [
  56. Returns the size, in bytes, of the input sequence.
  57. ]
  58. ][
  59. [`c.max_size()`]
  60. [`std::size_t`]
  61. [
  62. Returns the permitted maximum of the sum of the sizes of the input
  63. sequence and output sequence.
  64. ]
  65. ][
  66. [`c.capacity()`]
  67. [`std::size_t`]
  68. [
  69. Returns the maximum sum of the sizes of the input sequence and output
  70. sequence that the dynamic buffer can hold without requiring reallocation.
  71. ]
  72. ][
  73. [`c.data()`]
  74. [`D::const_buffers_type`]
  75. [
  76. Returns a constant buffer sequence u that represents the memory
  77. associated with the input sequence, and where `buffer_size(u) == size()`.
  78. ]
  79. ][
  80. [`a.prepare(n)`]
  81. [`D::mutable_buffers_type`]
  82. [
  83. Returns a mutable buffer sequence u representing the output sequence,
  84. and where `buffer_size(u) == n`. The dynamic buffer reallocates memory
  85. as required. All constant or mutable buffer sequences previously
  86. obtained using `data()` or `prepare()` are invalidated.
  87. Throws: `length_error` if `size() + n` exceeds `max_size()`.
  88. ]
  89. ][
  90. [`a.commit(n)`]
  91. [ ]
  92. [
  93. Appends `n` bytes from the start of the output sequence to the end of
  94. the input sequence. The remainder of the output sequence is discarded.
  95. If `n` is greater than the size of the output sequence, the entire
  96. output sequence is appended to the input sequence. All constant or
  97. mutable buffer sequences previously obtained using `data()` or
  98. `prepare()` are invalidated.
  99. ]
  100. ][
  101. [`a.consume(n)`]
  102. [ ]
  103. [
  104. Removes `n` bytes from beginning of the input sequence. If `n` is
  105. greater than the size of the input sequence, the entire input sequence
  106. is removed. All constant or mutable buffer sequences previously
  107. obtained using `data()` or `prepare()` are invalidated.
  108. ]
  109. ]]
  110. [heading Models]
  111. * [link beast.ref.boost__beast__basic_flat_buffer `basic_flat_buffer`]
  112. * [link beast.ref.boost__beast__basic_multi_buffer `basic_multi_buffer`]
  113. * [link beast.ref.boost__beast__flat_buffer `flat_buffer`]
  114. * [link beast.ref.boost__beast__flat_static_buffer `flat_static_buffer`]
  115. * [link beast.ref.boost__beast__flat_static_buffer_base `flat_static_buffer_base`]
  116. * [link beast.ref.boost__beast__static_buffer `static_buffer`]
  117. * [link beast.ref.boost__beast__static_buffer_base `static_buffer_base`]
  118. * [link beast.ref.boost__beast__multi_buffer `multi_buffer`]
  119. [endsect]