update boost

This commit is contained in:
2023-11-24 12:56:13 -06:00
parent cfc99971af
commit 19d727037a
9260 changed files with 849256 additions and 299957 deletions

View File

@@ -12,7 +12,6 @@
#include <boost/beast/core/string.hpp>
#include <cctype>
#include <string>
#include <utility>
namespace boost {
@@ -78,26 +77,6 @@ decode(void* dest, char const* src, std::size_t len);
} // base64
BOOST_BEAST_DECL
std::string
base64_encode(std::uint8_t const* data, std::size_t len);
BOOST_BEAST_DECL
std::string
base64_encode(string_view s);
template<class = void>
std::string
base64_decode(string_view data)
{
std::string dest;
dest.resize(base64::decoded_size(data.size()));
auto const result = base64::decode(
&dest[0], data.data(), data.size());
dest.resize(result.first);
return dest;
}
} // detail
} // beast
} // boost

View File

@@ -154,7 +154,7 @@ decode(void* dest, char const* src, std::size_t len)
{
char* out = static_cast<char*>(dest);
auto in = reinterpret_cast<unsigned char const*>(src);
unsigned char c3[3], c4[4];
unsigned char c3[3], c4[4] = {0,0,0,0};
int i = 0;
int j = 0;
@@ -195,24 +195,6 @@ decode(void* dest, char const* src, std::size_t len)
} // base64
std::string
base64_encode(
std::uint8_t const* data,
std::size_t len)
{
std::string dest;
dest.resize(base64::encoded_size(len));
dest.resize(base64::encode(&dest[0], data, len));
return dest;
}
std::string
base64_encode(string_view s)
{
return base64_encode (reinterpret_cast <
std::uint8_t const*> (s.data()), s.size());
}
} // detail
} // beast
} // boost

View File

