forked from boostorg/beast
basic_parser is abstract, not CRTP (API Change):
* `basic_parser` now uses pure virtual member functions instead of the curiously recurring template pattern. Actions Required: * Change uses of the `basic_parser` type to omit the `Derived` template parameter * Classes derived from `basic_parser` no longer need to friend the base. * Virtual functions in the derived class may be marked `override`.
This commit is contained in:
1 parent
bbd62dd181
commit
59bda5d9c6
33 files changed
+1365
-1236
No files matched your search
@@ -894,10 +894,10 @@ public:
|
||||
return {s.data(), s.size()};
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence, bool isRequest, class Derived>
|
||||
template<class ConstBufferSequence, bool isRequest>
|
||||
std::size_t
|
||||
feed(ConstBufferSequence const& buffers,
|
||||
basic_parser<isRequest, Derived>& p, error_code& ec)
|
||||
basic_parser<isRequest>& p, error_code& ec)
|
||||
{
|
||||
p.eager(true);
|
||||
return p.put(buffers, ec);
|
||||
|
||||
@@ -45,11 +45,11 @@ public:
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence,
|
||||
bool isRequest, class Derived>
|
||||
bool isRequest>
|
||||
static
|
||||
void
|
||||
put(ConstBufferSequence const& buffers,
|
||||
basic_parser<isRequest, Derived>& p,
|
||||
basic_parser<isRequest>& p,
|
||||
error_code& ec)
|
||||
{
|
||||
buffers_suffix<ConstBufferSequence> cb{buffers};
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace http {
|
||||
|
||||
template<bool isRequest>
|
||||
class test_parser
|
||||
: public basic_parser<isRequest, test_parser<isRequest>>
|
||||
: public basic_parser<isRequest>
|
||||
{
|
||||
test::fail_count* fc_ = nullptr;
|
||||
|
||||
@@ -65,8 +65,6 @@ public:
|
||||
++got_on_begin;
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
}
|
||||
|
||||
void
|
||||
@@ -81,8 +79,6 @@ public:
|
||||
++got_on_begin;
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
}
|
||||
|
||||
void
|
||||
@@ -92,8 +88,6 @@ public:
|
||||
++got_on_field;
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
fields[std::string(name)] = std::string(value);
|
||||
}
|
||||
|
||||
@@ -103,8 +97,6 @@ public:
|
||||
++got_on_header;
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
}
|
||||
|
||||
void
|
||||
@@ -117,8 +109,6 @@ public:
|
||||
static_cast<bool>(content_length_);
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
}
|
||||
|
||||
std::size_t
|
||||
@@ -128,8 +118,6 @@ public:
|
||||
body.append(s.data(), s.size());
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
return s.size();
|
||||
}
|
||||
|
||||
@@ -142,8 +130,6 @@ public:
|
||||
++got_on_chunk;
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
}
|
||||
|
||||
std::size_t
|
||||
@@ -155,8 +141,6 @@ public:
|
||||
body.append(s.data(), s.size());
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
return s.size();
|
||||
}
|
||||
|
||||
@@ -167,8 +151,6 @@ public:
|
||||
++got_on_complete;
|
||||
if(fc_)
|
||||
fc_->fail(ec);
|
||||
else
|
||||
ec = {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -70,11 +70,11 @@ public:
|
||||
}
|
||||
|
||||
template<class ConstBufferSequence,
|
||||
bool isRequest, class Derived>
|
||||
bool isRequest>
|
||||
static
|
||||
std::size_t
|
||||
feed(ConstBufferSequence const& buffers,
|
||||
basic_parser<isRequest, Derived>& parser,
|
||||
basic_parser<isRequest>& parser,
|
||||
error_code& ec)
|
||||
{
|
||||
beast::buffers_suffix<
|
||||
@@ -149,79 +149,131 @@ public:
|
||||
|
||||
template<bool isRequest>
|
||||
struct null_parser :
|
||||
basic_parser<isRequest, null_parser<isRequest>>
|
||||
basic_parser<isRequest>
|
||||
{
|
||||
void
|
||||
on_request_impl(
|
||||
verb, string_view, string_view,
|
||||
int, error_code&) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
on_response_impl(
|
||||
int, string_view, int,
|
||||
error_code&) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
on_field_impl(
|
||||
field, string_view, string_view,
|
||||
error_code&) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
on_header_impl(error_code&) override
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
on_body_init_impl(
|
||||
boost::optional<std::uint64_t> const&,
|
||||
error_code&) override
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t
|
||||
on_body_impl(
|
||||
string_view,
|
||||
error_code&) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
on_chunk_header_impl(
|
||||
std::uint64_t,
|
||||
string_view,
|
||||
error_code&) override
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t
|
||||
on_chunk_body_impl(
|
||||
std::uint64_t,
|
||||
string_view,
|
||||
error_code&) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
on_finish_impl(error_code& ec) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<bool isRequest, class Body, class Fields>
|
||||
struct bench_parser : basic_parser<
|
||||
isRequest, bench_parser<isRequest, Body, Fields>>
|
||||
struct bench_parser : basic_parser<isRequest>
|
||||
{
|
||||
using mutable_buffers_type =
|
||||
net::mutable_buffer;
|
||||
|
||||
void
|
||||
on_request_impl(verb, string_view,
|
||||
string_view, int, error_code& ec)
|
||||
string_view, int, error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
}
|
||||
|
||||
void
|
||||
on_response_impl(int,
|
||||
string_view,
|
||||
int, error_code& ec)
|
||||
string_view, int, error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
}
|
||||
|
||||
void
|
||||
on_field_impl(field,
|
||||
string_view, string_view, error_code& ec)
|
||||
string_view, string_view, error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
}
|
||||
|
||||
void
|
||||
on_header_impl(error_code& ec)
|
||||
on_header_impl(error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
}
|
||||
|
||||
void
|
||||
on_body_init_impl(
|
||||
boost::optional<std::uint64_t> const&,
|
||||
error_code& ec)
|
||||
error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
}
|
||||
|
||||
std::size_t
|
||||
on_body_impl(string_view s, error_code& ec)
|
||||
on_body_impl(
|
||||
string_view s, error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
return s.size();
|
||||
}
|
||||
|
||||
void
|
||||
on_chunk_header_impl(std::uint64_t,
|
||||
string_view, error_code& ec)
|
||||
string_view, error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
}
|
||||
|
||||
std::size_t
|
||||
on_chunk_body_impl(std::uint64_t,
|
||||
string_view s, error_code& ec)
|
||||
string_view s, error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
return s.size();
|
||||
}
|
||||
|
||||
void
|
||||
on_finish_impl(error_code& ec)
|
||||
on_finish_impl(error_code&) override
|
||||
{
|
||||
ec = {};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user