Rename to flat_buffer, basic_flat_buffer (API Change):

These classes are renamed:

* flat_streambuf to flat_buffer
* basic_flat_streambuf to basic_flat_buffer
This commit is contained in:
Vinnie Falco
2017-05-04 16:00:20 -07:00
parent 24fd254690
commit 6e47e9a0ac
14 changed files with 167 additions and 165 deletions

View File

@ -11,6 +11,7 @@ API Changes:
* New ostream() returns dynamic buffer output stream
* New buffers() replaces to_string()
* Rename to multi_buffer, basic_multi_buffer
* Rename to flat_buffer, basic_flat_buffer
--------------------------------------------------------------------------------

View File

@ -17,6 +17,7 @@ in the examples directory.
Use HTTP to request the root page from a website and print the response:
```
#include <beast/core.hpp>
#include <beast/http.hpp>
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
@ -45,7 +46,7 @@ int main()
beast::http::write(sock, req);
// Receive and print HTTP response using beast
beast::multi_buffer b;
beast::flat_buffer b;
beast::http::response<beast::http::dynamic_body> res;
beast::http::read(sock, b, res);
std::cout << res;

View File

@ -152,7 +152,7 @@
<bridgehead renderas="sect3">Classes</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="beast.ref.async_completion">async_completion</link></member>
<member><link linkend="beast.ref.basic_flat_streambuf">basic_flat_streambuf</link></member>
<member><link linkend="beast.ref.basic_flat_buffer">basic_flat_buffer</link></member>
<member><link linkend="beast.ref.basic_multi_buffer">basic_multi_buffer</link></member>
<member><link linkend="beast.ref.buffers_adapter">buffers_adapter</link></member>
<member><link linkend="beast.ref.consuming_buffers">consuming_buffers</link></member>
@ -161,7 +161,7 @@
<member><link linkend="beast.ref.error_category">error_category</link></member>
<member><link linkend="beast.ref.error_code">error_code</link></member>
<member><link linkend="beast.ref.error_condition">error_condition</link></member>
<member><link linkend="beast.ref.flat_streambuf">flat_streambuf</link></member>
<member><link linkend="beast.ref.flat_buffer">flat_buffer</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.multi_buffer">multi_buffer</link></member>

View File

@ -34,7 +34,7 @@ int main()
beast::http::write(sock, req);
// Receive and print HTTP response using beast
beast::multi_buffer b;
beast::flat_buffer b;
beast::http::response<beast::http::dynamic_body> res;
beast::http::read(sock, b, res);
std::cout << res;

View File

@ -18,7 +18,7 @@
#include <beast/core/consuming_buffers.hpp>
#include <beast/core/dynabuf_readstream.hpp>
#include <beast/core/error.hpp>
#include <beast/core/flat_streambuf.hpp>
#include <beast/core/flat_buffer.hpp>
#include <beast/core/handler_alloc.hpp>
#include <beast/core/handler_concepts.hpp>
#include <beast/core/handler_helpers.hpp>

View File

@ -5,8 +5,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BEAST_FLAT_STREAMBUF_HPP
#define BEAST_FLAT_STREAMBUF_HPP
#ifndef BEAST_FLAT_BUFFER_HPP
#define BEAST_FLAT_BUFFER_HPP
#include <beast/config.hpp>
#include <beast/core/detail/empty_base_optimization.hpp>
@ -34,7 +34,7 @@ namespace beast {
is stored in a single contiguous buffer.
*/
template<class Allocator>
class basic_flat_streambuf
class basic_flat_buffer
#if ! BEAST_DOXYGEN
: private detail::empty_base_optimization<
typename std::allocator_traits<Allocator>::
@ -58,7 +58,7 @@ private:
};
template<class OtherAlloc>
friend class basic_flat_streambuf;
friend class basic_flat_buffer;
using alloc_traits =
std::allocator_traits<allocator_type>;
@ -86,11 +86,11 @@ public:
using mutable_buffers_type = boost::asio::mutable_buffers_1;
/// Copy assignment (disallowed).
basic_flat_streambuf&
operator=(basic_flat_streambuf const&) = delete;
basic_flat_buffer&
operator=(basic_flat_buffer const&) = delete;
/// Destructor.
~basic_flat_streambuf();
~basic_flat_buffer();
/** Move constructor.
@ -101,7 +101,7 @@ public:
have a capacity of zero, an empty input sequence,
and an empty output sequence.
*/
basic_flat_streambuf(basic_flat_streambuf&&);
basic_flat_buffer(basic_flat_buffer&&);
/** Move constructor.
@ -115,7 +115,7 @@ public:
@param alloc The allocator to associate with the
stream buffer.
*/
basic_flat_streambuf(basic_flat_streambuf&&,
basic_flat_buffer(basic_flat_buffer&&,
Allocator const& alloc);
/** Copy constructor.
@ -123,7 +123,7 @@ public:
The new object will have a copy of the input sequence
and an empty output sequence.
*/
basic_flat_streambuf(basic_flat_streambuf const&);
basic_flat_buffer(basic_flat_buffer const&);
/** Copy constructor.
@ -133,7 +133,7 @@ public:
@param alloc The allocator to associate with the
stream buffer.
*/
basic_flat_streambuf(basic_flat_streambuf const&,
basic_flat_buffer(basic_flat_buffer const&,
Allocator const& alloc);
/** Copy constructor.
@ -142,8 +142,8 @@ public:
and an empty output sequence.
*/
template<class OtherAlloc>
basic_flat_streambuf(
basic_flat_streambuf<OtherAlloc> const&);
basic_flat_buffer(
basic_flat_buffer<OtherAlloc> const&);
/** Copy constructor.
@ -154,8 +154,8 @@ public:
stream buffer.
*/
template<class OtherAlloc>
basic_flat_streambuf(
basic_flat_streambuf<OtherAlloc> const&,
basic_flat_buffer(
basic_flat_buffer<OtherAlloc> const&,
Allocator const& alloc);
/** Construct a flat stream buffer.
@ -169,7 +169,7 @@ public:
possible value of `std::size_t` is used.
*/
explicit
basic_flat_streambuf(std::size_t limit = (
basic_flat_buffer(std::size_t limit = (
std::numeric_limits<std::size_t>::max)());
/** Construct a flat stream buffer.
@ -185,7 +185,7 @@ public:
that can be allocated. If unspecified, the largest
possible value of `std::size_t` is used.
*/
basic_flat_streambuf(Allocator const& alloc,
basic_flat_buffer(Allocator const& alloc,
std::size_t limit = (
std::numeric_limits<std::size_t>::max)());
@ -287,24 +287,24 @@ public:
template<class OtherAlloc>
friend
std::size_t
read_size_helper(basic_flat_streambuf<
read_size_helper(basic_flat_buffer<
OtherAlloc> const&, std::size_t);
private:
void
move_from(basic_flat_streambuf& other);
move_from(basic_flat_buffer& other);
template<class OtherAlloc>
void
copy_from(basic_flat_streambuf<
copy_from(basic_flat_buffer<
OtherAlloc> const& other);
};
using flat_streambuf =
basic_flat_streambuf<std::allocator<char>>;
using flat_buffer =
basic_flat_buffer<std::allocator<char>>;
} // beast
#include <beast/core/impl/flat_streambuf.ipp>
#include <beast/core/impl/flat_buffer.ipp>
#endif

View File

@ -5,8 +5,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BEAST_IMPL_FLAT_STREAMBUF_HPP
#define BEAST_IMPL_FLAT_STREAMBUF_HPP
#ifndef BEAST_IMPL_FLAT_BUFFER_HPP
#define BEAST_IMPL_FLAT_BUFFER_HPP
#include <boost/assert.hpp>
#include <stdexcept>
@ -37,8 +37,8 @@ next_pow2(std::size_t x)
template<class Allocator>
void
basic_flat_streambuf<Allocator>::
move_from(basic_flat_streambuf& other)
basic_flat_buffer<Allocator>::
move_from(basic_flat_buffer& other)
{
p_ = other.p_;
in_ = other.in_;
@ -56,8 +56,8 @@ move_from(basic_flat_streambuf& other)
template<class Allocator>
template<class OtherAlloc>
void
basic_flat_streambuf<Allocator>::
copy_from(basic_flat_streambuf<
basic_flat_buffer<Allocator>::
copy_from(basic_flat_buffer<
OtherAlloc> const& other)
{
max_ = other.max_;
@ -81,8 +81,8 @@ copy_from(basic_flat_streambuf<
}
template<class Allocator>
basic_flat_streambuf<Allocator>::
~basic_flat_streambuf()
basic_flat_buffer<Allocator>::
~basic_flat_buffer()
{
if(p_)
alloc_traits::deallocate(
@ -90,8 +90,8 @@ basic_flat_streambuf<Allocator>::
}
template<class Allocator>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(basic_flat_streambuf&& other)
basic_flat_buffer<Allocator>::
basic_flat_buffer(basic_flat_buffer&& other)
: detail::empty_base_optimization<
allocator_type>(std::move(other.member()))
{
@ -99,8 +99,8 @@ basic_flat_streambuf(basic_flat_streambuf&& other)
}
template<class Allocator>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(basic_flat_streambuf&& other,
basic_flat_buffer<Allocator>::
basic_flat_buffer(basic_flat_buffer&& other,
Allocator const& alloc)
: detail::empty_base_optimization<
allocator_type>(alloc)
@ -114,9 +114,9 @@ basic_flat_streambuf(basic_flat_streambuf&& other,
}
template<class Allocator>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(
basic_flat_streambuf const& other)
basic_flat_buffer<Allocator>::
basic_flat_buffer(
basic_flat_buffer const& other)
: detail::empty_base_optimization<allocator_type>(
alloc_traits::select_on_container_copy_construction(
other.member()))
@ -125,9 +125,9 @@ basic_flat_streambuf(
}
template<class Allocator>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(
basic_flat_streambuf const& other,
basic_flat_buffer<Allocator>::
basic_flat_buffer(
basic_flat_buffer const& other,
Allocator const& alloc)
: detail::empty_base_optimization<
allocator_type>(alloc)
@ -137,18 +137,18 @@ basic_flat_streambuf(
template<class Allocator>
template<class OtherAlloc>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(
basic_flat_streambuf<OtherAlloc> const& other)
basic_flat_buffer<Allocator>::
basic_flat_buffer(
basic_flat_buffer<OtherAlloc> const& other)
{
copy_from(other);
}
template<class Allocator>
template<class OtherAlloc>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(
basic_flat_streambuf<OtherAlloc> const& other,
basic_flat_buffer<Allocator>::
basic_flat_buffer(
basic_flat_buffer<OtherAlloc> const& other,
Allocator const& alloc)
: detail::empty_base_optimization<
allocator_type>(alloc)
@ -157,8 +157,8 @@ basic_flat_streambuf(
}
template<class Allocator>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(std::size_t limit)
basic_flat_buffer<Allocator>::
basic_flat_buffer(std::size_t limit)
: p_(nullptr)
, in_(nullptr)
, out_(nullptr)
@ -170,8 +170,8 @@ basic_flat_streambuf(std::size_t limit)
}
template<class Allocator>
basic_flat_streambuf<Allocator>::
basic_flat_streambuf(Allocator const& alloc,
basic_flat_buffer<Allocator>::
basic_flat_buffer(Allocator const& alloc,
std::size_t limit)
: detail::empty_base_optimization<
allocator_type>(alloc)
@ -187,7 +187,7 @@ basic_flat_streambuf(Allocator const& alloc,
template<class Allocator>
auto
basic_flat_streambuf<Allocator>::
basic_flat_buffer<Allocator>::
prepare(std::size_t n) ->
mutable_buffers_type
{
@ -212,7 +212,7 @@ prepare(std::size_t n) ->
// enforce maximum capacity
if(n > max_ - len)
throw std::length_error{
"flat_streambuf overflow"};
"basic_flat_buffer overflow"};
// allocate a new buffer
auto const new_size = (std::min)(max_,
std::max<std::size_t>(
@ -237,7 +237,7 @@ prepare(std::size_t n) ->
template<class Allocator>
void
basic_flat_streambuf<Allocator>::
basic_flat_buffer<Allocator>::
consume(std::size_t n)
{
if(n >= dist(in_, out_))
@ -251,14 +251,14 @@ consume(std::size_t n)
template<class Allocator>
void
basic_flat_streambuf<Allocator>::
basic_flat_buffer<Allocator>::
reserve(std::size_t n)
{
if(n <= capacity())
return;
if(n > max_)
throw std::length_error{
"flat_streambuf overflow"};
"basic_flat_buffer overflow"};
auto const new_size = (std::min)(max_,
std::max<std::size_t>(
detail::next_pow2(n), min_size));
@ -282,7 +282,7 @@ reserve(std::size_t n)
template<class Allocator>
void
basic_flat_streambuf<Allocator>::
basic_flat_buffer<Allocator>::
shrink_to_fit()
{
auto const len = size();
@ -312,7 +312,7 @@ shrink_to_fit()
template<class Allocator>
std::size_t
read_size_helper(basic_flat_streambuf<
read_size_helper(basic_flat_buffer<
Allocator> const& fb, std::size_t max_size)
{
BOOST_ASSERT(max_size >= 1);

View File

@ -190,10 +190,10 @@ enum class parse_state
The parser is optimized for the case where the input buffer
sequence consists of a single contiguous buffer. The
@ref beast::flat_streambuf class is provided, which guarantees
@ref beast::flat_buffer class is provided, which guarantees
that the input sequence of the stream buffer will be represented
by exactly one contiguous buffer. To ensure the optimum performance
of the parser, use @ref beast::flat_streambuf with HTTP algorithms
of the parser, use @ref beast::flat_buffer with HTTP algorithms
such as @ref beast::http::read, @ref beast::http::read_some,
@ref beast::http::async_read, and @ref beast::http::async_read_some.
Alternatively, the caller may use custom techniques to ensure that

View File

@ -25,7 +25,7 @@ unit-test core-tests :
core/consuming_buffers.cpp
core/dynabuf_readstream.cpp
core/error.cpp
core/flat_streambuf.cpp
core/flat_buffer.cpp
core/handler_alloc.cpp
core/handler_concepts.cpp
core/handler_ptr.cpp

View File

@ -18,7 +18,7 @@ add_executable (core-tests
consuming_buffers.cpp
dynabuf_readstream.cpp
error.cpp
flat_streambuf.cpp
flat_buffer.cpp
handler_alloc.cpp
handler_concepts.cpp
handler_ptr.cpp

View File

@ -6,7 +6,7 @@
//
// Test that header file is self-contained.
#include <beast/core/flat_streambuf.hpp>
#include <beast/core/flat_buffer.hpp>
#include "buffer_test.hpp"
#include <beast/core/ostream.hpp>
@ -17,10 +17,10 @@
namespace beast {
static_assert(is_DynamicBuffer<flat_streambuf>::value,
static_assert(is_DynamicBuffer<flat_buffer>::value,
"DynamicBuffer requirements not met");
class flat_streambuf_test : public beast::unit_test::suite
class flat_buffer_test : public beast::unit_test::suite
{
public:
template<class ConstBufferSequence>
@ -35,8 +35,8 @@ public:
template<class Alloc1, class Alloc2>
static
bool
eq(basic_flat_streambuf<Alloc1> const& sb1,
basic_flat_streambuf<Alloc2> const& sb2)
eq(basic_flat_buffer<Alloc1> const& sb1,
basic_flat_buffer<Alloc2> const& sb2)
{
return to_string(sb1.data()) == to_string(sb2.data());
}
@ -50,13 +50,13 @@ public:
Equal, Assign, Move, Swap, Select>;
{
using boost::asio::buffer_size;
basic_flat_streambuf<allocator> b1{10};
basic_flat_buffer<allocator> b1{10};
BEAST_EXPECT(b1.size() == 0);
BEAST_EXPECT(b1.capacity() == 0);
BEAST_EXPECT(b1.max_size() == 10);
b1.prepare(1);
b1.commit(1);
basic_flat_streambuf<allocator> b2{std::move(b1)};
basic_flat_buffer<allocator> b2{std::move(b1)};
BEAST_EXPECT(b1.capacity() == 0);
BEAST_EXPECT(b1.max_size() == 10);
BEAST_EXPECT(b2.size() == 1);
@ -65,29 +65,29 @@ public:
BEAST_EXPECT(buffer_size(b1.prepare(1)) == 1);
}
{
basic_flat_streambuf<allocator> b1{10};
basic_flat_streambuf<allocator> b2{std::move(b1), allocator{}};
basic_flat_buffer<allocator> b1{10};
basic_flat_buffer<allocator> b2{std::move(b1), allocator{}};
}
{
basic_flat_streambuf<allocator> b1{10};
basic_flat_streambuf<allocator> b2{b1};
basic_flat_buffer<allocator> b1{10};
basic_flat_buffer<allocator> b2{b1};
}
{
basic_flat_streambuf<allocator> b1{10};
basic_flat_streambuf<allocator> b2{b1, allocator{}};
basic_flat_buffer<allocator> b1{10};
basic_flat_buffer<allocator> b2{b1, allocator{}};
}
{
flat_streambuf b1{10};
flat_buffer b1{10};
b1.prepare(1);
b1.commit(1);
basic_flat_streambuf<allocator> b2{b1};
basic_flat_buffer<allocator> b2{b1};
BEAST_EXPECT(b2.size() == 1);
}
{
basic_flat_streambuf<allocator> b1{10};
basic_flat_buffer<allocator> b1{10};
}
{
basic_flat_streambuf<allocator> b1{allocator{}, 10};
basic_flat_buffer<allocator> b1{allocator{}, 10};
}
}
@ -136,14 +136,14 @@ public:
//
{
flat_streambuf b{10};
flat_buffer b{10};
b.prepare(1);
b.commit(1);
b.reserve(2);
BEAST_EXPECT(b.size() == 1);
}
{
flat_streambuf b{10};
flat_buffer b{10};
try
{
b.reserve(11);
@ -162,35 +162,35 @@ public:
using boost::asio::buffer;
using boost::asio::buffer_copy;
{
flat_streambuf fb{10};
BEAST_EXPECT(fb.max_size() == 10);
flat_buffer b{10};
BEAST_EXPECT(b.max_size() == 10);
}
{
flat_streambuf fb{1024};
BEAST_EXPECT(fb.max_size() == 1024);
flat_buffer b{1024};
BEAST_EXPECT(b.max_size() == 1024);
}
std::string const s = "Hello, world!";
for(std::size_t i = 1; i < s.size() - 1; ++i)
{
flat_streambuf fb{1024};
fb.commit(buffer_copy(
fb.prepare(i), buffer(s)));
fb.commit(buffer_copy(
fb.prepare(s.size() - i),
flat_buffer b{1024};
b.commit(buffer_copy(
b.prepare(i), buffer(s)));
b.commit(buffer_copy(
b.prepare(s.size() - i),
buffer(s.data() + i, s.size() - i)));
BEAST_EXPECT(to_string(fb.data()) == s);
BEAST_EXPECT(to_string(b.data()) == s);
{
flat_streambuf fb2{fb};
BEAST_EXPECT(eq(fb2, fb));
flat_streambuf fb3{std::move(fb2)};
BEAST_EXPECT(eq(fb3, fb));
BEAST_EXPECT(! eq(fb2, fb3));
BEAST_EXPECT(fb2.size() == 0);
flat_buffer b2{b};
BEAST_EXPECT(eq(b2, b));
flat_buffer b3{std::move(b2)};
BEAST_EXPECT(eq(b3, b));
BEAST_EXPECT(! eq(b2, b3));
BEAST_EXPECT(b2.size() == 0);
}
using alloc_type = std::allocator<double>;
using type =
basic_flat_streambuf<alloc_type>;
basic_flat_buffer<alloc_type>;
alloc_type alloc;
{
type fba{alloc, 1};
@ -201,18 +201,18 @@ public:
BEAST_EXPECT(fba.max_size() == 1024);
}
{
type fb2{fb};
BEAST_EXPECT(eq(fb2, fb));
type fb2{b};
BEAST_EXPECT(eq(fb2, b));
type fb3{std::move(fb2)};
BEAST_EXPECT(eq(fb3, fb));
BEAST_EXPECT(eq(fb3, b));
BEAST_EXPECT(! eq(fb2, fb3));
BEAST_EXPECT(fb2.size() == 0);
}
{
type fb2{fb, alloc};
BEAST_EXPECT(eq(fb2, fb));
type fb2{b, alloc};
BEAST_EXPECT(eq(fb2, b));
type fb3{std::move(fb2), alloc};
BEAST_EXPECT(eq(fb3, fb));
BEAST_EXPECT(eq(fb3, b));
BEAST_EXPECT(! eq(fb2, fb3));
BEAST_EXPECT(fb2.size() == 0);
}
@ -224,57 +224,57 @@ public:
{
using boost::asio::buffer_size;
flat_streambuf fb{100};
BEAST_EXPECT(fb.size() == 0);
BEAST_EXPECT(fb.capacity() == 0);
flat_buffer b{100};
BEAST_EXPECT(b.size() == 0);
BEAST_EXPECT(b.capacity() == 0);
BEAST_EXPECT(buffer_size(fb.prepare(100)) == 100);
BEAST_EXPECT(fb.size() == 0);
BEAST_EXPECT(fb.capacity() > 0);
BEAST_EXPECT(buffer_size(b.prepare(100)) == 100);
BEAST_EXPECT(b.size() == 0);
BEAST_EXPECT(b.capacity() > 0);
fb.commit(20);
BEAST_EXPECT(fb.size() == 20);
BEAST_EXPECT(fb.capacity() == 100);
b.commit(20);
BEAST_EXPECT(b.size() == 20);
BEAST_EXPECT(b.capacity() == 100);
fb.consume(5);
BEAST_EXPECT(fb.size() == 15);
BEAST_EXPECT(fb.capacity() == 100);
b.consume(5);
BEAST_EXPECT(b.size() == 15);
BEAST_EXPECT(b.capacity() == 100);
fb.prepare(80);
fb.commit(80);
BEAST_EXPECT(fb.size() == 95);
BEAST_EXPECT(fb.capacity() == 100);
b.prepare(80);
b.commit(80);
BEAST_EXPECT(b.size() == 95);
BEAST_EXPECT(b.capacity() == 100);
fb.shrink_to_fit();
BEAST_EXPECT(fb.size() == 95);
BEAST_EXPECT(fb.capacity() == 95);
b.shrink_to_fit();
BEAST_EXPECT(b.size() == 95);
BEAST_EXPECT(b.capacity() == 95);
}
void
testPrepare()
{
flat_streambuf fb{100};
fb.prepare(20);
BEAST_EXPECT(fb.capacity() == 100);
fb.commit(10);
BEAST_EXPECT(fb.capacity() == 100);
fb.consume(4);
BEAST_EXPECT(fb.capacity() == 100);
fb.prepare(14);
BEAST_EXPECT(fb.size() == 6);
BEAST_EXPECT(fb.capacity() == 100);
fb.consume(10);
BEAST_EXPECT(fb.size() == 0);
BEAST_EXPECT(fb.capacity() == 100);
flat_buffer b{100};
b.prepare(20);
BEAST_EXPECT(b.capacity() == 100);
b.commit(10);
BEAST_EXPECT(b.capacity() == 100);
b.consume(4);
BEAST_EXPECT(b.capacity() == 100);
b.prepare(14);
BEAST_EXPECT(b.size() == 6);
BEAST_EXPECT(b.capacity() == 100);
b.consume(10);
BEAST_EXPECT(b.size() == 0);
BEAST_EXPECT(b.capacity() == 100);
}
void
testMax()
{
flat_streambuf fb{1};
flat_buffer b{1};
try
{
fb.prepare(2);
b.prepare(2);
fail("", __FILE__, __LINE__);
}
catch(std::length_error const&)
@ -296,6 +296,6 @@ public:
}
};
BEAST_DEFINE_TESTSUITE(flat_streambuf,core,beast);
BEAST_DEFINE_TESTSUITE(flat_buffer,core,beast);
} // beast

View File

@ -5,7 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <beast/core/flat_streambuf.hpp>
#include <beast/core/flat_buffer.hpp>
#include <beast/core/prepare_buffers.hpp>
#include <beast/http/chunk_encode.hpp>
#include <beast/http/read.hpp>
@ -104,7 +104,7 @@ public:
"*"
};
message<true, direct_body, fields> m;
flat_streambuf b{1024};
flat_buffer b{1024};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@ -117,7 +117,7 @@ public:
"*"
};
message<false, direct_body, fields> m;
flat_streambuf b{20};
flat_buffer b{20};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@ -133,7 +133,7 @@ public:
"0\r\n\r\n"
};
message<true, direct_body, fields> m;
flat_streambuf b{100};
flat_buffer b{100};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@ -201,7 +201,7 @@ public:
"*"
};
message<true, indirect_body, fields> m;
flat_streambuf b{1024};
flat_buffer b{1024};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@ -214,7 +214,7 @@ public:
"*"
};
message<false, indirect_body, fields> m;
flat_streambuf b{20};
flat_buffer b{20};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@ -231,7 +231,7 @@ public:
"0\r\n\r\n"
};
message<true, indirect_body, fields> m;
flat_streambuf b{1024};
flat_buffer b{1024};
read(is, b, m);
BEAST_EXPECT(m.body == "*");
}
@ -253,7 +253,7 @@ public:
"*****"
};
header_parser<true, fields> p;
flat_streambuf b{38};
flat_buffer b{38};
auto const bytes_used =
read_some(is, b, p);
b.consume(bytes_used);
@ -272,7 +272,7 @@ public:
"*****"
};
header_parser<false, fields> p;
flat_streambuf b{20};
flat_buffer b{20};
auto const bytes_used =
read_some(is, b, p);
b.consume(bytes_used);
@ -303,7 +303,7 @@ public:
};
header_parser<true, fields> p;
flat_streambuf b{128};
flat_buffer b{128};
auto const bytes_used =
read_some(is, b, p);
b.consume(bytes_used);
@ -335,7 +335,7 @@ public:
DynamicBuffer& b,
SyncReadStream& in)
{
flat_streambuf buffer{4096}; // 4K limit
flat_buffer buffer{4096}; // 4K limit
header_parser<isRequest, fields> parser;
error_code ec;
do
@ -397,7 +397,7 @@ public:
3 // max_read
};
test::string_ostream os{ios_};
flat_streambuf b{16};
flat_buffer b{16};
relay<true>(os, b, is);
}
@ -410,7 +410,7 @@ public:
3 // max_read
};
test::string_ostream os{ios_};
flat_streambuf b{16};
flat_buffer b{16};
relay<false>(os, b, is);
}
@ -427,7 +427,7 @@ public:
2 // max_read
};
test::string_ostream os{ios_};
flat_streambuf b{16};
flat_buffer b{16};
relay<true>(os, b, is);
}
}
@ -444,7 +444,7 @@ public:
void
doFixedRead(SyncReadStream& stream, BodyCallback const& cb)
{
flat_streambuf buffer{4096}; // 4K limit
flat_buffer buffer{4096}; // 4K limit
header_parser<isRequest, fields> parser;
std::size_t bytes_used;
bytes_used = read_some(stream, buffer, parser);

View File

@ -8,7 +8,7 @@
// Test that header file is self-contained.
#include <beast/http/header_parser.hpp>
#include <beast/core/flat_streambuf.hpp>
#include <beast/core/flat_buffer.hpp>
#include <beast/http/read.hpp>
#include <beast/unit_test/suite.hpp>
#include <beast/test/string_istream.hpp>
@ -31,7 +31,7 @@ public:
"User-Agent: test\r\n"
"\r\n"
};
flat_streambuf db{1024};
flat_buffer db{1024};
header_parser<true, fields> p;
read_some(is, db, p);
BEAST_EXPECT(p.is_complete());
@ -44,7 +44,7 @@ public:
"\r\n"
"*"
};
flat_streambuf db{1024};
flat_buffer db{1024};
header_parser<true, fields> p;
read_some(is, db, p);
BEAST_EXPECT(! p.is_complete());

View File

@ -14,7 +14,7 @@
#include <beast/test/string_istream.hpp>
#include <beast/test/string_ostream.hpp>
#include <beast/test/yield_to.hpp>
#include <beast/core/flat_streambuf.hpp>
#include <beast/core/flat_buffer.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/http/header_parser.hpp>
#include <beast/http/read.hpp>
@ -39,7 +39,7 @@ public:
#if 0
multi_buffer dynabuf;
#else
flat_streambuf dynabuf{1024};
flat_buffer dynabuf{1024};
#endif
message<isRequest, string_body, fields> m;
read(ss, dynabuf, m, ec);
@ -124,7 +124,7 @@ public:
"Content-Length: 1\r\n"
"\r\n"
"*"};
flat_streambuf b{1024};
flat_buffer b{1024};
message_parser<true, string_body, fields> p;
read(is, b, p, ec);
auto const& m = p.get();