Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make source a nested type of serializer #74

Closed
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
3 changes: 0 additions & 3 deletions doc/qbk/3.0.concepts.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
[section Sink]
[endsect]

[section Source]
[endsect]

[section Filter]
[endsect]

Expand Down
3 changes: 0 additions & 3 deletions doc/qbk/quickref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<member><link linkend="http_proto.ref.boost__http_proto__serializer">serializer</link></member>
<member><link linkend="http_proto.ref.boost__http_proto__service">service</link></member>
<member><link linkend="http_proto.ref.boost__http_proto__sink">sink</link></member>
<member><link linkend="http_proto.ref.boost__http_proto__source">source</link></member>
<member><link linkend="http_proto.ref.boost__http_proto__string_body">string_body</link></member>
</simplelist>
<bridgehead renderas="sect3">Functions</bridgehead>
Expand All @@ -72,7 +71,6 @@
<bridgehead renderas="sect3">Type Traits</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="http_proto.ref.boost__http_proto__is_sink">is_sink</link></member>
<member><link linkend="http_proto.ref.boost__http_proto__is_source">is_source</link></member>
<member><link linkend="http_proto.ref.boost__http_proto__is_filter">is_filter</link></member>
</simplelist>
<bridgehead renderas="sect3">Constants</bridgehead>
Expand All @@ -96,7 +94,6 @@
<bridgehead renderas="sect3">Concepts</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="http_proto.concepts.sink">Sink</link></member>
<member><link linkend="http_proto.concepts.source">Source</link></member>
<member><link linkend="http_proto.concepts.filter">Filter</link></member>
</simplelist>
</entry>
Expand Down
1 change: 0 additions & 1 deletion include/boost/http_proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <boost/http_proto/response_view.hpp>
#include <boost/http_proto/serializer.hpp>
#include <boost/http_proto/sink.hpp>
#include <boost/http_proto/source.hpp>
#include <boost/http_proto/status.hpp>
#include <boost/http_proto/string_body.hpp>
#include <boost/http_proto/version.hpp>
Expand Down
5 changes: 3 additions & 2 deletions include/boost/http_proto/file_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

#include <boost/http_proto/detail/config.hpp>
#include <boost/http_proto/file.hpp>
#include <boost/http_proto/source.hpp>
#include <boost/http_proto/serializer.hpp>
#include <cstdint>

namespace boost {
namespace http_proto {

class BOOST_SYMBOL_VISIBLE
file_body
: public source
: public serializer::source
{
file f_;
std::uint64_t n_;
Expand All @@ -44,6 +44,7 @@ class BOOST_SYMBOL_VISIBLE
std::uint64_t size =
std::uint64_t(-1)) noexcept;

private:
BOOST_HTTP_PROTO_DECL
results
on_read(
Expand Down
41 changes: 38 additions & 3 deletions include/boost/http_proto/impl/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

#include <boost/http_proto/detail/except.hpp>
#include <boost/buffers/range.hpp>
#include <iterator>
#include <new>
#include <utility>

namespace boost {
namespace http_proto {
Expand Down Expand Up @@ -123,6 +120,44 @@
n };
}

//------------------------------------------------

template<class T>
auto
serializer::
source::
read_impl(
T const& bs) ->
results
{
results rv;
constexpr int SmallArraySize = 16;
buffers::mutable_buffer tmp[SmallArraySize];
auto const tmp_end =
tmp + SmallArraySize;
auto it = buffers::begin(bs);
auto const end_ = buffers::end(bs);
while(it != end_)
{
auto p = tmp;
do
{
*p++ = *it++;
}
while(
p != tmp_end &&
it != end_);
rv += on_read(
buffers::mutable_buffer_span(
tmp, p - tmp));
if(rv.ec.failed())
return rv;

Check warning on line 154 in include/boost/http_proto/impl/serializer.hpp

View check run for this annotation

Codecov / codecov/patch

include/boost/http_proto/impl/serializer.hpp#L154

Added line #L154 was not covered by tests
if(rv.finished)
break;
}
return rv;
}

} // http_proto
} // boost

Expand Down
77 changes: 0 additions & 77 deletions include/boost/http_proto/impl/source.hpp

This file was deleted.

Loading
Loading