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

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
       3                 : // Copyright (c) 2022 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_PCT_ENCODED_RULE_HPP
      12                 : #define BOOST_URL_RFC_IMPL_PCT_ENCODED_RULE_HPP
      13                 : 
      14                 : #include <boost/url/grammar/charset.hpp>
      15                 : #include <boost/url/grammar/error.hpp>
      16                 : #include <boost/url/grammar/hexdig_chars.hpp>
      17                 : 
      18                 : namespace boost {
      19                 : namespace urls {
      20                 : 
      21                 : namespace detail {
      22                 : 
      23                 : template<class CharSet>
      24                 : BOOST_URL_CXX20_CONSTEXPR
      25                 : auto
      26 HIT        9992 : parse_encoded(
      27                 :     char const*& it,
      28                 :     char const* end,
      29                 :     CharSet const& cs) noexcept ->
      30                 :         system::result<pct_string_view>
      31                 : {
      32            9992 :     auto const start = it;
      33            9992 :     std::size_t n = 0;
      34             356 :     for(;;)
      35                 :     {
      36           10348 :         auto it0 = it;
      37           10348 :         it = grammar::find_if_not(
      38                 :             it0, end, cs);
      39           10348 :         n += it - it0;
      40           10348 :         if(it == end || *it != '%')
      41                 :             break;
      42             457 :         bool at_end = false;
      43             212 :         for(;;)
      44                 :         {
      45             669 :             ++it;
      46             669 :             if(it == end)
      47                 :             {
      48                 :                 // expected HEXDIG
      49              15 :                 BOOST_URL_CONSTEXPR_RETURN_EC(
      50                 :                     grammar::error::invalid);
      51                 :             }
      52             654 :             auto r = grammar::hexdig_value(*it);
      53             654 :             if(r < 0)
      54                 :             {
      55                 :                 // expected HEXDIG
      56              13 :                 BOOST_URL_CONSTEXPR_RETURN_EC(
      57                 :                     grammar::error::invalid);
      58                 :             }
      59             641 :             ++it;
      60             641 :             if(it == end)
      61                 :             {
      62                 :                 // expected HEXDIG
      63               5 :                 BOOST_URL_CONSTEXPR_RETURN_EC(
      64                 :                     grammar::error::invalid);
      65                 :             }
      66             636 :             r = grammar::hexdig_value(*it);
      67             636 :             if(r < 0)
      68                 :             {
      69                 :                 // expected HEXDIG
      70               8 :                 BOOST_URL_CONSTEXPR_RETURN_EC(
      71                 :                     grammar::error::invalid);
      72                 :             }
      73             628 :             ++n;
      74             628 :             ++it;
      75             628 :             if(it == end)
      76                 :             {
      77              60 :                 at_end = true;
      78              60 :                 break;
      79                 :             }
      80             568 :             if(*it != '%')
      81             356 :                 break;
      82                 :         }
      83             416 :         if(at_end)
      84              60 :             break;
      85                 :     }
      86            9951 :     return make_pct_string_view_unsafe(
      87            9951 :         start, it - start, n);
      88                 : }
      89                 : 
      90                 : } // detail
      91                 : 
      92                 : //------------------------------------------------
      93                 : 
      94                 : template<class CharSet>
      95                 : BOOST_URL_CXX20_CONSTEXPR
      96                 : auto
      97            9992 : implementation_defined::pct_encoded_rule_t<CharSet>::
      98                 : parse(
      99                 :     char const*& it,
     100                 :     char const* end) const noexcept ->
     101                 :         system::result<value_type>
     102                 : {
     103            9992 :     return detail::parse_encoded(
     104            9992 :         it, end, cs_);
     105                 : }
     106                 : 
     107                 : } // urls
     108                 : } // boost
     109                 : 
     110                 : #endif
        

Generated by: LCOV version 2.3