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