libs/http/src/detail/filter.hpp
0.0% Lines (0/3)
0.0% Functions (0/2)
-% Branches (0/0)
libs/http/src/detail/filter.hpp
| Line | Hits | Source Code |
|---|---|---|
| 1 | // | |
| 2 | // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com) | |
| 3 | // Copyright (c) 2024 Mohammad Nejati | |
| 4 | // | |
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
| 7 | // | |
| 8 | // Official repository: https://github.com/cppalliance/http | |
| 9 | // | |
| 10 | ||
| 11 | #ifndef BOOST_HTTP_DETAIL_FILTER_HPP | |
| 12 | #define BOOST_HTTP_DETAIL_FILTER_HPP | |
| 13 | ||
| 14 | #include <boost/capy/buffers/buffer_pair.hpp> | |
| 15 | #include <boost/capy/buffers/slice.hpp> | |
| 16 | #include <boost/core/span.hpp> | |
| 17 | #include <boost/system/error_code.hpp> | |
| 18 | ||
| 19 | namespace boost { | |
| 20 | namespace http { | |
| 21 | namespace detail { | |
| 22 | ||
| 23 | /** Base class for all filters | |
| 24 | */ | |
| 25 | class filter | |
| 26 | { | |
| 27 | public: | |
| 28 | ✗ | virtual ~filter() = default; |
| 29 | ||
| 30 | /** The results of processing the filter. | |
| 31 | */ | |
| 32 | struct results | |
| 33 | { | |
| 34 | /** The error, if any occurred. | |
| 35 | */ | |
| 36 | system::error_code ec; | |
| 37 | ||
| 38 | /** The number of bytes produced in the output. | |
| 39 | ||
| 40 | This may be less than the total number | |
| 41 | of bytes available for writing in the | |
| 42 | destination buffers. | |
| 43 | */ | |
| 44 | std::size_t out_bytes = 0; | |
| 45 | ||
| 46 | /** The number of bytes consumed from the input. | |
| 47 | ||
| 48 | This may be less than the total number | |
| 49 | of bytes available for reading in the | |
| 50 | source buffers. | |
| 51 | */ | |
| 52 | std::size_t in_bytes = 0; | |
| 53 | ||
| 54 | /** True if the output buffer is too | |
| 55 | small to make progress. | |
| 56 | ||
| 57 | This can only happen in deflate operation. | |
| 58 | */ | |
| 59 | bool out_short = false; | |
| 60 | ||
| 61 | /** True if there will be no more output. | |
| 62 | */ | |
| 63 | bool finished = false; | |
| 64 | }; | |
| 65 | ||
| 66 | results | |
| 67 | process( | |
| 68 | capy::slice_of< | |
| 69 | boost::span<const capy::mutable_buffer>> out, | |
| 70 | capy::const_buffer_pair in, | |
| 71 | bool more); | |
| 72 | ||
| 73 | protected: | |
| 74 | virtual | |
| 75 | std::size_t | |
| 76 | ✗ | min_out_buffer() const noexcept |
| 77 | { | |
| 78 | ✗ | return 0; |
| 79 | } | |
| 80 | ||
| 81 | virtual | |
| 82 | results | |
| 83 | do_process( | |
| 84 | capy::mutable_buffer, | |
| 85 | capy::const_buffer, | |
| 86 | bool) noexcept = 0; | |
| 87 | }; | |
| 88 | ||
| 89 | } // detail | |
| 90 | } // http | |
| 91 | } // boost | |
| 92 | ||
| 93 | #endif | |
| 94 |