GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/absolute_uri_rule.cpp
Date: 2023-12-15 15:31:49
Exec Total Coverage
Lines: 27 27 100.0%
Functions: 1 1 100.0%
Branches: 10 10 100.0%

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_ABSOLUTE_URI_RULE_IPP
11 #define BOOST_URL_RFC_IMPL_ABSOLUTE_URI_RULE_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/rfc/absolute_uri_rule.hpp>
15 #include <boost/url/grammar/delim_rule.hpp>
16 #include <boost/url/grammar/tuple_rule.hpp>
17 #include <boost/url/grammar/optional_rule.hpp>
18 #include <boost/url/grammar/parse.hpp>
19 #include <boost/url/rfc/detail/hier_part_rule.hpp>
20 #include <boost/url/rfc/detail/query_part_rule.hpp>
21 #include <boost/url/rfc/detail/scheme_rule.hpp>
22 #include <utility>
23
24 namespace boost {
25 namespace urls {
26
27 auto
28 28 absolute_uri_rule_t::
29 parse(
30 char const*& it,
31 char const* const end
32 ) const noexcept ->
33 system::result<value_type>
34 {
35 28 detail::url_impl u(detail::url_impl::from::string);
36 28 u.cs_ = it;
37
38 // scheme
39 {
40 auto rv = grammar::parse(
41 it, end,
42 28 grammar::tuple_rule(
43 28 detail::scheme_rule(),
44 28 grammar::squelch(
45 28 grammar::delim_rule(':'))));
46
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 25 times.
28 if(! rv)
47 3 return rv.error();
48 25 u.apply_scheme(rv->scheme);
49 }
50
51 // hier_part
52 {
53 auto rv = grammar::parse(
54 25 it, end, detail::hier_part_rule);
55
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 24 times.
25 if(! rv)
56 1 return rv.error();
57
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
24 if(rv->has_authority)
58 18 u.apply_authority(rv->authority);
59 24 u.apply_path(
60 24 rv->path,
61 24 rv->segment_count);
62 }
63
64 // [ "?" query ]
65 {
66 auto rv = grammar::parse(
67 24 it, end, detail::query_part_rule);
68
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 23 times.
24 if(! rv)
69 1 return rv.error();
70
2/2
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 12 times.
23 if(rv->has_query)
71 {
72 // map "?" to { {} }
73 11 u.apply_query(
74 11 rv->query,
75 11 rv->count +
76 11 rv->query.empty());
77 }
78 }
79
80 23 return u.construct();
81 }
82
83 } // urls
84 } // boost
85
86 #endif
87