diff options
Diffstat (limited to 'boost/beast/core/impl/flat_static_buffer.ipp')
-rw-r--r-- | boost/beast/core/impl/flat_static_buffer.ipp | 99 |
1 files changed, 19 insertions, 80 deletions
diff --git a/boost/beast/core/impl/flat_static_buffer.ipp b/boost/beast/core/impl/flat_static_buffer.ipp index 54bf292116..31f158ebe7 100644 --- a/boost/beast/core/impl/flat_static_buffer.ipp +++ b/boost/beast/core/impl/flat_static_buffer.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,82 +10,36 @@ #ifndef BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_IPP #define BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_IPP -#include <boost/beast/core/detail/type_traits.hpp> -#include <boost/asio/buffer.hpp> +#include <boost/beast/core/flat_static_buffer.hpp> #include <boost/throw_exception.hpp> #include <algorithm> #include <cstring> #include <iterator> +#include <memory> #include <stdexcept> namespace boost { namespace beast { -/* Memory is laid out thusly: +/* Layout: - begin_ ..|.. in_ ..|.. out_ ..|.. last_ ..|.. end_ + begin_ in_ out_ last_ end_ + |<------->|<---------->|<---------->|<------->| + | readable | writable | */ -inline -auto -flat_static_buffer_base:: -data() const -> - const_buffers_type -{ - return {in_, dist(in_, out_)}; -} - -inline void flat_static_buffer_base:: -reset() -{ - reset_impl(); -} - -inline -auto -flat_static_buffer_base:: -prepare(std::size_t n) -> - mutable_buffers_type -{ - return prepare_impl(n); -} - -inline -void -flat_static_buffer_base:: -reset(void* p, std::size_t n) -{ - reset_impl(p, n); -} - -template<class> -void -flat_static_buffer_base:: -reset_impl() +clear() noexcept { in_ = begin_; out_ = begin_; last_ = begin_; } -template<class> -void -flat_static_buffer_base:: -reset_impl(void* p, std::size_t n) -{ - begin_ = static_cast<char*>(p); - in_ = begin_; - out_ = begin_; - last_ = begin_; - end_ = begin_ + n; -} - -template<class> auto flat_static_buffer_base:: -prepare_impl(std::size_t n) -> +prepare(std::size_t n) -> mutable_buffers_type { if(n <= dist(out_, end_)) @@ -105,10 +59,9 @@ prepare_impl(std::size_t n) -> return {out_, n}; } -template<class> void flat_static_buffer_base:: -consume_impl(std::size_t n) +consume(std::size_t n) noexcept { if(n >= size()) { @@ -119,32 +72,18 @@ consume_impl(std::size_t n) in_ += n; } -//------------------------------------------------------------------------------ - -template<std::size_t 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( - this->prepare(other.size()), other.data())); -} - -template<std::size_t N> -auto -flat_static_buffer<N>:: -operator=(flat_static_buffer const& other) -> - flat_static_buffer<N>& +void +flat_static_buffer_base:: +reset(void* p, std::size_t n) noexcept { - using boost::asio::buffer_copy; - this->consume(this->size()); - this->commit(buffer_copy( - this->prepare(other.size()), other.data())); - return *this; + begin_ = static_cast<char*>(p); + in_ = begin_; + out_ = begin_; + last_ = begin_; + end_ = begin_ + n; } } // beast } // boost -#endif +#endif
\ No newline at end of file |