GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/uri_rule.cpp
Date: 2024-03-15 19:37:09
Exec Total Coverage
Lines: 32 32 100.0%
Functions: 1 1 100.0%
Branches: 14 14 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
11 #include <boost/url/detail/config.hpp>
12 #include <boost/url/rfc/uri_rule.hpp>
13 #include <boost/url/rfc/query_rule.hpp>
14 #include "detail/fragment_part_rule.hpp"
15 #include "detail/hier_part_rule.hpp"
16 #include "detail/query_part_rule.hpp"
17 #include "detail/scheme_rule.hpp"
18 #include <boost/url/grammar/delim_rule.hpp>
19 #include <boost/url/grammar/tuple_rule.hpp>
20 #include <boost/url/grammar/optional_rule.hpp>
21 #include <boost/url/grammar/parse.hpp>
22
23 namespace boost {
24 namespace urls {
25
26 auto
27 3400 uri_rule_t::
28 parse(
29 char const*& it,
30 char const* const end
31 ) const noexcept ->
32 system::result<value_type>
33 {
34 3400 detail::url_impl u(detail::url_impl::from::string);
35 3400 u.cs_ = it;
36
37 // scheme
38 {
39 auto rv = grammar::parse(
40 it, end,
41 3400 grammar::tuple_rule(
42 3400 detail::scheme_rule(),
43 3400 grammar::squelch(
44 3400 grammar::delim_rule(':'))));
45
2/2
✓ Branch 1 taken 1160 times.
✓ Branch 2 taken 2240 times.
3400 if(! rv)
46 1160 return rv.error();
47 2240 u.apply_scheme(rv->scheme);
48 }
49
50 // hier_part
51 {
52 auto rv = grammar::parse(
53 it, end,
54 2240 detail::hier_part_rule);
55
2/2
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 2205 times.
2240 if(! rv)
56 35 return rv.error();
57
2/2
✓ Branch 1 taken 1436 times.
✓ Branch 2 taken 769 times.
2205 if(rv->has_authority)
58 1436 u.apply_authority(rv->authority);
59 2205 u.apply_path(
60 2205 rv->path,
61 2205 rv->segment_count);
62 }
63
64 // [ "?" query ]
65 {
66 auto rv = grammar::parse(
67 2205 it, end, detail::query_part_rule);
68
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2204 times.
2205 if(! rv)
69 1 return rv.error();
70
2/2
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 2012 times.
2204 if(rv->has_query)
71 {
72 // map "?" to { {} }
73 192 u.apply_query(
74 192 rv->query,
75 192 rv->count +
76 192 rv->query.empty());
77 }
78 }
79
80 // [ "#" fragment ]
81 {
82 auto rv = grammar::parse(
83 2204 it, end, detail::fragment_part_rule);
84
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2203 times.
2204 if(! rv)
85 1 return rv.error();
86
2/2
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 2052 times.
2203 if(rv->has_fragment)
87 151 u.apply_frag(rv->fragment);
88 }
89
90 2203 return u.construct();
91 }
92
93 } // urls
94 } // boost
95
96