src/detail/flat_buffer.cpp
100.0% Lines (27/27)
100.0% List of functions (9/9)
66.7% Branches (4/6)
Functions (9)
Function
Calls
Lines
Branches
Blocks
boost::burl::detail::flat_buffer::empty() const
:22
3767x
100.0%
–
100.0%
boost::burl::detail::flat_buffer::full() const
:29
26x
100.0%
–
100.0%
boost::burl::detail::flat_buffer::size() const
:36
4277x
100.0%
–
100.0%
boost::burl::detail::flat_buffer::capacity() const
:43
894x
100.0%
–
100.0%
boost::burl::detail::flat_buffer::data() const
:50
17x
100.0%
–
100.0%
boost::burl::detail::flat_buffer::prepare() const
:57
158x
100.0%
–
100.0%
boost::burl::detail::flat_buffer::commit(unsigned long)
:64
195x
100.0%
50.0%
75.0%
boost::burl::detail::flat_buffer::consume(unsigned long)
:72
1283x
100.0%
75.0%
80.0%
boost::burl::detail::flat_buffer::clear()
:83
401x
100.0%
–
100.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2026 Mohammad Nejati | |||
| 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/burl | |||
| 8 | // | |||
| 9 | ||||
| 10 | #include <boost/burl/detail/flat_buffer.hpp> | |||
| 11 | ||||
| 12 | #include <boost/assert.hpp> | |||
| 13 | ||||
| 14 | namespace boost | |||
| 15 | { | |||
| 16 | namespace burl | |||
| 17 | { | |||
| 18 | namespace detail | |||
| 19 | { | |||
| 20 | ||||
| 21 | bool | |||
| 22 | 3767x | flat_buffer:: | ||
| 23 | empty() const noexcept | |||
| 24 | { | |||
| 25 | 3767x | return len == 0; | ||
| 26 | } | |||
| 27 | ||||
| 28 | bool | |||
| 29 | 26x | flat_buffer:: | ||
| 30 | full() const noexcept | |||
| 31 | { | |||
| 32 | 26x | return len == cap; | ||
| 33 | } | |||
| 34 | ||||
| 35 | std::size_t | |||
| 36 | 4277x | flat_buffer:: | ||
| 37 | size() const noexcept | |||
| 38 | { | |||
| 39 | 4277x | return len; | ||
| 40 | } | |||
| 41 | ||||
| 42 | std::size_t | |||
| 43 | 894x | flat_buffer:: | ||
| 44 | capacity() const noexcept | |||
| 45 | { | |||
| 46 | 894x | return cap - pos - len; | ||
| 47 | } | |||
| 48 | ||||
| 49 | capy::const_buffer | |||
| 50 | 17x | flat_buffer:: | ||
| 51 | data() const noexcept | |||
| 52 | { | |||
| 53 | 17x | return { ptr + pos, len }; | ||
| 54 | } | |||
| 55 | ||||
| 56 | capy::mutable_buffer | |||
| 57 | 158x | flat_buffer:: | ||
| 58 | prepare() const noexcept | |||
| 59 | { | |||
| 60 | 158x | return { ptr + pos + len, cap - pos - len }; | ||
| 61 | } | |||
| 62 | ||||
| 63 | void | |||
| 64 | 195x | flat_buffer:: | ||
| 65 | commit(std::size_t n) noexcept | |||
| 66 | { | |||
| 67 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
|
195x | BOOST_ASSERT(n <= capacity()); | |
| 68 | 195x | len += n; | ||
| 69 | 195x | } | ||
| 70 | ||||
| 71 | void | |||
| 72 | 1283x | flat_buffer:: | ||
| 73 | consume(std::size_t n) noexcept | |||
| 74 | { | |||
| 75 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1283 times.
|
1283x | BOOST_ASSERT(n <= len); | |
| 76 | 1283x | pos += n; | ||
| 77 | 1283x | len -= n; | ||
| 78 |
2/2✓ Branch 0 taken 873 times.
✓ Branch 1 taken 410 times.
|
1283x | if(len == 0) | |
| 79 | 873x | pos = 0; | ||
| 80 | 1283x | } | ||
| 81 | ||||
| 82 | void | |||
| 83 | 401x | flat_buffer:: | ||
| 84 | clear() noexcept | |||
| 85 | { | |||
| 86 | 401x | pos = 0; | ||
| 87 | 401x | len = 0; | ||
| 88 | 401x | } | ||
| 89 | ||||
| 90 | } // namespace detail | |||
| 91 | } // namespace burl | |||
| 92 | } // namespace boost | |||
| 93 |