GCC Code Coverage Report


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