LCOV - code coverage report
Current view: top level - url/rfc/detail - fragment_part_rule.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 13 13
Test Date: 2026-02-25 21:00:01 Functions: 100.0 % 1 1

           TLA  Line data    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_DETAIL_FRAGMENT_PART_RULE_HPP
      12                 : #define BOOST_URL_RFC_DETAIL_FRAGMENT_PART_RULE_HPP
      13                 : 
      14                 : #include <boost/url/rfc/pct_encoded_rule.hpp>
      15                 : #include <boost/url/rfc/detail/charsets.hpp>
      16                 : #include <boost/url/grammar/parse.hpp>
      17                 : 
      18                 : namespace boost {
      19                 : namespace urls {
      20                 : namespace detail {
      21                 : 
      22                 : /** Rule for fragment-part
      23                 : 
      24                 :     @par BNF
      25                 :     @code
      26                 :     fragment-part   = [ "#" fragment ]
      27                 : 
      28                 :     fragment        = *( pchar / "/" / "?" )
      29                 :     @endcode
      30                 : 
      31                 :     @par Specification
      32                 :     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.5"
      33                 :         >3.5. Fragment (rfc3986)</a>
      34                 : */
      35                 : struct fragment_part_rule_t
      36                 : {
      37                 :     struct value_type
      38                 :     {
      39                 :         pct_string_view fragment;
      40                 :         bool has_fragment = false;
      41                 :     };
      42                 : 
      43                 :     BOOST_URL_CXX14_CONSTEXPR
      44                 :     system::result<value_type>
      45 HIT        3705 :     parse(
      46                 :         char const*& it,
      47                 :         char const* end
      48                 :             ) const noexcept
      49                 :     {
      50            3705 :         if( it == end ||
      51             418 :             *it != '#')
      52            3459 :             return {};
      53             246 :         ++it;
      54             246 :         auto rv = grammar::parse(
      55             246 :             it, end, pct_encoded_rule(
      56                 :                 fragment_chars));
      57             246 :         if(! rv)
      58               2 :             return rv.error();
      59             244 :         value_type t;
      60             244 :         t.fragment = *rv;
      61             244 :         t.has_fragment = true;
      62             244 :         return t;
      63                 :     }
      64                 : };
      65                 : constexpr fragment_part_rule_t fragment_part_rule{};
      66                 : 
      67                 : } // detail
      68                 : } // urls
      69                 : } // boost
      70                 : 
      71                 : #endif
        

Generated by: LCOV version 2.3