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

filter is an implementation detail #103

Merged
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
1 change: 0 additions & 1 deletion include/boost/http_proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <boost/http_proto/file_posix.hpp>
#include <boost/http_proto/file_win32.hpp>
#include <boost/http_proto/file_stdio.hpp>
#include <boost/http_proto/filter.hpp>
#include <boost/http_proto/header_limits.hpp>
#include <boost/http_proto/message_base.hpp>
#include <boost/http_proto/message_view_base.hpp>
Expand Down
7 changes: 4 additions & 3 deletions include/boost/http_proto/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ namespace http_proto {

#ifndef BOOST_HTTP_PROTO_DOCS
class parser_service;
class filter;
class request_parser;
class response_parser;
class context;

namespace detail {
class filter;
} // detail
#endif

/** A parser for HTTP/1 messages.
Expand Down Expand Up @@ -419,7 +420,7 @@ class BOOST_SYMBOL_VISIBLE

buffers::circular_buffer* body_buf_ = nullptr;
buffers::any_dynamic_buffer* eb_ = nullptr;
filter* filt_ = nullptr;
detail::filter* filt_ = nullptr;
sink* sink_ = nullptr;

state st_ = state::start;
Expand Down
6 changes: 4 additions & 2 deletions include/boost/http_proto/serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <boost/http_proto/detail/config.hpp>
#include <boost/http_proto/context.hpp>
#include <boost/http_proto/filter.hpp>
#include <boost/http_proto/source.hpp>
#include <boost/http_proto/detail/array_of_buffers.hpp>
#include <boost/http_proto/detail/except.hpp>
Expand All @@ -36,6 +35,9 @@ class response;
class request_view;
class response_view;
class message_view_base;
namespace detail {
class filter;
} // detail
#endif

/** A serializer for HTTP/1 messages
Expand Down Expand Up @@ -334,7 +336,7 @@ class BOOST_SYMBOL_VISIBLE

detail::workspace ws_;
detail::array_of_const_buffers buf_;
filter* filter_ = nullptr;
detail::filter* filter_ = nullptr;
source* src_;
context& ctx_;
buffers::circular_buffer tmp0_;
Expand Down
2 changes: 0 additions & 2 deletions include/boost/http_proto/service/zlib_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

#include <boost/http_proto/detail/config.hpp>
#include <boost/http_proto/context.hpp>
#include <boost/http_proto/filter.hpp>
#include <boost/http_proto/service/service.hpp>
#include <boost/http_proto/detail/workspace.hpp>

namespace boost {
namespace http_proto {
Expand Down
5 changes: 4 additions & 1 deletion src/filter.cpp → src/detail/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
// Official repository: https://github.com/cppalliance/http_proto
//

#include <boost/http_proto/filter.hpp>
#include <boost/buffers/range.hpp>

#include "filter.hpp"

namespace boost {
namespace http_proto {
namespace detail {

auto
filter::
Expand All @@ -38,5 +40,6 @@ on_process(
return rv;
}

} // detail
} // http_proto
} // boost
33 changes: 9 additions & 24 deletions include/boost/http_proto/filter.hpp → src/detail/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
// Official repository: https://github.com/cppalliance/buffers
//

#ifndef BOOST_HTTP_PROTO_FILTER_HPP
#define BOOST_HTTP_PROTO_FILTER_HPP
#ifndef BOOST_HTTP_PROTO_DETAIL_FILTER_HPP
#define BOOST_HTTP_PROTO_DETAIL_FILTER_HPP

#include <boost/http_proto/detail/config.hpp>
#include <boost/http_proto/buffered_base.hpp>
#include <boost/buffers/const_buffer.hpp>
#include <boost/buffers/const_buffer_span.hpp>
#include <boost/buffers/mutable_buffer_span.hpp>
Expand All @@ -21,14 +20,17 @@

namespace boost {
namespace http_proto {
namespace detail {

/** A filter for buffers
*/
class BOOST_HTTP_PROTO_DECL
filter
: public buffered_base
{
friend class serializer;
template<
class T,
std::size_t N>
class unrolled;

public:
/** The results of processing the filter.
Expand Down Expand Up @@ -148,27 +150,10 @@ class BOOST_HTTP_PROTO_DECL
bool more);
};

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

/** Metafunction which determines if T is a filter

@see
@ref source.
*/
#ifdef BOOST_BUFFERS_DOCS
template<class T>
using is_filter = __see_below__;
#else
template<class T>
using is_filter =
std::is_convertible<
typename std::decay<T>::type*,
filter*>;
#endif

} // detail
} // http_proto
} // boost

#include <boost/http_proto/impl/filter.hpp>
#include "impl/filter.hpp"

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// Official repository: https://github.com/cppalliance/http_proto
//

#ifndef BOOST_BUFFERS_IMPL_FILTER_HPP
#define BOOST_BUFFERS_IMPL_FILTER_HPP
#ifndef BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP
#define BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP

