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.8 % 31 30
Test Date: 2025-06-18 09:40:26 Functions: 100.0 % 6 6

            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/range.hpp>
      15              : #include <boost/buffers/sans_prefix.hpp>
      16              : 
      17              : namespace boost {
      18              : namespace http_proto {
      19              : namespace detail {
      20              : 
      21              : template<
      22              :     class MutableBufferSequence,
      23              :     class ConstBufferSequence>
      24              : auto
      25        70593 : filter::
      26              : process_impl(
      27              :     MutableBufferSequence const& out,
      28              :     ConstBufferSequence const& in,
      29              :     bool more) ->
      30              :         results
      31              : {
      32        70593 :     results rv;
      33              : 
      34        70593 :     auto it_o = buffers::begin(out);
      35        70593 :     auto it_i = buffers::begin(in);
      36              : 
      37       211779 :     auto ob = [&]() -> buffers::mutable_buffer
      38              :     {
      39        70593 :         if( it_o != buffers::end(out) )
      40        70593 :             return *it_o++;
      41            0 :         return {};
      42        70593 :     }();
      43              : 
      44        70593 :     buffers::const_buffer ib;
      45              : 
      46        63990 :     for(;;)
      47              :     {
      48       268887 :         while( ib.size() == 0 )
      49              :         {
      50       197961 :             if( it_i == buffers::end(in) )
      51              :             {
      52        63657 :                 if( more )
      53        70593 :                     return rv;
      54              : 
      55              :                 // if more == false we return only
      56              :                 // when output buffers are full.
      57          129 :                 break;
      58              :             }
      59              :             else
      60              :             {
      61       134304 :                 ib = *it_i++;
      62              :             }
      63              :         }
      64              : 
      65              :         // empty input buffers may be passed, and
      66              :         // this is intentional and valid.
      67        71055 :         results rs = process_impl(
      68              :             ob,
      69              :             ib,
      70        71055 :             more || it_i != buffers::end(in));
      71              : 
      72        71055 :         rv.out_bytes += rs.out_bytes;
      73        71055 :         rv.in_bytes  += rs.in_bytes;
      74        71055 :         rv.ec         = rs.ec;
      75        71055 :         rv.finished   = rs.finished;
      76              : 
      77        71055 :         if( rv.finished || rv.ec )
      78          194 :             return rv;
      79              : 
      80        70861 :         ob = buffers::sans_prefix(ob, rs.out_bytes);
      81        70861 :         ib = buffers::sans_prefix(ib, rs.in_bytes);
      82              : 
      83        76801 :         while( ob.size() == 0 )
      84              :         {
      85        12811 :             if( it_o == buffers::end(out) )
      86         6871 :                 return rv;
      87         5940 :             ob = *it_o++;
      88              :         }
      89              :     }
      90              : }
      91              : 
      92              : } // detail
      93              : } // http_proto
      94              : } // boost
      95              : 
      96              : #endif
        

Generated by: LCOV version 2.1