mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Dynamic buffer input areas are mutable
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
Version 106:
|
||||
|
||||
* Dynamic buffer input areas are mutable
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Version 105:
|
||||
|
||||
* Fix compile error in websocket snippet
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
using allocator_type = Allocator;
|
||||
|
||||
/// The type used to represent the input sequence as a list of buffers.
|
||||
using const_buffers_type = boost::asio::const_buffers_1;
|
||||
using const_buffers_type = boost::asio::mutable_buffers_1;
|
||||
|
||||
/// The type used to represent the output sequence as a list of buffers.
|
||||
using mutable_buffers_type = boost::asio::mutable_buffers_1;
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
|
||||
This buffer sequence is guaranteed to have length 1.
|
||||
*/
|
||||
using const_buffers_type = boost::asio::const_buffers_1;
|
||||
using const_buffers_type = boost::asio::mutable_buffers_1;
|
||||
|
||||
/** The type used to represent the mutable input sequence as a list of buffers.
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
@ -29,7 +28,7 @@ class buffers_adapter<MutableBufferSequence>::
|
||||
buffers_adapter const* ba_;
|
||||
|
||||
public:
|
||||
using value_type = boost::asio::const_buffer;
|
||||
using value_type = boost::asio::mutable_buffer;
|
||||
|
||||
class const_iterator;
|
||||
|
||||
|
@ -132,8 +132,7 @@ class basic_multi_buffer<Allocator>::const_buffers_type
|
||||
const_buffers_type(basic_multi_buffer const& b);
|
||||
|
||||
public:
|
||||
// Why?
|
||||
using value_type = boost::asio::const_buffer;
|
||||
using value_type = boost::asio::mutable_buffer;
|
||||
|
||||
class const_iterator;
|
||||
|
||||
|
@ -35,14 +35,19 @@ static_buffer_base::
|
||||
data() const ->
|
||||
const_buffers_type
|
||||
{
|
||||
using boost::asio::const_buffer;
|
||||
using boost::asio::mutable_buffer;
|
||||
const_buffers_type result;
|
||||
if(in_off_ + in_size_ <= capacity_)
|
||||
return {{
|
||||
{const_buffer{begin_ + in_off_, in_size_}},
|
||||
{const_buffer{begin_, 0}}}};
|
||||
return {{
|
||||
{const_buffer{begin_ + in_off_, capacity_ - in_off_}},
|
||||
{const_buffer{begin_, in_size_ - (capacity_ - in_off_)}}}};
|
||||
{
|
||||
result[0] = mutable_buffer{begin_ + in_off_, in_size_};
|
||||
result[1] = mutable_buffer{begin_, 0};
|
||||
}
|
||||
else
|
||||
{
|
||||
result[0] = mutable_buffer{begin_ + in_off_, capacity_ - in_off_};
|
||||
result[1] = mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
@ -52,13 +57,18 @@ mutable_data() ->
|
||||
mutable_data_type
|
||||
{
|
||||
using boost::asio::mutable_buffer;
|
||||
mutable_data_type result;
|
||||
if(in_off_ + in_size_ <= capacity_)
|
||||
return {{
|
||||
{mutable_buffer{begin_ + in_off_, in_size_}},
|
||||
{mutable_buffer{begin_, 0}}}};
|
||||
return {{
|
||||
{mutable_buffer{begin_ + in_off_, capacity_ - in_off_}},
|
||||
{mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)}}}};
|
||||
{
|
||||
result[0] = mutable_buffer{begin_ + in_off_, in_size_};
|
||||
result[1] = mutable_buffer{begin_, 0};
|
||||
}
|
||||
else
|
||||
{
|
||||
result[0] = mutable_buffer{begin_ + in_off_, capacity_ - in_off_};
|
||||
result[1] = mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
@ -73,13 +83,18 @@ prepare(std::size_t size) ->
|
||||
"buffer overflow"});
|
||||
out_size_ = size;
|
||||
auto const out_off = (in_off_ + in_size_) % capacity_;
|
||||
mutable_buffers_type result;
|
||||
if(out_off + out_size_ <= capacity_ )
|
||||
return {{
|
||||
{mutable_buffer{begin_ + out_off, out_size_}},
|
||||
{mutable_buffer{begin_, 0}}}};
|
||||
return {{
|
||||
{mutable_buffer{begin_ + out_off, capacity_ - out_off}},
|
||||
{mutable_buffer{begin_, out_size_ - (capacity_ - out_off)}}}};
|
||||
{
|
||||
result[0] = mutable_buffer{begin_ + out_off, out_size_};
|
||||
result[1] = mutable_buffer{begin_, 0};
|
||||
}
|
||||
else
|
||||
{
|
||||
result[0] = mutable_buffer{begin_ + out_off, capacity_ - out_off};
|
||||
result[1] = mutable_buffer{begin_, out_size_ - (capacity_ - out_off)};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
|
@ -52,7 +52,7 @@ class static_buffer_base
|
||||
public:
|
||||
/// The type used to represent the input sequence as a list of buffers.
|
||||
using const_buffers_type =
|
||||
std::array<boost::asio::const_buffer, 2>;
|
||||
std::array<boost::asio::mutable_buffer, 2>;
|
||||
|
||||
/// The type used to represent the mutable input sequence as a list of buffers.
|
||||
using mutable_data_type =
|
||||
|
Reference in New Issue
Block a user