#include <boost/http_proto/detail/except.hpp>
#include <boost/buffers/range.hpp>
Expand All @@ -17,53 +17,12 @@

namespace boost {
namespace http_proto {

/*
namespace detail {

template<
class Buffers,
class = void>
struct buffer_traits
{
};

template<class T>
struct buffer_traits<T, void_t<
typename std::enable_if<
is_mutable_buffer_sequence<T>::value
>::type
> >
{
using value_type = mutable_buffer;
using pair_type = mutable_buffer_pair;
using span_type = mutable_buffer_span;
using subspan_type = mutable_buffer_subspan;
};

template<class T>
struct buffer_traits<T, void_t<
typename std::enable_if<
is_const_buffer_sequence<T>::value &&
! is_mutable_buffer_sequence<T>::value
>::type
> >
{
using value_type = const_buffer;
using pair_type = const_buffer_pair;
using span_type = const_buffer_span;
using subspan_type = const_buffer_subspan;
};

} // detail
*/

namespace detail {

template<
class T,
std::size_t N>
class unrolled
class filter::unrolled
{
using value_type = typename
std::conditional<
Expand Down Expand Up @@ -119,8 +78,6 @@ class unrolled
}
};

} // detail

template<
class MutableBuffers,
class ConstBuffers>
Expand All @@ -135,12 +92,13 @@ process_impl(
boost::ignore_unused(more);
results rv;
constexpr int N = 16;
detail::unrolled<ConstBuffers, N> u0(in);
detail::unrolled<MutableBuffers, N> u1(out);
unrolled<ConstBuffers, N> u0(in);
unrolled<MutableBuffers, N> u1(out);

return rv;
}

} // detail
} // http_proto
} // boost

Expand Down
4 changes: 2 additions & 2 deletions src/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

#include <boost/http_proto/serializer.hpp>
#include <boost/http_proto/message_view_base.hpp>
#include <boost/http_proto/filter.hpp>
#include <boost/http_proto/detail/except.hpp>
#include <boost/buffers/algorithm.hpp>
#include <boost/buffers/buffer_copy.hpp>
#include <boost/buffers/buffer_size.hpp>
#include <boost/core/ignore_unused.hpp>
#include <stddef.h>

#include "detail/filter.hpp"
#include "zlib_service.hpp"

namespace boost {
Expand Down Expand Up @@ -271,7 +271,7 @@ prepare() ->
break;
}

auto rs = filter_->on_process(
auto rs = filter_->process(
out, in, more_);

if( rs.finished )
Expand Down
6 changes: 4 additions & 2 deletions src/zlib_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <boost/http_proto/service/zlib_service.hpp>
#include <boost/http_proto/detail/workspace.hpp>

#include "detail/filter.hpp"

namespace boost {
namespace http_proto {
namespace zlib {
Expand All @@ -36,12 +38,12 @@ struct BOOST_HTTP_PROTO_ZLIB_DECL
space_needed() const noexcept = 0;

virtual
filter&
http_proto::detail::filter&
make_deflate_filter(
http_proto::detail::workspace& ws) const = 0;

virtual
filter&
http_proto::detail::filter&
make_gzip_filter(
http_proto::detail::workspace& ws) const = 0;
};
Expand Down
11 changes: 5 additions & 6 deletions src_zlib/service/zlib_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <boost/http_proto/service/zlib_service.hpp>

#include <boost/http_proto/metadata.hpp>
#include <boost/http_proto/detail/workspace.hpp>

#include <boost/assert/source_location.hpp>
#include <boost/buffers/circular_buffer.hpp>
Expand Down Expand Up @@ -265,8 +264,8 @@ void zfree_impl(void* /* opaque */, void* /* addr */)

} // namespace

class BOOST_HTTP_PROTO_ZLIB_DECL
deflate_filter final : public filter
class deflate_filter final
: public http_proto::detail::filter
{
private:
z_stream stream_;
Expand Down Expand Up @@ -335,7 +334,7 @@ init(bool use_gzip)
stream_.avail_in = 0;
}

filter::results
http_proto::detail::filter::results
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto with a trailing return type might make this shorter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deflate_filter is in a different namespace. we need the whole http_proto::detail::filter::results.

deflate_filter::
on_process(
buffers::mutable_buffer out,
Expand Down Expand Up @@ -440,14 +439,14 @@ struct
return 0;
}

filter&
http_proto::detail::filter&
make_deflate_filter(
http_proto::detail::workspace& ws) const override
{
return ws.emplace<deflate_filter>(ws, false);
}

filter&
http_proto::detail::filter&
make_gzip_filter(
http_proto::detail::workspace& ws) const override
{
Expand Down
1 change: 0 additions & 1 deletion test/unit/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ local SOURCES =
file.cpp
file_base.cpp
file_body.cpp
filter.cpp
header_limits.cpp
http_proto.cpp
message_base.cpp
Expand Down
31 changes: 0 additions & 31 deletions test/unit/filter.cpp

This file was deleted.

Loading