Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions include/boost/http_proto/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,16 +614,11 @@ class parser
friend class response_parser;
class impl;

BOOST_HTTP_PROTO_DECL
parser(
const rts::context&,
detail::kind);

BOOST_HTTP_PROTO_DECL
parser(parser&& other) noexcept;

BOOST_HTTP_PROTO_DECL
~parser();
BOOST_HTTP_PROTO_DECL ~parser();
BOOST_HTTP_PROTO_DECL parser() noexcept;
BOOST_HTTP_PROTO_DECL parser(parser&& other) noexcept;
BOOST_HTTP_PROTO_DECL parser(rts::context const&, detail::kind);
BOOST_HTTP_PROTO_DECL void assign(parser&& other) noexcept;

BOOST_HTTP_PROTO_DECL
void
Expand Down
86 changes: 57 additions & 29 deletions include/boost/http_proto/request_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,62 @@ class request_parser
}
};

/** Destructor.

Any views or buffers obtained from this
parser become invalid.
*/
~request_parser() = default;

/** Constructor.

Default-constructed parsers do not reference any
implementation and therefore must be assigned to before using.
*/
request_parser() noexcept = default;

/** Constructor.

The states of `other` are transferred
to the newly constructed object,
including the allocated buffer.
After construction, the only valid
operations on the moved-from object
are destruction and assignment.

Buffer sequences previously obtained
using @ref prepare or @ref pull_body
remain valid.

@par Complexity
Constant.

@param other The parser to move from.
*/
request_parser(
request_parser&& other) noexcept = default;

/** Assignment.
The states of `other` are transferred
to this object, including the allocated
buffer.
After assignment, the only valid
operations on the moved-from object
are destruction and assignment.
Buffer sequences previously obtained
using @ref prepare or @ref pull_body
remain valid.
@par Complexity
Constant.
@param other The parser to move from.
*/
request_parser&
operator=(request_parser&& other) noexcept
{
assign(std::move(other));
return *this;
}

/** Constructor.

Constructs a parser that uses the @ref
Expand Down Expand Up @@ -84,35 +140,7 @@ class request_parser
*/
BOOST_HTTP_PROTO_DECL
explicit
request_parser(const rts::context& ctx);

/** Constructor.

The states of `other` are transferred
to the newly constructed object,
including the allocated buffer.
After construction, the only valid
operations on the moved-from object
are destruction and assignment.

Buffer sequences previously obtained
using @ref prepare or @ref pull_body
remain valid.

@par Complexity
Constant.

@param other The parser to move from.
*/
request_parser(
request_parser&& other) noexcept = default;

/** Destructor.

Any views or buffers obtained from this
parser become invalid.
*/
~request_parser() = default;
request_parser(rts::context const& ctx);

/** Return a reference to the parsed request headers.

Expand Down
86 changes: 57 additions & 29 deletions include/boost/http_proto/response_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,62 @@ class response_parser
}
};

/** Destructor.

Any views or buffers obtained from this
parser become invalid.
*/
~response_parser() = default;

/** Constructor.

Default-constructed parsers do not reference any
implementation and therefore must be assigned to before using.
*/
response_parser() = default;

/** Constructor.

The states of `other` are transferred
to the newly constructed object,
including the allocated buffer.
After construction, the only valid
operations on the moved-from object
are destruction and assignemt.

Buffer sequences previously obtained
using @ref prepare or @ref pull_body
remain valid.

@par Complexity
Constant.

@param other The parser to move from.
*/
response_parser(
response_parser&& other) noexcept = default;

/** Assignment.
The states of `other` are transferred
to this object, including the allocated
buffer.
After assignment, the only valid
operations on the moved-from object
are destruction and assignment.
Buffer sequences previously obtained
using @ref prepare or @ref pull_body
remain valid.
@par Complexity
Constant.
@param other The parser to move from.
*/
response_parser&
operator=(response_parser&& other) noexcept
{
assign(std::move(other));
return *this;
}

