mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 13:27:33 +02:00
Rename to static_buffer, static_buffer_n (API Change):
These classes are renamed: * static_streambuf to static_buffer * static_streambuf_n to static_buffer_n
This commit is contained in:
@ -12,6 +12,7 @@ API Changes:
|
|||||||
* New buffers() replaces to_string()
|
* New buffers() replaces to_string()
|
||||||
* Rename to multi_buffer, basic_multi_buffer
|
* Rename to multi_buffer, basic_multi_buffer
|
||||||
* Rename to flat_buffer, basic_flat_buffer
|
* Rename to flat_buffer, basic_flat_buffer
|
||||||
|
* Rename to static_buffer, static_buffer_n
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -165,8 +165,8 @@
|
|||||||
<member><link linkend="beast.ref.handler_alloc">handler_alloc</link></member>
|
<member><link linkend="beast.ref.handler_alloc">handler_alloc</link></member>
|
||||||
<member><link linkend="beast.ref.handler_ptr">handler_ptr</link></member>
|
<member><link linkend="beast.ref.handler_ptr">handler_ptr</link></member>
|
||||||
<member><link linkend="beast.ref.multi_buffer">multi_buffer</link></member>
|
<member><link linkend="beast.ref.multi_buffer">multi_buffer</link></member>
|
||||||
<member><link linkend="beast.ref.static_streambuf">static_streambuf</link></member>
|
<member><link linkend="beast.ref.static_buffer">static_buffer</link></member>
|
||||||
<member><link linkend="beast.ref.static_streambuf_n">static_streambuf_n</link></member>
|
<member><link linkend="beast.ref.static_buffer_n">static_buffer_n</link></member>
|
||||||
<member><link linkend="beast.ref.static_string">static_string</link></member>
|
<member><link linkend="beast.ref.static_string">static_string</link></member>
|
||||||
<member><link linkend="beast.ref.system_error">system_error</link></member>
|
<member><link linkend="beast.ref.system_error">system_error</link></member>
|
||||||
</simplelist>
|
</simplelist>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <beast/core/ostream.hpp>
|
#include <beast/core/ostream.hpp>
|
||||||
#include <beast/core/placeholders.hpp>
|
#include <beast/core/placeholders.hpp>
|
||||||
#include <beast/core/prepare_buffers.hpp>
|
#include <beast/core/prepare_buffers.hpp>
|
||||||
#include <beast/core/static_streambuf.hpp>
|
#include <beast/core/static_buffer.hpp>
|
||||||
#include <beast/core/static_string.hpp>
|
#include <beast/core/static_string.hpp>
|
||||||
#include <beast/core/stream_concepts.hpp>
|
#include <beast/core/stream_concepts.hpp>
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BEAST_IMPL_STATIC_STREAMBUF_IPP
|
#ifndef BEAST_IMPL_STATIC_BUFFER_IPP
|
||||||
#define BEAST_IMPL_STATIC_STREAMBUF_IPP
|
#define BEAST_IMPL_STATIC_BUFFER_IPP
|
||||||
|
|
||||||
#include <beast/core/detail/type_traits.hpp>
|
#include <beast/core/detail/type_traits.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
class static_streambuf::const_buffers_type
|
class static_buffer::const_buffers_type
|
||||||
{
|
{
|
||||||
std::size_t n_;
|
std::size_t n_;
|
||||||
std::uint8_t const* p_;
|
std::uint8_t const* p_;
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
end() const;
|
end() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class static_streambuf;
|
friend class static_buffer;
|
||||||
|
|
||||||
const_buffers_type(
|
const_buffers_type(
|
||||||
std::uint8_t const* p, std::size_t n)
|
std::uint8_t const* p, std::size_t n)
|
||||||
@ -50,7 +50,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class static_streambuf::const_buffers_type::const_iterator
|
class static_buffer::const_buffers_type::const_iterator
|
||||||
{
|
{
|
||||||
std::size_t n_ = 0;
|
std::size_t n_ = 0;
|
||||||
std::uint8_t const* p_ = nullptr;
|
std::uint8_t const* p_ = nullptr;
|
||||||
@ -133,7 +133,7 @@ private:
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
auto
|
auto
|
||||||
static_streambuf::const_buffers_type::begin() const ->
|
static_buffer::const_buffers_type::begin() const ->
|
||||||
const_iterator
|
const_iterator
|
||||||
{
|
{
|
||||||
return const_iterator{p_, n_};
|
return const_iterator{p_, n_};
|
||||||
@ -141,7 +141,7 @@ static_streambuf::const_buffers_type::begin() const ->
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
auto
|
auto
|
||||||
static_streambuf::const_buffers_type::end() const ->
|
static_buffer::const_buffers_type::end() const ->
|
||||||
const_iterator
|
const_iterator
|
||||||
{
|
{
|
||||||
return const_iterator{p_ + n_, n_};
|
return const_iterator{p_ + n_, n_};
|
||||||
@ -149,7 +149,7 @@ static_streambuf::const_buffers_type::end() const ->
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
class static_streambuf::mutable_buffers_type
|
class static_buffer::mutable_buffers_type
|
||||||
{
|
{
|
||||||
std::size_t n_;
|
std::size_t n_;
|
||||||
std::uint8_t* p_;
|
std::uint8_t* p_;
|
||||||
@ -172,7 +172,7 @@ public:
|
|||||||
end() const;
|
end() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class static_streambuf;
|
friend class static_buffer;
|
||||||
|
|
||||||
mutable_buffers_type(
|
mutable_buffers_type(
|
||||||
std::uint8_t* p, std::size_t n)
|
std::uint8_t* p, std::size_t n)
|
||||||
@ -182,7 +182,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class static_streambuf::mutable_buffers_type::const_iterator
|
class static_buffer::mutable_buffers_type::const_iterator
|
||||||
{
|
{
|
||||||
std::size_t n_ = 0;
|
std::size_t n_ = 0;
|
||||||
std::uint8_t* p_ = nullptr;
|
std::uint8_t* p_ = nullptr;
|
||||||
@ -264,7 +264,7 @@ private:
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
auto
|
auto
|
||||||
static_streambuf::mutable_buffers_type::begin() const ->
|
static_buffer::mutable_buffers_type::begin() const ->
|
||||||
const_iterator
|
const_iterator
|
||||||
{
|
{
|
||||||
return const_iterator{p_, n_};
|
return const_iterator{p_, n_};
|
||||||
@ -272,7 +272,7 @@ static_streambuf::mutable_buffers_type::begin() const ->
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
auto
|
auto
|
||||||
static_streambuf::mutable_buffers_type::end() const ->
|
static_buffer::mutable_buffers_type::end() const ->
|
||||||
const_iterator
|
const_iterator
|
||||||
{
|
{
|
||||||
return const_iterator{p_ + n_, n_};
|
return const_iterator{p_ + n_, n_};
|
||||||
@ -280,10 +280,9 @@ static_streambuf::mutable_buffers_type::end() const ->
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
auto
|
auto
|
||||||
static_streambuf::data() const ->
|
static_buffer::data() const ->
|
||||||
const_buffers_type
|
const_buffers_type
|
||||||
{
|
{
|
||||||
return const_buffers_type{in_,
|
return const_buffers_type{in_,
|
||||||
@ -292,12 +291,12 @@ static_streambuf::data() const ->
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
auto
|
auto
|
||||||
static_streambuf::prepare(std::size_t n) ->
|
static_buffer::prepare(std::size_t n) ->
|
||||||
mutable_buffers_type
|
mutable_buffers_type
|
||||||
{
|
{
|
||||||
if(n > static_cast<std::size_t>(end_ - out_))
|
if(n > static_cast<std::size_t>(end_ - out_))
|
||||||
throw detail::make_exception<std::length_error>(
|
throw detail::make_exception<std::length_error>(
|
||||||
"no space in static_buffer", __FILE__, __LINE__);
|
"static_buffer overflow", __FILE__, __LINE__);
|
||||||
last_ = out_ + n;
|
last_ = out_ + n;
|
||||||
return mutable_buffers_type{out_, n};
|
return mutable_buffers_type{out_, n};
|
||||||
}
|
}
|
@ -5,8 +5,8 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BEAST_STATIC_STREAMBUF_HPP
|
#ifndef BEAST_STATIC_BUFFER_HPP
|
||||||
#define BEAST_STATIC_STREAMBUF_HPP
|
#define BEAST_STATIC_BUFFER_HPP
|
||||||
|
|
||||||
#include <beast/config.hpp>
|
#include <beast/config.hpp>
|
||||||
#include <boost/utility/base_from_member.hpp>
|
#include <boost/utility/base_from_member.hpp>
|
||||||
@ -16,17 +16,17 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
/** A @b `DynamicBuffer` with a fixed size internal buffer.
|
/** A @b DynamicBuffer with a fixed size internal buffer.
|
||||||
|
|
||||||
Ownership of the underlying storage belongs to the derived class.
|
Ownership of the underlying storage belongs to the derived class.
|
||||||
|
|
||||||
@note Variables are usually declared using the template class
|
@note Variables are usually declared using the template class
|
||||||
@ref static_streambuf_n; however, to reduce the number of instantiations
|
@ref static_buffer_n; however, to reduce the number of instantiations
|
||||||
of template functions receiving static stream buffer arguments in a
|
of template functions receiving static stream buffer arguments in a
|
||||||
deduced context, the signature of the receiving function should use
|
deduced context, the signature of the receiving function should use
|
||||||
@ref static_streambuf.
|
@ref static_buffer.
|
||||||
*/
|
*/
|
||||||
class static_streambuf
|
class static_buffer
|
||||||
{
|
{
|
||||||
#if BEAST_DOXYGEN
|
#if BEAST_DOXYGEN
|
||||||
private:
|
private:
|
||||||
@ -51,11 +51,11 @@ public:
|
|||||||
class const_buffers_type;
|
class const_buffers_type;
|
||||||
class mutable_buffers_type;
|
class mutable_buffers_type;
|
||||||
|
|
||||||
static_streambuf(
|
static_buffer(
|
||||||
static_streambuf const& other) noexcept = delete;
|
static_buffer const& other) noexcept = delete;
|
||||||
|
|
||||||
static_streambuf& operator=(
|
static_buffer& operator=(
|
||||||
static_streambuf const&) noexcept = delete;
|
static_buffer const&) noexcept = delete;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ private:
|
|||||||
#else
|
#else
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
static_streambuf(std::uint8_t* p, std::size_t n)
|
static_buffer(std::uint8_t* p, std::size_t n)
|
||||||
{
|
{
|
||||||
reset(p, n);
|
reset(p, n);
|
||||||
}
|
}
|
||||||
@ -139,17 +139,17 @@ protected:
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** A `DynamicBuffer` with a fixed size internal buffer.
|
/** A @b DynamicBuffer with a fixed size internal buffer.
|
||||||
|
|
||||||
@tparam N The number of bytes in the internal buffer.
|
@tparam N The number of bytes in the internal buffer.
|
||||||
|
|
||||||
@note To reduce the number of template instantiations when passing
|
@note To reduce the number of template instantiations when passing
|
||||||
objects of this type in a deduced context, the signature of the
|
objects of this type in a deduced context, the signature of the
|
||||||
receiving function should use `static_streambuf` instead.
|
receiving function should use `static_buffer` instead.
|
||||||
*/
|
*/
|
||||||
template<std::size_t N>
|
template<std::size_t N>
|
||||||
class static_streambuf_n
|
class static_buffer_n
|
||||||
: public static_streambuf
|
: public static_buffer
|
||||||
#if ! BEAST_DOXYGEN
|
#if ! BEAST_DOXYGEN
|
||||||
, private boost::base_from_member<
|
, private boost::base_from_member<
|
||||||
std::array<std::uint8_t, N>>
|
std::array<std::uint8_t, N>>
|
||||||
@ -161,23 +161,23 @@ public:
|
|||||||
#if BEAST_DOXYGEN
|
#if BEAST_DOXYGEN
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
static_streambuf_n(
|
static_buffer_n(
|
||||||
static_streambuf_n const&) = delete;
|
static_buffer_n const&) = delete;
|
||||||
static_streambuf_n& operator=(
|
static_buffer_n& operator=(
|
||||||
static_streambuf_n const&) = delete;
|
static_buffer_n const&) = delete;
|
||||||
#if BEAST_DOXYGEN
|
#if BEAST_DOXYGEN
|
||||||
public:
|
public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Construct a static stream buffer.
|
/// Construct a static buffer.
|
||||||
static_streambuf_n()
|
static_buffer_n()
|
||||||
: static_streambuf(
|
: static_buffer(
|
||||||
member_type::member.data(),
|
member_type::member.data(),
|
||||||
member_type::member.size())
|
member_type::member.size())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reset the stream buffer.
|
/** Reset the static buffer.
|
||||||
|
|
||||||
Postconditions:
|
Postconditions:
|
||||||
The input sequence and output sequence are empty,
|
The input sequence and output sequence are empty,
|
||||||
@ -186,7 +186,7 @@ public:
|
|||||||
void
|
void
|
||||||
reset()
|
reset()
|
||||||
{
|
{
|
||||||
static_streambuf::reset(
|
static_buffer::reset(
|
||||||
member_type::member.data(),
|
member_type::member.data(),
|
||||||
member_type::member.size());
|
member_type::member.size());
|
||||||
}
|
}
|
||||||
@ -194,6 +194,6 @@ public:
|
|||||||
|
|
||||||
} // beast
|
} // beast
|
||||||
|
|
||||||
#include <beast/core/impl/static_streambuf.ipp>
|
#include <beast/core/impl/static_buffer.ipp>
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -12,7 +12,7 @@
|
|||||||
#include <beast/websocket/detail/endian.hpp>
|
#include <beast/websocket/detail/endian.hpp>
|
||||||
#include <beast/websocket/detail/utf8_checker.hpp>
|
#include <beast/websocket/detail/utf8_checker.hpp>
|
||||||
#include <beast/core/consuming_buffers.hpp>
|
#include <beast/core/consuming_buffers.hpp>
|
||||||
#include <beast/core/static_streambuf.hpp>
|
#include <beast/core/static_buffer.hpp>
|
||||||
#include <beast/core/static_string.hpp>
|
#include <beast/core/static_string.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@ -38,11 +38,11 @@ struct frame_header
|
|||||||
|
|
||||||
// holds the largest possible frame header
|
// holds the largest possible frame header
|
||||||
using fh_streambuf =
|
using fh_streambuf =
|
||||||
static_streambuf_n<14>;
|
static_buffer_n<14>;
|
||||||
|
|
||||||
// holds the largest possible control frame
|
// holds the largest possible control frame
|
||||||
using frame_streambuf =
|
using frame_streambuf =
|
||||||
static_streambuf_n< 2 + 8 + 4 + 125 >;
|
static_buffer_n< 2 + 8 + 4 + 125 >;
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool constexpr
|
bool constexpr
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <beast/core/handler_helpers.hpp>
|
#include <beast/core/handler_helpers.hpp>
|
||||||
#include <beast/core/handler_ptr.hpp>
|
#include <beast/core/handler_ptr.hpp>
|
||||||
#include <beast/core/static_streambuf.hpp>
|
#include <beast/core/static_buffer.hpp>
|
||||||
#include <beast/core/stream_concepts.hpp>
|
#include <beast/core/stream_concepts.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class stream<NextLayer>::close_op
|
|||||||
, cr(cr_)
|
, cr(cr_)
|
||||||
{
|
{
|
||||||
ws.template write_close<
|
ws.template write_close<
|
||||||
static_streambuf>(fb, cr);
|
static_buffer>(fb, cr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ close(close_reason const& cr, error_code& ec)
|
|||||||
BOOST_ASSERT(! wr_close_);
|
BOOST_ASSERT(! wr_close_);
|
||||||
wr_close_ = true;
|
wr_close_ = true;
|
||||||
detail::frame_streambuf fb;
|
detail::frame_streambuf fb;
|
||||||
write_close<static_streambuf>(fb, cr);
|
write_close<static_buffer>(fb, cr);
|
||||||
boost::asio::write(stream_, fb.data(), ec);
|
boost::asio::write(stream_, fb.data(), ec);
|
||||||
failed_ = ec != 0;
|
failed_ = ec != 0;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class stream<NextLayer>::ping_op
|
|||||||
using boost::asio::buffer;
|
using boost::asio::buffer;
|
||||||
using boost::asio::buffer_copy;
|
using boost::asio::buffer_copy;
|
||||||
ws.template write_ping<
|
ws.template write_ping<
|
||||||
static_streambuf>(fb, op_, payload);
|
static_buffer>(fb, op_, payload);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ stream<NextLayer>::
|
|||||||
ping(ping_data const& payload, error_code& ec)
|
ping(ping_data const& payload, error_code& ec)
|
||||||
{
|
{
|
||||||
detail::frame_streambuf db;
|
detail::frame_streambuf db;
|
||||||
write_ping<static_streambuf>(
|
write_ping<static_buffer>(
|
||||||
db, opcode::ping, payload);
|
db, opcode::ping, payload);
|
||||||
boost::asio::write(stream_, db.data(), ec);
|
boost::asio::write(stream_, db.data(), ec);
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ stream<NextLayer>::
|
|||||||
pong(ping_data const& payload, error_code& ec)
|
pong(ping_data const& payload, error_code& ec)
|
||||||
{
|
{
|
||||||
detail::frame_streambuf db;
|
detail::frame_streambuf db;
|
||||||
write_ping<static_streambuf>(
|
write_ping<static_buffer>(
|
||||||
db, opcode::pong, payload);
|
db, opcode::pong, payload);
|
||||||
boost::asio::write(stream_, db.data(), ec);
|
boost::asio::write(stream_, db.data(), ec);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <beast/core/handler_helpers.hpp>
|
#include <beast/core/handler_helpers.hpp>
|
||||||
#include <beast/core/handler_ptr.hpp>
|
#include <beast/core/handler_ptr.hpp>
|
||||||
#include <beast/core/prepare_buffers.hpp>
|
#include <beast/core/prepare_buffers.hpp>
|
||||||
#include <beast/core/static_streambuf.hpp>
|
#include <beast/core/static_buffer.hpp>
|
||||||
#include <beast/core/stream_concepts.hpp>
|
#include <beast/core/stream_concepts.hpp>
|
||||||
#include <beast/core/detail/clamp.hpp>
|
#include <beast/core/detail/clamp.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@ -444,7 +444,7 @@ operator()(error_code ec,
|
|||||||
d.state = do_read_fh;
|
d.state = do_read_fh;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
d.ws.template write_ping<static_streambuf>(
|
d.ws.template write_ping<static_buffer>(
|
||||||
d.fb, opcode::pong, payload);
|
d.fb, opcode::pong, payload);
|
||||||
if(d.ws.wr_block_)
|
if(d.ws.wr_block_)
|
||||||
{
|
{
|
||||||
@ -486,7 +486,7 @@ operator()(error_code ec,
|
|||||||
cr.reason = "";
|
cr.reason = "";
|
||||||
d.fb.reset();
|
d.fb.reset();
|
||||||
d.ws.template write_close<
|
d.ws.template write_close<
|
||||||
static_streambuf>(d.fb, cr);
|
static_buffer>(d.fb, cr);
|
||||||
if(d.ws.wr_block_)
|
if(d.ws.wr_block_)
|
||||||
{
|
{
|
||||||
// suspend
|
// suspend
|
||||||
@ -620,7 +620,7 @@ operator()(error_code ec,
|
|||||||
}
|
}
|
||||||
d.fb.reset();
|
d.fb.reset();
|
||||||
d.ws.template write_close<
|
d.ws.template write_close<
|
||||||
static_streambuf>(d.fb, code);
|
static_buffer>(d.fb, code);
|
||||||
if(d.ws.wr_block_)
|
if(d.ws.wr_block_)
|
||||||
{
|
{
|
||||||
// suspend
|
// suspend
|
||||||
@ -793,7 +793,7 @@ read_frame(frame_info& fi, DynamicBuffer& dynabuf, error_code& ec)
|
|||||||
fb.reset();
|
fb.reset();
|
||||||
if(ping_cb_)
|
if(ping_cb_)
|
||||||
ping_cb_(false, payload);
|
ping_cb_(false, payload);
|
||||||
write_ping<static_streambuf>(
|
write_ping<static_buffer>(
|
||||||
fb, opcode::pong, payload);
|
fb, opcode::pong, payload);
|
||||||
boost::asio::write(stream_, fb.data(), ec);
|
boost::asio::write(stream_, fb.data(), ec);
|
||||||
failed_ = ec != 0;
|
failed_ = ec != 0;
|
||||||
@ -822,7 +822,7 @@ read_frame(frame_info& fi, DynamicBuffer& dynabuf, error_code& ec)
|
|||||||
cr.reason = "";
|
cr.reason = "";
|
||||||
fb.reset();
|
fb.reset();
|
||||||
wr_close_ = true;
|
wr_close_ = true;
|
||||||
write_close<static_streambuf>(fb, cr);
|
write_close<static_buffer>(fb, cr);
|
||||||
boost::asio::write(stream_, fb.data(), ec);
|
boost::asio::write(stream_, fb.data(), ec);
|
||||||
failed_ = ec != 0;
|
failed_ = ec != 0;
|
||||||
if(failed_)
|
if(failed_)
|
||||||
@ -951,7 +951,7 @@ do_close:
|
|||||||
{
|
{
|
||||||
wr_close_ = true;
|
wr_close_ = true;
|
||||||
detail::frame_streambuf fb;
|
detail::frame_streambuf fb;
|
||||||
write_close<static_streambuf>(fb, code);
|
write_close<static_buffer>(fb, code);
|
||||||
boost::asio::write(stream_, fb.data(), ec);
|
boost::asio::write(stream_, fb.data(), ec);
|
||||||
failed_ = ec != 0;
|
failed_ = ec != 0;
|
||||||
if(failed_)
|
if(failed_)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <beast/core/buffer_concepts.hpp>
|
#include <beast/core/buffer_concepts.hpp>
|
||||||
#include <beast/core/consuming_buffers.hpp>
|
#include <beast/core/consuming_buffers.hpp>
|
||||||
#include <beast/core/prepare_buffers.hpp>
|
#include <beast/core/prepare_buffers.hpp>
|
||||||
#include <beast/core/static_streambuf.hpp>
|
#include <beast/core/static_buffer.hpp>
|
||||||
#include <beast/core/stream_concepts.hpp>
|
#include <beast/core/stream_concepts.hpp>
|
||||||
#include <beast/core/detail/type_traits.hpp>
|
#include <beast/core/detail/type_traits.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <beast/core/handler_helpers.hpp>
|
#include <beast/core/handler_helpers.hpp>
|
||||||
#include <beast/core/handler_ptr.hpp>
|
#include <beast/core/handler_ptr.hpp>
|
||||||
#include <beast/core/prepare_buffers.hpp>
|
#include <beast/core/prepare_buffers.hpp>
|
||||||
#include <beast/core/static_streambuf.hpp>
|
#include <beast/core/static_buffer.hpp>
|
||||||
#include <beast/core/stream_concepts.hpp>
|
#include <beast/core/stream_concepts.hpp>
|
||||||
#include <beast/core/detail/clamp.hpp>
|
#include <beast/core/detail/clamp.hpp>
|
||||||
#include <beast/websocket/detail/frame.hpp>
|
#include <beast/websocket/detail/frame.hpp>
|
||||||
@ -234,7 +234,7 @@ operator()(error_code ec,
|
|||||||
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
BOOST_ASSERT(d.ws.wr_block_ == &d);
|
||||||
d.fh.fin = d.fin;
|
d.fh.fin = d.fin;
|
||||||
d.fh.len = buffer_size(d.cb);
|
d.fh.len = buffer_size(d.cb);
|
||||||
detail::write<static_streambuf>(
|
detail::write<static_buffer>(
|
||||||
d.fh_buf, d.fh);
|
d.fh_buf, d.fh);
|
||||||
d.ws.wr_.cont = ! d.fin;
|
d.ws.wr_.cont = ! d.fin;
|
||||||
// Send frame
|
// Send frame
|
||||||
@ -260,7 +260,7 @@ operator()(error_code ec,
|
|||||||
d.remain -= n;
|
d.remain -= n;
|
||||||
d.fh.len = n;
|
d.fh.len = n;
|
||||||
d.fh.fin = d.fin ? d.remain == 0 : false;
|
d.fh.fin = d.fin ? d.remain == 0 : false;
|
||||||
detail::write<static_streambuf>(
|
detail::write<static_buffer>(
|
||||||
d.fh_buf, d.fh);
|
d.fh_buf, d.fh);
|
||||||
d.ws.wr_.cont = ! d.fin;
|
d.ws.wr_.cont = ! d.fin;
|
||||||
// Send frame
|
// Send frame
|
||||||
@ -308,7 +308,7 @@ operator()(error_code ec,
|
|||||||
d.fh.len = d.remain;
|
d.fh.len = d.remain;
|
||||||
d.fh.key = d.ws.maskgen_();
|
d.fh.key = d.ws.maskgen_();
|
||||||
detail::prepare_key(d.key, d.fh.key);
|
detail::prepare_key(d.key, d.fh.key);
|
||||||
detail::write<static_streambuf>(
|
detail::write<static_buffer>(
|
||||||
d.fh_buf, d.fh);
|
d.fh_buf, d.fh);
|
||||||
auto const n =
|
auto const n =
|
||||||
clamp(d.remain, d.ws.wr_.buf_size);
|
clamp(d.remain, d.ws.wr_.buf_size);
|
||||||
@ -366,7 +366,7 @@ operator()(error_code ec,
|
|||||||
d.ws.wr_.buf.get(), n);
|
d.ws.wr_.buf.get(), n);
|
||||||
buffer_copy(b, d.cb);
|
buffer_copy(b, d.cb);
|
||||||
detail::mask_inplace(b, d.key);
|
detail::mask_inplace(b, d.key);
|
||||||
detail::write<static_streambuf>(
|
detail::write<static_buffer>(
|
||||||
d.fh_buf, d.fh);
|
d.fh_buf, d.fh);
|
||||||
d.ws.wr_.cont = ! d.fin;
|
d.ws.wr_.cont = ! d.fin;
|
||||||
// Send frame
|
// Send frame
|
||||||
@ -442,7 +442,7 @@ operator()(error_code ec,
|
|||||||
d.fh.fin = ! more;
|
d.fh.fin = ! more;
|
||||||
d.fh.len = n;
|
d.fh.len = n;
|
||||||
detail::fh_streambuf fh_buf;
|
detail::fh_streambuf fh_buf;
|
||||||
detail::write<static_streambuf>(fh_buf, d.fh);
|
detail::write<static_buffer>(fh_buf, d.fh);
|
||||||
d.ws.wr_.cont = ! d.fin;
|
d.ws.wr_.cont = ! d.fin;
|
||||||
// Send frame
|
// Send frame
|
||||||
d.state = more ?
|
d.state = more ?
|
||||||
@ -647,7 +647,7 @@ write_frame(bool fin,
|
|||||||
fh.fin = ! more;
|
fh.fin = ! more;
|
||||||
fh.len = n;
|
fh.len = n;
|
||||||
detail::fh_streambuf fh_buf;
|
detail::fh_streambuf fh_buf;
|
||||||
detail::write<static_streambuf>(fh_buf, fh);
|
detail::write<static_buffer>(fh_buf, fh);
|
||||||
wr_.cont = ! fin;
|
wr_.cont = ! fin;
|
||||||
boost::asio::write(stream_,
|
boost::asio::write(stream_,
|
||||||
buffer_cat(fh_buf.data(), b), ec);
|
buffer_cat(fh_buf.data(), b), ec);
|
||||||
@ -675,7 +675,7 @@ write_frame(bool fin,
|
|||||||
fh.fin = fin;
|
fh.fin = fin;
|
||||||
fh.len = remain;
|
fh.len = remain;
|
||||||
detail::fh_streambuf fh_buf;
|
detail::fh_streambuf fh_buf;
|
||||||
detail::write<static_streambuf>(fh_buf, fh);
|
detail::write<static_buffer>(fh_buf, fh);
|
||||||
wr_.cont = ! fin;
|
wr_.cont = ! fin;
|
||||||
boost::asio::write(stream_,
|
boost::asio::write(stream_,
|
||||||
buffer_cat(fh_buf.data(), buffers), ec);
|
buffer_cat(fh_buf.data(), buffers), ec);
|
||||||
@ -696,7 +696,7 @@ write_frame(bool fin,
|
|||||||
fh.len = n;
|
fh.len = n;
|
||||||
fh.fin = fin ? remain == 0 : false;
|
fh.fin = fin ? remain == 0 : false;
|
||||||
detail::fh_streambuf fh_buf;
|
detail::fh_streambuf fh_buf;
|
||||||
detail::write<static_streambuf>(fh_buf, fh);
|
detail::write<static_buffer>(fh_buf, fh);
|
||||||
wr_.cont = ! fin;
|
wr_.cont = ! fin;
|
||||||
boost::asio::write(stream_,
|
boost::asio::write(stream_,
|
||||||
buffer_cat(fh_buf.data(),
|
buffer_cat(fh_buf.data(),
|
||||||
@ -721,7 +721,7 @@ write_frame(bool fin,
|
|||||||
detail::prepared_key key;
|
detail::prepared_key key;
|
||||||
detail::prepare_key(key, fh.key);
|
detail::prepare_key(key, fh.key);
|
||||||
detail::fh_streambuf fh_buf;
|
detail::fh_streambuf fh_buf;
|
||||||
detail::write<static_streambuf>(fh_buf, fh);
|
detail::write<static_buffer>(fh_buf, fh);
|
||||||
consuming_buffers<
|
consuming_buffers<
|
||||||
ConstBufferSequence> cb{buffers};
|
ConstBufferSequence> cb{buffers};
|
||||||
{
|
{
|
||||||
@ -772,7 +772,7 @@ write_frame(bool fin,
|
|||||||
fh.fin = fin ? remain == 0 : false;
|
fh.fin = fin ? remain == 0 : false;
|
||||||
wr_.cont = ! fh.fin;
|
wr_.cont = ! fh.fin;
|
||||||
detail::fh_streambuf fh_buf;
|
detail::fh_streambuf fh_buf;
|
||||||
detail::write<static_streambuf>(fh_buf, fh);
|
detail::write<static_buffer>(fh_buf, fh);
|
||||||
boost::asio::write(stream_,
|
boost::asio::write(stream_,
|
||||||
buffer_cat(fh_buf.data(), b), ec);
|
buffer_cat(fh_buf.data(), b), ec);
|
||||||
failed_ = ec != 0;
|
failed_ = ec != 0;
|
||||||
|
@ -34,7 +34,7 @@ unit-test core-tests :
|
|||||||
core/placeholders.cpp
|
core/placeholders.cpp
|
||||||
core/prepare_buffer.cpp
|
core/prepare_buffer.cpp
|
||||||
core/prepare_buffers.cpp
|
core/prepare_buffers.cpp
|
||||||
core/static_streambuf.cpp
|
core/static_buffer.cpp
|
||||||
core/static_string.cpp
|
core/static_string.cpp
|
||||||
core/stream_concepts.cpp
|
core/stream_concepts.cpp
|
||||||
core/base64.cpp
|
core/base64.cpp
|
||||||
|
@ -27,7 +27,7 @@ add_executable (core-tests
|
|||||||
placeholders.cpp
|
placeholders.cpp
|
||||||
prepare_buffer.cpp
|
prepare_buffer.cpp
|
||||||
prepare_buffers.cpp
|
prepare_buffers.cpp
|
||||||
static_streambuf.cpp
|
static_buffer.cpp
|
||||||
static_string.cpp
|
static_string.cpp
|
||||||
stream_concepts.cpp
|
stream_concepts.cpp
|
||||||
base64.cpp
|
base64.cpp
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
// Test that header file is self-contained.
|
// Test that header file is self-contained.
|
||||||
#include <beast/core/static_streambuf.hpp>
|
#include <beast/core/static_buffer.hpp>
|
||||||
|
|
||||||
#include <beast/unit_test/suite.hpp>
|
#include <beast/unit_test/suite.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
class static_streambuf_test : public beast::unit_test::suite
|
class static_buffer_test : public beast::unit_test::suite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template<class ConstBufferSequence>
|
template<class ConstBufferSequence>
|
||||||
@ -32,7 +32,8 @@ public:
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testStaticStreambuf()
|
void
|
||||||
|
testStaticBuffer()
|
||||||
{
|
{
|
||||||
using boost::asio::buffer;
|
using boost::asio::buffer;
|
||||||
using boost::asio::buffer_cast;
|
using boost::asio::buffer_cast;
|
||||||
@ -50,7 +51,7 @@ public:
|
|||||||
std::size_t v = sizeof(buf) - (t + u);
|
std::size_t v = sizeof(buf) - (t + u);
|
||||||
{
|
{
|
||||||
std::memset(buf, 0, sizeof(buf));
|
std::memset(buf, 0, sizeof(buf));
|
||||||
static_streambuf_n<sizeof(buf)> ba;
|
static_buffer_n<sizeof(buf)> ba;
|
||||||
{
|
{
|
||||||
auto d = ba.prepare(z);
|
auto d = ba.prepare(z);
|
||||||
BEAST_EXPECT(buffer_size(d) == z);
|
BEAST_EXPECT(buffer_size(d) == z);
|
||||||
@ -141,7 +142,7 @@ public:
|
|||||||
|
|
||||||
void testIterators()
|
void testIterators()
|
||||||
{
|
{
|
||||||
static_streambuf_n<2> ba;
|
static_buffer_n<2> ba;
|
||||||
{
|
{
|
||||||
auto mb = ba.prepare(2);
|
auto mb = ba.prepare(2);
|
||||||
std::size_t n;
|
std::size_t n;
|
||||||
@ -196,11 +197,11 @@ public:
|
|||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
testStaticStreambuf();
|
testStaticBuffer();
|
||||||
testIterators();
|
testIterators();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BEAST_DEFINE_TESTSUITE(static_streambuf,core,beast);
|
BEAST_DEFINE_TESTSUITE(static_buffer,core,beast);
|
||||||
|
|
||||||
} // beastp
|
} // beastp
|
Reference in New Issue
Block a user