LCOV - code coverage report
Current view: top level - src/detail - array_of_const_buffers.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 10 10
Test Date: 2026-06-13 19:44:58 Functions: 100.0 % 5 5

           TLA  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
       9                 : //
      10                 : 
      11                 : #ifndef BOOST_HTTP_DETAIL_ARRAY_OF_BUFFERS_HPP
      12                 : #define BOOST_HTTP_DETAIL_ARRAY_OF_BUFFERS_HPP
      13                 : 
      14                 : #include <boost/assert.hpp>
      15                 : #include <boost/capy/buffers.hpp>
      16                 : 
      17                 : #include <cstdint>
      18                 : 
      19                 : namespace boost {
      20                 : namespace http {
      21                 : namespace detail {
      22                 : 
      23                 : class array_of_const_buffers
      24                 : {
      25                 : public:
      26                 :     using value_type = capy::const_buffer;
      27                 :     using iterator = value_type*;
      28                 :     using const_iterator = iterator;
      29                 : 
      30 HIT         158 :     array_of_const_buffers() = default;
      31                 :     array_of_const_buffers(
      32                 :         array_of_const_buffers const&) = default;
      33                 :     array_of_const_buffers&
      34                 :     operator=(array_of_const_buffers const&) = default;
      35                 : 
      36                 :     array_of_const_buffers(
      37                 :         value_type* p,
      38                 :         std::uint16_t n) noexcept;
      39                 : 
      40                 :     bool
      41            1853 :     empty() const noexcept
      42                 :     {
      43            1853 :         return size_ == 0;
      44                 :     }
      45                 : 
      46                 :     std::uint16_t
      47                 :     size() const noexcept
      48                 :     {
      49                 :         return size_;
      50                 :     }
      51                 : 
      52                 :     std::uint16_t
      53                 :     max_size() const noexcept
      54                 :     {
      55                 :         return cap_;
      56                 :     }
      57                 : 
      58                 :     std::uint16_t
      59                 :     capacity() const noexcept
      60                 :     {
      61                 :         return cap_ - size_;
      62                 :     }
      63                 : 
      64                 :     iterator
      65             534 :     begin() const noexcept
      66                 :     {
      67             534 :         return base_ + pos_;
      68                 :     }
      69                 : 
      70                 :     iterator
      71             266 :     end() const noexcept
      72                 :     {
      73             266 :         return base_ + pos_ + size_;
      74                 :     }
      75                 : 
      76                 :     value_type&
      77             132 :     operator[](
      78                 :         std::uint16_t i) const noexcept
      79                 :     {
      80             132 :         BOOST_ASSERT(i < cap_ - pos_);
      81             132 :         return base_[i + pos_];
      82                 :     }
      83                 : 
      84                 :     void
      85                 :     consume(std::size_t n);
      86                 : 
      87                 :     void
      88                 :     reset(std::uint16_t n) noexcept;
      89                 : 
      90                 :     void
      91                 :     slide_to_front() noexcept;
      92                 : 
      93                 :     void append(value_type) noexcept;
      94                 : 
      95                 : private:
      96                 :     value_type* base_ = nullptr;
      97                 :     std::uint16_t cap_ = 0;
      98                 :     std::uint16_t pos_ = 0;
      99                 :     std::uint16_t size_ = 0;
     100                 : };
     101                 : 
     102                 : } // detail
     103                 : } // http
     104                 : } // boost
     105                 : 
     106                 : #endif
        

Generated by: LCOV version 2.3