@@ -67,30 +67,38 @@ public:
h_, this->get());
}
template<class Function>
void
asio_handler_invoke(Function&& f,
bind_default_executor_wrapper* p)
using cancellation_slot_type =
net::associated_cancellation_slot_t<Handler>;
cancellation_slot_type
get_cancellation_slot() const noexcept
{
net::dispatch(p->get_executor(), std::move(f));
return net::get_associated_cancellation_slot(h_,
net::cancellation_slot());
}
// The allocation hooks are still defined because they trivially forward to
// user hooks. Forward here ensures that the user will get a compile error
// if they build their code with BOOST_ASIO_NO_DEPRECATED.
friend
void* asio_handler_allocate(
boost::asio::asio_handler_allocate_is_deprecated
asio_handler_allocate(
std::size_t size, bind_default_executor_wrapper* p)
{
using net::asio_handler_allocate;
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(p->h_));
}
friend
void asio_handler_deallocate(
boost::asio::asio_handler_deallocate_is_deprecated
asio_handler_deallocate(
void* mem, std::size_t size,
bind_default_executor_wrapper* p)
{
using net::asio_handler_deallocate;
asio_handler_deallocate(mem, size,
using boost::asio::asio_handler_deallocate;
return asio_handler_deallocate(mem, size,
std::addressof(p->h_));
}
@@ -98,7 +106,7 @@ public:
bool asio_handler_is_continuation(
bind_default_executor_wrapper* p)
{
using net::asio_handler_is_continuation;
using boost::asio::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(p->h_));
}

View File

@@ -13,12 +13,14 @@
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/detail/tuple.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_cancellation_slot.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/bind/std_placeholders.hpp>
#include <boost/is_placeholder.hpp>
#include <functional>
#include <type_traits>
@@ -48,6 +50,9 @@ class bind_wrapper
template<class T, class Allocator>
friend struct net::associated_allocator;
template<class T, class CancellationSlot>
friend struct net::associated_cancellation_slot;
template<class Arg, class Vals>
static
typename std::enable_if<
@@ -81,7 +86,9 @@ class bind_wrapper
static
typename std::enable_if<
boost::is_placeholder<typename
std::decay<Arg>::type>::value != 0,
std::decay<Arg>::type>::value != 0 &&
std::is_placeholder<typename
std::decay<Arg>::type>::value == 0,
tuple_element<boost::is_placeholder<
typename std::decay<Arg>::type>::value - 1,
Vals>>::type&&
@@ -155,37 +162,40 @@ public:
template<class Function>
friend
void asio_handler_invoke(
boost::asio::asio_handler_invoke_is_deprecated
asio_handler_invoke(
Function&& f, bind_wrapper* op)
{
using net::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->h_));
using boost::asio::asio_handler_invoke;
return asio_handler_invoke(f, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(
bind_wrapper* op)
{
using net::asio_handler_is_continuation;
using boost::asio::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
}
friend
void* asio_handler_allocate(
boost::asio::asio_handler_allocate_is_deprecated
asio_handler_allocate(
std::size_t size, bind_wrapper* op)
{
using net::asio_handler_allocate;
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
boost::asio::asio_handler_deallocate_is_deprecated
asio_handler_deallocate(
void* p, std::size_t size, bind_wrapper* op)
{
using net::asio_handler_deallocate;
asio_handler_deallocate(
using boost::asio::asio_handler_deallocate;
return asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
};
@@ -214,6 +224,10 @@ class bind_front_wrapper
template<class T, class Allocator>
friend struct net::associated_allocator;
template<class T, class CancellationSlot>
friend struct net::associated_cancellation_slot;
template<std::size_t... I, class... Ts>
void
invoke(
@@ -265,37 +279,40 @@ public:
template<class Function>
friend
void asio_handler_invoke(
boost::asio::asio_handler_invoke_is_deprecated
asio_handler_invoke(
Function&& f, bind_front_wrapper* op)
{
using net::asio_handler_invoke;
asio_handler_invoke(f, std::addressof(op->h_));
using boost::asio::asio_handler_invoke;
return asio_handler_invoke(f, std::addressof(op->h_));
}
friend
bool asio_handler_is_continuation(
bind_front_wrapper* op)
{
using net::asio_handler_is_continuation;
using boost::asio::asio_handler_is_continuation;
return asio_handler_is_continuation(
std::addressof(op->h_));
}
friend
void* asio_handler_allocate(
boost::asio::asio_handler_allocate_is_deprecated
asio_handler_allocate(
std::size_t size, bind_front_wrapper* op)
{
using net::asio_handler_allocate;
using boost::asio::asio_handler_allocate;
return asio_handler_allocate(
size, std::addressof(op->h_));
}
friend
void asio_handler_deallocate(
boost::asio::asio_handler_deallocate_is_deprecated
asio_handler_deallocate(
void* p, std::size_t size, bind_front_wrapper* op)
{
using net::asio_handler_deallocate;
asio_handler_deallocate(
using boost::asio::asio_handler_deallocate;
return asio_handler_deallocate(
p, size, std::addressof(op->h_));
}
};
@@ -379,6 +396,42 @@ struct associated_allocator<
}
};
template<class Handler, class... Args, class CancellationSlot>
struct associated_cancellation_slot<
beast::detail::bind_wrapper<Handler, Args...>, CancellationSlot>
{
using type = typename
associated_cancellation_slot<Handler>::type;
static
type
get(beast::detail::bind_wrapper<Handler, Args...> const& op,
CancellationSlot const& slot = CancellationSlot{}) noexcept
{
return associated_cancellation_slot<
Handler, CancellationSlot>::get(op.h_, slot);
}
};
template<class Handler, class... Args, class CancellationSlot>
struct associated_cancellation_slot<
beast::detail::bind_front_wrapper<Handler, Args...>, CancellationSlot>
{
using type = typename
associated_cancellation_slot<Handler>::type;
static
type
get(beast::detail::bind_front_wrapper<Handler, Args...> const& op,
CancellationSlot const& slot = CancellationSlot{}) noexcept
{
return associated_cancellation_slot<
Handler, CancellationSlot>::get(op.h_, slot);
}
};
} // asio
} // boost

View File

@@ -11,6 +11,7 @@
#define BOOST_BEAST_CORE_DETAIL_BUFFER_HPP
#include <boost/beast/core/error.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/optional.hpp>
#include <stdexcept>
@@ -33,7 +34,7 @@ dynamic_buffer_prepare_noexcept(
if(buffer.max_size() - buffer.size() < size)
{
// length error
ec = ev;
BOOST_BEAST_ASSIGN_EC(ec, ev);
return boost::none;
}
boost::optional<typename
@@ -66,7 +67,7 @@ dynamic_buffer_prepare(
}
catch(std::length_error const&)
{
ec = ev;
BOOST_BEAST_ASSIGN_EC(ec, ev);
}
return boost::none;

View File

@@ -38,13 +38,9 @@ public:
buffers_iterator_type<BufferSequence>;
iter_type it_{};
buffers_range_adaptor const* b_ = nullptr;
const_iterator(
buffers_range_adaptor const& b,
iter_type const& it)
const_iterator(iter_type const& it)
: it_(it)
, b_(&b)
{
}
@@ -62,7 +58,7 @@ public:
bool
operator==(const_iterator const& other) const
{
return b_ == other.b_ && it_ == other.it_;
return it_ == other.it_;
}
bool
@@ -111,11 +107,6 @@ public:
}
};
buffers_range_adaptor(
buffers_range_adaptor const&) = default;
buffers_range_adaptor& operator=(
buffers_range_adaptor const&) = default;
explicit
buffers_range_adaptor(BufferSequence const& b)
: b_(b)
@@ -125,13 +116,13 @@ public:
const_iterator
begin() const noexcept
{
return {*this, net::buffer_sequence_begin(b_)};
return {net::buffer_sequence_begin(b_)};
}
const_iterator
end() const noexcept
{
return {*this, net::buffer_sequence_end(b_)};
return {net::buffer_sequence_end(b_)};
}
};

View File

@@ -0,0 +1,78 @@
//
// Copyright (c) 2019 Damian Jarek(damian.jarek93@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_CORE_DETAIL_CHAR_BUFFER_HPP
#define BOOST_BEAST_CORE_DETAIL_CHAR_BUFFER_HPP
#include <boost/config.hpp>
#include <cstddef>
#include <cstring>
#include <cstdint>
namespace boost {
namespace beast {
namespace detail {
template <std::size_t N>
class char_buffer
{
public:
bool try_push_back(char c)
{
if (size_ == N)
return false;
buf_[size_++] = c;
return true;
}
bool try_append(char const* first, char const* last)
{
std::size_t const n = last - first;
if (n > N - size_)
return false;
std::memmove(&buf_[size_], first, n);
size_ += n;
return true;
}
void clear() noexcept
{
size_ = 0;
}
char* data() noexcept
{
return buf_;
}
char const* data() const noexcept
{
return buf_;
}
std::size_t size() const noexcept
{
return size_;
}
bool empty() const noexcept
{
return size_ == 0;
}
private:
std::size_t size_= 0;
char buf_[N];
};
} // detail
} // beast
} // boost
#endif

View File

@@ -15,6 +15,7 @@
#include <boost/version.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/static_assert.hpp>
#include <boost/preprocessor/cat.hpp>
namespace boost {
namespace asio
@@ -85,12 +86,35 @@ namespace net = boost::asio;
#ifndef BOOST_BEAST_ASYNC_RESULT1
#define BOOST_BEAST_ASYNC_RESULT1(type) \
BOOST_ASIO_INITFN_RESULT_TYPE(type, void(::boost::beast::error_code))
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(type, void(::boost::beast::error_code))
#endif
#ifndef BOOST_BEAST_ASYNC_RESULT2
#define BOOST_BEAST_ASYNC_RESULT2(type) \
BOOST_ASIO_INITFN_RESULT_TYPE(type, void(::boost::beast::error_code, std::size_t))
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(type, void(::boost::beast::error_code, ::std::size_t))
#endif
#ifndef BOOST_BEAST_ASYNC_TPARAM1
#define BOOST_BEAST_ASYNC_TPARAM1 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::beast::error_code))
#endif
#ifndef BOOST_BEAST_ASYNC_TPARAM2
#define BOOST_BEAST_ASYNC_TPARAM2 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::beast::error_code, ::std::size_t))
#endif
#ifdef BOOST_BEAST_NO_SOURCE_LOCATION
#define BOOST_BEAST_ASSIGN_EC(ec, error) ec = error
#else
#define BOOST_BEAST_ASSIGN_EC(ec, error) \
static constexpr auto BOOST_PP_CAT(loc_, __LINE__) ((BOOST_CURRENT_LOCATION)); \
ec.assign(error, & BOOST_PP_CAT(loc_, __LINE__) )
#endif
#ifndef BOOST_BEAST_FILE_BUFFER_SIZE
#define BOOST_BEAST_FILE_BUFFER_SIZE 4096
#endif
#endif

View File

@@ -0,0 +1,65 @@
//
// Copyright (c) 2022 Klemens Morgenstern (klemens.morgenstern@gmx.net)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_BEAST_CORE_DETAIL_FILTERING_CANCELLATION_SLOT_HPP
#define BOOST_BEAST_CORE_DETAIL_FILTERING_CANCELLATION_SLOT_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/asio/cancellation_signal.hpp>
namespace boost {
namespace beast {
namespace detail {
template<typename CancellationSlot = net::cancellation_slot>
struct filtering_cancellation_slot : CancellationSlot
{
template<typename ... Args>
filtering_cancellation_slot(net::cancellation_type type, Args && ... args)
: CancellationSlot(std::forward<Args>(args)...), type(type) {}
net::cancellation_type type = net::cancellation_type::terminal;
using CancellationSlot::operator=;
template<typename Handler>
struct handler_wrapper
{
Handler handler;
const net::cancellation_type type;
template<typename ... Args>
handler_wrapper(net::cancellation_type type, Args && ... args)
: handler(std::forward<Args>(args)...),
type(type) {}
void operator()(net::cancellation_type tp)
{
if ((tp & type) != net::cancellation_type::none)
handler(tp);
}
};
template <typename CancellationHandler, typename ... Args>
CancellationHandler& emplace(Args && ... args)
{
return CancellationSlot::template emplace<handler_wrapper<CancellationHandler>>(
type, std::forward<Args>(args)...).handler;
}
template <typename CancellationHandler>
CancellationHandler& assign(CancellationHandler && ch)
{
return CancellationSlot::template emplace<handler_wrapper<CancellationHandler>>(
type, std::forward<CancellationHandler>(ch)).handler;
}
};
}
}
}
#endif //BOOST_BEAST_CORE_DETAIL_FILTERING_CANCELLATION_SLOT_HPP

View File

@@ -11,6 +11,9 @@
#define BOOST_BEAST_DETAIL_GET_IO_CONTEXT_HPP
#include <boost/beast/core/stream_traits.hpp>
#ifdef BOOST_ASIO_NO_TS_EXECUTORS
#include <boost/asio/execution.hpp>
#endif
#include <boost/asio/executor.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/strand.hpp>
@@ -34,7 +37,7 @@ inline
net::io_context*
get_io_context(net::io_context::executor_type const& ex)
{
return std::addressof(ex.context());
return std::addressof(net::query(ex, net::execution::context));
}
inline
@@ -42,8 +45,7 @@ net::io_context*
get_io_context(net::strand<
net::io_context::executor_type> const& ex)
{
return std::addressof(
ex.get_inner_executor().context());
return get_io_context(ex.get_inner_executor());
}
template<class Executor>
@@ -56,7 +58,7 @@ get_io_context(net::strand<Executor> const& ex)
template<
class T,
class = typename std::enable_if<
std::is_same<T, net::executor>::value>::type>
std::is_same<T, net::executor>::value || std::is_same<T, net::any_io_executor>::value>::type>
net::io_context*
get_io_context(T const& ex)
{
@@ -64,7 +66,7 @@ get_io_context(T const& ex)
net::io_context::executor_type>();
if(! p)
return nullptr;
return std::addressof(p->context());
return get_io_context(*p);
}
inline

View File

@@ -13,6 +13,7 @@
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
#include <boost/beast/core/read_size.hpp>
#include <boost/asio/basic_stream_socket.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/throw_exception.hpp>
@@ -37,7 +38,7 @@ template<
class Condition,
class Handler>
class read_op
: public net::coroutine
: public asio::coroutine
, public async_base<
Handler, beast::executor_type<Stream>>
{
@@ -73,18 +74,12 @@ public:
std::size_t bytes_transferred,
bool cont = true)
{
std::size_t max_size;
std::size_t max_prepare;
BOOST_ASIO_CORO_REENTER(*this)
{
for(;;)
{
max_size = cond_(ec, total_, b_);
max_prepare = std::min<std::size_t>(
std::max<std::size_t>(
512, b_.capacity() - b_.size()),
std::min<std::size_t>(
max_size, b_.max_size() - b_.size()));
max_prepare = beast::read_size(b_, cond_(ec, total_, b_));
if(max_prepare == 0)
break;
BOOST_ASIO_CORO_YIELD
@@ -101,7 +96,7 @@ public:
BOOST_ASIO_CORO_YIELD
s_.async_read_some(
b_.prepare(0), std::move(*this));
ec = ec_;
BOOST_BEAST_ASSIGN_EC(ec, ec_);
}
this->complete_now(ec, total_);
}
@@ -201,16 +196,10 @@ read(
"CompletionCondition type requirements not met");
ec = {};
std::size_t total = 0;
std::size_t max_size;
std::size_t max_prepare;
for(;;)
{
max_size = cond(ec, total, buffer);
max_prepare = std::min<std::size_t>(
std::max<std::size_t>(
512, buffer.capacity() - buffer.size()),
std::min<std::size_t>(
max_size, buffer.max_size() - buffer.size()));
max_prepare = beast::read_size(buffer, cond(ec, total, buffer));
if(max_prepare == 0)
break;
std::size_t const bytes_transferred =
@@ -225,7 +214,7 @@ template<
class AsyncReadStream,
class DynamicBuffer,
class CompletionCondition,
class ReadHandler,
BOOST_BEAST_ASYNC_TPARAM2 ReadHandler,
class>
BOOST_BEAST_ASYNC_RESULT2(ReadHandler)
async_read(

View File

@@ -0,0 +1,69 @@
//
// Copyright (c) 2019 Damian Jarek(damian.jarek93@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_DETAIL_IMPL_TEMPORARY_BUFFER_IPP
#define BOOST_BEAST_DETAIL_IMPL_TEMPORARY_BUFFER_IPP
#include <boost/beast/core/detail/temporary_buffer.hpp>
#include <boost/beast/core/detail/clamp.hpp>
#include <boost/core/exchange.hpp>
#include <boost/assert.hpp>
#include <memory>
#include <cstring>
namespace boost {
namespace beast {
namespace detail {
void
temporary_buffer::
append(string_view s)
{
grow(s.size());
unchecked_append(s);
}
void
temporary_buffer::
append(string_view s1, string_view s2)
{
grow(s1.size() + s2.size());
unchecked_append(s1);
unchecked_append(s2);
}
void
temporary_buffer::
unchecked_append(string_view s)
{
auto n = s.size();
std::memcpy(&data_[size_], s.data(), n);
size_ += n;
}
void
temporary_buffer::
grow(std::size_t n)
{
if (capacity_ - size_ >= n)
return;
auto const capacity = (n + size_) * 2u;
BOOST_ASSERT(! detail::sum_exceeds(
n, size_, capacity));
char* const p = new char[capacity];
std::memcpy(p, data_, size_);
deallocate(boost::exchange(data_, p));
capacity_ = capacity;
}
} // detail
} // beast
} // boost
#endif

View File

@@ -10,6 +10,8 @@
#ifndef BOOST_BEAST_DETAIL_IS_INVOCABLE_HPP
#define BOOST_BEAST_DETAIL_IS_INVOCABLE_HPP
#include <boost/asio/async_result.hpp>
#include <boost/type_traits/make_void.hpp>
#include <type_traits>
#include <utility>
@@ -51,6 +53,26 @@ struct is_invocable<C, R(A...)>
};
/** @} */
template<class CompletionToken, class Signature, class = void>
struct is_completion_token_for : std::false_type
{
};
struct any_initiation
{
template<class...AnyArgs>
void operator()(AnyArgs&&...);
};
template<class CompletionToken, class R, class...Args>
struct is_completion_token_for<
CompletionToken, R(Args...), boost::void_t<decltype(
boost::asio::async_initiate<CompletionToken, R(Args...)>(
any_initiation(), std::declval<CompletionToken&>())
)>> : std::true_type
{
};
} // detail
} // beast
} // boost

View File

@@ -12,7 +12,6 @@
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_range.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/throw_exception.hpp>
#include <boost/asio/buffer.hpp>
#include <memory>
@@ -43,7 +42,7 @@ class ostream_buffer;
template<class DynamicBuffer, class CharT, class Traits>
class ostream_buffer
<DynamicBuffer, CharT, Traits, true>
<DynamicBuffer, CharT, Traits, true> final
: public std::basic_streambuf<CharT, Traits>
{
using int_type = typename
@@ -67,6 +66,7 @@ public:
ostream_buffer(DynamicBuffer& b)
: b_(b)
{
b_.prepare(0);
}
int_type
@@ -100,6 +100,7 @@ public:
b_.commit(
(this->pptr() - this->pbase()) *
sizeof(CharT));
this->setp(nullptr, nullptr);
return 0;
}
};
@@ -169,6 +170,7 @@ public:
b_.commit(
(this->pptr() - this->pbase()) *
sizeof(CharT));
this->setp(nullptr, nullptr);
return 0;
}
};

