LCOV - code coverage report
Current view: top level - libs/http_proto/src/detail/impl/filter.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 96.4 % 28 27
Test Date: 2024-12-31 05:34:48 Functions: 100.0 % 1 1

            Line data    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_proto
       9              : //
      10              : 
      11              : #ifndef BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP
      12              : #define BOOST_HTTP_PROTO_DETAIL_IMPL_FILTER_HPP
      13              : 
      14              : #include <boost/buffers/algorithm.hpp>
      15              : 
      16              : namespace boost {
      17              : namespace http_proto {
      18              : namespace detail {
      19              : 
      20              : template<
      21              :     class MutableBufferSequence,
      22              :     class ConstBufferSequence>
      23              : auto
      24        19673 : filter::
      25              : process_impl(
      26              :     MutableBufferSequence const& out,
      27              :     ConstBufferSequence const& in,
      28              :     bool more) ->
      29              :         results
      30              : {
      31        19673 :     results rv;
      32        19673 :     auto it_o = buffers::begin(out);
      33        19673 :     auto it_i = buffers::begin(in);
      34              : 
      35        39346 :     if( it_o == buffers::end(out) ||
      36        19673 :         it_i == buffers::end(in) )
      37            0 :         return rv;
      38              : 
      39        19673 :     auto ob = *it_o++;
      40        19673 :     auto ib = *it_i++;
      41        19804 :     for(;;)
      42              :     {
      43              :         // empty buffers may be passed, and this is
      44              :         // intentional and valid.
      45        39477 :         results rs = process_impl(ob, ib, more);
      46              : 
      47        39477 :         rv.out_bytes += rs.out_bytes;
      48        39477 :         rv.in_bytes  += rs.in_bytes;
      49        39477 :         rv.ec         = rs.ec;
      50        39477 :         rv.finished   = rs.finished;
      51              : 
      52        39477 :         if( rv.finished || rv.ec )
      53        19673 :             return rv;
      54              : 
      55        39452 :         ob = buffers::sans_prefix(ob, rs.out_bytes);
      56        39452 :         ib = buffers::sans_prefix(ib, rs.in_bytes);
      57              : 
      58        39452 :         if( ob.size() == 0 )
      59              :         {
      60         2160 :             if( it_o == buffers::end(out) )
      61         1080 :                 return rv;
      62         1080 :             ob = *it_o++;
      63              :         }
      64              : 
      65        38372 :         if( ib.size() == 0 )
      66              :         {
      67        37302 :             if( it_i == buffers::end(in) )
      68              :             {
      69              :                 // if `more == false` we return only
      70              :                 // when `out` buffers are full.
      71        18568 :                 if( more )
      72        18568 :                     return rv;
      73              :             }
      74              :             else
      75              :             {
      76        18734 :                 ib = *it_i++;
      77              :             }
      78              :         }
      79              :     }
      80              : }
      81              : 
      82              : } // detail
      83              : } // http_proto
      84              : } // boost
      85              : 
      86              : #endif
        

Generated by: LCOV version 2.1