mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Tidy up core files
This commit is contained in:
@ -7,6 +7,7 @@ Version 198:
|
||||
* saved_handler maintains a work_guard (websocket)
|
||||
* Add buffer_traits.hpp, buffers_type
|
||||
* Tidy up experimental files
|
||||
* Tidy up core files
|
||||
|
||||
API Changes:
|
||||
|
||||
|
@ -289,9 +289,9 @@ PREDEFINED = \
|
||||
BOOST_BEAST_DOXYGEN \
|
||||
BOOST_BEAST_USE_POSIX_FILE=1 \
|
||||
BOOST_BEAST_USE_WIN32_FILE=1 \
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=void_or_deduced \
|
||||
GENERATING_DOCUMENTATION
|
||||
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=__deduced__ \
|
||||
GENERATING_DOCUMENTATION \
|
||||
BOOST_BEAST_DECL
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
<xsl:text>class __AsyncWriteStream__</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="type = 'class Body'">
|
||||
<xsl:text>class ``[link beast.concepts.Body [*Body]]``</xsl:text>
|
||||
<xsl:text>class __Body__</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="type = 'class BufferSequence'">
|
||||
<xsl:text>class ``[link beast.concepts.BufferSequence [*BufferSequence]]``</xsl:text>
|
||||
@ -76,24 +76,3 @@
|
||||
<xsl:text>class __WriteHandler__</xsl:text>
|
||||
</xsl:when>
|
||||
<!-- CLASS_DETAIL_TEMPLATE END -->
|
||||
|
||||
|
||||
|
||||
<xsl:when test="type = 'class Protocol'">
|
||||
<xsl:text>class __Protocol__</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="type = 'class Executor'">
|
||||
<xsl:text>class __Executor__</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="type = 'class EndpointSequence'">
|
||||
<xsl:text>class __EndpointSequence__</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="type = 'class RangeConnectHandler'">
|
||||
<xsl:text>class __RangeConnectHandler__</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="type = 'class ConnectCondition'">
|
||||
<xsl:text>class __ConnectCondition__</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="type = 'class IteratorConnectHandler'">
|
||||
<xsl:text>class __IteratorConnectHandler__</xsl:text>
|
||||
</xsl:when>
|
||||
|
@ -31,7 +31,7 @@ namespace beast {
|
||||
is part of the object.
|
||||
|
||||
The use-case for this class is different than that of the
|
||||
`net::buffered_readstream`. It is designed to facilitate
|
||||
`net::buffered_read_stream`. It is designed to facilitate
|
||||
the use of `net::read_until`, and to allow buffers
|
||||
acquired during detection of handshakes to be made transparently
|
||||
available to callers. A hypothetical implementation of the
|
||||
@ -51,9 +51,9 @@ namespace beast {
|
||||
// Process the next HTTP header on the stream,
|
||||
// leaving excess bytes behind for the next call.
|
||||
//
|
||||
template<class DynamicBuffer>
|
||||
template<class Stream, class DynamicBuffer>
|
||||
void process_http_message(
|
||||
buffered_read_stream<DynamicBuffer>& stream)
|
||||
buffered_read_stream<Stream, DynamicBuffer>& stream)
|
||||
{
|
||||
// Read up to and including the end of the HTTP
|
||||
// header, leaving the sequence in the stream's
|
||||
@ -137,28 +137,28 @@ public:
|
||||
|
||||
/// Get a reference to the next layer.
|
||||
next_layer_type&
|
||||
next_layer()
|
||||
next_layer() noexcept
|
||||
{
|
||||
return next_layer_;
|
||||
}
|
||||
|
||||
/// Get a const reference to the next layer.
|
||||
next_layer_type const&
|
||||
next_layer() const
|
||||
next_layer() const noexcept
|
||||
{
|
||||
return next_layer_;
|
||||
}
|
||||
|
||||
/// Get a reference to the lowest layer.
|
||||
lowest_layer_type&
|
||||
lowest_layer()
|
||||
lowest_layer() noexcept
|
||||
{
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
|
||||
/// Get a const reference to the lowest layer.
|
||||
lowest_layer_type const&
|
||||
lowest_layer() const
|
||||
lowest_layer() const noexcept
|
||||
{
|
||||
return next_layer_.lowest_layer();
|
||||
}
|
||||
@ -196,14 +196,14 @@ public:
|
||||
the caller defined maximum.
|
||||
*/
|
||||
DynamicBuffer&
|
||||
buffer()
|
||||
buffer() noexcept
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
/// Access the internal buffer
|
||||
DynamicBuffer const&
|
||||
buffer() const
|
||||
buffer() const noexcept
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
@ -224,7 +224,7 @@ public:
|
||||
than the amount of data in the buffer, no bytes are discarded.
|
||||
*/
|
||||
void
|
||||
capacity(std::size_t size)
|
||||
capacity(std::size_t size) noexcept
|
||||
{
|
||||
capacity_ = size;
|
||||
}
|
||||
@ -367,6 +367,6 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/buffered_read_stream.ipp>
|
||||
#include <boost/beast/core/impl/buffered_read_stream.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -19,11 +19,11 @@
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
/** Adapts a @b MutableBufferSequence into a @b DynamicBuffer.
|
||||
/** Adapts a <em>MutableBufferSequence</em> into a <em>DynamicBuffer</em>.
|
||||
|
||||
This class wraps a @b MutableBufferSequence to meet the requirements
|
||||
of @b DynamicBuffer. Upon construction the input and output sequences are
|
||||
empty. A copy of the mutable buffer sequence object is stored; however,
|
||||
This class wraps a <em>MutableBufferSequence</em> to meet the requirements
|
||||
of <em>DynamicBuffer</em>. Upon construction the input and output sequences
|
||||
are empty. A copy of the mutable buffer sequence object is stored; however,
|
||||
ownership of the underlying memory is not transferred. The caller is
|
||||
responsible for making sure that referenced memory remains valid
|
||||
for the duration of any operations.
|
||||
@ -36,7 +36,8 @@ namespace beast {
|
||||
template<class MutableBufferSequence>
|
||||
class buffers_adapter
|
||||
{
|
||||
static_assert(net::is_mutable_buffer_sequence<MutableBufferSequence>::value,
|
||||
static_assert(net::is_mutable_buffer_sequence<
|
||||
MutableBufferSequence>::value,
|
||||
"MutableBufferSequence requirements not met");
|
||||
|
||||
using iter_type = typename
|
||||
@ -75,20 +76,6 @@ public:
|
||||
/// The type of the underlying mutable buffer sequence
|
||||
using value_type = MutableBufferSequence;
|
||||
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
/// The type used to represent the input sequence as a list of buffers.
|
||||
using const_buffers_type = __implementation_defined__;
|
||||
|
||||
/// The type used to represent the output sequence as a list of buffers.
|
||||
using mutable_buffers_type = __implementation_defined__;
|
||||
|
||||
#else
|
||||
class const_buffers_type;
|
||||
|
||||
class mutable_buffers_type;
|
||||
|
||||
#endif
|
||||
|
||||
/// Move constructor.
|
||||
buffers_adapter(buffers_adapter&& other);
|
||||
|
||||
@ -121,27 +108,6 @@ public:
|
||||
explicit
|
||||
buffers_adapter(boost::in_place_init_t, Args&&... args);
|
||||
|
||||
/// Returns the largest size output sequence possible.
|
||||
std::size_t
|
||||
max_size() const
|
||||
{
|
||||
return max_size_;
|
||||
}
|
||||
|
||||
/// Get the size of the input sequence.
|
||||
std::size_t
|
||||
size() const
|
||||
{
|
||||
return in_size_;
|
||||
}
|
||||
|
||||
/// Returns the maximum sum of the sizes of the input sequence and output sequence the buffer can hold without requiring reallocation.
|
||||
std::size_t
|
||||
capacity() const
|
||||
{
|
||||
return max_size_;
|
||||
}
|
||||
|
||||
/// Returns the original mutable buffer sequence
|
||||
value_type const&
|
||||
value() const
|
||||
@ -149,40 +115,112 @@ public:
|
||||
return bs_;
|
||||
}
|
||||
|
||||
/** Get a list of buffers that represents the output sequence, with the given size.
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@throws std::length_error if the size would exceed the limit
|
||||
imposed by the underlying mutable buffer sequence.
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
/// The ConstBufferSequence used to represent the readable bytes.
|
||||
using const_buffers_type = __implementation_defined__;
|
||||
|
||||
@note Buffers representing the input sequence acquired prior to
|
||||
this call remain valid.
|
||||
/// The MutableBufferSequence used to represent the writable bytes.
|
||||
using mutable_buffers_type = __implementation_defined__;
|
||||
|
||||
#else
|
||||
class const_buffers_type;
|
||||
class mutable_buffers_type;
|
||||
#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 max_size_;
|
||||
}
|
||||
|
||||
/// 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 max_size_;
|
||||
}
|
||||
|
||||
/// Returns a constant buffer sequence representing the readable bytes
|
||||
const_buffers_type
|
||||
data() const noexcept;
|
||||
|
||||
/** Returns a mutable buffer sequence representing writable bytes.
|
||||
|
||||
Returns a mutable buffer sequence representing the writable
|
||||
bytes containing exactly `n` bytes of storage. This function
|
||||
does not allocate memory. Instead, the storage comes from
|
||||
the underlying mutable buffer sequence.
|
||||
|
||||
All buffer sequences previously obtained using @ref prepare are
|
||||
invalidated. Buffer sequences previously obtained using @ref data
|
||||
remain valid.
|
||||
|
||||
@param n The desired number of bytes in the returned buffer
|
||||
sequence.
|
||||
|
||||
@throws std::length_error if `size() + n` exceeds `max_size()`.
|
||||
|
||||
@par Exception Safety
|
||||
|
||||
Strong guarantee.
|
||||
*/
|
||||
mutable_buffers_type
|
||||
prepare(std::size_t n);
|
||||
|
||||
/** Move bytes from the output sequence to the input sequence.
|
||||
/** Append writable bytes to the readable bytes.
|
||||
|
||||
@note Buffers representing the input sequence acquired prior to
|
||||
this call remain valid.
|
||||
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 buffer sequences previously obtained using @ref prepare are
|
||||
invalidated. Buffer sequences previously obtained using @ref data
|
||||
remain valid.
|
||||
|
||||
@param n The number of bytes to append. If this number
|
||||
is greater than the number of writable bytes, all
|
||||
writable bytes are appended.
|
||||
|
||||
@par Exception Safety
|
||||
|
||||
No-throw guarantee.
|
||||
*/
|
||||
void
|
||||
commit(std::size_t n);
|
||||
commit(std::size_t n) noexcept;
|
||||
|
||||
/** Get a list of buffers that represents the input sequence.
|
||||
/** Remove bytes from beginning of the readable bytes.
|
||||
|
||||
@note These buffers remain valid across subsequent calls to `prepare`.
|
||||
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.
|
||||
|
||||
@par Exception Safety
|
||||
|
||||
No-throw guarantee.
|
||||
*/
|
||||
const_buffers_type
|
||||
data() const;
|
||||
|
||||
/// Remove bytes from the input sequence.
|
||||
void
|
||||
consume(std::size_t n);
|
||||
consume(std::size_t n) noexcept;
|
||||
};
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/buffers_adapter.ipp>
|
||||
#include <boost/beast/core/impl/buffers_adapter.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define BOOST_BEAST_BUFFERS_CAT_HPP
|
||||
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/detail/lean_tuple.hpp>
|
||||
#include <boost/beast/core/detail/tuple.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
@ -24,12 +24,12 @@ namespace beast {
|
||||
template<class... Buffers>
|
||||
class buffers_cat_view
|
||||
{
|
||||
detail::lean_tuple<Buffers...> bn_;
|
||||
detail::tuple<Buffers...> bn_;
|
||||
|
||||
public:
|
||||
/** The type of buffer returned when dereferencing an iterator.
|
||||
|
||||
If every buffer sequence in the view is a @b MutableBufferSequence,
|
||||
If every buffer sequence in the view is a <em>MutableBufferSequence</em>,
|
||||
then `value_type` will be `net::mutable_buffer`.
|
||||
Otherwise, `value_type` will be `net::const_buffer`.
|
||||
*/
|
||||
@ -43,34 +43,33 @@ public:
|
||||
/// The type of iterator used by the concatenated sequence
|
||||
class const_iterator;
|
||||
|
||||
/// Constructor
|
||||
/// Copy Constructor
|
||||
buffers_cat_view(buffers_cat_view const&) = default;
|
||||
|
||||
/// Move Constructor
|
||||
buffers_cat_view(buffers_cat_view&&) = default;
|
||||
|
||||
/// Assignment
|
||||
buffers_cat_view& operator=(buffers_cat_view&&) = default;
|
||||
|
||||
/// Assignment
|
||||
/// Copy Assignment
|
||||
buffers_cat_view& operator=(buffers_cat_view const&) = default;
|
||||
|
||||
/// Move Assignment
|
||||
buffers_cat_view& operator=(buffers_cat_view&&) = default;
|
||||
|
||||
/** Constructor
|
||||
|
||||
@param buffers The list of buffer sequences to concatenate.
|
||||
Copies of the arguments will be made; however, the ownership
|
||||
of memory is not transferred.
|
||||
Copies of the arguments will be maintained for the lifetime
|
||||
of the concatenated sequence; however, the ownership of memory
|
||||
is not transferred.
|
||||
*/
|
||||
explicit
|
||||
buffers_cat_view(Buffers const&... buffers);
|
||||
|
||||
//-----
|
||||
|
||||
/// Required for @b BufferSequence
|
||||
buffers_cat_view(buffers_cat_view const&) = default;
|
||||
|
||||
/// Required for @b BufferSequence
|
||||
/// Returns an iterator to the first buffer in the sequence
|
||||
const_iterator
|
||||
begin() const;
|
||||
|
||||
/// Required for @b BufferSequence
|
||||
/// Returns an iterator to one past the last buffer in the sequence
|
||||
const_iterator
|
||||
end() const;
|
||||
};
|
||||
@ -88,9 +87,9 @@ public:
|
||||
|
||||
@return A new buffer sequence that represents the concatenation of
|
||||
the input buffer sequences. This buffer sequence will be a
|
||||
@b MutableBufferSequence if each of the passed buffer sequences is
|
||||
also a @b MutableBufferSequence; otherwise the returned buffer
|
||||
sequence will be a @b ConstBufferSequence.
|
||||
<em>MutableBufferSequence</em> if each of the passed buffer sequences is
|
||||
also a <em>MutableBufferSequence</em>; otherwise the returned buffer
|
||||
sequence will be a <em>ConstBufferSequence</em>.
|
||||
|
||||
@see @ref buffers_cat_view
|
||||
*/
|
||||
@ -100,7 +99,6 @@ buffers_cat_view<BufferSequence...>
|
||||
buffers_cat(BufferSequence const&... buffers)
|
||||
#else
|
||||
template<class B1, class B2, class... Bn>
|
||||
inline
|
||||
buffers_cat_view<B1, B2, Bn...>
|
||||
buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn)
|
||||
#endif
|
||||
@ -114,6 +112,6 @@ buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn)
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/buffers_cat.ipp>
|
||||
#include <boost/beast/core/impl/buffers_cat.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,8 @@
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/optional/optional.hpp> // for in_place_init_t
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
|
||||
@ -73,16 +74,16 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
/// Move constructor.
|
||||
/// Move Constructor
|
||||
buffers_prefix_view(buffers_prefix_view&&);
|
||||
|
||||
/// Copy constructor.
|
||||
/// Copy Constructor
|
||||
buffers_prefix_view(buffers_prefix_view const&);
|
||||
|
||||
/// Move assignment.
|
||||
/// Move Assignment
|
||||
buffers_prefix_view& operator=(buffers_prefix_view&&);
|
||||
|
||||
/// Copy assignment.
|
||||
/// Copy Assignment
|
||||
buffers_prefix_view& operator=(buffers_prefix_view const&);
|
||||
|
||||
/** Construct a buffer sequence prefix.
|
||||
@ -94,7 +95,8 @@ public:
|
||||
|
||||
@param buffers The buffer sequence to adapt. A copy of
|
||||
the sequence will be made, but ownership of the underlying
|
||||
memory is not transferred.
|
||||
memory is not transferred. The copy is maintained for
|
||||
the lifetime of the view.
|
||||
*/
|
||||
buffers_prefix_view(
|
||||
std::size_t size,
|
||||
@ -115,96 +117,117 @@ public:
|
||||
boost::in_place_init_t,
|
||||
Args&&... args);
|
||||
|
||||
/// Get a bidirectional iterator to the first element.
|
||||
/// Returns an iterator to the first buffer in the sequence
|
||||
const_iterator
|
||||
begin() const;
|
||||
|
||||
/// Get a bidirectional iterator to one past the last element.
|
||||
/// Returns an iterator to one past the last buffer in the sequence
|
||||
const_iterator
|
||||
end() const;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** Returns a prefix of a constant buffer.
|
||||
|
||||
The returned buffer points to the same memory as the
|
||||
passed buffer, but with a size that is equal to or less
|
||||
than the size of the original buffer.
|
||||
The returned buffer points to the same memory as the passed
|
||||
buffer, but with a size that is equal to or smaller.
|
||||
|
||||
@param size The size of the returned buffer.
|
||||
@param size The maximum size of the returned buffer in bytes. If
|
||||
this is greater than or equal to the size of the passed buffer,
|
||||
the result will have the same size as the original buffer.
|
||||
|
||||
@param buffer The buffer to shorten. The underlying
|
||||
memory is not modified.
|
||||
@param buffer The buffer to return a prefix for. The
|
||||
underlying memory is not modified, and ownership of the
|
||||
memory is not transferred.
|
||||
|
||||
@return A new buffer that points to the first `size`
|
||||
bytes of the original buffer.
|
||||
@return A constant buffer that represents the prefix of
|
||||
the original buffer.
|
||||
|
||||
@par Exception Safety
|
||||
|
||||
No-throw guarantee.
|
||||
*/
|
||||
inline
|
||||
net::const_buffer
|
||||
buffers_prefix(std::size_t size,
|
||||
net::const_buffer buffer)
|
||||
net::const_buffer buffer) noexcept
|
||||
{
|
||||
return {buffer.data(),
|
||||
(std::min)(size, buffer.size())};
|
||||
return {buffer.data(), std::min<
|
||||
std::size_t>(size, buffer.size())};
|
||||
}
|
||||
|
||||
/** Returns a prefix of a mutable buffer.
|
||||
|
||||
The returned buffer points to the same memory as the
|
||||
passed buffer, but with a size that is equal to or less
|
||||
than the size of the original buffer.
|
||||
The returned buffer points to the same memory as the passed
|
||||
buffer, but with a size that is equal to or smaller.
|
||||
|
||||
@param size The size of the returned buffer.
|
||||
@param size The maximum size of the returned buffer in bytes. If
|
||||
this is greater than or equal to the size of the passed buffer,
|
||||
the result will have the same size as the original buffer.
|
||||
|
||||
@param buffer The buffer to shorten. The underlying
|
||||
memory is not modified.
|
||||
@param buffer The buffer to return a prefix for. The
|
||||
underlying memory is not modified, and ownership of the
|
||||
memory is not transferred.
|
||||
|
||||
@return A new buffer that points to the first `size` bytes
|
||||
of the original buffer.
|
||||
@return A mutable buffer that represents the prefix of
|
||||
the original buffer.
|
||||
*/
|
||||
inline
|
||||
net::mutable_buffer
|
||||
buffers_prefix(std::size_t size,
|
||||
net::mutable_buffer buffer)
|
||||
net::mutable_buffer buffer) noexcept
|
||||
{
|
||||
return {buffer.data(),
|
||||
(std::min)(size, buffer.size())};
|
||||
return {buffer.data(), std::min<
|
||||
std::size_t>(size, buffer.size())};
|
||||
}
|
||||
|
||||
/** Returns a prefix of a buffer sequence.
|
||||
/** Returns a prefix of a constant or mutable buffer sequence.
|
||||
|
||||
This function returns a new buffer sequence which when iterated,
|
||||
presents a shorter subset of the original list of buffers starting
|
||||
with the first byte of the original sequence.
|
||||
The returned buffer sequence points to the same memory as the
|
||||
passed buffer sequence, but with a size that is equal to or
|
||||
smaller. No memory allocations are performed; the resulting
|
||||
sequence is calculated as a lazy range.
|
||||
|
||||
@param size The maximum number of bytes in the wrapped
|
||||
sequence. If this is larger than the size of passed,
|
||||
buffers, the resulting sequence will represent the
|
||||
entire input sequence.
|
||||
@param size The maximum size of the returned buffer sequence
|
||||
in bytes. If this is greater than or equal to the size of
|
||||
the passed buffer sequence, the result will have the same
|
||||
size as the original buffer sequence.
|
||||
|
||||
@param buffers An instance of @b ConstBufferSequence or
|
||||
@b MutableBufferSequence to adapt. A copy of the sequence
|
||||
will be made, but ownership of the underlying memory is
|
||||
not transferred.
|
||||
@param buffers An object whose type meets the requirements
|
||||
of <em>ConstBufferSequence</em>. The returned value will
|
||||
maintain a copy of the passed buffers for its lifetime;
|
||||
however, ownership of the underlying memory is not
|
||||
transferred.
|
||||
|
||||
@return A constant buffer sequence that represents the prefix
|
||||
of the original buffer sequence. If the original buffer sequence
|
||||
also meets the requirements of <em>MutableBufferSequence</em>,
|
||||
then the returned value will also be a mutable buffer sequence.
|
||||
|
||||
@note This function does not participate in overload resolution
|
||||
if `buffers` is convertible to either `net::const_buffer` or
|
||||
`net::mutable_buffer`.
|
||||
*/
|
||||
template<class BufferSequence>
|
||||
template<class ConstBufferSequence>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
buffers_prefix_view<BufferSequence>
|
||||
buffers_prefix_view<ConstBufferSequence>
|
||||
#else
|
||||
inline
|
||||
typename std::enable_if<
|
||||
! std::is_same<BufferSequence,
|
||||
! std::is_convertible<ConstBufferSequence,
|
||||
net::const_buffer>::value &&
|
||||
! std::is_same<BufferSequence,
|
||||
! std::is_convertible<ConstBufferSequence,
|
||||
net::mutable_buffer>::value,
|
||||
buffers_prefix_view<BufferSequence>>::type
|
||||
buffers_prefix_view<ConstBufferSequence>>::type
|
||||
#endif
|
||||
buffers_prefix(std::size_t size, BufferSequence const& buffers)
|
||||
buffers_prefix(std::size_t size, ConstBufferSequence const& buffers)
|
||||
{
|
||||
static_assert(
|
||||
net::is_const_buffer_sequence<BufferSequence>::value ||
|
||||
net::is_mutable_buffer_sequence<BufferSequence>::value,
|
||||
"BufferSequence requirements not met");
|
||||
return buffers_prefix_view<BufferSequence>(size, buffers);
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value ||
|
||||
net::is_mutable_buffer_sequence<ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
return buffers_prefix_view<ConstBufferSequence>(size, buffers);
|
||||
}
|
||||
|
||||
/** Returns the first buffer in a buffer sequence
|
||||
@ -234,6 +257,6 @@ buffers_front(BufferSequence const& buffers)
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/buffers_prefix.ipp>
|
||||
#include <boost/beast/core/impl/buffers_prefix.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
/** Return a range representing a const or mutable buffer sequence.
|
||||
/** Returns an iterable range representing a buffer sequence.
|
||||
|
||||
This function returns an iterable range representing the
|
||||
passed buffer sequence. The values obtained when iterating
|
||||
@ -51,7 +51,7 @@ namespace beast {
|
||||
the lifetime of the returned range.
|
||||
|
||||
@return An object of unspecified type, meeting the requirements of
|
||||
@em ConstBufferSequence, or @em MutableBufferSequence if `buffers`
|
||||
<em>ConstBufferSequence</em>, and also @em MutableBufferSequence if `buffers`
|
||||
is a mutable buffer sequence.
|
||||
*/
|
||||
/** @{ */
|
||||
|
@ -21,12 +21,12 @@
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
/** Adapter to trim the front of a `BufferSequence`.
|
||||
/** Adaptor to progressively trim the front of a <em>BufferSequence</em>.
|
||||
|
||||
This adapter wraps a buffer sequence to create a new sequence
|
||||
This adaptor wraps a buffer sequence to create a new sequence
|
||||
which may be incrementally consumed. Bytes consumed are removed
|
||||
from the front of the buffer. The underlying memory is not changed,
|
||||
instead the adapter efficiently iterates through a subset of
|
||||
instead the adaptor efficiently iterates through a subset of
|
||||
the buffers wrapped.
|
||||
|
||||
The wrapped buffer is not modified, a copy is made instead.
|
||||
@ -104,10 +104,7 @@ public:
|
||||
/// Constructor
|
||||
buffers_suffix();
|
||||
|
||||
/// Constructor
|
||||
buffers_suffix(buffers_suffix&&);
|
||||
|
||||
/// Constructor
|
||||
/// Copy Constructor
|
||||
buffers_suffix(buffers_suffix const&);
|
||||
|
||||
/** Constructor
|
||||
@ -128,9 +125,6 @@ public:
|
||||
template<class... Args>
|
||||
buffers_suffix(boost::in_place_init_t, Args&&... args);
|
||||
|
||||
/// Assignment
|
||||
buffers_suffix& operator=(buffers_suffix&&);
|
||||
|
||||
/// Assignment
|
||||
buffers_suffix& operator=(buffers_suffix const&);
|
||||
|
||||
@ -155,6 +149,6 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/buffers_suffix.ipp>
|
||||
#include <boost/beast/core/impl/buffers_suffix.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -48,8 +48,9 @@ buffers_to_string(ConstBufferSequence const& buffers)
|
||||
net::is_const_buffer_sequence<ConstBufferSequence>::value,
|
||||
"ConstBufferSequence requirements not met");
|
||||
std::string result;
|
||||
result.reserve(net::buffer_size(buffers));
|
||||
for(auto const buffer : buffers_range(std::ref(buffers)))
|
||||
using net::buffer_size;
|
||||
result.reserve(buffer_size(buffers));
|
||||
for(auto const buffer : beast::buffers_range(std::ref(buffers)))
|
||||
result.append(static_cast<char const*>(
|
||||
buffer.data()), buffer.size());
|
||||
return result;
|
||||
|
@ -34,12 +34,12 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Rene Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BOOST_BEAST_DETAIL_BASE64_HPP
|
||||
#define BOOST_BEAST_DETAIL_BASE64_HPP
|
||||
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -55,7 +55,10 @@ char const*
|
||||
get_alphabet()
|
||||
{
|
||||
static char constexpr tab[] = {
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||
"ABCDEFGHIJKLMNOP"
|
||||
"QRSTUVWXYZabcdef"
|
||||
"ghijklmnopqrstuv"
|
||||
"wxyz0123456789+/"
|
||||
};
|
||||
return &tab[0];
|
||||
}
|
||||
@ -115,7 +118,7 @@ decoded_size(std::size_t n)
|
||||
@return The number of characters written to `out`. This
|
||||
will exclude any null termination.
|
||||
*/
|
||||
template<class = void>
|
||||
inline
|
||||
std::size_t
|
||||
encode(void* dest, void const* src, std::size_t len)
|
||||
{
|
||||
@ -166,7 +169,7 @@ encode(void* dest, void const* src, std::size_t len)
|
||||
the number of characters read from the input string,
|
||||
expressed as a pair.
|
||||
*/
|
||||
template<class = void>
|
||||
inline
|
||||
std::pair<std::size_t, std::size_t>
|
||||
decode(void* dest, char const* src, std::size_t len)
|
||||
{
|
||||
@ -213,9 +216,10 @@ decode(void* dest, char const* src, std::size_t len)
|
||||
|
||||
} // base64
|
||||
|
||||
template<class = void>
|
||||
inline
|
||||
std::string
|
||||
base64_encode (std::uint8_t const* data,
|
||||
base64_encode(
|
||||
std::uint8_t const* data,
|
||||
std::size_t len)
|
||||
{
|
||||
std::string dest;
|
||||
@ -226,7 +230,7 @@ base64_encode (std::uint8_t const* data,
|
||||
|
||||
inline
|
||||
std::string
|
||||
base64_encode(std::string const& s)
|
||||
base64_encode(string_view s)
|
||||
{
|
||||
return base64_encode (reinterpret_cast <
|
||||
std::uint8_t const*> (s.data()), s.size());
|
||||
@ -234,7 +238,7 @@ base64_encode(std::string const& s)
|
||||
|
||||
template<class = void>
|
||||
std::string
|
||||
base64_decode(std::string const& data)
|
||||
base64_decode(string_view data)
|
||||
{
|
||||
std::string dest;
|
||||
dest.resize(base64::decoded_size(data.size()));
|
||||
|
@ -11,18 +11,18 @@
|
||||
#define BOOST_BEAST_DETAIL_BIND_HANDLER_HPP
|
||||
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/detail/lean_tuple.hpp>
|
||||
#include <boost/beast/core/detail/tuple.hpp>
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/mp11/integer_sequence.hpp>
|
||||
#include <boost/is_placeholder.hpp>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
@ -31,7 +31,7 @@ namespace detail {
|
||||
template<class Handler, class... Args>
|
||||
class bind_wrapper
|
||||
{
|
||||
using args_type = detail::lean_tuple<
|
||||
using args_type = detail::tuple<
|
||||
typename std::decay<Args>::type...>;
|
||||
|
||||
Handler h_;
|
||||
@ -94,7 +94,7 @@ class bind_wrapper
|
||||
invoke(
|
||||
Handler& h,
|
||||
ArgsTuple& args,
|
||||
lean_tuple<>&&,
|
||||
tuple<>&&,
|
||||
mp11::index_sequence<S...>)
|
||||
{
|
||||
boost::ignore_unused(args);
|
||||
@ -122,9 +122,6 @@ class bind_wrapper
|
||||
public:
|
||||
using result_type = void;
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
bind_wrapper(bind_wrapper&&) = default;
|
||||
bind_wrapper(bind_wrapper const&) = default;
|
||||
|
||||
@ -137,47 +134,76 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return (net::get_associated_allocator)(h_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bind_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, bind_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class... Values>
|
||||
void
|
||||
operator()(Values&&... values)
|
||||
{
|
||||
invoke(h_, args_,
|
||||
lean_tuple<Values&&...>(
|
||||
tuple<Values&&...>(
|
||||
std::forward<Values>(values)...),
|
||||
mp11::index_sequence_for<Args...>());
|
||||
}
|
||||
|
||||
// VFALCO I don't think this should be needed,
|
||||
// please let me know if something breaks.
|
||||
/*
|
||||
template<class... Values>
|
||||
void
|
||||
operator()(Values&&... values) const
|
||||
{
|
||||
invoke(h_, args_,
|
||||
lean_tuple<Values&&...>(
|
||||
tuple<Values&&...>(
|
||||
std::forward<Values>(values)...),
|
||||
mp11::index_sequence_for<Args...>());
|
||||
}
|
||||
*/
|
||||
|
||||
//
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(
|
||||
Function&& f, bind_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, bind_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, bind_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(
|
||||
bind_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -199,9 +225,6 @@ class bind_front_wrapper<Handler>
|
||||
public:
|
||||
using result_type = void;
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
bind_front_wrapper(bind_front_wrapper&&) = default;
|
||||
bind_front_wrapper(bind_front_wrapper const&) = default;
|
||||
|
||||
@ -212,32 +235,57 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void operator()(Ts&&... ts)
|
||||
{
|
||||
h_(std::forward<Ts>(ts)...);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, bind_front_wrapper* w)
|
||||
void asio_handler_invoke(
|
||||
Function&& f, bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void operator()(Ts&&... ts)
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
h_(std::forward<Ts>(ts)...);
|
||||
using net::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(
|
||||
bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
@ -256,9 +304,6 @@ class bind_front_wrapper<Handler, Arg>
|
||||
public:
|
||||
using result_type = void;
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
bind_front_wrapper(bind_front_wrapper&&) = default;
|
||||
bind_front_wrapper(bind_front_wrapper const&) = default;
|
||||
|
||||
@ -270,33 +315,58 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void operator()(Ts&&... ts)
|
||||
{
|
||||
h_( std::forward<Arg>(arg_),
|
||||
std::forward<Ts>(ts)...);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, bind_front_wrapper* w)
|
||||
void asio_handler_invoke(
|
||||
Function&& f, bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void operator()(Ts&&... ts)
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
h_( std::forward<Arg>(arg_),
|
||||
std::forward<Ts>(ts)...);
|
||||
using net::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(
|
||||
bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
@ -316,9 +386,6 @@ class bind_front_wrapper<Handler, Arg1, Arg2>
|
||||
public:
|
||||
using result_type = void;
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
bind_front_wrapper(bind_front_wrapper&&) = default;
|
||||
bind_front_wrapper(bind_front_wrapper const&) = default;
|
||||
|
||||
@ -331,28 +398,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void operator()(Ts&&... ts)
|
||||
{
|
||||
@ -360,6 +405,53 @@ public:
|
||||
std::forward<Arg2>(arg2_),
|
||||
std::forward<Ts>(ts)...);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(
|
||||
Function&& f, bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(
|
||||
bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
// 3+ arg specialization
|
||||
@ -367,7 +459,7 @@ template<class Handler,
|
||||
class Arg1, class Arg2, class Arg3, class... Args>
|
||||
class bind_front_wrapper<Handler, Arg1, Arg2, Arg3, Args...>
|
||||
{
|
||||
using args_type = lean_tuple<
|
||||
using args_type = tuple<
|
||||
typename std::decay<Arg1>::type,
|
||||
typename std::decay<Arg2>::type,
|
||||
typename std::decay<Arg3>::type,
|
||||
@ -394,9 +486,6 @@ class bind_front_wrapper<Handler, Arg1, Arg2, Arg3, Args...>
|
||||
public:
|
||||
using result_type = void;
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
bind_front_wrapper(bind_front_wrapper&&) = default;
|
||||
bind_front_wrapper(bind_front_wrapper const&) = default;
|
||||
|
||||
@ -413,28 +502,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class... Ts>
|
||||
void operator()(Ts&&... ts)
|
||||
{
|
||||
@ -443,6 +510,53 @@ public:
|
||||
Arg1, Arg2, Arg3, Args...>{},
|
||||
std::forward<Ts>(ts)...);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(
|
||||
Function&& f, bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(
|
||||
bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -460,9 +574,6 @@ class bind_front_wrapper<
|
||||
public:
|
||||
using result_type = void;
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
bind_front_wrapper(bind_front_wrapper&&) = default;
|
||||
bind_front_wrapper(bind_front_wrapper const&) = default;
|
||||
|
||||
@ -475,39 +586,66 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
h_(ec_, n_);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
asio_handler_is_continuation(bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(std::addressof(w->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, bind_front_wrapper* w)
|
||||
void asio_handler_invoke(
|
||||
Function&& f, bind_front_wrapper* w)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(w->h_));
|
||||
}
|
||||
|
||||
void operator()()
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
h_(ec_, n_);
|
||||
using net::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(
|
||||
bind_front_wrapper* op)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
|
||||
template<class Handler, class... Args, class Executor>
|
||||
@ -545,9 +683,10 @@ struct associated_executor<
|
||||
};
|
||||
|
||||
} // asio
|
||||
|
||||
} // boost
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class Handler, class... Args>
|
||||
@ -562,4 +701,6 @@ bind(boost::beast::detail::bind_front_wrapper<
|
||||
|
||||
} // std
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
|
@ -10,11 +10,9 @@
|
||||
#ifndef BOOST_BEAST_CORE_DETAIL_CONFIG_HPP
|
||||
#define BOOST_BEAST_CORE_DETAIL_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
// Available to every header
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/version.hpp>
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
@ -69,6 +67,10 @@ namespace net = boost::asio;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define BOOST_BEAST_DECL inline
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
# define BOOST_BEAST_DECL
|
||||
#else
|
||||
# define BOOST_BEAST_DECL inline
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -12,6 +12,9 @@
|
||||
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/asio/basic_stream_socket.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
@ -431,7 +434,7 @@ read(
|
||||
void(error_code&, std::size_t, DynamicBuffer&)>::value,
|
||||
"CompletionCondition requirements not met");
|
||||
error_code ec;
|
||||
auto const bytes_transferred = read(
|
||||
auto const bytes_transferred = detail::read(
|
||||
stream, buffer, std::move(cond), ec);
|
||||
if(ec)
|
||||
BOOST_THROW_EXCEPTION(system_error{ec});
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define BOOST_BEAST_DETAIL_OSTREAM_HPP
|
||||
|
||||
#include <boost/beast/core/buffers_prefix.hpp>
|
||||
#include <boost/beast/core/buffers_range.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
|
@ -41,24 +41,22 @@ lexicographical_compare(
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
int
|
||||
lexicographical_compare(
|
||||
basic_string_view<CharT, Traits> s1,
|
||||
CharT const* s2, std::size_t n2)
|
||||
{
|
||||
return lexicographical_compare<CharT, Traits>(
|
||||
s1.data(), s1.size(), s2, n2);
|
||||
return detail::lexicographical_compare<
|
||||
CharT, Traits>(s1.data(), s1.size(), s2, n2);
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
int
|
||||
lexicographical_compare(
|
||||
basic_string_view<CharT, Traits> s1,
|
||||
basic_string_view<CharT, Traits> s2)
|
||||
{
|
||||
return lexicographical_compare<CharT, Traits>(
|
||||
return detail::lexicographical_compare<CharT, Traits>(
|
||||
s1.data(), s1.size(), s2.data(), s2.size());
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <boost/asio/async_result.hpp>
|
||||
#include <boost/asio/coroutine.hpp>
|
||||
#include <boost/asio/executor_work_guard.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_DETAIL_LEAN_TUPLE_HPP
|
||||
#define BOOST_BEAST_DETAIL_LEAN_TUPLE_HPP
|
||||
#ifndef BOOST_BEAST_DETAIL_TUPLE_HPP
|
||||
#define BOOST_BEAST_DETAIL_TUPLE_HPP
|
||||
|
||||
#include <boost/mp11/integer_sequence.hpp>
|
||||
#include <boost/mp11/algorithm.hpp>
|
||||
@ -22,33 +22,33 @@ namespace beast {
|
||||
namespace detail {
|
||||
|
||||
template<std::size_t I, class T>
|
||||
struct lean_tuple_element
|
||||
struct tuple_element_impl
|
||||
{
|
||||
T t;
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
struct lean_tuple_impl;
|
||||
struct tuple_impl;
|
||||
|
||||
template<class... Ts, std::size_t... Is>
|
||||
struct lean_tuple_impl<
|
||||
struct tuple_impl<
|
||||
boost::mp11::index_sequence<Is...>, Ts...>
|
||||
: lean_tuple_element<Is, Ts>...
|
||||
: tuple_element_impl<Is, Ts>...
|
||||
{
|
||||
template<class... Us>
|
||||
explicit lean_tuple_impl(Us&&... us)
|
||||
: lean_tuple_element<Is, Ts>{std::forward<Us>(us)}...
|
||||
explicit tuple_impl(Us&&... us)
|
||||
: tuple_element_impl<Is, Ts>{std::forward<Us>(us)}...
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<class... Ts>
|
||||
struct lean_tuple : lean_tuple_impl<
|
||||
struct tuple : tuple_impl<
|
||||
boost::mp11::index_sequence_for<Ts...>, Ts...>
|
||||
{
|
||||
template<class... Us>
|
||||
explicit lean_tuple(Us&&... us)
|
||||
: lean_tuple_impl<
|
||||
explicit tuple(Us&&... us)
|
||||
: tuple_impl<
|
||||
boost::mp11::index_sequence_for<Ts...>, Ts...>{
|
||||
std::forward<Us>(us)...}
|
||||
{
|
||||
@ -57,21 +57,21 @@ struct lean_tuple : lean_tuple_impl<
|
||||
|
||||
template<std::size_t I, class T>
|
||||
T&
|
||||
get(lean_tuple_element<I, T>& te)
|
||||
get(tuple_element_impl<I, T>& te)
|
||||
{
|
||||
return te.t;
|
||||
}
|
||||
|
||||
template<std::size_t I, class T>
|
||||
T const&
|
||||
get(lean_tuple_element<I, T> const& te)
|
||||
get(tuple_element_impl<I, T> const& te)
|
||||
{
|
||||
return te.t;
|
||||
}
|
||||
|
||||
template<std::size_t I, class T>
|
||||
T&&
|
||||
get(lean_tuple_element<I, T>&& te)
|
||||
get(tuple_element_impl<I, T>&& te)
|
||||
{
|
||||
return std::move(te.t);
|
||||
}
|
@ -15,7 +15,6 @@
|
||||
#include <boost/beast/core/file_posix.hpp>
|
||||
#include <boost/beast/core/file_stdio.hpp>
|
||||
#include <boost/beast/core/file_win32.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#ifndef BOOST_BEAST_CORE_FILE_POSIX_HPP
|
||||
#define BOOST_BEAST_CORE_FILE_POSIX_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
|
||||
#if ! defined(BOOST_BEAST_NO_POSIX_FILE)
|
||||
# if ! defined(__APPLE__) && ! defined(__linux__)
|
||||
@ -54,6 +54,7 @@ public:
|
||||
|
||||
If the file is open it is first closed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
~file_posix();
|
||||
|
||||
/** Constructor
|
||||
@ -66,12 +67,14 @@ public:
|
||||
|
||||
The moved-from object behaves as if default constructed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
file_posix(file_posix&& other);
|
||||
|
||||
/** Assignment
|
||||
|
||||
The moved-from object behaves as if default constructed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
file_posix& operator=(file_posix&& other);
|
||||
|
||||
/// Returns the native handle associated with the file.
|
||||
@ -87,6 +90,7 @@ public:
|
||||
|
||||
@param fd The native file handle to assign.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
native_handle(native_handle_type fd);
|
||||
|
||||
@ -101,6 +105,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
close(error_code& ec);
|
||||
|
||||
@ -112,6 +117,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
open(char const* path, file_mode mode, error_code& ec);
|
||||
|
||||
@ -121,6 +127,7 @@ public:
|
||||
|
||||
@return The size in bytes
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::uint64_t
|
||||
size(error_code& ec) const;
|
||||
|
||||
@ -130,6 +137,7 @@ public:
|
||||
|
||||
@return The offset in bytes from the beginning of the file
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::uint64_t
|
||||
pos(error_code& ec) const;
|
||||
|
||||
@ -139,6 +147,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
seek(std::uint64_t offset, error_code& ec);
|
||||
|
||||
@ -150,6 +159,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::size_t
|
||||
read(void* buffer, std::size_t n, error_code& ec) const;
|
||||
|
||||
@ -161,6 +171,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::size_t
|
||||
write(void const* buffer, std::size_t n, error_code& ec);
|
||||
};
|
||||
@ -168,7 +179,7 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/file_posix.ipp>
|
||||
#include <boost/beast/core/impl/file_posix.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
|
||||
If the file is open it is first closed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
~file_stdio();
|
||||
|
||||
/** Constructor
|
||||
@ -51,12 +52,14 @@ public:
|
||||
|
||||
The moved-from object behaves as if default constructed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
file_stdio(file_stdio&& other);
|
||||
|
||||
/** Assignment
|
||||
|
||||
The moved-from object behaves as if default constructed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
file_stdio& operator=(file_stdio&& other);
|
||||
|
||||
/// Returns the native handle associated with the file.
|
||||
@ -72,6 +75,7 @@ public:
|
||||
|
||||
@param f The native file handle to assign.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
native_handle(FILE* f);
|
||||
|
||||
@ -86,6 +90,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
close(error_code& ec);
|
||||
|
||||
@ -97,6 +102,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
open(char const* path, file_mode mode, error_code& ec);
|
||||
|
||||
@ -106,6 +112,7 @@ public:
|
||||
|
||||
@return The size in bytes
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::uint64_t
|
||||
size(error_code& ec) const;
|
||||
|
||||
@ -115,6 +122,7 @@ public:
|
||||
|
||||
@return The offset in bytes from the beginning of the file
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::uint64_t
|
||||
pos(error_code& ec) const;
|
||||
|
||||
@ -124,6 +132,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
seek(std::uint64_t offset, error_code& ec);
|
||||
|
||||
@ -135,6 +144,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::size_t
|
||||
read(void* buffer, std::size_t n, error_code& ec) const;
|
||||
|
||||
@ -146,6 +156,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::size_t
|
||||
write(void const* buffer, std::size_t n, error_code& ec);
|
||||
};
|
||||
@ -153,6 +164,6 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/file_stdio.ipp>
|
||||
#include <boost/beast/core/impl/file_stdio.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -10,7 +10,7 @@
|
||||
#ifndef BOOST_BEAST_CORE_FILE_WIN32_HPP
|
||||
#define BOOST_BEAST_CORE_FILE_WIN32_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/beast/core/detail/config.hpp>
|
||||
|
||||
#if ! defined(BOOST_BEAST_USE_WIN32_FILE)
|
||||
# ifdef BOOST_MSVC
|
||||
@ -56,6 +56,7 @@ public:
|
||||
|
||||
If the file is open it is first closed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
~file_win32();
|
||||
|
||||
/** Constructor
|
||||
@ -68,12 +69,14 @@ public:
|
||||
|
||||
The moved-from object behaves as if default constructed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
file_win32(file_win32&& other);
|
||||
|
||||
/** Assignment
|
||||
|
||||
The moved-from object behaves as if default constructed.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
file_win32& operator=(file_win32&& other);
|
||||
|
||||
/// Returns the native handle associated with the file.
|
||||
@ -89,6 +92,7 @@ public:
|
||||
|
||||
@param h The native file handle to assign.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
native_handle(native_handle_type h);
|
||||
|
||||
@ -103,6 +107,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred.
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
close(error_code& ec);
|
||||
|
||||
@ -114,6 +119,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
open(char const* path, file_mode mode, error_code& ec);
|
||||
|
||||
@ -123,6 +129,7 @@ public:
|
||||
|
||||
@return The size in bytes
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::uint64_t
|
||||
size(error_code& ec) const;
|
||||
|
||||
@ -132,6 +139,7 @@ public:
|
||||
|
||||
@return The offset in bytes from the beginning of the file
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::uint64_t
|
||||
pos(error_code& ec);
|
||||
|
||||
@ -141,6 +149,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
seek(std::uint64_t offset, error_code& ec);
|
||||
|
||||
@ -152,6 +161,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::size_t
|
||||
read(void* buffer, std::size_t n, error_code& ec);
|
||||
|
||||
@ -163,6 +173,7 @@ public:
|
||||
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
BOOST_BEAST_DECL
|
||||
std::size_t
|
||||
write(void const* buffer, std::size_t n, error_code& ec);
|
||||
};
|
||||
@ -170,7 +181,7 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/file_win32.ipp>
|
||||
#include <boost/beast/core/impl/file_win32.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -73,7 +73,7 @@ class basic_flat_buffer
|
||||
std::is_nothrow_default_constructible<Allocator>::value;
|
||||
|
||||
using alloc_traits =
|
||||
detail::allocator_traits<base_alloc_type>;
|
||||
beast::detail::allocator_traits<base_alloc_type>;
|
||||
|
||||
using pocma = typename
|
||||
alloc_traits::propagate_on_container_move_assignment;
|
||||
@ -516,6 +516,6 @@ using flat_buffer =
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/flat_buffer.ipp>
|
||||
#include <boost/beast/core/impl/flat_buffer.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
}
|
||||
|
||||
/// Change the number of readable and writable bytes to zero.
|
||||
inline
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
clear() noexcept;
|
||||
|
||||
@ -168,7 +168,7 @@ public:
|
||||
|
||||
Strong guarantee.
|
||||
*/
|
||||
inline
|
||||
BOOST_BEAST_DECL
|
||||
mutable_buffers_type
|
||||
prepare(std::size_t n);
|
||||
|
||||
@ -211,7 +211,7 @@ public:
|
||||
|
||||
No-throw guarantee.
|
||||
*/
|
||||
inline
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
consume(std::size_t n) noexcept;
|
||||
|
||||
@ -239,7 +239,7 @@ protected:
|
||||
|
||||
No-throw guarantee.
|
||||
*/
|
||||
inline
|
||||
BOOST_BEAST_DECL
|
||||
void
|
||||
reset(void* p, std::size_t n) noexcept;
|
||||
|
||||
@ -318,6 +318,6 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/flat_static_buffer.ipp>
|
||||
#include <boost/beast/core/impl/flat_static_buffer.hpp>
|
||||
|
||||
#endif
|
@ -118,14 +118,14 @@ public:
|
||||
|
||||
/// Return a reference to the handler
|
||||
handler_type const&
|
||||
handler() const
|
||||
handler() const noexcept
|
||||
{
|
||||
return h_;
|
||||
}
|
||||
|
||||
/// Return a reference to the handler
|
||||
handler_type&
|
||||
handler()
|
||||
handler() noexcept
|
||||
{
|
||||
return h_;
|
||||
}
|
||||
@ -165,6 +165,7 @@ public:
|
||||
T*
|
||||
operator->() const
|
||||
{
|
||||
BOOST_ASSERT(t_);
|
||||
return t_;
|
||||
}
|
||||
|
||||
@ -211,6 +212,6 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/handler_ptr.ipp>
|
||||
#include <boost/beast/core/impl/handler_ptr.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_IPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_HPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERED_READ_STREAM_HPP
|
||||
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
@ -19,6 +19,7 @@
|
||||
#include <boost/asio/associated_allocator.hpp>
|
||||
#include <boost/asio/associated_executor.hpp>
|
||||
#include <boost/asio/executor_work_guard.hpp>
|
||||
#include <boost/asio/handler_alloc_hook.hpp>
|
||||
#include <boost/asio/handler_continuation_hook.hpp>
|
||||
#include <boost/asio/handler_invoke_hook.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
@ -54,44 +55,65 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(error_code ec,
|
||||
std::size_t bytes_transferred);
|
||||
|
||||
//
|
||||
|
||||
using allocator_type =
|
||||
net::associated_allocator_t<Handler>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return (net::get_associated_allocator)(h_);
|
||||
}
|
||||
|
||||
using executor_type =
|
||||
net::associated_executor_t<Handler, decltype(
|
||||
std::declval<buffered_read_stream&>().get_executor())>;
|
||||
|
||||
allocator_type
|
||||
get_allocator() const noexcept
|
||||
{
|
||||
return net::get_associated_allocator(h_);
|
||||
}
|
||||
|
||||
executor_type
|
||||
get_executor() const noexcept
|
||||
{
|
||||
return (net::get_associated_executor)(
|
||||
return net::get_associated_executor(
|
||||
h_, s_.get_executor());
|
||||
}
|
||||
|
||||
void
|
||||
operator()(error_code const& ec,
|
||||
std::size_t bytes_transferred);
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(
|
||||
Function&& f, read_some_op* op)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_some_op* op)
|
||||
{
|
||||
using net::asio_handler_allocate;
|
||||
return asio_handler_allocate(
|
||||
size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_some_op* op)
|
||||
{
|
||||
using net::asio_handler_deallocate;
|
||||
asio_handler_deallocate(
|
||||
p, size, std::addressof(op->h_));
|
||||
}
|
||||
|
||||
friend
|
||||
bool asio_handler_is_continuation(read_some_op* op)
|
||||
{
|
||||
using net::asio_handler_is_continuation;
|
||||
return asio_handler_is_continuation(
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
|
||||
template<class Function>
|
||||
friend
|
||||
void asio_handler_invoke(Function&& f, read_some_op* op)
|
||||
{
|
||||
using net::asio_handler_invoke;
|
||||
asio_handler_invoke(f, std::addressof(op->h_));
|
||||
std::addressof(op->h_));
|
||||
}
|
||||
};
|
||||
|
||||
@ -99,8 +121,9 @@ template<class Stream, class DynamicBuffer>
|
||||
template<class MutableBufferSequence, class Handler>
|
||||
void
|
||||
buffered_read_stream<Stream, DynamicBuffer>::
|
||||
read_some_op<MutableBufferSequence, Handler>::operator()(
|
||||
error_code const& ec, std::size_t bytes_transferred)
|
||||
read_some_op<MutableBufferSequence, Handler>::
|
||||
operator()(
|
||||
error_code ec, std::size_t bytes_transferred)
|
||||
{
|
||||
switch(step_)
|
||||
{
|
||||
@ -114,19 +137,18 @@ read_some_op<MutableBufferSequence, Handler>::operator()(
|
||||
return s_.next_layer_.async_read_some(
|
||||
b_, std::move(*this));
|
||||
}
|
||||
|
||||
// read
|
||||
step_ = 2;
|
||||
return s_.next_layer_.async_read_some(
|
||||
s_.buffer_.prepare(read_size(
|
||||
s_.buffer_, s_.capacity_)),
|
||||
std::move(*this));
|
||||
|
||||
}
|
||||
step_ = 3;
|
||||
return net::post(
|
||||
s_.get_executor(),
|
||||
beast::bind_front_handler(std::move(*this), ec, 0));
|
||||
beast::bind_front_handler(
|
||||
std::move(*this), ec, 0));
|
||||
|
||||
case 1:
|
||||
// upcall
|
||||
@ -221,7 +243,7 @@ read_some(MutableBufferSequence const& buffers,
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
auto bytes_transferred =
|
||||
buffer_copy(buffers, buffer_.data());
|
@ -308,7 +308,6 @@ private:
|
||||
};
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
inline
|
||||
auto
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
mutable_buffers_type::
|
||||
@ -319,7 +318,6 @@ begin() const ->
|
||||
}
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
inline
|
||||
auto
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
mutable_buffers_type::
|
||||
@ -479,19 +477,27 @@ prepare(std::size_t n) ->
|
||||
return mutable_buffers_type{*this};
|
||||
}
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
auto
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
data() const noexcept ->
|
||||
const_buffers_type
|
||||
{
|
||||
return const_buffers_type{*this};
|
||||
}
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
void
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
commit(std::size_t n)
|
||||
commit(std::size_t n) noexcept
|
||||
{
|
||||
using net::buffer_size;
|
||||
if(out_ == end_)
|
||||
return;
|
||||
auto const last = std::prev(end_);
|
||||
while(out_ != last)
|
||||
{
|
||||
auto const avail =
|
||||
buffer_size(*out_) - out_pos_;
|
||||
net::buffer_size(*out_) - out_pos_;
|
||||
if(n < avail)
|
||||
{
|
||||
out_pos_ += n;
|
||||
@ -504,10 +510,11 @@ commit(std::size_t n)
|
||||
in_size_ += avail;
|
||||
}
|
||||
|
||||
n = (std::min)(n, out_end_ - out_pos_);
|
||||
n = std::min<std::size_t>(
|
||||
n, out_end_ - out_pos_);
|
||||
out_pos_ += n;
|
||||
in_size_ += n;
|
||||
if(out_pos_ == buffer_size(*out_))
|
||||
if(out_pos_ == net::buffer_size(*out_))
|
||||
{
|
||||
++out_;
|
||||
out_pos_ = 0;
|
||||
@ -515,26 +522,15 @@ commit(std::size_t n)
|
||||
}
|
||||
}
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
inline
|
||||
auto
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
data() const ->
|
||||
const_buffers_type
|
||||
{
|
||||
return const_buffers_type{*this};
|
||||
}
|
||||
|
||||
template<class MutableBufferSequence>
|
||||
void
|
||||
buffers_adapter<MutableBufferSequence>::
|
||||
consume(std::size_t n)
|
||||
consume(std::size_t n) noexcept
|
||||
{
|
||||
using net::buffer_size;
|
||||
while(begin_ != out_)
|
||||
{
|
||||
auto const avail =
|
||||
buffer_size(*begin_) - in_pos_;
|
||||
net::buffer_size(*begin_) - in_pos_;
|
||||
if(n < avail)
|
||||
{
|
||||
in_size_ -= n;
|
@ -7,10 +7,10 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_CAT_IPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERS_CAT_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_CAT_HPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERS_CAT_HPP
|
||||
|
||||
#include <boost/beast/core/detail/lean_tuple.hpp>
|
||||
#include <boost/beast/core/detail/tuple.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/variant.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
@ -57,7 +57,7 @@ class buffers_cat_view<Bn...>::const_iterator
|
||||
static_assert(sizeof...(Bn) >= 2,
|
||||
"A minimum of two sequences are required");
|
||||
|
||||
detail::lean_tuple<Bn...> const* bn_ = nullptr;
|
||||
detail::tuple<Bn...> const* bn_ = nullptr;
|
||||
detail::variant<typename
|
||||
detail::buffer_sequence_iterator<Bn>::type...,
|
||||
past_end> it_;
|
||||
@ -113,7 +113,7 @@ public:
|
||||
|
||||
private:
|
||||
const_iterator(
|
||||
detail::lean_tuple<Bn...> const& bn, bool at_end);
|
||||
detail::tuple<Bn...> const& bn, bool at_end);
|
||||
|
||||
template<std::size_t I>
|
||||
void
|
||||
@ -260,7 +260,7 @@ template<class... Bn>
|
||||
buffers_cat_view<Bn...>::
|
||||
const_iterator::
|
||||
const_iterator(
|
||||
detail::lean_tuple<Bn...> const& bn, bool at_end)
|
||||
detail::tuple<Bn...> const& bn, bool at_end)
|
||||
: bn_(&bn)
|
||||
{
|
||||
if(! at_end)
|
||||
@ -375,7 +375,7 @@ buffers_cat_view<Bn...>::begin() const ->
|
||||
template<class... Bn>
|
||||
inline
|
||||
auto
|
||||
buffers_cat_view<Bn...>::end() const ->
|
||||
buffers_cat_view<Bn...>::end() const->
|
||||
const_iterator
|
||||
{
|
||||
return const_iterator{bn_, true};
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_IPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
||||
#define BOOST_BEAST_IMPL_BUFFERS_SUFFIX_HPP
|
||||
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
@ -135,16 +135,6 @@ buffers_suffix()
|
||||
{
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
buffers_suffix<Buffers>::
|
||||
buffers_suffix(buffers_suffix&& other)
|
||||
: buffers_suffix(std::move(other),
|
||||
std::distance<iter_type>(
|
||||
net::buffer_sequence_begin(
|
||||
other.bs_), other.begin_))
|
||||
{
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
buffers_suffix<Buffers>::
|
||||
buffers_suffix(buffers_suffix const& other)
|
||||
@ -181,23 +171,6 @@ buffers_suffix(boost::in_place_init_t, Args&&... args)
|
||||
"Buffers not constructible from arguments");
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
auto
|
||||
buffers_suffix<Buffers>::
|
||||
operator=(buffers_suffix&& other) ->
|
||||
buffers_suffix&
|
||||
{
|
||||
auto const dist = std::distance<iter_type>(
|
||||
net::buffer_sequence_begin(other.bs_),
|
||||
other.begin_);
|
||||
bs_ = std::move(other.bs_);
|
||||
begin_ = std::next(
|
||||
net::buffer_sequence_begin(bs_),
|
||||
dist);
|
||||
skip_ = other.skip_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
auto
|
||||
buffers_suffix<Buffers>::
|
||||
@ -215,7 +188,6 @@ operator=(buffers_suffix const& other) ->
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
inline
|
||||
auto
|
||||
buffers_suffix<Buffers>::
|
||||
begin() const ->
|
||||
@ -225,7 +197,6 @@ begin() const ->
|
||||
}
|
||||
|
||||
template<class Buffers>
|
||||
inline
|
||||
auto
|
||||
buffers_suffix<Buffers>::
|
||||
end() const ->
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_POSIX_IPP
|
||||
#define BOOST_BEAST_CORE_IMPL_FILE_POSIX_IPP
|
||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_POSIX_HPP
|
||||
#define BOOST_BEAST_CORE_IMPL_FILE_POSIX_HPP
|
||||
|
||||
#if ! defined(BOOST_BEAST_NO_POSIX_FADVISE)
|
||||
# if defined(__APPLE__) || (defined(ANDROID) && (__ANDROID_API__ < 21))
|
||||
@ -55,7 +55,6 @@ file_posix_close(int fd)
|
||||
|
||||
} // detail
|
||||
|
||||
inline
|
||||
file_posix::
|
||||
~file_posix()
|
||||
{
|
||||
@ -63,14 +62,12 @@ file_posix::
|
||||
detail::file_posix_close(fd_);
|
||||
}
|
||||
|
||||
inline
|
||||
file_posix::
|
||||
file_posix(file_posix&& other)
|
||||
: fd_(boost::exchange(other.fd_, -1))
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
file_posix&
|
||||
file_posix::
|
||||
operator=(file_posix&& other)
|
||||
@ -84,7 +81,6 @@ operator=(file_posix&& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_posix::
|
||||
native_handle(native_handle_type fd)
|
||||
@ -94,7 +90,6 @@ native_handle(native_handle_type fd)
|
||||
fd_ = fd;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_posix::
|
||||
close(error_code& ec)
|
||||
@ -104,18 +99,17 @@ close(error_code& ec)
|
||||
auto const ev =
|
||||
detail::file_posix_close(fd_);
|
||||
if(ev)
|
||||
ec.assign(ev, generic_category());
|
||||
ec.assign(ev, system_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
fd_ = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_posix::
|
||||
open(char const* path, file_mode mode, error_code& ec)
|
||||
@ -125,9 +119,9 @@ open(char const* path, file_mode mode, error_code& ec)
|
||||
auto const ev =
|
||||
detail::file_posix_close(fd_);
|
||||
if(ev)
|
||||
ec.assign(ev, generic_category());
|
||||
ec.assign(ev, system_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
fd_ = -1;
|
||||
}
|
||||
int f = 0;
|
||||
@ -200,7 +194,7 @@ open(char const* path, file_mode mode, error_code& ec)
|
||||
auto const ev = errno;
|
||||
if(ev != EINTR)
|
||||
{
|
||||
ec.assign(ev, generic_category());
|
||||
ec.assign(ev, system_category());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -210,14 +204,13 @@ open(char const* path, file_mode mode, error_code& ec)
|
||||
auto const ev = errno;
|
||||
detail::file_posix_close(fd_);
|
||||
fd_ = -1;
|
||||
ec.assign(ev, generic_category());
|
||||
ec.assign(ev, system_category());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint64_t
|
||||
file_posix::
|
||||
size(error_code& ec) const
|
||||
@ -230,14 +223,13 @@ size(error_code& ec) const
|
||||
struct stat st;
|
||||
if(::fstat(fd_, &st) != 0)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return 0;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint64_t
|
||||
file_posix::
|
||||
pos(error_code& ec) const
|
||||
@ -250,14 +242,13 @@ pos(error_code& ec) const
|
||||
auto const result = ::lseek(fd_, 0, SEEK_CUR);
|
||||
if(result == (off_t)-1)
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return 0;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_posix::
|
||||
seek(std::uint64_t offset, error_code& ec)
|
||||
@ -270,13 +261,12 @@ seek(std::uint64_t offset, error_code& ec)
|
||||
auto const result = ::lseek(fd_, offset, SEEK_SET);
|
||||
if(result == static_cast<off_t>(-1))
|
||||
{
|
||||
ec.assign(errno, generic_category());
|
||||
ec.assign(errno, system_category());
|
||||
return;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
file_posix::
|
||||
read(void* buffer, std::size_t n, error_code& ec) const
|
||||
@ -297,7 +287,7 @@ read(void* buffer, std::size_t n, error_code& ec) const
|
||||
auto const ev = errno;
|
||||
if(ev == EINTR)
|
||||
continue;
|
||||
ec.assign(ev, generic_category());
|
||||
ec.assign(ev, system_category());
|
||||
return nread;
|
||||
}
|
||||
if(result == 0)
|
||||
@ -312,7 +302,6 @@ read(void* buffer, std::size_t n, error_code& ec) const
|
||||
return nread;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
file_posix::
|
||||
write(void const* buffer, std::size_t n, error_code& ec)
|
||||
@ -333,7 +322,7 @@ write(void const* buffer, std::size_t n, error_code& ec)
|
||||
auto const ev = errno;
|
||||
if(ev == EINTR)
|
||||
continue;
|
||||
ec.assign(ev, generic_category());
|
||||
ec.assign(ev, system_category());
|
||||
return nwritten;
|
||||
}
|
||||
n -= result;
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP
|
||||
#define BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP
|
||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_STDIO_HPP
|
||||
#define BOOST_BEAST_CORE_IMPL_FILE_STDIO_HPP
|
||||
|
||||
#include <boost/core/exchange.hpp>
|
||||
#include <limits>
|
||||
@ -16,7 +16,6 @@
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
inline
|
||||
file_stdio::
|
||||
~file_stdio()
|
||||
{
|
||||
@ -24,14 +23,12 @@ file_stdio::
|
||||
fclose(f_);
|
||||
}
|
||||
|
||||
inline
|
||||
file_stdio::
|
||||
file_stdio(file_stdio&& other)
|
||||
: f_(boost::exchange(other.f_, nullptr))
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
file_stdio&
|
||||
file_stdio::
|
||||
operator=(file_stdio&& other)
|
||||
@ -45,7 +42,6 @@ operator=(file_stdio&& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_stdio::
|
||||
native_handle(FILE* f)
|
||||
@ -55,7 +51,6 @@ native_handle(FILE* f)
|
||||
f_ = f;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_stdio::
|
||||
close(error_code& ec)
|
||||
@ -70,10 +65,9 @@ close(error_code& ec)
|
||||
return;
|
||||
}
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_stdio::
|
||||
open(char const* path, file_mode mode, error_code& ec)
|
||||
@ -112,10 +106,9 @@ open(char const* path, file_mode mode, error_code& ec)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint64_t
|
||||
file_stdio::
|
||||
size(error_code& ec) const
|
||||
@ -148,11 +141,10 @@ size(error_code& ec) const
|
||||
if(result != 0)
|
||||
ec.assign(errno, generic_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return size;
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint64_t
|
||||
file_stdio::
|
||||
pos(error_code& ec) const
|
||||
@ -168,11 +160,10 @@ pos(error_code& ec) const
|
||||
ec.assign(errno, generic_category());
|
||||
return 0;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return pos;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_stdio::
|
||||
seek(std::uint64_t offset, error_code& ec)
|
||||
@ -192,10 +183,9 @@ seek(std::uint64_t offset, error_code& ec)
|
||||
if(result != 0)
|
||||
ec.assign(errno, generic_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
file_stdio::
|
||||
read(void* buffer, std::size_t n, error_code& ec) const
|
||||
@ -214,7 +204,6 @@ read(void* buffer, std::size_t n, error_code& ec) const
|
||||
return nread;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
file_stdio::
|
||||
write(void const* buffer, std::size_t n, error_code& ec)
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
||||
#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_HPP
|
||||
#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_HPP
|
||||
|
||||
#include <boost/core/exchange.hpp>
|
||||
#include <boost/winapi/access_rights.hpp>
|
||||
@ -51,7 +51,6 @@ set_file_pointer_ex(
|
||||
|
||||
} // detail
|
||||
|
||||
inline
|
||||
file_win32::
|
||||
~file_win32()
|
||||
{
|
||||
@ -59,14 +58,13 @@ file_win32::
|
||||
boost::winapi::CloseHandle(h_);
|
||||
}
|
||||
|
||||
inline
|
||||
file_win32::
|
||||
file_win32(file_win32&& other)
|
||||
: h_(boost::exchange(other.h_, boost::winapi::INVALID_HANDLE_VALUE_))
|
||||
: h_(boost::exchange(other.h_,
|
||||
boost::winapi::INVALID_HANDLE_VALUE_))
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
file_win32&
|
||||
file_win32::
|
||||
operator=(file_win32&& other)
|
||||
@ -80,7 +78,6 @@ operator=(file_win32&& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_win32::
|
||||
native_handle(native_handle_type h)
|
||||
@ -90,7 +87,6 @@ native_handle(native_handle_type h)
|
||||
h_ = h;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_win32::
|
||||
close(error_code& ec)
|
||||
@ -101,16 +97,15 @@ close(error_code& ec)
|
||||
ec.assign(boost::winapi::GetLastError(),
|
||||
system_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
h_ = boost::winapi::INVALID_HANDLE_VALUE_;
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_win32::
|
||||
open(char const* path, file_mode mode, error_code& ec)
|
||||
@ -206,10 +201,9 @@ open(char const* path, file_mode mode, error_code& ec)
|
||||
ec.assign(boost::winapi::GetLastError(),
|
||||
system_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint64_t
|
||||
file_win32::
|
||||
size(error_code& ec) const
|
||||
@ -226,11 +220,10 @@ size(error_code& ec) const
|
||||
system_category());
|
||||
return 0;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return fileSize.QuadPart;
|
||||
}
|
||||
|
||||
inline
|
||||
std::uint64_t
|
||||
file_win32::
|
||||
pos(error_code& ec)
|
||||
@ -250,11 +243,10 @@ pos(error_code& ec)
|
||||
system_category());
|
||||
return 0;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return out.QuadPart;
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
file_win32::
|
||||
seek(std::uint64_t offset, error_code& ec)
|
||||
@ -273,10 +265,9 @@ seek(std::uint64_t offset, error_code& ec)
|
||||
system_category());
|
||||
return;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
file_win32::
|
||||
read(void* buffer, std::size_t n, error_code& ec)
|
||||
@ -304,7 +295,7 @@ read(void* buffer, std::size_t n, error_code& ec)
|
||||
if(dwError != boost::winapi::ERROR_HANDLE_EOF_)
|
||||
ec.assign(dwError, system_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return nread;
|
||||
}
|
||||
if(bytesRead == 0)
|
||||
@ -313,11 +304,10 @@ read(void* buffer, std::size_t n, error_code& ec)
|
||||
nread += bytesRead;
|
||||
buffer = static_cast<char*>(buffer) + bytesRead;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return nread;
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
file_win32::
|
||||
write(void const* buffer, std::size_t n, error_code& ec)
|
||||
@ -345,7 +335,7 @@ write(void const* buffer, std::size_t n, error_code& ec)
|
||||
if(dwError != boost::winapi::ERROR_HANDLE_EOF_)
|
||||
ec.assign(dwError, system_category());
|
||||
else
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return nwritten;
|
||||
}
|
||||
if(bytesWritten == 0)
|
||||
@ -354,7 +344,7 @@ write(void const* buffer, std::size_t n, error_code& ec)
|
||||
nwritten += bytesWritten;
|
||||
buffer = static_cast<char const*>(buffer) + bytesWritten;
|
||||
}
|
||||
ec.assign(0, ec.category());
|
||||
ec = {};
|
||||
return nwritten;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_IPP
|
||||
#define BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_HPP
|
||||
#define BOOST_BEAST_IMPL_FLAT_STATIC_BUFFER_HPP
|
||||
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
@ -22,15 +22,15 @@ void
|
||||
handler_ptr<T, Handler>::
|
||||
clear()
|
||||
{
|
||||
typename beast::detail::allocator_traits<
|
||||
using A = typename detail::allocator_traits<
|
||||
net::associated_allocator_t<
|
||||
Handler>>::template rebind_alloc<T> alloc(
|
||||
net::get_associated_allocator(
|
||||
handler()));
|
||||
beast::detail::allocator_traits<
|
||||
decltype(alloc)>::destroy(alloc, t_);
|
||||
beast::detail::allocator_traits<
|
||||
decltype(alloc)>::deallocate(alloc, t_, 1);
|
||||
Handler>>::template rebind_alloc<T>;
|
||||
using alloc_traits =
|
||||
beast::detail::allocator_traits<A>;
|
||||
A alloc(
|
||||
net::get_associated_allocator(handler()));
|
||||
alloc_traits::destroy(alloc, t_);
|
||||
alloc_traits::deallocate(alloc, t_, 1);
|
||||
t_ = nullptr;
|
||||
}
|
||||
|
||||
@ -65,22 +65,22 @@ handler_ptr<T, Handler>::
|
||||
handler_ptr(DeducedHandler&& h, Args&&... args)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(! std::is_array<T>::value);
|
||||
using A = typename beast::detail::allocator_traits<
|
||||
using A = typename detail::allocator_traits<
|
||||
net::associated_allocator_t<
|
||||
Handler>>::template rebind_alloc<T>;
|
||||
using alloc_traits =
|
||||
beast::detail::allocator_traits<A>;
|
||||
A alloc{net::get_associated_allocator(h)};
|
||||
using traits =
|
||||
typename beast::detail::allocator_traits<A>;
|
||||
bool destroy = false;
|
||||
auto deleter = [&alloc, &destroy](T* p)
|
||||
{
|
||||
if(destroy)
|
||||
traits::destroy(alloc, p);
|
||||
traits::deallocate(alloc, p, 1);
|
||||
alloc_traits::destroy(alloc, p);
|
||||
alloc_traits::deallocate(alloc, p, 1);
|
||||
};
|
||||
std::unique_ptr<T, decltype(deleter)> t{
|
||||
traits::allocate(alloc, 1), deleter};
|
||||
traits::construct(alloc, t.get(),
|
||||
alloc_traits::allocate(alloc, 1), deleter};
|
||||
alloc_traits::construct(alloc, t.get(),
|
||||
static_cast<DeducedHandler const&>(h),
|
||||
std::forward<Args>(args)...);
|
||||
destroy = true;
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_MULTI_BUFFER_IPP
|
||||
#define BOOST_BEAST_IMPL_MULTI_BUFFER_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
||||
#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
||||
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/core/exchange.hpp>
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_READ_SIZE_IPP
|
||||
#define BOOST_BEAST_IMPL_READ_SIZE_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_READ_SIZE_HPP
|
||||
#define BOOST_BEAST_IMPL_READ_SIZE_HPP
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <stdexcept>
|
||||
@ -49,15 +49,14 @@ read_size(DynamicBuffer& buffer,
|
||||
auto const size = buffer.size();
|
||||
auto const limit = buffer.max_size() - size;
|
||||
BOOST_ASSERT(size <= buffer.max_size());
|
||||
return (std::min<std::size_t>)(
|
||||
(std::max<std::size_t>)(512, buffer.capacity() - size),
|
||||
(std::min<std::size_t>)(max_size, limit));
|
||||
return std::min<std::size_t>(
|
||||
std::max<std::size_t>(512, buffer.capacity() - size),
|
||||
std::min<std::size_t>(max_size, limit));
|
||||
}
|
||||
|
||||
} // detail
|
||||
|
||||
template<class DynamicBuffer>
|
||||
inline
|
||||
std::size_t
|
||||
read_size(
|
||||
DynamicBuffer& buffer, std::size_t max_size)
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_STATIC_BUFFER_IPP
|
||||
#define BOOST_BEAST_IMPL_STATIC_BUFFER_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_STATIC_BUFFER_HPP
|
||||
#define BOOST_BEAST_IMPL_STATIC_BUFFER_HPP
|
||||
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_STATIC_STRING_IPP
|
||||
#define BOOST_BEAST_IMPL_STATIC_STRING_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_STATIC_STRING_HPP
|
||||
#define BOOST_BEAST_IMPL_STATIC_STRING_HPP
|
||||
|
||||
#include <boost/beast/core/detail/static_string.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
@ -65,7 +65,12 @@ template<std::size_t N, class CharT, class Traits>
|
||||
static_string<N, CharT, Traits>::
|
||||
static_string(CharT const* s)
|
||||
{
|
||||
assign(s);
|
||||
auto const count = Traits::length(s);
|
||||
if(count > max_size())
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"count > max_size()"});
|
||||
n_ = count;
|
||||
Traits::copy(&s_[0], s, n_ + 1);
|
||||
}
|
||||
|
||||
template<std::size_t N, class CharT, class Traits>
|
||||
@ -117,6 +122,21 @@ static_string(T const& t, size_type pos, size_type n)
|
||||
// (assignment)
|
||||
//
|
||||
|
||||
template<std::size_t N, class CharT, class Traits>
|
||||
auto
|
||||
static_string<N, CharT, Traits>::
|
||||
operator=(CharT const* s) ->
|
||||
static_string&
|
||||
{
|
||||
auto const count = Traits::length(s);
|
||||
if(count > max_size())
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"count > max_size()"});
|
||||
n_ = count;
|
||||
Traits::copy(&s_[0], s, n_ + 1);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<std::size_t N, class CharT, class Traits>
|
||||
auto
|
||||
static_string<N, CharT, Traits>::
|
||||
@ -465,6 +485,8 @@ resize(std::size_t n)
|
||||
if(n > max_size())
|
||||
BOOST_THROW_EXCEPTION(std::length_error{
|
||||
"n > max_size()"});
|
||||
if(n > n_)
|
||||
Traits::assign(&s_[n_], n - n_, CharT{});
|
||||
n_ = n;
|
||||
term();
|
||||
}
|
@ -7,8 +7,8 @@
|
||||
// Official repository: https://github.com/boostorg/beast
|
||||
//
|
||||
|
||||
#ifndef BOOST_BEAST_IMPL_STRING_PARAM_IPP
|
||||
#define BOOST_BEAST_IMPL_STRING_PARAM_IPP
|
||||
#ifndef BOOST_BEAST_IMPL_STRING_PARAM_HPP
|
||||
#define BOOST_BEAST_IMPL_STRING_PARAM_HPP
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
@ -82,7 +82,8 @@ class basic_multi_buffer
|
||||
template<bool IsMutable>
|
||||
class readable_bytes;
|
||||
|
||||
using alloc_traits = detail::allocator_traits<base_alloc_type>;
|
||||
using alloc_traits =
|
||||
beast::detail::allocator_traits<base_alloc_type>;
|
||||
using list_type = typename boost::intrusive::make_list<element,
|
||||
boost::intrusive::constant_time_size<true>>::type;
|
||||
using iter = typename list_type::iterator;
|
||||
@ -540,6 +541,6 @@ using multi_buffer = basic_multi_buffer<std::allocator<char>>;
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/multi_buffer.ipp>
|
||||
#include <boost/beast/core/impl/multi_buffer.hpp>
|
||||
|
||||
#endif
|
@ -59,6 +59,6 @@ read_size_or_throw(DynamicBuffer& buffer,
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/read_size.ipp>
|
||||
#include <boost/beast/core/impl/read_size.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -305,6 +305,6 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/static_buffer.ipp>
|
||||
#include <boost/beast/core/impl/static_buffer.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -171,10 +171,7 @@ public:
|
||||
|
||||
/// Assign from null-terminated string.
|
||||
static_string&
|
||||
operator=(CharT const* s)
|
||||
{
|
||||
return assign(s);
|
||||
}
|
||||
operator=(CharT const* s);
|
||||
|
||||
/// Assign from single character.
|
||||
static_string&
|
||||
@ -1107,6 +1104,6 @@ to_static_string(Integer x);
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/static_string.ipp>
|
||||
#include <boost/beast/core/impl/static_string.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -64,25 +64,25 @@ iequals(
|
||||
auto p1 = lhs.data();
|
||||
auto p2 = rhs.data();
|
||||
char a, b;
|
||||
// fast loop
|
||||
while(n--)
|
||||
{
|
||||
a = *p1++;
|
||||
b = *p2++;
|
||||
if(a != b)
|
||||
{
|
||||
// slow loop
|
||||
do
|
||||
{
|
||||
if(ascii_tolower(a) != ascii_tolower(b))
|
||||
return false;
|
||||
a = *p1++;
|
||||
b = *p2++;
|
||||
}
|
||||
while(n--);
|
||||
return true;
|
||||
}
|
||||
goto slow;
|
||||
}
|
||||
return true;
|
||||
slow:
|
||||
do
|
||||
{
|
||||
if(ascii_tolower(a) != ascii_tolower(b))
|
||||
return false;
|
||||
a = *p1++;
|
||||
b = *p2++;
|
||||
}
|
||||
while(n--);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // detail
|
||||
|
@ -125,6 +125,6 @@ public:
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#include <boost/beast/core/impl/string_param.ipp>
|
||||
#include <boost/beast/core/impl/string_param.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -46,9 +46,9 @@ add_executable (tests-beast-core
|
||||
string_param.cpp
|
||||
type_traits.cpp
|
||||
detail_read.cpp
|
||||
detail_tuple.cpp
|
||||
detail/base64.cpp
|
||||
detail/clamp.cpp
|
||||
detail/lean_tuple.cpp
|
||||
detail/sha1.cpp
|
||||
detail/variant.cpp
|
||||
detail/varint.cpp
|
||||
|
@ -36,9 +36,9 @@ local SOURCES =
|
||||
string_param.cpp
|
||||
type_traits.cpp
|
||||
detail_read.cpp
|
||||
detail_tuple.cpp
|
||||
detail/base64.cpp
|
||||
detail/clamp.cpp
|
||||
detail/lean_tuple.cpp
|
||||
detail/sha1.cpp
|
||||
detail/variant.cpp
|
||||
detail/varint.cpp
|
||||
|
@ -8,7 +8,7 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <boost/beast/core/detail/lean_tuple.hpp>
|
||||
#include <boost/beast/core/detail/tuple.hpp>
|
||||
|
||||
#include <boost/beast/_experimental/unit_test/suite.hpp>
|
||||
|
||||
@ -16,7 +16,7 @@ namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
class lean_tuple_test : public beast::unit_test::suite
|
||||
class tuple_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
void
|
||||
@ -37,17 +37,17 @@ public:
|
||||
int i_;
|
||||
};
|
||||
|
||||
lean_tuple<explicit_constructible, int> t{nullptr, 42};
|
||||
tuple<explicit_constructible, int> t{nullptr, 42};
|
||||
BEAST_EXPECT(detail::get<1>(t) == 42);
|
||||
BEAST_EXPECT(detail::get<0>(t).i_ == 0);
|
||||
|
||||
t = lean_tuple<explicit_constructible, int>{explicit_constructible(42), 43};
|
||||
t = tuple<explicit_constructible, int>{explicit_constructible(42), 43};
|
||||
BEAST_EXPECT(detail::get<1>(t) == 43);
|
||||
BEAST_EXPECT(detail::get<0>(t).i_ == 42);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,lean_tuple);
|
||||
BEAST_DEFINE_TESTSUITE(beast,core,tuple);
|
||||
|
||||
} // detail
|
||||
} // beast
|
Reference in New Issue
Block a user