View File

@@ -219,7 +219,7 @@ template<
class AsyncReadStream,
class DynamicBuffer,
class CompletionCondition,
class ReadHandler
BOOST_BEAST_ASYNC_TPARAM2 ReadHandler
#if ! BOOST_BEAST_DOXYGEN
, class = typename std::enable_if<
is_async_read_stream<AsyncReadStream>::value &&

View File

@@ -10,7 +10,6 @@
#ifndef BOOST_BEAST_DETAIL_REMAP_POST_TO_DEFER_HPP
#define BOOST_BEAST_DETAIL_REMAP_POST_TO_DEFER_HPP
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/is_executor.hpp>
#include <boost/core/empty_value.hpp>
#include <type_traits>

View File

@@ -16,15 +16,10 @@ namespace boost {
namespace beast {
namespace detail {
template<class T>
struct service_id : net::execution_context::id
{
};
template<class T>
struct service_base : net::execution_context::service
{
static service_id<T> id;
static net::execution_context::id const id;
explicit
service_base(net::execution_context& ctx)
@@ -34,7 +29,7 @@ struct service_base : net::execution_context::service
};
template<class T>
service_id<T> service_base<T>::id;
net::execution_context::id const service_base<T>::id;
} // detail
} // beast

View File

@@ -11,10 +11,8 @@
#define BOOST_BEAST_DETAIL_SHA1_HPP
#include <boost/beast/core/detail/config.hpp>
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <cstddef>
// Based on https://github.com/vog/sha1
/*

View File

@@ -10,56 +10,15 @@
#ifndef BOOST_BEAST_DETAIL_STATIC_STRING_HPP
#define BOOST_BEAST_DETAIL_STATIC_STRING_HPP
#include <boost/beast/core/string.hpp>
#include <boost/assert.hpp>
#include <iterator>
#include <boost/core/ignore_unused.hpp>
#include <string>
#include <type_traits>
namespace boost {
namespace beast {
namespace detail {
// Because k-ballo said so
template<class T>
using is_input_iterator =
std::integral_constant<bool,
! std::is_integral<T>::value>;
template<class CharT, class Traits>
int
lexicographical_compare(
CharT const* s1, std::size_t n1,
CharT const* s2, std::size_t n2)
{
if(n1 < n2)
return Traits::compare(
s1, s2, n1) <= 0 ? -1 : 1;
if(n1 > n2)
return Traits::compare(
s1, s2, n2) >= 0 ? 1 : -1;
return Traits::compare(s1, s2, n1);
}
template<class CharT, class Traits>
int
lexicographical_compare(
basic_string_view<CharT, Traits> s1,
CharT const* s2, std::size_t n2)
{
return detail::lexicographical_compare<
CharT, Traits>(s1.data(), s1.size(), s2, n2);
}
template<class CharT, class Traits>
int
lexicographical_compare(
basic_string_view<CharT, Traits> s1,
basic_string_view<CharT, Traits> s2)
{
return detail::lexicographical_compare<CharT, Traits>(
s1.data(), s1.size(), s2.data(), s2.size());
}
// Maximum number of characters in the decimal
// representation of a binary number. This includes
// the potential minus sign.

View File

@@ -39,16 +39,21 @@ struct stream_base
std::chrono::steady_clock::time_point;
using tick_type = std::uint64_t;
struct op_state
template<typename Executor>
struct basic_op_state
{
net::steady_timer timer; // for timing out
net::basic_waitable_timer<
std::chrono::steady_clock,
net::wait_traits<
std::chrono::steady_clock>,
Executor> timer; // for timing out
tick_type tick = 0; // counts waits
bool pending = false; // if op is pending
bool timeout = false; // if timed out
template<class... Args>
explicit
op_state(Args&&... args)
basic_op_state(Args&&... args)
: timer(std::forward<Args>(args)...)
{
}
@@ -56,22 +61,35 @@ struct stream_base
class pending_guard
{
bool& b_;
bool* b_ = nullptr;
bool clear_ = true;
public:
~pending_guard()
{
if(clear_)
b_ = false;
if(clear_ && b_)
*b_ = false;
}
pending_guard()
: b_(nullptr)
, clear_(true)
{
}
explicit
pending_guard(bool& b)
: b_(b)
: b_(&b)
{
BOOST_ASSERT(! b_);
b_ = true;
// If this assert goes off, it means you are attempting
// to issue two of the same asynchronous I/O operation
// at the same time, without waiting for the first one
// to complete. For example, attempting two simultaneous
// calls to async_read_some. Only one pending call of
// each I/O type (read and write) is permitted.
//
BOOST_ASSERT(! *b_);
*b_ = true;
}
pending_guard(
@@ -82,11 +100,29 @@ struct stream_base
{
}
void assign(bool& b)
{
BOOST_ASSERT(!b_);
BOOST_ASSERT(clear_);
b_ = &b;
// If this assert goes off, it means you are attempting
// to issue two of the same asynchronous I/O operation
// at the same time, without waiting for the first one
// to complete. For example, attempting two simultaneous
// calls to async_read_some. Only one pending call of
// each I/O type (read and write) is permitted.
//
BOOST_ASSERT(! *b_);
*b_ = true;
}
void
reset()
{
BOOST_ASSERT(clear_);
b_ = false;
if (b_)
*b_ = false;
clear_ = false;
}
};

View File

@@ -0,0 +1,44 @@
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_DETAIL_STRING_HPP
#define BOOST_BEAST_DETAIL_STRING_HPP
#include <boost/beast/core/string_type.hpp>
namespace boost {
namespace beast {
namespace detail {
// Pulling in the UDL directly breaks in some places on MSVC,
// so introduce a namespace for this purprose.
namespace string_literals {
inline
string_view
operator"" _sv(char const* p, std::size_t n)
{
return string_view{p, n};
}
} // string_literals
inline
char
ascii_tolower(char c)
{
return ((static_cast<unsigned>(c) - 65U) < 26) ?
c + 'a' - 'A' : c;
}
} // detail
} // beast
} // boost
#endif

View File

@@ -0,0 +1,83 @@
//
// Copyright (c) 2019 Damian Jarek(damian.jarek93@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_DETAIL_TEMPORARY_BUFFER_HPP
#define BOOST_BEAST_DETAIL_TEMPORARY_BUFFER_HPP
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/string.hpp>
#include <memory>
namespace boost {
namespace beast {
namespace detail {
struct temporary_buffer
{
temporary_buffer() = default;
temporary_buffer(temporary_buffer const&) = delete;
temporary_buffer& operator=(temporary_buffer const&) = delete;
~temporary_buffer() noexcept
{
deallocate(data_);
}
BOOST_BEAST_DECL
void
append(string_view s);
BOOST_BEAST_DECL
void
append(string_view s1, string_view s2);
string_view
view() const noexcept
{
return {data_, size_};
}
bool
empty() const noexcept
{
return size_ == 0;
}
private:
BOOST_BEAST_DECL
void
unchecked_append(string_view s);
BOOST_BEAST_DECL
void
grow(std::size_t n);
void
deallocate(char* data) noexcept
{
if (data != buffer_)
delete[] data;
}
char buffer_[4096];
char* data_ = buffer_;
std::size_t capacity_ = sizeof(buffer_);
std::size_t size_ = 0;
};
} // detail
} // beast
} // boost
#ifdef BOOST_BEAST_HEADER_ONLY
#include <boost/beast/core/detail/impl/temporary_buffer.ipp>
#endif
#endif

View File

@@ -1,5 +1,5 @@
//
// Copyright (c) 2016-2019Damian Jarek (damian dot jarek93 at gmail dot com)
// Copyright (c) 2016-2019 Damian Jarek (damian dot jarek93 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

View File

@@ -10,36 +10,14 @@
#ifndef BOOST_BEAST_DETAIL_TYPE_TRAITS_HPP
#define BOOST_BEAST_DETAIL_TYPE_TRAITS_HPP
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/detail/is_invocable.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/mp11/function.hpp>
#include <boost/type_traits/make_void.hpp>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <string>
#include <utility>
#include <new>
namespace boost {
namespace beast {
namespace detail {
// variadic min
template<class T>
T constexpr min(T t)
{
return t;
}
template<class T, class...Tn>
T constexpr min(T t0, T t1, Tn... tn)
{
return (t0 < t1) ?
(detail::min)(t0, tn...) :
(detail::min)(t1, tn...);
}
template<class U>
std::size_t constexpr
max_sizeof()
@@ -97,32 +75,17 @@ using aligned_union_t =
//------------------------------------------------------------------------------
template<class T>
void
accept_rv(T){}
//------------------------------------------------------------------------------
// for span
template<class T, class E, class = void>
struct is_contiguous_container: std::false_type {};
template<class T, class E>
struct is_contiguous_container<T, E, void_t<
decltype(
std::declval<std::size_t&>() = std::declval<T const&>().size(),
std::declval<E*&>() = std::declval<T&>().data()),
typename std::enable_if<
std::is_same<
typename std::remove_cv<E>::type,
typename std::remove_cv<
typename std::remove_pointer<
decltype(std::declval<T&>().data())
>::type
>::type
>::value
>::type>>: std::true_type
{};
template <class T, class U>
T launder_cast(U* u)
{
#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
return std::launder(reinterpret_cast<T>(u));
#elif defined(BOOST_GCC) && BOOST_GCC_VERSION > 80000
return __builtin_launder(reinterpret_cast<T>(u));
#else
return reinterpret_cast<T>(u);
#endif
}
} // detail
} // beast

View File

@@ -45,7 +45,7 @@ class variant
{
using T =
mp11::mp_at_c<variant, I::value - 1>;
reinterpret_cast<T&>(self.buf_).~T();
detail::launder_cast<T*>(&self.buf_)->~T();
}
};
@@ -64,7 +64,7 @@ class variant
using T =
mp11::mp_at_c<variant, I::value - 1>;
::new(&self.buf_) T(
reinterpret_cast<T const&>(other.buf_));
*detail::launder_cast<T const*>(&other.buf_));
self.i_ = I::value;
}
};
@@ -83,9 +83,9 @@ class variant
{
using T =
mp11::mp_at_c<variant, I::value - 1>;
::new(&self.buf_) T(
reinterpret_cast<T&&>(other.buf_));
reinterpret_cast<T&>(other.buf_).~T();
::new(&self.buf_) T(std::move(
*detail::launder_cast<T*>(&other.buf_)));
detail::launder_cast<T*>(&other.buf_)->~T();
self.i_ = I::value;
}
};
@@ -106,8 +106,8 @@ class variant
using T =
mp11::mp_at_c<variant, I::value - 1>;
return
reinterpret_cast<T const&>(self.buf_) ==
reinterpret_cast<T const&>(other.buf_);
*detail::launder_cast<T const*>(&self.buf_) ==
*detail::launder_cast<T const*>(&other.buf_);
}
};
@@ -181,7 +181,7 @@ public:
}
return *this;
}
variant& operator=(variant const& other)
{
if(this != &other)
@@ -208,7 +208,7 @@ public:
get()
{
BOOST_ASSERT(i_ == I);
return *reinterpret_cast<
return *detail::launder_cast<
mp11::mp_at_c<variant, I - 1>*>(&buf_);
}
@@ -217,7 +217,7 @@ public:
get() const
{
BOOST_ASSERT(i_ == I);
return *reinterpret_cast<
return *detail::launder_cast<
mp11::mp_at_c<variant, I - 1> const*>(&buf_);
}

View File

@@ -0,0 +1,82 @@
//
// Copyright (c) 2019 Mika Fischer (mika.fischer@zoopnet.de)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/beast
//
#ifndef BOOST_BEAST_CORE_DETAIL_WIN32_UNICODE_PATH_HPP
#define BOOST_BEAST_CORE_DETAIL_WIN32_UNICODE_PATH_HPP
#ifdef _WIN32
#include <boost/config.hpp>
#include <boost/beast/core/error.hpp>
#include <boost/winapi/character_code_conversion.hpp>
#include <boost/winapi/file_management.hpp>
#include <boost/winapi/get_last_error.hpp>
#include <array>
#include <vector>
namespace boost {
namespace beast {
namespace detail {
class win32_unicode_path
{
using WCHAR_ = boost::winapi::WCHAR_;
public:
win32_unicode_path(const char* utf8_path, error_code& ec) {
int ret = mb2wide(utf8_path, static_buf_.data(),
static_buf_.size());
if (ret == 0)
{
int sz = mb2wide(utf8_path, nullptr, 0);
if (sz == 0)
{
ec.assign(boost::winapi::GetLastError(),
system_category());
return;
}
dynamic_buf_.resize(sz);
int ret2 = mb2wide(utf8_path,
dynamic_buf_.data(),
dynamic_buf_.size());
if (ret2 == 0)
{
ec.assign(boost::winapi::GetLastError(),
system_category());
return;
}
}
}
WCHAR_ const* c_str() const noexcept
{
return dynamic_buf_.empty()
? static_buf_.data()
: dynamic_buf_.data();
}
private:
int mb2wide(const char* utf8_path, WCHAR_* buf, size_t sz)
{
return boost::winapi::MultiByteToWideChar(
boost::winapi::CP_UTF8_,
boost::winapi::MB_ERR_INVALID_CHARS_,
utf8_path, -1,
buf, static_cast<int>(sz));
}
std::array<WCHAR_, boost::winapi::MAX_PATH_> static_buf_;
std::vector<WCHAR_> dynamic_buf_;
};
} // detail
} // beast
} // boost
#endif
#endif

View File

@@ -0,0 +1,93 @@
#ifndef BOOST_BEAST_CORE_DETAIL_WORK_GUARD_HPP
#define BOOST_BEAST_CORE_DETAIL_WORK_GUARD_HPP
#include <boost/asio/executor_work_guard.hpp>
#include <boost/asio/execution.hpp>
#include <boost/optional.hpp>
namespace boost {
namespace beast {
namespace detail {
template<class Executor, class Enable = void>
struct select_work_guard;
template<class Executor>
using select_work_guard_t = typename
select_work_guard<Executor>::type;
#if !defined(BOOST_ASIO_NO_TS_EXECUTORS)
template<class Executor>
struct select_work_guard
<
Executor,
typename std::enable_if
<
net::is_executor<Executor>::value
>::type
>
{
using type = net::executor_work_guard<Executor>;
};
#endif
template<class Executor>
struct execution_work_guard
{
using executor_type = typename std::decay<decltype(
net::prefer(std::declval<Executor const&>(),
net::execution::outstanding_work.tracked))>::type;
execution_work_guard(Executor const& exec)
: ex_(net::prefer(exec, net::execution::outstanding_work.tracked))
{
}
executor_type
get_executor() const noexcept
{
BOOST_ASSERT(ex_.has_value());
return *ex_;
}
void reset() noexcept
{
ex_.reset();
}
private:
boost::optional<executor_type> ex_;
};
template<class Executor>
struct select_work_guard
<
Executor,
typename std::enable_if
<
net::execution::is_executor<Executor>::value
#if defined(BOOST_ASIO_NO_TS_EXECUTORS)
|| net::is_executor<Executor>::value
#else
&& !net::is_executor<Executor>::value
#endif
>::type
>
{
using type = execution_work_guard<Executor>;
};
template<class Executor>
select_work_guard_t<Executor>
make_work_guard(Executor const& exec) noexcept
{
return select_work_guard_t<Executor>(exec);
}
}
}
}
#endif // BOOST_BEAST_CORE_DETAIL_WORK_GUARD_HPP