/** Constructor.

Constructs a parser that uses the @ref
Expand Down Expand Up @@ -84,35 +140,7 @@ class response_parser
*/
BOOST_HTTP_PROTO_DECL
explicit
response_parser(const rts::context& ctx);

/** Constructor.

The states of `other` are transferred
to the newly constructed object,
including the allocated buffer.
After construction, the only valid
operations on the moved-from object
are destruction and assignemt.

Buffer sequences previously obtained
using @ref prepare or @ref pull_body
remain valid.

@par Complexity
Constant.

@param other The parser to move from.
*/
response_parser(
response_parser&& other) noexcept = default;

/** Destructor.

Any views or buffers obtained from this
parser become invalid.
*/
~response_parser() = default;
response_parser(rts::context const& ctx);

/** Prepare for the next message on the stream.

Expand Down
91 changes: 58 additions & 33 deletions include/boost/http_proto/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,63 @@ class serializer
using const_buffers_type =
boost::span<buffers::const_buffer const>;

/** Destructor
*/
BOOST_HTTP_PROTO_DECL
~serializer();

/** Constructor
Default-constructed serializers do not reference any implementation;
the only valid operations are destruction and assignment.
*/
serializer() = default;

/** Constructor.

The states of `other` are transferred
to the newly constructed object,
which includes the allocated buffer.
After construction, the only valid
operations on the moved-from object
are destruction and assignment.

Buffer sequences previously obtained
using @ref prepare or @ref stream::prepare
remain valid.

@par Postconditions
@code
other.is_done() == true
@endcode

@par Complexity
Constant.

@param other The serializer to move from.
*/
BOOST_HTTP_PROTO_DECL
serializer(
serializer&& other) noexcept;

/** Assignment.
The states of `other` are transferred
to this object, which includes the
allocated buffer. After assignment,
the only valid operations on the
moved-from object are destruction and
assignment.
Buffer sequences previously obtained
using @ref prepare or @ref stream::prepare
remain valid.
@par Complexity
Constant.
@param other The serializer to move from.
@return A reference to this object.
*/
BOOST_HTTP_PROTO_DECL
serializer&
operator=(serializer&& other) noexcept;

/** Constructor.

Constructs a serializer that uses the @ref
Expand Down Expand Up @@ -116,38 +173,6 @@ class serializer
serializer(
const rts::context& ctx);

/** Constructor.

The states of `other` are transferred
to the newly constructed object,
which includes the allocated buffer.
After construction, the only valid
operations on the moved-from object
are destruction and assignment.

Buffer sequences previously obtained
using @ref prepare or @ref stream::prepare
remain valid.

@par Postconditions
@code
other.is_done() == true
@endcode

@par Complexity
Constant.

@param other The serializer to move from.
*/
BOOST_HTTP_PROTO_DECL
serializer(
serializer&& other) noexcept;

/** Destructor
*/
BOOST_HTTP_PROTO_DECL
~serializer();

/** Reset the serializer for a new message.

Aborts any ongoing serialization and
Expand Down Expand Up @@ -536,7 +561,7 @@ class serializer
message_base const&,
source&);

impl* impl_;
impl* impl_ = nullptr;
};

/** Serializer configuration settings.
Expand Down
29 changes: 24 additions & 5 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,11 +1848,15 @@ class parser::impl
//------------------------------------------------

parser::
parser(const rts::context& ctx, detail::kind k)
: impl_(new impl(ctx, k))
~parser()
{
delete impl_;
}

parser::
parser() noexcept
: impl_(nullptr)
{
// TODO: use a single allocation for
// impl and workspace buffer.
}

parser::
Expand All @@ -1863,9 +1867,24 @@ parser(parser&& other) noexcept
}

parser::
~parser()
parser(
rts::context const& ctx,
detail::kind k)
: impl_(new impl(ctx, k))
{
// TODO: use a single allocation for
// impl and workspace buffer.
}

void
parser::
assign(parser&& other) noexcept
{
if(this == &other)
return;
delete impl_;
impl_ = other.impl_;
other.impl_ = nullptr;
}

//--------------------------------------------
Expand Down
Loading
Loading