forked from boostorg/beast
serializing file_body is not const
This commit is contained in:
@@ -75,7 +75,7 @@ public:
|
||||
|
||||
/// Returns the native handle associated with the file.
|
||||
native_handle_type
|
||||
native_handle() const
|
||||
native_handle()
|
||||
{
|
||||
return h_;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
@return The offset in bytes from the beginning of the file
|
||||
*/
|
||||
std::uint64_t
|
||||
pos(error_code& ec) const;
|
||||
pos(error_code& ec);
|
||||
|
||||
/** Adjust the current position in the open file
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
@param ec Set to the error, if any occurred
|
||||
*/
|
||||
std::size_t
|
||||
read(void* buffer, std::size_t n, error_code& ec) const;
|
||||
read(void* buffer, std::size_t n, error_code& ec);
|
||||
|
||||
/** Write to the open file
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ size(error_code& ec) const
|
||||
inline
|
||||
std::uint64_t
|
||||
file_win32::
|
||||
pos(error_code& ec) const
|
||||
pos(error_code& ec)
|
||||
{
|
||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ seek(std::uint64_t offset, error_code& ec)
|
||||
inline
|
||||
std::size_t
|
||||
file_win32::
|
||||
read(void* buffer, std::size_t n, error_code& ec) const
|
||||
read(void* buffer, std::size_t n, error_code& ec)
|
||||
{
|
||||
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
|
||||
{
|
||||
|
||||
@@ -219,9 +219,9 @@ size(value_type const& v)
|
||||
template<class File>
|
||||
class basic_file_body<File>::reader
|
||||
{
|
||||
value_type const& body_; // The body we are reading from
|
||||
std::uint64_t remain_; // The number of unread bytes
|
||||
char buf_[4096]; // Small buffer for reading
|
||||
value_type& body_; // The body we are reading from
|
||||
std::uint64_t remain_; // The number of unread bytes
|
||||
char buf_[4096]; // Small buffer for reading
|
||||
|
||||
public:
|
||||
// The type of buffer sequence returned by `get`.
|
||||
@@ -234,9 +234,28 @@ public:
|
||||
// `m` holds the message we are sending, which will
|
||||
// always have the `file_body` as the body type.
|
||||
//
|
||||
// Note that the message is passed by non-const reference.
|
||||
// This is intentional, because reading from the file
|
||||
// changes its "current position" which counts makes the
|
||||
// operation logically not-const (although it is bitwise
|
||||
// const).
|
||||
//
|
||||
// The BodyReader concept allows the reader to choose
|
||||
// whether to take the message by const reference or
|
||||
// non-const reference. Depending on the choice, a
|
||||
// serializer constructed using that body type will
|
||||
// require the same const or non-const reference to
|
||||
// construct.
|
||||
//
|
||||
// Readers which accept const messages usually allow
|
||||
// the same body to be serialized by multiple threads
|
||||
// concurrently, while readers accepting non-const
|
||||
// messages may only be serialized by one thread at
|
||||
// a time.
|
||||
//
|
||||
template<bool isRequest, class Fields>
|
||||
reader(message<
|
||||
isRequest, basic_file_body, Fields> const& m);
|
||||
isRequest, basic_file_body, Fields>& m);
|
||||
|
||||
// Initializer
|
||||
//
|
||||
@@ -269,7 +288,7 @@ template<class File>
|
||||
template<bool isRequest, class Fields>
|
||||
basic_file_body<File>::
|
||||
reader::
|
||||
reader(message<isRequest, basic_file_body, Fields> const& m)
|
||||
reader(message<isRequest, basic_file_body, Fields>& m)
|
||||
: body_(m.body)
|
||||
{
|
||||
// The file must already be open
|
||||
|
||||
Reference in New Issue
Block a user