GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/relative_ref_rule.cpp
Date: 2024-02-29 20:02:56
Exec Total Coverage
Lines: 23 24 95.8%
Functions: 1 1 100.0%
Branches: 11 12 91.7%

Line Branch Exec Source
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/url
8 //
9
10 #ifndef BOOST_URL_RFC_IMPL_RELATIVE_REF_RULE_IPP
11 #define BOOST_URL_RFC_IMPL_RELATIVE_REF_RULE_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/rfc/relative_ref_rule.hpp>
15 #include <boost/url/rfc/query_rule.hpp>
16 #include "detail/fragment_part_rule.hpp"
17 #include "detail/query_part_rule.hpp"
18 #include "detail/relative_part_rule.hpp"
19 #include <boost/url/grammar/delim_rule.hpp>
20 #include <boost/url/grammar/tuple_rule.hpp>
21 #include <boost/url/grammar/optional_rule.hpp>
22 #include <boost/url/grammar/parse.hpp>
23
24 namespace boost {
25 namespace urls {
26
27 auto
28 1339 relative_ref_rule_t::
29 parse(
30 char const*& it,
31 char const* const end
32 ) const noexcept ->
33 system::result<value_type>
34 {
35 1339 detail::url_impl u(detail::url_impl::from::string);
36 1339 u.cs_ = it;
37
38 // relative-part
39 {
40 auto rv = grammar::parse(
41 it, end,
42 1339 detail::relative_part_rule);
43
2/2
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 1297 times.
1339 if(! rv)
44 42 return rv.error();
45
2/2
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 1054 times.
1297 if(rv->has_authority)
46 243 u.apply_authority(rv->authority);
47 1297 u.apply_path(
48 1297 rv->path, rv->segment_count);
49 }
50
51 // [ "?" query ]
52 {
53 auto rv = grammar::parse(
54 1297 it, end, detail::query_part_rule);
55
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1297 times.
1297 if(! rv)
56 return rv.error();
57
2/2
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 1078 times.
1297 if(rv->has_query)
58 {
59 // map "?" to { {} }
60 219 u.apply_query(
61 219 rv->query,
62 219 rv->count +
63 219 rv->query.empty());
64 }
65 }
66
67 // [ "#" fragment ]
68 {
69 auto rv = grammar::parse(
70 1297 it, end, detail::fragment_part_rule);
71
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1296 times.
1297 if(! rv)
72 1 return rv.error();
73
2/2
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1237 times.
1296 if(rv->has_fragment)
74 59 u.apply_frag(rv->fragment);
75 }
76
77 1296 return u.construct();
78 }
79
80 } // urls
81 } // boost
82
83 #endif
84