100.00% Lines (13/13)
100.00% Functions (1/1)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | |||||
| 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) | |||||
| 4 | // | 4 | // | |||||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 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) | 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 7 | // | 7 | // | |||||
| 8 | // Official repository: https://github.com/boostorg/url | 8 | // Official repository: https://github.com/boostorg/url | |||||
| 9 | // | 9 | // | |||||
| 10 | 10 | |||||||
| 11 | #ifndef BOOST_URL_RFC_DETAIL_FRAGMENT_PART_RULE_HPP | 11 | #ifndef BOOST_URL_RFC_DETAIL_FRAGMENT_PART_RULE_HPP | |||||
| 12 | #define BOOST_URL_RFC_DETAIL_FRAGMENT_PART_RULE_HPP | 12 | #define BOOST_URL_RFC_DETAIL_FRAGMENT_PART_RULE_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/rfc/pct_encoded_rule.hpp> | 14 | #include <boost/url/rfc/pct_encoded_rule.hpp> | |||||
| 15 | #include <boost/url/rfc/detail/charsets.hpp> | 15 | #include <boost/url/rfc/detail/charsets.hpp> | |||||
| 16 | #include <boost/url/grammar/parse.hpp> | 16 | #include <boost/url/grammar/parse.hpp> | |||||
| 17 | 17 | |||||||
| 18 | namespace boost { | 18 | namespace boost { | |||||
| 19 | namespace urls { | 19 | namespace urls { | |||||
| 20 | namespace detail { | 20 | namespace detail { | |||||
| 21 | 21 | |||||||
| 22 | /** Rule for fragment-part | 22 | /** Rule for fragment-part | |||||
| 23 | 23 | |||||||
| 24 | @par BNF | 24 | @par BNF | |||||
| 25 | @code | 25 | @code | |||||
| 26 | fragment-part = [ "#" fragment ] | 26 | fragment-part = [ "#" fragment ] | |||||
| 27 | 27 | |||||||
| 28 | fragment = *( pchar / "/" / "?" ) | 28 | fragment = *( pchar / "/" / "?" ) | |||||
| 29 | @endcode | 29 | @endcode | |||||
| 30 | 30 | |||||||
| 31 | @par Specification | 31 | @par Specification | |||||
| 32 | @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.5" | 32 | @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.5" | |||||
| 33 | >3.5. Fragment (rfc3986)</a> | 33 | >3.5. Fragment (rfc3986)</a> | |||||
| 34 | */ | 34 | */ | |||||
| 35 | struct fragment_part_rule_t | 35 | struct fragment_part_rule_t | |||||
| 36 | { | 36 | { | |||||
| 37 | struct value_type | 37 | struct value_type | |||||
| 38 | { | 38 | { | |||||
| 39 | pct_string_view fragment; | 39 | pct_string_view fragment; | |||||
| 40 | bool has_fragment = false; | 40 | bool has_fragment = false; | |||||
| 41 | }; | 41 | }; | |||||
| 42 | 42 | |||||||
| 43 | BOOST_URL_CXX14_CONSTEXPR | 43 | BOOST_URL_CXX14_CONSTEXPR | |||||
| 44 | system::result<value_type> | 44 | system::result<value_type> | |||||
| HITCBC | 45 | 19757 | parse( | 45 | 19761 | parse( | ||
| 46 | char const*& it, | 46 | char const*& it, | |||||
| 47 | char const* end | 47 | char const* end | |||||
| 48 | ) const noexcept | 48 | ) const noexcept | |||||
| 49 | { | 49 | { | |||||
| HITCBC | 50 | 19757 | if( it == end || | 50 | 19761 | if( it == end || | ||
| HITCBC | 51 | 12013 | *it != '#') | 51 | 12013 | *it != '#') | ||
| HITCBC | 52 | 18505 | return {}; | 52 | 18509 | return {}; | ||
| HITCBC | 53 | 1252 | ++it; | 53 | 1252 | ++it; | ||
| HITCBC | 54 | 1252 | auto rv = grammar::parse( | 54 | 1252 | auto rv = grammar::parse( | ||
| HITCBC | 55 | 1252 | it, end, pct_encoded_rule( | 55 | 1252 | it, end, pct_encoded_rule( | ||
| 56 | fragment_chars)); | 56 | fragment_chars)); | |||||
| HITCBC | 57 | 1252 | if(! rv) | 57 | 1252 | if(! rv) | ||
| HITCBC | 58 | 10 | return rv.error(); | 58 | 10 | return rv.error(); | ||
| HITCBC | 59 | 1242 | value_type t; | 59 | 1242 | value_type t; | ||
| HITCBC | 60 | 1242 | t.fragment = *rv; | 60 | 1242 | t.fragment = *rv; | ||
| HITCBC | 61 | 1242 | t.has_fragment = true; | 61 | 1242 | t.has_fragment = true; | ||
| HITCBC | 62 | 1242 | return t; | 62 | 1242 | return t; | ||
| 63 | } | 63 | } | |||||
| 64 | }; | 64 | }; | |||||
| 65 | constexpr fragment_part_rule_t fragment_part_rule{}; | 65 | constexpr fragment_part_rule_t fragment_part_rule{}; | |||||
| 66 | 66 | |||||||
| 67 | } // detail | 67 | } // detail | |||||
| 68 | } // urls | 68 | } // urls | |||||
| 69 | } // boost | 69 | } // boost | |||||
| 70 | 70 | |||||||
| 71 | #endif | 71 | #endif | |||||