include/boost/url/rfc/impl/uri_reference_rule.hpp
100.0% Lines (14/14)
100.0% Functions (2/2)
100.0% Branches (4/4)
include/boost/url/rfc/impl/uri_reference_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_URI_REFERENCE_RULE_HPP | ||
| 12 | #define BOOST_URL_RFC_IMPL_URI_REFERENCE_RULE_HPP | ||
| 13 | |||
| 14 | #include <boost/url/detail/config.hpp> | ||
| 15 | #include <boost/url/url_view.hpp> | ||
| 16 | #include <boost/url/rfc/uri_rule.hpp> | ||
| 17 | #include <boost/url/rfc/relative_ref_rule.hpp> | ||
| 18 | #include <boost/url/grammar/error.hpp> | ||
| 19 | #include <boost/url/grammar/parse.hpp> | ||
| 20 | |||
| 21 | namespace boost { | ||
| 22 | namespace urls { | ||
| 23 | |||
| 24 | inline BOOST_URL_CXX20_CONSTEXPR | ||
| 25 | auto | ||
| 26 | 2637 | implementation_defined::uri_reference_rule_t:: | |
| 27 | parse( | ||
| 28 | char const*& it, | ||
| 29 | char const* const end | ||
| 30 | ) const noexcept -> | ||
| 31 | system::result<value_type> | ||
| 32 | { | ||
| 33 | // Try URI first, then relative-ref. | ||
| 34 | // Both return url_view, so no variant needed. | ||
| 35 | 2637 | auto const it0 = it; | |
| 36 | 2637 | auto rv = grammar::parse( | |
| 37 | it, end, uri_rule); | ||
| 38 |
2/2✓ Branch 1 taken 1434 times.
✓ Branch 2 taken 1203 times.
|
2637 | if(rv) |
| 39 | 1434 | return *rv; | |
| 40 | 1203 | it = it0; | |
| 41 | 1203 | rv = grammar::parse( | |
| 42 | 1203 | it, end, relative_ref_rule); | |
| 43 |
2/2✓ Branch 1 taken 1163 times.
✓ Branch 2 taken 40 times.
|
1203 | if(rv) |
| 44 | 1163 | return *rv; | |
| 45 | 40 | BOOST_URL_CONSTEXPR_RETURN_EC( | |
| 46 | grammar::error::mismatch); | ||
| 47 | } | ||
| 48 | |||
| 49 | inline BOOST_URL_CXX20_CONSTEXPR | ||
| 50 | system::result<url_view> | ||
| 51 | 2636 | parse_uri_reference( | |
| 52 | core::string_view s) | ||
| 53 | { | ||
| 54 | 2636 | return grammar::parse( | |
| 55 | 2636 | s, uri_reference_rule); | |
| 56 | } | ||
| 57 | |||
| 58 | } // urls | ||
| 59 | } // boost | ||
| 60 | |||
| 61 | |||
| 62 | #endif | ||
| 63 |