LCOV - code coverage report
Current view: top level - url/rfc/impl - query_rule.hpp (source / functions) Coverage Total Hit Missed
Test: coverage_remapped.info Lines: 90.0 % 30 27 3
Test Date: 2026-03-02 22:26:03 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_IMPL_QUERY_RULE_HPP
      12                 : #define BOOST_URL_RFC_IMPL_QUERY_RULE_HPP
      13                 : 
      14                 : #include <boost/url/detail/config.hpp>
      15                 : #include <boost/url/rfc/detail/charsets.hpp>
      16                 : #include <boost/url/error.hpp>
      17                 : #include <boost/url/grammar/hexdig_chars.hpp>
      18                 : 
      19                 : namespace boost {
      20                 : namespace urls {
      21                 : 
      22                 : inline
      23                 : auto
      24 HIT        3157 : implementation_defined::query_rule_t::
      25                 : parse(
      26                 :     char const*& it,
      27                 :     char const* end
      28                 :         ) const noexcept ->
      29                 :     system::result<value_type>
      30                 : {
      31            3157 :     if(it == end)
      32                 :     {
      33                 :         // empty string = 1 param
      34 MIS           0 :         core::string_view str(it, 0);
      35               0 :         return params_encoded_view(
      36               0 :             detail::query_ref(str, 0, 1));
      37                 :     }
      38 HIT        3157 :     auto const it0 = it;
      39            3157 :     std::size_t dn = 0;
      40            3157 :     std::size_t nparam = 1;
      41           24337 :     while(it != end)
      42                 :     {
      43           24175 :         if(*it == '&')
      44                 :         {
      45             428 :             ++nparam;
      46             428 :             ++it;
      47             428 :             continue;
      48                 :         }
      49           23747 :         if(detail::query_chars(*it))
      50                 :         {
      51           20499 :             ++it;
      52           20499 :             continue;
      53                 :         }
      54            3248 :         if(*it == '%')
      55                 :         {
      56             589 :             if(end - it < 3 ||
      57             289 :                 (!grammar::hexdig_chars(it[1]) ||
      58             271 :                  !grammar::hexdig_chars(it[2])))
      59                 :             {
      60                 :                 // missing valid HEXDIG
      61              47 :                 break;
      62                 :             }
      63             253 :             it += 3;
      64             253 :             dn += 2;
      65             253 :             continue;
      66                 :         }
      67                 :         // got reserved character
      68            2948 :         break;
      69                 :     }
      70            3157 :     std::size_t const n(it - it0);
      71            3157 :     core::string_view str(it0, n);
      72            3157 :     return params_encoded_view(
      73            6314 :         detail::query_ref(
      74            3157 :             str, n - dn, nparam));
      75                 : }
      76                 : 
      77                 : } // urls
      78                 : } // boost
      79                 : 
      80                 : 
      81                 : #endif
        

Generated by: LCOV version 2.3