@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
| 1942 | * output sequence. |
| 1943 | */ |
| 1944 | mutable_buffers_type prepare(std::size_t n) |
| 1945 | { |
| 1946 | if (size() > max_size() || max_size() - size() < n) |
| 1947 | { |
| 1948 | std::length_error ex("dynamic_string_buffer too long"); |
| 1949 | boost::asio::detail::throw_exception(ex); |
| 1950 | } |
| 1951 | |
| 1952 | if (size_ == (std::numeric_limits<std::size_t>::max)()) |
| 1953 | size_ = string_.size(); // Enable v1 behaviour. |
| 1954 | |
| 1955 | string_.resize(size_ + n); |
| 1956 | |
| 1957 | return boost::asio::buffer(boost::asio::buffer(string_) + size_, n); |
| 1958 | } |
| 1959 | |
| 1960 | /// @b DynamicBuffer_v1: Move bytes from the output sequence to the input |
| 1961 | /// sequence. |