GCC Code Coverage Report


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