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
+1 -1
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>
@@ -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
@@ -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);
+2 -2
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