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 <boost/url/rfc/detail/fragment_part_rule.hpp> | ||
17 | #include <boost/url/rfc/detail/query_part_rule.hpp> | ||
18 | #include <boost/url/rfc/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 | 1331 | 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 | 1331 | detail::url_impl u(detail::url_impl::from::string); | |
36 | 1331 | u.cs_ = it; | |
37 | |||
38 | // relative-part | ||
39 | { | ||
40 | auto rv = grammar::parse( | ||
41 | it, end, | ||
42 | 1331 | detail::relative_part_rule); | |
43 |
2/2✓ Branch 1 taken 42 times.
✓ Branch 2 taken 1289 times.
|
1331 | if(! rv) |
44 | 42 | return rv.error(); | |
45 |
2/2✓ Branch 1 taken 243 times.
✓ Branch 2 taken 1046 times.
|
1289 | if(rv->has_authority) |
46 | 243 | u.apply_authority(rv->authority); | |
47 | 1289 | u.apply_path( | |
48 | 1289 | rv->path, rv->segment_count); | |
49 | } | ||
50 | |||
51 | // [ "?" query ] | ||
52 | { | ||
53 | auto rv = grammar::parse( | ||
54 | 1289 | it, end, detail::query_part_rule); | |
55 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1289 times.
|
1289 | if(! rv) |
56 | ✗ | return rv.error(); | |
57 |
2/2✓ Branch 1 taken 219 times.
✓ Branch 2 taken 1070 times.
|
1289 | 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 | 1289 | it, end, detail::fragment_part_rule); | |
71 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1288 times.
|
1289 | if(! rv) |
72 | 1 | return rv.error(); | |
73 |
2/2✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1229 times.
|
1288 | if(rv->has_fragment) |
74 | 59 | u.apply_frag(rv->fragment); | |
75 | } | ||
76 | |||
77 | 1288 | return u.construct(); | |
78 | } | ||
79 | |||
80 | } // urls | ||
81 | } // boost | ||
82 | |||
83 | #endif | ||
84 |