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 <boost/url/rfc/detail/fragment_part_rule.hpp> | ||
17 | #include <boost/url/rfc/detail/hier_part_rule.hpp> | ||
18 | #include <boost/url/rfc/detail/query_part_rule.hpp> | ||
19 | #include <boost/url/rfc/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 | 3359 | uri_rule_t:: | |
30 | parse( | ||
31 | char const*& it, | ||
32 | char const* const end | ||
33 | ) const noexcept -> | ||
34 | system::result<value_type> | ||
35 | { | ||
36 | 3359 | detail::url_impl u(detail::url_impl::from::string); | |
37 | 3359 | u.cs_ = it; | |
38 | |||
39 | // scheme | ||
40 | { | ||
41 | auto rv = grammar::parse( | ||
42 | it, end, | ||
43 | 3359 | grammar::tuple_rule( | |
44 | 3359 | detail::scheme_rule(), | |
45 | 3359 | grammar::squelch( | |
46 | 3359 | grammar::delim_rule(':')))); | |
47 |
2/2✓ Branch 1 taken 1151 times.
✓ Branch 2 taken 2208 times.
|
3359 | if(! rv) |
48 | 1151 | return rv.error(); | |
49 | 2208 | u.apply_scheme(rv->scheme); | |
50 | } | ||
51 | |||
52 | // hier_part | ||
53 | { | ||
54 | auto rv = grammar::parse( | ||
55 | it, end, | ||
56 | 2208 | detail::hier_part_rule); | |
57 |
2/2✓ Branch 1 taken 35 times.
✓ Branch 2 taken 2173 times.
|
2208 | if(! rv) |
58 | 35 | return rv.error(); | |
59 |
2/2✓ Branch 1 taken 1412 times.
✓ Branch 2 taken 761 times.
|
2173 | if(rv->has_authority) |
60 | 1412 | u.apply_authority(rv->authority); | |
61 | 2173 | u.apply_path( | |
62 | 2173 | rv->path, | |
63 | 2173 | rv->segment_count); | |
64 | } | ||
65 | |||
66 | // [ "?" query ] | ||
67 | { | ||
68 | auto rv = grammar::parse( | ||
69 | 2173 | it, end, detail::query_part_rule); | |
70 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2172 times.
|
2173 | if(! rv) |
71 | 1 | return rv.error(); | |
72 |
2/2✓ Branch 1 taken 184 times.
✓ Branch 2 taken 1988 times.
|
2172 | if(rv->has_query) |
73 | { | ||
74 | // map "?" to { {} } | ||
75 | 184 | u.apply_query( | |
76 | 184 | rv->query, | |
77 | 184 | rv->count + | |
78 | 184 | rv->query.empty()); | |
79 | } | ||
80 | } | ||
81 | |||
82 | // [ "#" fragment ] | ||
83 | { | ||
84 | auto rv = grammar::parse( | ||
85 | 2172 | it, end, detail::fragment_part_rule); | |
86 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2171 times.
|
2172 | if(! rv) |
87 | 1 | return rv.error(); | |
88 |
2/2✓ Branch 1 taken 143 times.
✓ Branch 2 taken 2028 times.
|
2171 | if(rv->has_fragment) |
89 | 143 | u.apply_frag(rv->fragment); | |
90 | } | ||
91 | |||
92 | 2171 | return u.construct(); | |
93 | } | ||
94 | |||
95 | } // urls | ||
96 | } // boost | ||
97 | |||
98 | #endif | ||
99 |