Add flat_static_buffer::mutable_data

This commit is contained in:
Vinnie Falco
2017-07-15 09:47:56 -07:00
parent cda710bda0
commit 6fa9a97727
4 changed files with 29 additions and 0 deletions

View File

@@ -1,3 +1,9 @@
Version 83:
* Add flat_static_buffer::mutable_data
--------------------------------------------------------------------------------
Version 82:
* Documentation tidying

View File

@@ -51,6 +51,12 @@ public:
*/
using const_buffers_type = boost::asio::const_buffers_1;
/** The type used to represent the mutable input sequence as a list of buffers.
This buffer sequence is guaranteed to have length 1.
*/
using mutable_data_type = boost::asio::mutable_buffers_1;
/** The type used to represent the output sequence as a list of buffers.
This buffer sequence is guaranteed to have length 1.
@@ -98,6 +104,13 @@ public:
const_buffers_type
data() const;
/** Get a list of mutable buffers that represent the input sequence.
@note These buffers remain valid across subsequent calls to `prepare`.
*/
mutable_data_type
mutable_data();
/** Get a list of buffers that represent the output sequence, with the given size.
@throws std::length_error if the size would exceed the limit

View File

@@ -32,6 +32,15 @@ data() const ->
return {in_, dist(in_, out_)};
}
inline
auto
flat_static_buffer_base::
mutable_data() ->
mutable_data_type
{
return {in_, dist(in_, out_)};
}
inline
auto
flat_static_buffer_base::

View File

@@ -102,6 +102,7 @@ public:
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
}
ba.commit(2);
BEAST_EXPECT(buffer_size(ba.data()) == buffer_size(ba.mutable_data()));
BEAST_EXPECT(ba.size() == x + y + z);
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
BEAST_EXPECT(to_string(ba.data()) == s);