LCOV - code coverage report
Current view: top level - libs/http_proto/src/file_body.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 0.0 % 28 0
Test Date: 2025-05-26 06:53:20 Functions: 0.0 % 5 0

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2022 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/http_proto
       8              : //
       9              : 
      10              : #include <boost/http_proto/file_body.hpp>
      11              : #include <boost/assert.hpp>
      12              : 
      13              : namespace boost {
      14              : namespace http_proto {
      15              : 
      16            0 : file_body::
      17              : ~file_body() = default;
      18              : 
      19            0 : file_body::
      20              : file_body(
      21              :     file_body&&) noexcept = default;
      22              : 
      23            0 : file_body::
      24              : file_body(
      25              :     file&& f,
      26            0 :     std::uint64_t size) noexcept
      27            0 :     : f_(std::move(f))
      28            0 :     , n_(size)
      29              : {
      30            0 : }
      31              : 
      32              : auto
      33            0 : file_body::
      34              : on_read(
      35              :     buffers::mutable_buffer b) ->
      36              :         source::results
      37              : {
      38            0 :     source::results rv;
      39            0 :     if(n_ > 0)
      40              :     {
      41              :         std::size_t n;
      42            0 :         if( n_ >= b.size())
      43            0 :             n = b.size();
      44              :         else
      45            0 :             n = static_cast<std::size_t>(n_);
      46            0 :         n = f_.read(
      47              :             b.data(), n, rv.ec);
      48            0 :         rv.bytes = n;
      49            0 :         n_ -= n;
      50              :     }
      51            0 :     rv.finished = n_ == 0;
      52            0 :     return rv;
      53              : }
      54              : 
      55              : auto
      56            0 : file_body::
      57              : on_write(
      58              :     buffers::const_buffer b, bool) ->
      59              :         sink::results
      60              : {
      61            0 :     sink::results rv;
      62            0 :     if(n_ > 0)
      63              :     {
      64              :         std::size_t n;
      65            0 :         if( n_ >= b.size())
      66            0 :             n = b.size();
      67              :         else
      68            0 :             n = static_cast<std::size_t>(n_);
      69            0 :         n = f_.write(
      70              :             b.data(), n, rv.ec);
      71            0 :         rv.bytes = n;
      72            0 :         n_ -= n;
      73              :     }
      74            0 :     return rv;
      75              : }
      76              : 
      77              : } // http_proto
      78              : } // boost
        

Generated by: LCOV version 2.1