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