GCC Code Coverage Report


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