mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Rename to flat_static_buffer and flat_static_buffer_base (API Change):
Actions Required: * Rename static_buffer to flat_static_buffer_base * Rename static_buffer_n to flat_static_buffer
This commit is contained in:
@ -10,6 +10,15 @@ WebSocket
|
||||
* stream uses flat_buffer
|
||||
* accept requires a message
|
||||
|
||||
API Changes:
|
||||
|
||||
* Rename to flat_static_buffer and flat_static_buffer_base
|
||||
|
||||
Actions Required:
|
||||
|
||||
* Rename static_buffer to flat_static_buffer_base
|
||||
* Rename static_buffer_n to flat_static_buffer
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Version 81:
|
||||
|
@ -75,8 +75,8 @@
|
||||
[def __multi_buffer__ [link beast.ref.beast__multi_buffer `multi_buffer`]]
|
||||
[def __parser__ [link beast.ref.beast__http__parser `parser`]]
|
||||
[def __serializer__ [link beast.ref.beast__http__serializer `serializer`]]
|
||||
[def __static_buffer__ [link beast.ref.beast__static_buffer `static_buffer`]]
|
||||
[def __static_buffer_n__ [link beast.ref.beast__static_buffer_n `static_buffer_n`]]
|
||||
[def __flat_static_buffer__ [link beast.ref.beast__flat_static_buffer `flat_static_buffer`]]
|
||||
[def __flat_static_buffer_base__ [link beast.ref.beast__flat_static_buffer_base `flat_static_buffer_base`]]
|
||||
|
||||
[import ../../example/common/detect_ssl.hpp]
|
||||
[import ../../example/doc/http_examples.hpp]
|
||||
|
@ -62,9 +62,10 @@ of scenarios:
|
||||
[link beast.ref.beast__basic_flat_buffer `basic_flat_buffer`]
|
||||
][
|
||||
Guarantees that input and output areas are buffer sequences with
|
||||
length one. Upon construction an optional upper limit to the total
|
||||
size of the input and output areas may be set. The basic container
|
||||
is an
|
||||
length one.
|
||||
Upon construction an optional upper limit to the total size of the
|
||||
input and output areas may be set.
|
||||
The basic container is an
|
||||
[@http://en.cppreference.com/w/cpp/concept/AllocatorAwareContainer [*AllocatorAwareContainer]].
|
||||
]]
|
||||
[[
|
||||
@ -73,14 +74,16 @@ of scenarios:
|
||||
][
|
||||
Uses a sequence of one or more character arrays of varying sizes.
|
||||
Additional character array objects are appended to the sequence to
|
||||
accommodate changes in the size of the character sequence. The basic
|
||||
container is an
|
||||
accommodate changes in the size of the character sequence.
|
||||
The basic container is an
|
||||
[@http://en.cppreference.com/w/cpp/concept/AllocatorAwareContainer [*AllocatorAwareContainer]].
|
||||
]]
|
||||
[[
|
||||
[link beast.ref.beast__static_buffer `static_buffer`]
|
||||
[link beast.ref.beast__static_buffer `static_buffer_n`]
|
||||
[link beast.ref.beast__flat_static_buffer `flat_static_buffer`]
|
||||
[link beast.ref.beast__flat_static_buffer_base `flat_static_buffer_base`]
|
||||
][
|
||||
Guarantees that input and output areas are buffer sequences with
|
||||
length one.
|
||||
Provides the facilities of a dynamic buffer, subject to an upper
|
||||
limit placed on the total size of the input and output areas defined
|
||||
by a constexpr template parameter. The storage for the sequences are
|
||||
|
@ -104,9 +104,10 @@ As with message stream operations, parser stream operations require a
|
||||
persisted __DynamicBuffer__ for holding unused octets from the stream.
|
||||
The basic parser implementation is optimized for the case where this dynamic
|
||||
buffer stores its input sequence in a single contiguous memory buffer. It is
|
||||
advised to use an instance of __flat_buffer__, __static_buffer__, or
|
||||
__static_buffer_n__ for this purpose, although a user defined instance of
|
||||
__DynamicBuffer__ which produces input sequences of length one is also suitable.
|
||||
advised to use an instance of __flat_buffer__, __flat_static_buffer__, or
|
||||
__flat_static_buffer_base__ for this purpose, although a user defined instance
|
||||
of __DynamicBuffer__ which produces input sequences of length one is also
|
||||
suitable.
|
||||
|
||||
The parser contains a message constructed internally. Arguments passed
|
||||
to the parser's constructor are forwarded into the message container.
|
||||
|
@ -129,8 +129,8 @@ In this table:
|
||||
* [link beast.ref.beast__basic_multi_buffer `basic_multi_buffer`]
|
||||
* [link beast.ref.beast__drain_buffer `drain_buffer`]
|
||||
* [link beast.ref.beast__flat_buffer `flat_buffer`]
|
||||
* [link beast.ref.beast__flat_static_buffer `flat_static_buffer`]
|
||||
* [link beast.ref.beast__flat_static_buffer_base `flat_static_buffer_base`]
|
||||
* [link beast.ref.beast__multi_buffer `multi_buffer`]
|
||||
* [link beast.ref.beast__static_buffer `static_buffer`]
|
||||
* [link beast.ref.beast__static_buffer_n `static_buffer_n`]
|
||||
|
||||
[endsect]
|
||||
|
@ -30,7 +30,7 @@ __MutableBufferSequence__ concepts for passing buffers to functions.
|
||||
The authors have found the dynamic buffer and buffer sequence interfaces to
|
||||
be optimal for interacting with Asio, and for other tasks such as incremental
|
||||
parsing of data in buffers (for example, parsing websocket frames stored
|
||||
in a [link beast.ref.beast__static_buffer `static_buffer`]).
|
||||
in a [link beast.ref.beast__flat_static_buffer `flat_static_buffer`]).
|
||||
|
||||
During the development of Beast the authors have studied other software
|
||||
packages and in particular the comments left during the Boost Review process
|
||||
|
@ -195,6 +195,8 @@
|
||||
<member><link linkend="beast.ref.beast__file_stdio">file_stdio</link></member>
|
||||
<member><link linkend="beast.ref.beast__file_win32">file_win32</link></member>
|
||||
<member><link linkend="beast.ref.beast__flat_buffer">flat_buffer</link></member>
|
||||
<member><link linkend="beast.ref.beast__flat_static_buffer">flat_static_buffer</link></member>
|
||||
<member><link linkend="beast.ref.beast__flat_static_buffer_base">flat_static_buffer_base</link></member>
|
||||
<member><link linkend="beast.ref.beast__handler_alloc">handler_alloc</link></member>
|
||||
<member><link linkend="beast.ref.beast__handler_ptr">handler_ptr</link></member>
|
||||
<member><link linkend="beast.ref.beast__handler_type">handler_type</link></member>
|
||||
@ -202,8 +204,6 @@
|
||||
<member><link linkend="beast.ref.beast__iless">iless</link></member>
|
||||
<member><link linkend="beast.ref.beast__multi_buffer">multi_buffer</link></member>
|
||||
<member><link linkend="beast.ref.beast__span">span</link></member>
|
||||
<member><link linkend="beast.ref.beast__static_buffer">static_buffer</link></member>
|
||||
<member><link linkend="beast.ref.beast__static_buffer_n">static_buffer_n</link></member>
|
||||
<member><link linkend="beast.ref.beast__static_string">static_string</link></member>
|
||||
<member><link linkend="beast.ref.beast__string_param">string_param</link></member>
|
||||
<member><link linkend="beast.ref.beast__string_view">string_view</link></member>
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
|
||||
private:
|
||||
using alloc_t = fields_alloc<char>;
|
||||
using request_body_t = http::basic_dynamic_body<beast::static_buffer_n<1024 * 1024>>;
|
||||
using request_body_t = http::basic_dynamic_body<beast::flat_static_buffer<1024 * 1024>>;
|
||||
|
||||
// The acceptor used to listen for incoming connections.
|
||||
tcp::acceptor& acceptor_;
|
||||
@ -59,7 +59,7 @@ private:
|
||||
tcp::socket socket_{acceptor_.get_io_service()};
|
||||
|
||||
// The buffer for performing reads
|
||||
beast::static_buffer_n<8192> buffer_;
|
||||
beast::flat_static_buffer<8192> buffer_;
|
||||
|
||||
// The allocator used for the fields in the request and reply.
|
||||
alloc_t alloc_{8192};
|
||||
|
@ -54,7 +54,7 @@ class multi_con
|
||||
boost::asio::ssl::context& ctx_;
|
||||
|
||||
// Holds the data we read during ssl detection
|
||||
beast::static_buffer_n<6> buffer_;
|
||||
beast::flat_static_buffer<6> buffer_;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/read_size.hpp>
|
||||
#include <beast/core/span.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/core/static_string.hpp>
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/core/string_param.hpp>
|
||||
|
@ -5,8 +5,8 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BEAST_STATIC_BUFFER_HPP
|
||||
#define BEAST_STATIC_BUFFER_HPP
|
||||
#ifndef BEAST_FLAT_STATIC_BUFFER_HPP
|
||||
#define BEAST_FLAT_STATIC_BUFFER_HPP
|
||||
|
||||
#include <beast/config.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@ -16,22 +16,24 @@
|
||||
|
||||
namespace beast {
|
||||
|
||||
/** A @b DynamicBuffer with a fixed size internal buffer.
|
||||
/** A flat @b DynamicBuffer with a fixed size internal buffer.
|
||||
|
||||
Buffer sequences returned by @ref data and @ref prepare
|
||||
will always be of length one.
|
||||
Ownership of the underlying storage belongs to the derived class.
|
||||
|
||||
@note Variables are usually declared using the template class
|
||||
@ref static_buffer_n; however, to reduce the number of instantiations
|
||||
@ref flat_static_buffer; however, to reduce the number of instantiations
|
||||
of template functions receiving static stream buffer arguments in a
|
||||
deduced context, the signature of the receiving function should use
|
||||
@ref static_buffer.
|
||||
@ref flat_static_buffer_base.
|
||||
|
||||
When used with @ref static_buffer_n this implements a dynamic
|
||||
When used with @ref flat_static_buffer this implements a dynamic
|
||||
buffer using no memory allocations.
|
||||
|
||||
@see @ref static_buffer_n
|
||||
@see @ref flat_static_buffer
|
||||
*/
|
||||
class static_buffer
|
||||
class flat_static_buffer_base
|
||||
{
|
||||
char* begin_;
|
||||
char* in_;
|
||||
@ -39,17 +41,23 @@ class static_buffer
|
||||
char* last_;
|
||||
char* end_;
|
||||
|
||||
static_buffer(static_buffer const& other) = delete;
|
||||
static_buffer& operator=(static_buffer const&) = delete;
|
||||
flat_static_buffer_base(flat_static_buffer_base const& other) = delete;
|
||||
flat_static_buffer_base& operator=(flat_static_buffer_base const&) = delete;
|
||||
|
||||
public:
|
||||
/// The type used to represent the input sequence as a list of buffers.
|
||||
/** The type used to represent the input sequence as a list of buffers.
|
||||
|
||||
This buffer sequence is guaranteed to have length 1.
|
||||
*/
|
||||
using const_buffers_type = boost::asio::const_buffers_1;
|
||||
|
||||
/// The type used to represent the output sequence as a list of buffers.
|
||||
/** The type used to represent the output sequence as a list of buffers.
|
||||
|
||||
This buffer sequence is guaranteed to have length 1.
|
||||
*/
|
||||
using mutable_buffers_type = boost::asio::mutable_buffers_1;
|
||||
|
||||
/** Constructor.
|
||||
/** Constructor
|
||||
|
||||
This creates a dynamic buffer using the provided storage area.
|
||||
|
||||
@ -57,7 +65,7 @@ public:
|
||||
|
||||
@param n The number of valid bytes pointed to by `p`.
|
||||
*/
|
||||
static_buffer(void* p, std::size_t n)
|
||||
flat_static_buffer_base(void* p, std::size_t n)
|
||||
{
|
||||
reset_impl(p, n);
|
||||
}
|
||||
@ -120,13 +128,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
/** Default constructor.
|
||||
/** Constructor
|
||||
|
||||
The buffer will be in an undefined state. It is necessary
|
||||
for the derived class to call @ref reset in order to
|
||||
initialize the object.
|
||||
*/
|
||||
static_buffer();
|
||||
flat_static_buffer_base();
|
||||
|
||||
/** Reset the pointed-to buffer.
|
||||
|
||||
@ -168,43 +176,45 @@ private:
|
||||
|
||||
/** A @b DynamicBuffer with a fixed size internal buffer.
|
||||
|
||||
Buffer sequences returned by @ref data and @ref prepare
|
||||
will always be of length one.
|
||||
This implements a dynamic buffer using no memory allocations.
|
||||
|
||||
@tparam N The number of bytes in the internal buffer.
|
||||
|
||||
@note To reduce the number of template instantiations when passing
|
||||
objects of this type in a deduced context, the signature of the
|
||||
receiving function should use @ref static_buffer instead.
|
||||
receiving function should use @ref flat_static_buffer_base instead.
|
||||
|
||||
@see @ref static_buffer
|
||||
@see @ref flat_static_buffer_base
|
||||
*/
|
||||
template<std::size_t N>
|
||||
class static_buffer_n : public static_buffer
|
||||
class flat_static_buffer : public flat_static_buffer_base
|
||||
{
|
||||
char buf_[N];
|
||||
|
||||
public:
|
||||
/// Copy constructor
|
||||
static_buffer_n(static_buffer_n const&);
|
||||
/// Constructor
|
||||
flat_static_buffer(flat_static_buffer const&);
|
||||
|
||||
/// Copy assignment
|
||||
static_buffer_n& operator=(static_buffer_n const&);
|
||||
|
||||
/// Construct a static buffer.
|
||||
static_buffer_n()
|
||||
: static_buffer(buf_, N)
|
||||
/// Constructor
|
||||
flat_static_buffer()
|
||||
: flat_static_buffer_base(buf_, N)
|
||||
{
|
||||
}
|
||||
|
||||
/// Returns the @ref static_buffer portion of this object
|
||||
static_buffer&
|
||||
/// Assignment
|
||||
flat_static_buffer& operator=(flat_static_buffer const&);
|
||||
|
||||
/// Returns the @ref flat_static_buffer_base portion of this object
|
||||
flat_static_buffer_base&
|
||||
base()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Returns the @ref static_buffer portion of this object
|
||||
static_buffer const&
|
||||
/// Returns the @ref flat_static_buffer_base portion of this object
|
||||
flat_static_buffer_base const&
|
||||
base() const
|
||||
{
|
||||
return *this;
|
||||
@ -213,6 +223,6 @@ public:
|
||||
|
||||
} // beast
|
||||
|
||||
#include <beast/core/impl/static_buffer.ipp>
|
||||
#include <beast/core/impl/flat_static_buffer.ipp>
|
||||
|
||||
#endif
|
@ -5,8 +5,8 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BEAST_IMPL_STATIC_BUFFER_IPP
|
||||
#define BEAST_IMPL_STATIC_BUFFER_IPP
|
||||
#ifndef BEAST_IMPL_FLAT_STATIC_BUFFER_IPP
|
||||
#define BEAST_IMPL_FLAT_STATIC_BUFFER_IPP
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@ -25,7 +25,7 @@ namespace beast {
|
||||
|
||||
inline
|
||||
auto
|
||||
static_buffer::
|
||||
flat_static_buffer_base::
|
||||
data() const ->
|
||||
const_buffers_type
|
||||
{
|
||||
@ -34,7 +34,7 @@ data() const ->
|
||||
|
||||
inline
|
||||
auto
|
||||
static_buffer::
|
||||
flat_static_buffer_base::
|
||||
prepare(std::size_t n) ->
|
||||
mutable_buffers_type
|
||||
{
|
||||
@ -43,7 +43,7 @@ prepare(std::size_t n) ->
|
||||
|
||||
inline
|
||||
void
|
||||
static_buffer::
|
||||
flat_static_buffer_base::
|
||||
reset(void* p, std::size_t n)
|
||||
{
|
||||
reset_impl(p, n);
|
||||
@ -51,7 +51,7 @@ reset(void* p, std::size_t n)
|
||||
|
||||
template<class>
|
||||
void
|
||||
static_buffer::
|
||||
flat_static_buffer_base::
|
||||
reset_impl(void* p, std::size_t n)
|
||||
{
|
||||
begin_ =
|
||||
@ -64,7 +64,7 @@ reset_impl(void* p, std::size_t n)
|
||||
|
||||
template<class>
|
||||
auto
|
||||
static_buffer::
|
||||
flat_static_buffer_base::
|
||||
prepare_impl(std::size_t n) ->
|
||||
mutable_buffers_type
|
||||
{
|
||||
@ -87,7 +87,7 @@ prepare_impl(std::size_t n) ->
|
||||
|
||||
template<class>
|
||||
void
|
||||
static_buffer::
|
||||
flat_static_buffer_base::
|
||||
consume_impl(std::size_t n)
|
||||
{
|
||||
if(n >= size())
|
||||
@ -102,9 +102,9 @@ consume_impl(std::size_t n)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<std::size_t N>
|
||||
static_buffer_n<N>::
|
||||
static_buffer_n(static_buffer_n const& other)
|
||||
: static_buffer(buf_, N)
|
||||
flat_static_buffer<N>::
|
||||
flat_static_buffer(flat_static_buffer const& other)
|
||||
: flat_static_buffer_base(buf_, N)
|
||||
{
|
||||
using boost::asio::buffer_copy;
|
||||
this->commit(buffer_copy(
|
||||
@ -113,9 +113,9 @@ static_buffer_n(static_buffer_n const& other)
|
||||
|
||||
template<std::size_t N>
|
||||
auto
|
||||
static_buffer_n<N>::
|
||||
operator=(static_buffer_n const& other) ->
|
||||
static_buffer_n<N>&
|
||||
flat_static_buffer<N>::
|
||||
operator=(flat_static_buffer const& other) ->
|
||||
flat_static_buffer<N>&
|
||||
{
|
||||
using boost::asio::buffer_copy;
|
||||
this->consume(this->size());
|
@ -401,7 +401,7 @@ public:
|
||||
@b ConstBufferSequence that represents the next chunk of
|
||||
message data. If the length of this buffer sequence is
|
||||
one, the implementation will not allocate additional memory.
|
||||
The class @ref flat_buffer is provided as one way to
|
||||
The class @ref beast::flat_buffer is provided as one way to
|
||||
meet this requirement
|
||||
|
||||
@param ec Set to the error, if any occurred.
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <beast/websocket/rfc6455.hpp>
|
||||
#include <beast/websocket/detail/utf8_checker.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/core/static_string.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
@ -108,11 +108,11 @@ struct frame_header
|
||||
|
||||
// holds the largest possible frame header
|
||||
using fh_streambuf =
|
||||
static_buffer_n<14>;
|
||||
flat_static_buffer<14>;
|
||||
|
||||
// holds the largest possible control frame
|
||||
using frame_streambuf =
|
||||
static_buffer_n< 2 + 8 + 4 + 125 >;
|
||||
flat_static_buffer< 2 + 8 + 4 + 125 >;
|
||||
|
||||
inline
|
||||
bool constexpr
|
||||
|
@ -9,7 +9,7 @@
|
||||
#define BEAST_WEBSOCKET_IMPL_CLOSE_IPP
|
||||
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/config.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
@ -42,7 +42,7 @@ class stream<NextLayer>::close_op
|
||||
, cr(cr_)
|
||||
{
|
||||
ws.template write_close<
|
||||
static_buffer>(fb, cr);
|
||||
flat_static_buffer_base>(fb, cr);
|
||||
}
|
||||
};
|
||||
|
||||
@ -227,7 +227,7 @@ close(close_reason const& cr, error_code& ec)
|
||||
}
|
||||
wr_close_ = true;
|
||||
detail::frame_streambuf fb;
|
||||
write_close<static_buffer>(fb, cr);
|
||||
write_close<flat_static_buffer_base>(fb, cr);
|
||||
boost::asio::write(stream_, fb.data(), ec);
|
||||
failed_ = !!ec;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class stream<NextLayer>::ping_op
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_copy;
|
||||
ws.template write_ping<
|
||||
static_buffer>(fb, op_, payload);
|
||||
flat_static_buffer_base>(fb, op_, payload);
|
||||
}
|
||||
};
|
||||
|
||||
@ -234,7 +234,7 @@ stream<NextLayer>::
|
||||
ping(ping_data const& payload, error_code& ec)
|
||||
{
|
||||
detail::frame_streambuf db;
|
||||
write_ping<static_buffer>(
|
||||
write_ping<flat_static_buffer_base>(
|
||||
db, detail::opcode::ping, payload);
|
||||
boost::asio::write(stream_, db.data(), ec);
|
||||
}
|
||||
@ -256,7 +256,7 @@ stream<NextLayer>::
|
||||
pong(ping_data const& payload, error_code& ec)
|
||||
{
|
||||
detail::frame_streambuf db;
|
||||
write_ping<static_buffer>(
|
||||
write_ping<flat_static_buffer_base>(
|
||||
db, detail::opcode::pong, payload);
|
||||
boost::asio::write(stream_, db.data(), ec);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <beast/websocket/teardown.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/clamp.hpp>
|
||||
#include <beast/core/detail/config.hpp>
|
||||
@ -445,7 +445,7 @@ operator()(error_code ec,
|
||||
d.state = do_read_fh;
|
||||
break;
|
||||
}
|
||||
d.ws.template write_ping<static_buffer>(
|
||||
d.ws.template write_ping<flat_static_buffer_base>(
|
||||
d.fb, detail::opcode::pong, payload);
|
||||
if(d.ws.wr_block_)
|
||||
{
|
||||
@ -492,7 +492,7 @@ operator()(error_code ec,
|
||||
cr.reason = "";
|
||||
d.fb.consume(d.fb.size());
|
||||
d.ws.template write_close<
|
||||
static_buffer>(d.fb, cr);
|
||||
flat_static_buffer_base>(d.fb, cr);
|
||||
if(d.ws.wr_block_)
|
||||
{
|
||||
// suspend
|
||||
@ -619,7 +619,7 @@ operator()(error_code ec,
|
||||
}
|
||||
d.fb.consume(d.fb.size());
|
||||
d.ws.template write_close<
|
||||
static_buffer>(d.fb, code);
|
||||
flat_static_buffer_base>(d.fb, code);
|
||||
if(d.ws.wr_block_)
|
||||
{
|
||||
// suspend
|
||||
@ -806,7 +806,7 @@ read_frame(DynamicBuffer& dynabuf, error_code& ec)
|
||||
fb.consume(fb.size());
|
||||
if(ctrl_cb_)
|
||||
ctrl_cb_(frame_type::ping, payload);
|
||||
write_ping<static_buffer>(fb,
|
||||
write_ping<flat_static_buffer_base>(fb,
|
||||
detail::opcode::pong, payload);
|
||||
boost::asio::write(stream_, fb.data(), ec);
|
||||
failed_ = !!ec;
|
||||
@ -839,7 +839,7 @@ read_frame(DynamicBuffer& dynabuf, error_code& ec)
|
||||
cr.reason = "";
|
||||
fb.consume(fb.size());
|
||||
wr_close_ = true;
|
||||
write_close<static_buffer>(fb, cr);
|
||||
write_close<flat_static_buffer_base>(fb, cr);
|
||||
boost::asio::write(stream_, fb.data(), ec);
|
||||
failed_ = !!ec;
|
||||
if(failed_)
|
||||
@ -966,7 +966,7 @@ do_close:
|
||||
{
|
||||
wr_close_ = true;
|
||||
detail::frame_streambuf fb;
|
||||
write_close<static_buffer>(fb, code);
|
||||
write_close<flat_static_buffer_base>(fb, code);
|
||||
boost::asio::write(stream_, fb.data(), ec);
|
||||
failed_ = !!ec;
|
||||
if(failed_)
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/handler_ptr.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/clamp.hpp>
|
||||
#include <beast/core/detail/config.hpp>
|
||||
@ -215,7 +215,7 @@ loop:
|
||||
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
||||
d.fh.fin = d.fin;
|
||||
d.fh.len = buffer_size(d.cb);
|
||||
detail::write<static_buffer>(
|
||||
detail::write<flat_static_buffer_base>(
|
||||
d.fh_buf, d.fh);
|
||||
d.ws.wr_.cont = ! d.fin;
|
||||
// Send frame
|
||||
@ -235,7 +235,7 @@ loop:
|
||||
d.remain -= n;
|
||||
d.fh.len = n;
|
||||
d.fh.fin = d.fin ? d.remain == 0 : false;
|
||||
detail::write<static_buffer>(
|
||||
detail::write<flat_static_buffer_base>(
|
||||
d.fh_buf, d.fh);
|
||||
d.ws.wr_.cont = ! d.fin;
|
||||
// Send frame
|
||||
@ -277,7 +277,7 @@ loop:
|
||||
d.fh.len = d.remain;
|
||||
d.fh.key = d.ws.maskgen_();
|
||||
detail::prepare_key(d.key, d.fh.key);
|
||||
detail::write<static_buffer>(
|
||||
detail::write<flat_static_buffer_base>(
|
||||
d.fh_buf, d.fh);
|
||||
auto const n =
|
||||
clamp(d.remain, d.ws.wr_.buf_size);
|
||||
@ -329,7 +329,7 @@ loop:
|
||||
d.ws.wr_.buf.get(), n);
|
||||
buffer_copy(b, d.cb);
|
||||
detail::mask_inplace(b, d.key);
|
||||
detail::write<static_buffer>(
|
||||
detail::write<flat_static_buffer_base>(
|
||||
d.fh_buf, d.fh);
|
||||
d.ws.wr_.cont = ! d.fin;
|
||||
// Send frame
|
||||
@ -402,7 +402,7 @@ loop:
|
||||
d.fh.fin = ! more;
|
||||
d.fh.len = n;
|
||||
detail::fh_streambuf fh_buf;
|
||||
detail::write<static_buffer>(fh_buf, d.fh);
|
||||
detail::write<flat_static_buffer_base>(fh_buf, d.fh);
|
||||
d.ws.wr_.cont = ! d.fin;
|
||||
// Send frame
|
||||
d.step = more ?
|
||||
@ -699,7 +699,7 @@ write_frame(bool fin,
|
||||
fh.fin = ! more;
|
||||
fh.len = n;
|
||||
detail::fh_streambuf fh_buf;
|
||||
detail::write<static_buffer>(fh_buf, fh);
|
||||
detail::write<flat_static_buffer_base>(fh_buf, fh);
|
||||
wr_.cont = ! fin;
|
||||
boost::asio::write(stream_,
|
||||
buffer_cat(fh_buf.data(), b), ec);
|
||||
@ -727,7 +727,7 @@ write_frame(bool fin,
|
||||
fh.fin = fin;
|
||||
fh.len = remain;
|
||||
detail::fh_streambuf fh_buf;
|
||||
detail::write<static_buffer>(fh_buf, fh);
|
||||
detail::write<flat_static_buffer_base>(fh_buf, fh);
|
||||
wr_.cont = ! fin;
|
||||
boost::asio::write(stream_,
|
||||
buffer_cat(fh_buf.data(), buffers), ec);
|
||||
@ -748,7 +748,7 @@ write_frame(bool fin,
|
||||
fh.len = n;
|
||||
fh.fin = fin ? remain == 0 : false;
|
||||
detail::fh_streambuf fh_buf;
|
||||
detail::write<static_buffer>(fh_buf, fh);
|
||||
detail::write<flat_static_buffer_base>(fh_buf, fh);
|
||||
wr_.cont = ! fin;
|
||||
boost::asio::write(stream_,
|
||||
buffer_cat(fh_buf.data(),
|
||||
@ -773,7 +773,7 @@ write_frame(bool fin,
|
||||
detail::prepared_key key;
|
||||
detail::prepare_key(key, fh.key);
|
||||
detail::fh_streambuf fh_buf;
|
||||
detail::write<static_buffer>(fh_buf, fh);
|
||||
detail::write<flat_static_buffer_base>(fh_buf, fh);
|
||||
consuming_buffers<
|
||||
ConstBufferSequence> cb{buffers};
|
||||
{
|
||||
@ -824,7 +824,7 @@ write_frame(bool fin,
|
||||
fh.fin = fin ? remain == 0 : false;
|
||||
wr_.cont = ! fh.fin;
|
||||
detail::fh_streambuf fh_buf;
|
||||
detail::write<static_buffer>(fh_buf, fh);
|
||||
detail::write<flat_static_buffer_base>(fh_buf, fh);
|
||||
boost::asio::write(stream_,
|
||||
buffer_cat(fh_buf.data(), b), ec);
|
||||
failed_ = !!ec;
|
||||
|
@ -30,13 +30,13 @@ add_executable (core-tests
|
||||
file_stdio.cpp
|
||||
file_win32.cpp
|
||||
flat_buffer.cpp
|
||||
flat_static_buffer.cpp
|
||||
handler_alloc.cpp
|
||||
handler_ptr.cpp
|
||||
multi_buffer.cpp
|
||||
ostream.cpp
|
||||
read_size.cpp
|
||||
span.cpp
|
||||
static_buffer.cpp
|
||||
static_string.cpp
|
||||
string.cpp
|
||||
string_param.cpp
|
||||
|
@ -24,13 +24,13 @@ unit-test core-tests :
|
||||
file_stdio.cpp
|
||||
file_win32.cpp
|
||||
flat_buffer.cpp
|
||||
flat_static_buffer.cpp
|
||||
handler_alloc.cpp
|
||||
handler_ptr.cpp
|
||||
multi_buffer.cpp
|
||||
ostream.cpp
|
||||
read_size.cpp
|
||||
span.cpp
|
||||
static_buffer.cpp
|
||||
static_string.cpp
|
||||
string.cpp
|
||||
string_param.cpp
|
||||
|
@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
|
||||
#include "buffer_test.hpp"
|
||||
|
||||
@ -18,10 +18,10 @@
|
||||
namespace beast {
|
||||
|
||||
static_assert(
|
||||
is_dynamic_buffer<static_buffer>::value,
|
||||
is_dynamic_buffer<flat_static_buffer_base>::value,
|
||||
"DynamicBuffer requirements not met");
|
||||
|
||||
class static_buffer_test : public beast::unit_test::suite
|
||||
class flat_static_buffer_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
@ -44,7 +44,7 @@ public:
|
||||
std::size_t v = sizeof(buf) - (t + u);
|
||||
{
|
||||
std::memset(buf, 0, sizeof(buf));
|
||||
static_buffer_n<sizeof(buf)> ba;
|
||||
flat_static_buffer<sizeof(buf)> ba;
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
@ -139,32 +139,32 @@ public:
|
||||
using namespace test;
|
||||
string_view const s = "Hello, world!";
|
||||
|
||||
// static_buffer
|
||||
// flat_static_buffer_base
|
||||
{
|
||||
char buf[64];
|
||||
static_buffer b{buf, sizeof(buf)};
|
||||
flat_static_buffer_base b{buf, sizeof(buf)};
|
||||
ostream(b) << s;
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
b.consume(b.size());
|
||||
BEAST_EXPECT(to_string(b.data()) == "");
|
||||
}
|
||||
|
||||
// static_buffer_n
|
||||
// flat_static_buffer
|
||||
{
|
||||
static_buffer_n<64> b1;
|
||||
flat_static_buffer<64> b1;
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.max_size() == 64);
|
||||
BEAST_EXPECT(b1.capacity() == 64);
|
||||
ostream(b1) << s;
|
||||
BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
{
|
||||
static_buffer_n<64> b2{b1};
|
||||
flat_static_buffer<64> b2{b1};
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
{
|
||||
static_buffer_n<64> b2;
|
||||
flat_static_buffer<64> b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
@ -174,7 +174,7 @@ public:
|
||||
|
||||
// cause memmove
|
||||
{
|
||||
static_buffer_n<10> b;
|
||||
flat_static_buffer<10> b;
|
||||
write_buffer(b, "12345");
|
||||
b.consume(3);
|
||||
write_buffer(b, "67890123");
|
||||
@ -192,7 +192,7 @@ public:
|
||||
|
||||
// read_size
|
||||
{
|
||||
static_buffer_n<10> b;
|
||||
flat_static_buffer<10> b;
|
||||
BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
b.prepare(4);
|
||||
b.commit(4);
|
||||
@ -206,14 +206,14 @@ public:
|
||||
|
||||
// base
|
||||
{
|
||||
static_buffer_n<10> b;
|
||||
[&](static_buffer& base)
|
||||
flat_static_buffer<10> b;
|
||||
[&](flat_static_buffer_base& base)
|
||||
{
|
||||
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
}
|
||||
(b.base());
|
||||
|
||||
[&](static_buffer const& base)
|
||||
[&](flat_static_buffer_base const& base)
|
||||
{
|
||||
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
}
|
||||
@ -228,6 +228,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(static_buffer,core,beast);
|
||||
BEAST_DEFINE_TESTSUITE(flat_static_buffer,core,beast);
|
||||
|
||||
} // beastp
|
@ -11,7 +11,7 @@
|
||||
#include "test_parser.hpp"
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/static_buffer.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/dynamic_body.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
@ -135,7 +135,7 @@ public:
|
||||
"10\r\n"
|
||||
"****************\r\n"
|
||||
"0\r\n\r\n";
|
||||
static_buffer_n<1024> b;
|
||||
flat_static_buffer<1024> b;
|
||||
request<string_body> req;
|
||||
try
|
||||
{
|
||||
@ -159,7 +159,7 @@ public:
|
||||
"****************\r\n"
|
||||
"0\r\n\r\n";
|
||||
error_code ec = test::error::fail_error;
|
||||
static_buffer_n<10> b;
|
||||
flat_static_buffer<10> b;
|
||||
request<string_body> req;
|
||||
read(p.server, b, req, ec);
|
||||
BEAST_EXPECTS(ec == error::buffer_overflow,
|
||||
|
Reference in New Issue
Block a user