From 94e92e75b729d432717b2cd023fb8b0bc3188221 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 14 Jul 2017 20:25:39 -0700 Subject: [PATCH] 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 --- CHANGELOG.md | 9 +++ doc/qbk/00_main.qbk | 4 +- doc/qbk/03_core/3_buffers.qbk | 17 +++-- doc/qbk/04_http/05_parser_streams.qbk | 7 +- doc/qbk/07_concepts/DynamicBuffer.qbk | 4 +- doc/qbk/08_design.qbk | 2 +- doc/qbk/quickref.xml | 4 +- example/http-server-fast/http_server_fast.cpp | 4 +- example/server-framework/multi_port.hpp | 2 +- include/beast/core.hpp | 2 +- ...atic_buffer.hpp => flat_static_buffer.hpp} | 74 +++++++++++-------- ...atic_buffer.ipp => flat_static_buffer.ipp} | 28 +++---- include/beast/http/basic_parser.hpp | 2 +- include/beast/websocket/detail/frame.hpp | 6 +- include/beast/websocket/impl/close.ipp | 6 +- include/beast/websocket/impl/ping.ipp | 6 +- include/beast/websocket/impl/read.ipp | 14 ++-- include/beast/websocket/impl/stream.ipp | 2 +- include/beast/websocket/impl/write.ipp | 22 +++--- test/core/CMakeLists.txt | 2 +- test/core/Jamfile | 2 +- ...atic_buffer.cpp => flat_static_buffer.cpp} | 32 ++++---- test/http/read.cpp | 6 +- 23 files changed, 140 insertions(+), 117 deletions(-) rename include/beast/core/{static_buffer.hpp => flat_static_buffer.hpp} (70%) rename include/beast/core/impl/{static_buffer.ipp => flat_static_buffer.ipp} (82%) rename test/core/{static_buffer.cpp => flat_static_buffer.cpp} (89%) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbb24e3d..d3dda2b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/doc/qbk/00_main.qbk b/doc/qbk/00_main.qbk index 02be5720..8e200687 100644 --- a/doc/qbk/00_main.qbk +++ b/doc/qbk/00_main.qbk @@ -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] diff --git a/doc/qbk/03_core/3_buffers.qbk b/doc/qbk/03_core/3_buffers.qbk index 21d9df3e..5a943df8 100644 --- a/doc/qbk/03_core/3_buffers.qbk +++ b/doc/qbk/03_core/3_buffers.qbk @@ -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 diff --git a/doc/qbk/04_http/05_parser_streams.qbk b/doc/qbk/04_http/05_parser_streams.qbk index 465e1a9f..840a5e6c 100644 --- a/doc/qbk/04_http/05_parser_streams.qbk +++ b/doc/qbk/04_http/05_parser_streams.qbk @@ -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. diff --git a/doc/qbk/07_concepts/DynamicBuffer.qbk b/doc/qbk/07_concepts/DynamicBuffer.qbk index c9abd7df..d2048a2a 100644 --- a/doc/qbk/07_concepts/DynamicBuffer.qbk +++ b/doc/qbk/07_concepts/DynamicBuffer.qbk @@ -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] diff --git a/doc/qbk/08_design.qbk b/doc/qbk/08_design.qbk index 5a9c51dd..9c263ad8 100644 --- a/doc/qbk/08_design.qbk +++ b/doc/qbk/08_design.qbk @@ -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 diff --git a/doc/qbk/quickref.xml b/doc/qbk/quickref.xml index 8fcbd10e..5d93d1d2 100644 --- a/doc/qbk/quickref.xml +++ b/doc/qbk/quickref.xml @@ -195,6 +195,8 @@ file_stdio file_win32 flat_buffer + flat_static_buffer + flat_static_buffer_base handler_alloc handler_ptr handler_type @@ -202,8 +204,6 @@ iless multi_buffer span - static_buffer - static_buffer_n static_string string_param string_view diff --git a/example/http-server-fast/http_server_fast.cpp b/example/http-server-fast/http_server_fast.cpp index bdcea284..95078fc1 100644 --- a/example/http-server-fast/http_server_fast.cpp +++ b/example/http-server-fast/http_server_fast.cpp @@ -47,7 +47,7 @@ public: private: using alloc_t = fields_alloc; - using request_body_t = http::basic_dynamic_body>; + using request_body_t = http::basic_dynamic_body>; // 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}; diff --git a/example/server-framework/multi_port.hpp b/example/server-framework/multi_port.hpp index 37741332..c576058e 100644 --- a/example/server-framework/multi_port.hpp +++ b/example/server-framework/multi_port.hpp @@ -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 diff --git a/include/beast/core.hpp b/include/beast/core.hpp index 3084c3e8..7b898c45 100644 --- a/include/beast/core.hpp +++ b/include/beast/core.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/beast/core/static_buffer.hpp b/include/beast/core/flat_static_buffer.hpp similarity index 70% rename from include/beast/core/static_buffer.hpp rename to include/beast/core/flat_static_buffer.hpp index 1f86c336..4f088196 100644 --- a/include/beast/core/static_buffer.hpp +++ b/include/beast/core/flat_static_buffer.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 #include @@ -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 -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 +#include #endif diff --git a/include/beast/core/impl/static_buffer.ipp b/include/beast/core/impl/flat_static_buffer.ipp similarity index 82% rename from include/beast/core/impl/static_buffer.ipp rename to include/beast/core/impl/flat_static_buffer.ipp index 13652ca5..b605a1c2 100644 --- a/include/beast/core/impl/static_buffer.ipp +++ b/include/beast/core/impl/flat_static_buffer.ipp @@ -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 #include @@ -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 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 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 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 -static_buffer_n:: -static_buffer_n(static_buffer_n const& other) - : static_buffer(buf_, N) +flat_static_buffer:: +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 auto -static_buffer_n:: -operator=(static_buffer_n const& other) -> - static_buffer_n& +flat_static_buffer:: +operator=(flat_static_buffer const& other) -> + flat_static_buffer& { using boost::asio::buffer_copy; this->consume(this->size()); diff --git a/include/beast/http/basic_parser.hpp b/include/beast/http/basic_parser.hpp index c7dbd9c2..256104ec 100644 --- a/include/beast/http/basic_parser.hpp +++ b/include/beast/http/basic_parser.hpp @@ -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. diff --git a/include/beast/websocket/detail/frame.hpp b/include/beast/websocket/detail/frame.hpp index 512f817a..ccc653ac 100644 --- a/include/beast/websocket/detail/frame.hpp +++ b/include/beast/websocket/detail/frame.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -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 diff --git a/include/beast/websocket/impl/close.ipp b/include/beast/websocket/impl/close.ipp index add4bd6b..2d3d3187 100644 --- a/include/beast/websocket/impl/close.ipp +++ b/include/beast/websocket/impl/close.ipp @@ -9,7 +9,7 @@ #define BEAST_WEBSOCKET_IMPL_CLOSE_IPP #include -#include +#include #include #include #include @@ -42,7 +42,7 @@ class stream::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(fb, cr); + write_close(fb, cr); boost::asio::write(stream_, fb.data(), ec); failed_ = !!ec; } diff --git a/include/beast/websocket/impl/ping.ipp b/include/beast/websocket/impl/ping.ipp index dc37278e..77b1c806 100644 --- a/include/beast/websocket/impl/ping.ipp +++ b/include/beast/websocket/impl/ping.ipp @@ -43,7 +43,7 @@ class stream::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:: ping(ping_data const& payload, error_code& ec) { detail::frame_streambuf db; - write_ping( + write_ping( db, detail::opcode::ping, payload); boost::asio::write(stream_, db.data(), ec); } @@ -256,7 +256,7 @@ stream:: pong(ping_data const& payload, error_code& ec) { detail::frame_streambuf db; - write_ping( + write_ping( db, detail::opcode::pong, payload); boost::asio::write(stream_, db.data(), ec); } diff --git a/include/beast/websocket/impl/read.ipp b/include/beast/websocket/impl/read.ipp index 403bc646..3a279385 100644 --- a/include/beast/websocket/impl/read.ipp +++ b/include/beast/websocket/impl/read.ipp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -445,7 +445,7 @@ operator()(error_code ec, d.state = do_read_fh; break; } - d.ws.template write_ping( + d.ws.template write_ping( 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(fb, + write_ping(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(fb, cr); + write_close(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(fb, code); + write_close(fb, code); boost::asio::write(stream_, fb.data(), ec); failed_ = !!ec; if(failed_) diff --git a/include/beast/websocket/impl/stream.ipp b/include/beast/websocket/impl/stream.ipp index 286b7e9a..005ee98d 100644 --- a/include/beast/websocket/impl/stream.ipp +++ b/include/beast/websocket/impl/stream.ipp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/beast/websocket/impl/write.ipp b/include/beast/websocket/impl/write.ipp index 0da91b11..ca12eb60 100644 --- a/include/beast/websocket/impl/write.ipp +++ b/include/beast/websocket/impl/write.ipp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -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( + detail::write( 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( + detail::write( 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( + detail::write( 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( + detail::write( 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(fh_buf, d.fh); + detail::write(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(fh_buf, fh); + detail::write(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(fh_buf, fh); + detail::write(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(fh_buf, fh); + detail::write(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(fh_buf, fh); + detail::write(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(fh_buf, fh); + detail::write(fh_buf, fh); boost::asio::write(stream_, buffer_cat(fh_buf.data(), b), ec); failed_ = !!ec; diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 9fa0467f..35af205d 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -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 diff --git a/test/core/Jamfile b/test/core/Jamfile index 62f63bee..4d57d6fe 100644 --- a/test/core/Jamfile +++ b/test/core/Jamfile @@ -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 diff --git a/test/core/static_buffer.cpp b/test/core/flat_static_buffer.cpp similarity index 89% rename from test/core/static_buffer.cpp rename to test/core/flat_static_buffer.cpp index fb0f4f62..773cde9e 100644 --- a/test/core/static_buffer.cpp +++ b/test/core/flat_static_buffer.cpp @@ -6,7 +6,7 @@ // // Test that header file is self-contained. -#include +#include #include "buffer_test.hpp" @@ -18,10 +18,10 @@ namespace beast { static_assert( - is_dynamic_buffer::value, + is_dynamic_buffer::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 ba; + flat_static_buffer 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 diff --git a/test/http/read.cpp b/test/http/read.cpp index 3e28ea50..8069569f 100644 --- a/test/http/read.cpp +++ b/test/http/read.cpp @@ -11,7 +11,7 @@ #include "test_parser.hpp" #include -#include +#include #include #include #include @@ -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 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 req; read(p.server, b, req, ec); BEAST_EXPECTS(ec == error::buffer_overflow,