LCOV - code coverage report
Current view: top level - http_proto/impl - file_body.ipp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 0 20 0.0 %
Date: 2023-01-15 07:18:31 Functions: 0 2 0.0 %

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot 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             : #ifndef BOOST_HTTP_PROTO_IMPL_FILE_BODY_IPP
      11             : #define BOOST_HTTP_PROTO_IMPL_FILE_BODY_IPP
      12             : 
      13             : #include <boost/http_proto/file_body.hpp>
      14             : #include <boost/assert.hpp>
      15             : 
      16             : namespace boost {
      17             : namespace http_proto {
      18             : 
      19             : file_body::
      20             : ~file_body() = default;
      21             : 
      22             : file_body::
      23             : file_body(
      24             :     file_body&&) noexcept = default;
      25             : 
      26           0 : file_body::
      27             : file_body(
      28             :     file&& f,
      29           0 :     std::uint64_t size) noexcept
      30           0 :     : f_(std::move(f))
      31           0 :     , n_(size)
      32             : {
      33           0 : }
      34             : 
      35             : auto
      36           0 : file_body::
      37             : read(
      38             :     mutable_buffers_pair dest) ->
      39             :         results
      40             : {
      41           0 :     results rv;
      42           0 :     for(auto const& mb : dest)
      43             :     {
      44           0 :         if(n_ == 0)
      45           0 :             break;
      46             :         std::size_t n;
      47           0 :         if( n_ >= mb.size())
      48           0 :             n = mb.size();
      49             :         else
      50           0 :             n = n_;
      51           0 :         n = f_.read(
      52             :             mb.data(), n, rv.ec);
      53           0 :         rv.bytes += n;
      54           0 :         n_ -= n;
      55           0 :         rv.more = n_ > 0;
      56           0 :         if(rv.ec.failed())
      57           0 :             return rv;
      58             :     }
      59           0 :     return rv;
      60             : }
      61             : 
      62             : } // http_proto
      63             : } // boost
      64             : 
      65             : #endif

Generated by: LCOV version 1.15