@b DynamicBuffer_v1: Get a list of buffers that represents the output sequence, with the given size. * Ensures that the output sequence can accommodate @c n bytes, resizing the * basic_string object as necessary. * * @returns An object of type @c mutable_buffers_type that satisfies * MutableBufferSequence requirements, representing basic_string memory * at the start of the output se
| 1712 | * output sequence. |
| 1713 | */ |
| 1714 | mutable_buffers_type prepare(std::size_t n) |
| 1715 | { |
| 1716 | if (size() > max_size() || max_size() - size() < n) |
| 1717 | { |
| 1718 | std::length_error ex("dynamic_string_buffer too long"); |
| 1719 | asio::detail::throw_exception(ex); |
| 1720 | } |
| 1721 | |
| 1722 | if (size_ == (std::numeric_limits<std::size_t>::max)()) |
| 1723 | size_ = string_.size(); // Enable v1 behaviour. |
| 1724 | |
| 1725 | string_.resize(size_ + n); |
| 1726 | |
| 1727 | return asio::buffer(asio::buffer(string_) + size_, n); |
| 1728 | } |
| 1729 | |
| 1730 | /// @b DynamicBuffer_v1: Move bytes from the output sequence to the input |
| 1731 | /// sequence. |