LCOV - code coverage report
Current view: top level - boost/http_proto/impl - source.hpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 25 26 96.2 %
Date: 2024-02-07 16:12:48 Functions: 2 2 100.0 %

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2023 Vinnie Falco (vinnie.falco@gmail.com)
       3             : //
       4             : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5             : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6             : //
       7             : // Official repository: https://github.com/cppalliance/buffers
       8             : //
       9             : 
      10             : #ifndef BOOST_BUFFERS_IMPL_SOURCE_HPP
      11             : #define BOOST_BUFFERS_IMPL_SOURCE_HPP
      12             : 
      13             : #include <boost/http_proto/detail/except.hpp>
      14             : #include <boost/buffers/range.hpp>
      15             : #include <boost/buffers/type_traits.hpp>
      16             : #include <boost/assert.hpp>
      17             : 
      18             : namespace boost {
      19             : namespace http_proto {
      20             : 
      21             : inline
      22             : auto
      23          17 : source::
      24             : results::
      25             : operator+=(
      26             :     results const& rv) noexcept ->
      27             :         results&
      28             : {
      29          17 :     BOOST_ASSERT(! ec.failed());
      30          17 :     BOOST_ASSERT(! finished);
      31          17 :     ec = rv.ec;
      32          17 :     bytes += rv.bytes;
      33          17 :     finished = rv.finished;
      34          17 :     return *this;
      35             : }
      36             : 
      37             : //------------------------------------------------
      38             : 
      39             : template<class T>
      40             : auto
      41           4 : source::
      42             : read_impl(
      43             :     T const& bs) ->
      44             :         results
      45             : {
      46           4 :     results rv;
      47           4 :     constexpr int SmallArraySize = 16;
      48           4 :     buffers::mutable_buffer tmp[SmallArraySize];
      49           4 :     auto const tmp_end =
      50             :         tmp + SmallArraySize;
      51           4 :     auto it = buffers::begin(bs);
      52           4 :     auto const end_ = buffers::end(bs);
      53           4 :     while(it != end_)
      54             :     {
      55           4 :         auto p = tmp;
      56           4 :         do
      57             :         {
      58           8 :             *p++ = *it++;
      59             :         }
      60             :         while(
      61           8 :             p != tmp_end &&
      62             :             it != end_);
      63           4 :         rv += on_read(
      64             :             buffers::mutable_buffer_span(
      65           4 :                 tmp, p - tmp));
      66           4 :         if(rv.ec.failed())
      67           0 :             return rv;
      68           4 :         if(rv.finished)
      69           4 :             break;
      70             :     }
      71           4 :     return rv;
      72             : }
      73             : 
      74             : } // http_proto
      75             : } // boost
      76             : 
      77             : #endif

Generated by: LCOV version 1.15