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