GCC Code Coverage Report


Directory: libs/url/
File: src/segments_encoded_base.cpp
Date: 2025-11-10 19:06:22
Exec Total Coverage
Lines: 27 27 100.0%
Functions: 10 10 100.0%
Branches: 1 2 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
12 #include <boost/url/detail/config.hpp>
13 #include <boost/url/segments_encoded_base.hpp>
14 #include <boost/assert.hpp>
15 #include <ostream>
16
17 namespace boost {
18 namespace urls {
19
20 1761 segments_encoded_base::
21 iterator::
22 iterator(
23 1761 detail::path_ref const& ref) noexcept
24 1761 : it_(ref)
25 {
26 1761 }
27
28 1450 segments_encoded_base::
29 iterator::
30 iterator(
31 detail::path_ref const& ref,
32 1450 int) noexcept
33 1450 : it_(ref, 0)
34 {
35 1450 }
36
37 //------------------------------------------------
38 //
39 // segments_encoded_base
40 //
41 //------------------------------------------------
42
43 1332 segments_encoded_base::
44 segments_encoded_base(
45 1332 detail::path_ref const& ref) noexcept
46 1332 : ref_(ref)
47 {
48 1332 }
49
50 //------------------------------------------------
51 //
52 // Observers
53 //
54 //------------------------------------------------
55
56 pct_string_view
57 58 segments_encoded_base::
58 buffer() const noexcept
59 {
60 58 return ref_.buffer();
61 }
62
63 bool
64 392 segments_encoded_base::
65 is_absolute() const noexcept
66 {
67 392 return ref_.buffer().starts_with('/');
68 }
69
70 bool
71 598 segments_encoded_base::
72 empty() const noexcept
73 {
74 598 return ref_.nseg() == 0;
75 }
76
77 std::size_t
78 414 segments_encoded_base::
79 size() const noexcept
80 {
81 414 return ref_.nseg();
82 }
83
84 auto
85 1761 segments_encoded_base::
86 begin() const noexcept ->
87 iterator
88 {
89 1761 return iterator(ref_);
90 }
91
92 auto
93 1450 segments_encoded_base::
94 end() const noexcept ->
95 iterator
96 {
97 1450 return iterator(ref_, 0);
98 }
99
100 //------------------------------------------------
101
102 std::ostream&
103 15 operator<<(
104 std::ostream& os,
105 segments_encoded_base const& ps)
106 {
107
1/2
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
15 os << ps.buffer();
108 15 return os;
109 }
110
111 } // urls
112 } // boost
113
114