include/boost/url/rfc/impl/absolute_uri_rule.hpp
96.8% Lines (30/31)
100.0% Functions (2/2)
90.0% Branches (9/10)
include/boost/url/rfc/impl/absolute_uri_rule.hpp
| Line | Branch | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | ||
| 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | ||
| 4 | // | ||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 7 | // | ||
| 8 | // Official repository: https://github.com/boostorg/url | ||
| 9 | // | ||
| 10 | |||
| 11 | #ifndef BOOST_URL_RFC_IMPL_ABSOLUTE_URI_RULE_HPP | ||
| 12 | #define BOOST_URL_RFC_IMPL_ABSOLUTE_URI_RULE_HPP | ||
| 13 | |||
| 14 | #include <boost/url/detail/config.hpp> | ||
| 15 | #include <boost/url/url_view.hpp> | ||
| 16 | #include <boost/url/grammar/delim_rule.hpp> | ||
| 17 | #include <boost/url/grammar/tuple_rule.hpp> | ||
| 18 | #include <boost/url/grammar/optional_rule.hpp> | ||
| 19 | #include <boost/url/grammar/parse.hpp> | ||
| 20 | #include <boost/url/rfc/detail/hier_part_rule.hpp> | ||
| 21 | #include <boost/url/rfc/detail/query_part_rule.hpp> | ||
| 22 | #include <boost/url/rfc/detail/scheme_rule.hpp> | ||
| 23 | |||
| 24 | namespace boost { | ||
| 25 | namespace urls { | ||
| 26 | |||
| 27 | inline BOOST_URL_CXX20_CONSTEXPR | ||
| 28 | auto | ||
| 29 | 29 | implementation_defined::absolute_uri_rule_t:: | |
| 30 | parse( | ||
| 31 | char const*& it, | ||
| 32 | char const* const end | ||
| 33 | ) const noexcept -> | ||
| 34 | system::result<value_type> | ||
| 35 | { | ||
| 36 | 29 | detail::url_impl u(detail::url_impl::from::string); | |
| 37 | 29 | u.cs_ = it; | |
| 38 | |||
| 39 | // scheme | ||
| 40 | { | ||
| 41 | 29 | auto rv = grammar::parse( | |
| 42 | it, end, | ||
| 43 | 29 | grammar::tuple_rule( | |
| 44 | 29 | detail::scheme_rule(), | |
| 45 | 29 | grammar::squelch( | |
| 46 | 29 | grammar::delim_rule(':')))); | |
| 47 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 26 times.
|
29 | if(! rv) |
| 48 | 3 | return rv.error(); | |
| 49 | 26 | u.apply_scheme(rv->scheme); | |
| 50 | } | ||
| 51 | |||
| 52 | // hier_part | ||
| 53 | { | ||
| 54 | auto rv = grammar::parse( | ||
| 55 | 26 | it, end, detail::hier_part_rule); | |
| 56 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 25 times.
|
26 | if(! rv) |
| 57 | 1 | return rv.error(); | |
| 58 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 2 taken 6 times.
|
25 | if(rv->has_authority) |
| 59 | 19 | u.apply_authority(rv->authority); | |
| 60 | 25 | u.apply_path( | |
| 61 | 25 | rv->path, | |
| 62 | 25 | rv->segment_count); | |
| 63 | 26 | } | |
| 64 | |||
| 65 | // [ "?" query ] | ||
| 66 | { | ||
| 67 | 25 | auto rv = grammar::parse( | |
| 68 | it, end, detail::query_part_rule); | ||
| 69 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
|
25 | if(! rv) |
| 70 | ✗ | return rv.error(); | |
| 71 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 2 taken 12 times.
|
25 | if(rv->has_query) |
| 72 | { | ||
| 73 | 13 | u.apply_query( | |
| 74 | 13 | rv->query, | |
| 75 | 13 | rv->count); | |
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | 25 | return u.construct(); | |
| 80 | } | ||
| 81 | |||
| 82 | inline BOOST_URL_CXX20_CONSTEXPR | ||
| 83 | system::result<url_view> | ||
| 84 | 3 | parse_absolute_uri( | |
| 85 | core::string_view s) | ||
| 86 | { | ||
| 87 | 3 | return grammar::parse( | |
| 88 | 3 | s, absolute_uri_rule); | |
| 89 | } | ||
| 90 | |||
| 91 | } // urls | ||
| 92 | } // boost | ||
| 93 | |||
| 94 | |||
| 95 | #endif | ||
| 96 |