DynamicBuffer_v1.qbk 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. [/
  2. / Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  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. [section:DynamicBuffer_v1 Dynamic buffer requirements (version 1)]
  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
  11. sequence, but direct access to the elements is provided to permit them to be
  12. efficiently used with I/O operations, such as the `send` or `receive`
  13. operations of a socket. Data written to the output sequence of a dynamic buffer
  14. sequence object is appended to the input sequence of the same object.
  15. A dynamic buffer type `X` shall satisfy the requirements of `MoveConstructible`
  16. (C++ Std, [moveconstructible]) types in addition to those listed below.
  17. In the table below, `X` denotes a dynamic buffer class, `x` denotes a
  18. value of type `X&`, `x1` denotes values of type `const X&`, and `n` denotes a
  19. value of type `size_t`, and `u` denotes an identifier.
  20. [table DynamicBuffer_v1 requirements
  21. [[expression] [type] [assertion/note\npre/post-conditions]]
  22. [
  23. [`X::const_buffers_type`]
  24. [type meeting [link boost_asio.reference.ConstBufferSequence ConstBufferSequence]
  25. requirements.]
  26. [This type represents the memory associated with the input sequence.]
  27. ]
  28. [
  29. [`X::mutable_buffers_type`]
  30. [type meeting [link boost_asio.reference.MutableBufferSequence MutableBufferSequence]
  31. requirements.]
  32. [This type represents the memory associated with the output sequence.]
  33. ]
  34. [
  35. [`x1.size()`]
  36. [`size_t`]
  37. [Returns the size, in bytes, of the input sequence.]
  38. ]
  39. [
  40. [`x1.max_size()`]
  41. [`size_t`]
  42. [Returns the permitted maximum of the sum of the sizes of the input
  43. sequence and output sequence.]
  44. ]
  45. [
  46. [`x1.capacity()`]
  47. [`size_t`]
  48. [Returns the maximum sum of the sizes of the input sequence and output
  49. sequence that the dynamic buffer can hold without requiring reallocation.]
  50. ]
  51. [
  52. [`x1.data()`]
  53. [`X::const_buffers_type`]
  54. [Returns a constant buffer sequence `u` that represents the memory
  55. associated with the input sequence, and where `buffer_size(u) == size()`.]
  56. ]
  57. [
  58. [`x.prepare(n)`]
  59. [`X::mutable_buffers_type`]
  60. [Requires: `size() + n <= max_size()`.\n
  61. \n
  62. Returns a mutable buffer sequence `u` representing the output sequence, and
  63. where `buffer_size(u) == n`. The dynamic buffer reallocates memory as
  64. required. All constant or mutable buffer sequences previously obtained
  65. using `data()` or `prepare()` are invalidated.\n
  66. \n
  67. Throws: `length_error` if `size() + n > max_size()`.]
  68. ]
  69. [
  70. [`x.commit(n)`]
  71. []
  72. [Appends `n` bytes from the start of the output sequence to the end of the
  73. input sequence. The remainder of the output sequence is discarded. If `n`
  74. is greater than the size of the output sequence, the entire output sequence
  75. is appended to the input sequence. All constant or mutable buffer sequences
  76. previously obtained using `data()` or `prepare()` are invalidated.]
  77. ]
  78. [
  79. [`x.consume(n)`]
  80. []
  81. [Removes `n` bytes from beginning of the input sequence. If `n` is greater
  82. than the size of the input sequence, the entire input sequence is removed.
  83. All constant or mutable buffer sequences previously obtained using `data()`
  84. or `prepare()` are invalidated.]
  85. ]
  86. ]
  87. [endsect]