GCC Code Coverage Report


Directory: libs/url/
File: boost/url/impl/segments_encoded_base.hpp
Date: 2024-03-13 19:32:03
Exec Total Coverage
Lines: 31 31 100.0%
Functions: 11 11 100.0%
Branches: 2 4 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3 // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
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/boostorg/url
9 //
10
11 #ifndef BOOST_URL_IMPL_SEGMENTS_ENCODED_BASE_HPP
12 #define BOOST_URL_IMPL_SEGMENTS_ENCODED_BASE_HPP
13
14 #include <boost/url/detail/segments_iter_impl.hpp>
15 #include <boost/assert.hpp>
16
17 namespace boost {
18 namespace urls {
19
20 class segments_encoded_base::iterator
21 {
22 detail::segments_iter_impl it_;
23
24 friend class url_base;
25 friend class segments_encoded_base;
26 friend class segments_encoded_ref;
27
28 iterator(detail::path_ref const&) noexcept;
29 iterator(detail::path_ref const&, int) noexcept;
30
31 387 iterator(
32 detail::segments_iter_impl const& it) noexcept
33 387 : it_(it)
34 {
35 387 }
36
37 public:
38 using value_type =
39 segments_encoded_base::value_type;
40 using reference =
41 segments_encoded_base::reference;
42 using pointer = reference;
43 using difference_type = std::ptrdiff_t;
44 using iterator_category =
45 std::bidirectional_iterator_tag;
46
47 iterator() = default;
48 iterator(iterator const&) = default;
49 iterator& operator=(
50 iterator const&) = default;
51
52 reference
53 3839 operator*() const noexcept
54 {
55 3839 return it_.dereference();
56 }
57
58 pointer
59 21 operator->() const noexcept
60 {
61 21 return it_.dereference();
62 }
63
64 iterator&
65 1951 operator++() noexcept
66 {
67 1951 it_.increment();
68 1951 return *this;
69 }
70
71 iterator&
72 1484 operator--() noexcept
73 {
74 1484 it_.decrement();
75 1484 return *this;
76 }
77
78 iterator
79 598 operator++(int) noexcept
80 {
81 598 auto tmp = *this;
82 598 ++*this;
83 598 return tmp;
84 }
85
86 iterator
87 21 operator--(int) noexcept
88 {
89 21 auto tmp = *this;
90 21 --*this;
91 21 return tmp;
92 }
93
94 bool
95 693 operator==(
96 iterator const& other) const noexcept
97 {
98 693 return it_.equal(other.it_);
99 }
100
101 bool
102 3425 operator!=(
103 iterator const& other) const noexcept
104 {
105 3425 return ! it_.equal(other.it_);
106 }
107 };
108
109 //------------------------------------------------
110
111 inline
112 pct_string_view
113 97 segments_encoded_base::
114 front() const noexcept
115 {
116
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
97 BOOST_ASSERT(! empty());
117 97 return *begin();
118 }
119
120 inline
121 pct_string_view
122 16 segments_encoded_base::
123 back() const noexcept
124 {
125
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
16 BOOST_ASSERT(! empty());
126 16 return *--end();
127 }
128
129 } // urls
130 } // boost
131
132 #endif
133