LCOV - code coverage report
Current view: top level - libs/http_proto/src/detail/array_of_const_buffers.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 34 34
Test Date: 2025-09-21 18:08:14 Functions: 100.0 % 5 5

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
       3              : // Copyright (c) 2025 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              : #include "src/detail/array_of_const_buffers.hpp"
      12              : 
      13              : #include <boost/http_proto/detail/except.hpp>
      14              : 
      15              : #include <boost/buffers/slice.hpp>
      16              : 
      17              : namespace boost {
      18              : namespace http_proto {
      19              : namespace detail {
      20              : 
      21           83 : array_of_const_buffers::
      22              : array_of_const_buffers(
      23              :     value_type* p,
      24           83 :     std::uint16_t capacity) noexcept
      25           83 :     : base_(p)
      26           83 :     , cap_(capacity)
      27           83 :     , pos_(0)
      28           83 :     , size_(0)
      29              : {
      30           83 : }
      31              : 
      32              : void
      33         3789 : array_of_const_buffers::
      34              : consume(std::size_t n)
      35              : {
      36         5842 :     while(size_ > 0)
      37              :     {
      38         3888 :         auto* p = base_ + pos_;
      39         3888 :         if(n < p->size())
      40              :         {
      41         1835 :             buffers::trim_front(*p, n);
      42         1835 :             return;
      43              :         }
      44         2053 :         n -= p->size();
      45         2053 :         ++pos_;
      46         2053 :         --size_;
      47              :     }
      48              : }
      49              : 
      50              : void
      51         1956 : array_of_const_buffers::
      52              : reset(std::uint16_t n) noexcept
      53              : {
      54         1956 :     BOOST_ASSERT(n <= cap_);
      55         1956 :     pos_  = 0;
      56         1956 :     size_ = n;
      57         1956 : }
      58              : 
      59              : void
      60            4 : array_of_const_buffers::
      61              : slide_to_front() noexcept
      62              : {
      63            4 :     auto* p = base_ + pos_; // begin
      64            4 :     auto* e = p + size_; // end
      65            4 :     auto* d = base_; // dest
      66           20 :     while(p < e)
      67           16 :         *d++ = *p++;
      68            4 :     pos_ = 0;
      69            4 : }
      70              : 
      71              : void
      72         2080 : array_of_const_buffers::
      73              : append(value_type buf) noexcept
      74              : {
      75         2080 :     BOOST_ASSERT(size_ < cap_);
      76         2080 :     base_[pos_ + size_] = buf;
      77         2080 :     ++size_;
      78         2080 : }
      79              : 
      80              : } // detail
      81              : } // http_proto
      82              : } // boost
        

Generated by: LCOV version 2.1