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 16 0.0 %
Date: 2023-03-01 04:48:12 Functions: 0 2 0.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             : #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/buffers/algorithm.hpp>
      15             : #include <boost/assert.hpp>
      16             : 
      17             : namespace boost {
      18             : namespace http_proto {
      19             : 
      20             : file_body::
      21             : ~file_body() = default;
      22             : 
      23             : file_body::
      24             : file_body(
      25             :     file_body&&) noexcept = default;
      26             : 
      27           0 : file_body::
      28             : file_body(
      29             :     file&& f,
      30           0 :     std::uint64_t size) noexcept
      31           0 :     : f_(std::move(f))
      32           0 :     , n_(size)
      33             : {
      34           0 : }
      35             : 
      36             : auto
      37           0 : file_body::
      38             : on_read(
      39             :     buffers::mutable_buffer b) ->
      40             :         results
      41             : {
      42           0 :     results rv;
      43           0 :     if(n_ > 0)
      44             :     {
      45             :         std::size_t n;
      46           0 :         if( n_ >= b.size())
      47           0 :             n = b.size();
      48             :         else
      49           0 :             n = n_;
      50           0 :         n = f_.read(
      51             :             b.data(), n, rv.ec);
      52           0 :         rv.bytes = n;
      53           0 :         n_ -= n;
      54             :     }
      55           0 :     rv.finished = n_ == 0;
      56           0 :     return rv;
      57             : }
      58             : 
      59             : } // http_proto
      60             : } // boost
      61             : 
      62             : #endif

Generated by: LCOV version 1.15