forked from boostorg/beast
Tidy up core files
This commit is contained in:
1 parent
d8a23776d4
commit
120d5481e2
50 files changed
+770
-577
No files matched your search
+49
-27
@@ -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());
|
||||
+16
-20
@@ -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
-7
@@ -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};
|
||||
File renamed without changes.
+2
-31
@@ -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 ->
|
||||
+18
-29
@@ -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
-18
@@ -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)
|
||||
+14
-24
@@ -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;
|
||||
}
|
||||
|
||||
File renamed without changes.
+2
-2
@@ -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>
|
||||
+15
-15
@@ -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;
|
||||
+2
-2
@@ -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>
|
||||
+5
-6
@@ -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)
|
||||
+2
-2
@@ -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>
|
||||
+25
-3
@@ -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();
|
||||
}
|
||||
+2
-2
@@ -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 {
|
||||
Reference in new issue
Block a user