GCC Code Coverage Report


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