GCC Code Coverage Report


Directory: libs/url/
File: src/segments_encoded_base.cpp
Date: 2025-05-15 19:47:38
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 1752 segments_encoded_base::
21 iterator::
22 iterator(
23 1752 detail::path_ref const& ref) noexcept
24 1752 : it_(ref)
25 {
26 1752 }
27
28 1445 segments_encoded_base::
29 iterator::
30 iterator(
31 detail::path_ref const& ref,
32 1445 int) noexcept
33 1445 : it_(ref, 0)
34 {
35 1445 }
36
37 //------------------------------------------------
38 //
39 // segments_encoded_base
40 //
41 //------------------------------------------------
42
43 1310 segments_encoded_base::
44 segments_encoded_base(
45 1310 detail::path_ref const& ref) noexcept
46 1310 : ref_(ref)
47 {
48 1310 }
49
50 //------------------------------------------------
51 //
52 // Observers
53 //
54 //------------------------------------------------
55
56 pct_string_view
57 47 segments_encoded_base::
58 buffer() const noexcept
59 {
60 47 return ref_.buffer();
61 }
62
63 bool
64 387 segments_encoded_base::
65 is_absolute() const noexcept
66 {
67 387 return ref_.buffer().starts_with('/');
68 }
69
70 bool
71 596 segments_encoded_base::
72 empty() const noexcept
73 {
74 596 return ref_.nseg() == 0;
75 }
76
77 std::size_t
78 413 segments_encoded_base::
79 size() const noexcept
80 {
81 413 return ref_.nseg();
82 }
83
84 auto
85 1752 segments_encoded_base::
86 begin() const noexcept ->
87 iterator
88 {
89 1752 return iterator(ref_);
90 }
91
92 auto
93 1445 segments_encoded_base::
94 end() const noexcept ->
95 iterator
96 {
97 1445 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