/usr/include/boost/beast/core
NameSizeModeActions
detail/-0755rm
impl/-0755rm
async_base.hpp264610644editdlrm
basic_stream.hpp553420644editdlrm
bind_handler.hpp41720644editdlrm
buffered_read_stream.hpp118770644editdlrm
buffers_adaptor.hpp67830644editdlrm
buffers_cat.hpp33830644editdlrm
buffers_prefix.hpp61520644editdlrm
buffers_range.hpp42110644editdlrm
buffers_suffix.hpp39710644editdlrm
buffers_to_string.hpp17700644editdlrm
buffer_traits.hpp57570644editdlrm
detect_ssl.hpp223450644editdlrm
error.hpp22570644editdlrm
file.hpp10280644editdlrm
file_base.hpp50150644editdlrm
file_posix.hpp42220644editdlrm
file_stdio.hpp38490644editdlrm
file_win32.hpp42480644editdlrm
flat_buffer.hpp154270644editdlrm
flat_static_buffer.hpp87060644editdlrm
flat_stream.hpp126030644editdlrm
make_printable.hpp28030644editdlrm
multi_buffer.hpp181530644editdlrm
ostream.hpp26900644editdlrm
rate_policy.hpp45920644editdlrm
read_size.hpp18440644editdlrm
role.hpp13220644editdlrm
saved_handler.hpp37880644editdlrm
span.hpp47870644editdlrm
static_buffer.hpp85150644editdlrm
static_string.hpp257200644editdlrm
stream_traits.hpp163990644editdlrm
string.hpp19410644editdlrm
string_param.hpp34590644editdlrm
string_type.hpp10920644editdlrm
tcp_stream.hpp8530644editdlrm
Edit: /usr/include/boost/beast/core/static_buffer.hpp (8515B)
// // 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) // // Official repository: https://github.com/boostorg/beast // #ifndef BOOST_BEAST_STATIC_BUFFER_HPP #define BOOST_BEAST_STATIC_BUFFER_HPP #include #include #include #include namespace boost { namespace beast { /** A dynamic buffer providing a fixed size, circular buffer. A dynamic buffer encapsulates memory storage that may be automatically resized as required, where the memory is divided into two regions: readable bytes followed by writable bytes. These memory regions are internal to the dynamic buffer, but direct access to the elements is provided to permit them to be efficiently used with I/O operations. Objects of this type meet the requirements of DynamicBuffer and have the following additional properties: @li A mutable buffer sequence representing the readable bytes is returned by @ref data when `this` is non-const. @li Buffer sequences representing the readable and writable bytes, returned by @ref data and @ref prepare, may have length up to two. @li All operations execute in constant time. @li Ownership of the underlying storage belongs to the derived class. @note Variables are usually declared using the template class @ref static_buffer; however, to reduce the number of template instantiations, objects should be passed `static_buffer_base&`. @see static_buffer */ class static_buffer_base { char* begin_; std::size_t in_off_ = 0; std::size_t in_size_ = 0; std::size_t out_size_ = 0; std::size_t capacity_; static_buffer_base(static_buffer_base const& other) = delete; static_buffer_base& operator=(static_buffer_base const&) = delete; public: /** Constructor This creates a dynamic buffer using the provided storage area. @param p A pointer to valid storage of at least `n` bytes. @param size The number of valid bytes pointed to by `p`. */ BOOST_BEAST_DECL static_buffer_base(void* p, std::size_t size) noexcept; /** Clear the readable and writable bytes to zero. This function causes the readable and writable bytes to become empty. The capacity is not changed. Buffer sequences previously obtained using @ref data or @ref prepare become invalid. @esafe No-throw guarantee. */ BOOST_BEAST_DECL void clear() noexcept; //-------------------------------------------------------------------------- #if BOOST_BEAST_DOXYGEN /// The ConstBufferSequence used to represent the readable bytes. using const_buffers_type = __implementation_defined__; /// The MutableBufferSequence used to represent the writable bytes. using mutable_buffers_type = __implementation_defined__; #else using const_buffers_type = detail::buffers_pair; using mutable_buffers_type = detail::buffers_pair; #endif /// Returns the number of readable bytes. std::size_t size() const noexcept { return in_size_; } /// Return the maximum number of bytes, both readable and writable, that can ever be held. std::size_t max_size() const noexcept { return capacity_; } /// Return the maximum number of bytes, both readable and writable, that can be held without requiring an allocation. std::size_t capacity() const noexcept { return capacity_; } /// Returns a constant buffer sequence representing the readable bytes BOOST_BEAST_DECL const_buffers_type data() const noexcept; /// Returns a constant buffer sequence representing the readable bytes const_buffers_type cdata() const noexcept { return data(); } /// Returns a mutable buffer sequence representing the readable bytes BOOST_BEAST_DECL mutable_buffers_type data() noexcept; /** Returns a mutable buffer sequence representing writable bytes. Returns a mutable buffer sequence representing the writable bytes containing exactly `n` bytes of storage. Memory may be reallocated as needed. All buffers sequences previously obtained using @ref data or @ref prepare are invalidated. @param n The desired number of bytes in the returned buffer sequence. @throws std::length_error if `size() + n` exceeds `max_size()`. @esafe Strong guarantee. */ BOOST_BEAST_DECL mutable_buffers_type prepare(std::size_t n); /** Append writable bytes to the readable bytes. Appends n bytes from the start of the writable bytes to the end of the readable bytes. The remainder of the writable bytes are discarded. If n is greater than the number of writable bytes, all writable bytes are appended to the readable bytes. All buffers sequences previously obtained using @ref data or @ref prepare are invalidated. @param n The number of bytes to append. If this number is greater than the number of writable bytes, all writable bytes are appended. @esafe No-throw guarantee. */ BOOST_BEAST_DECL void commit(std::size_t n) noexcept; /** Remove bytes from beginning of the readable bytes. Removes n bytes from the beginning of the readable bytes. All buffers sequences previously obtained using @ref data or @ref prepare are invalidated. @param n The number of bytes to remove. If this number is greater than the number of readable bytes, all readable bytes are removed. @esafe No-throw guarantee. */ BOOST_BEAST_DECL void consume(std::size_t n) noexcept; }; //------------------------------------------------------------------------------ /** A dynamic buffer providing a fixed size, circular buffer. A dynamic buffer encapsulates memory storage that may be automatically resized as required, where the memory is divided into two regions: readable bytes followed by writable bytes. These memory regions are internal to the dynamic buffer, but direct access to the elements is provided to permit them to be efficiently used with I/O operations. Objects of this type meet the requirements of DynamicBuffer and have the following additional properties: @li A mutable buffer sequence representing the readable bytes is returned by @ref data when `this` is non-const. @li Buffer sequences representing the readable and writable bytes, returned by @ref data and @ref prepare, may have length up to two. @li All operations execute in constant time. @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_base instead. @see static_buffer_base */ template class static_buffer : public static_buffer_base { char buf_[N]; public: /// Constructor static_buffer() noexcept : static_buffer_base(buf_, N) { } /// Constructor static_buffer(static_buffer const&) noexcept; /// Assignment static_buffer& operator=(static_buffer const&) noexcept; /// Returns the @ref static_buffer_base portion of this object static_buffer_base& base() noexcept { return *this; } /// Returns the @ref static_buffer_base portion of this object static_buffer_base const& base() const noexcept { return *this; } /// Return the maximum sum of the input and output sequence sizes. std::size_t constexpr max_size() const noexcept { return N; } /// Return the maximum sum of input and output sizes that can be held without an allocation. std::size_t constexpr capacity() const noexcept { return N; } }; } // beast } // boost #include #ifdef BOOST_BEAST_HEADER_ONLY #include #endif #endif