LCOV - code coverage report
Current view: top level - boost/url/rfc/pct_encoded_rule.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 5 5
Test Date: 2025-11-10 19:06:20 Functions: 100.0 % 5 5

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
       3              : //
       4              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6              : //
       7              : // Official repository: https://github.com/boostorg/url
       8              : //
       9              : 
      10              : #ifndef BOOST_URL_RFC_PCT_ENCODED_RULE_HPP
      11              : #define BOOST_URL_RFC_PCT_ENCODED_RULE_HPP
      12              : 
      13              : #include <boost/url/detail/config.hpp>
      14              : #include <boost/url/error_types.hpp>
      15              : #include <boost/url/pct_string_view.hpp>
      16              : #include <boost/url/grammar/charset.hpp>
      17              : 
      18              : namespace boost {
      19              : namespace urls {
      20              : namespace implementation_defined {
      21              : template<class CharSet>
      22              : struct pct_encoded_rule_t
      23              : {
      24              :     using value_type = pct_string_view;
      25              : 
      26              :     system::result<value_type>
      27              :     parse(
      28              :         char const*& it,
      29              :         char const* end) const noexcept;
      30              : 
      31              :     constexpr
      32         3279 :     pct_encoded_rule_t(
      33              :         CharSet const& cs) noexcept
      34         3279 :         : cs_(cs)
      35              :     {
      36         3279 :     }
      37              : 
      38              : private:
      39              :     CharSet cs_;
      40              : };
      41              : } // implementation_defined
      42              : 
      43              : /** Rule for a string with percent-encoded escapes
      44              : 
      45              :     This function returns a rule which matches
      46              :     a percent-encoded string, permitting characters
      47              :     in the string which are also in the specified
      48              :     character set to be used unescaped.
      49              : 
      50              :     @par Value Type
      51              :     @code
      52              :     using value_type = pct_string_view;
      53              :     @endcode
      54              : 
      55              :     @par Example
      56              :     Rules are used with the function @ref grammar::parse.
      57              :     @code
      58              :     //  pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
      59              : 
      60              :     system::result< pct_string_view > rv = grammar::parse( "Program%20Files", pct_encoded_rule( pchars ) );
      61              :     @endcode
      62              : 
      63              :     @par BNF
      64              :     @code
      65              :     pct-encoded   = "%" HEXDIG HEXDIG
      66              :     @endcode
      67              : 
      68              :     @param cs The character set indicating
      69              :     which characters are allowed without escapes.
      70              :     Any character which is not in this set must be
      71              :     escaped, or else parsing returns an error.
      72              : 
      73              :     @return A rule object.
      74              : 
      75              :     @par Specification
      76              :     @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-2.1">
      77              :         2.1. Percent-Encoding (rfc3986)</a>
      78              : 
      79              :     @see
      80              :         @ref grammar::parse,
      81              :         @ref pchars,
      82              :         @ref pct_string_view.
      83              : */
      84              : template<BOOST_URL_CONSTRAINT(grammar::CharSet) CS>
      85              : constexpr
      86              : auto
      87         3279 : pct_encoded_rule(CS const& cs) noexcept ->
      88              :     implementation_defined::pct_encoded_rule_t<CS>
      89              : {
      90              :     // If an error occurs here it means that
      91              :     // the value of your type does not meet
      92              :     // the requirements. Please check the
      93              :     // documentation!
      94              :     static_assert(
      95              :         grammar::is_charset<CS>::value,
      96              :         "CharSet requirements not met");
      97              : 
      98         3279 :     return implementation_defined::pct_encoded_rule_t<CS>(cs);
      99              : }
     100              : 
     101              : } // urls
     102              : } // boost
     103              : 
     104              : #include <boost/url/rfc/impl/pct_encoded_rule.hpp>
     105              : 
     106              : #endif
        

Generated by: LCOV version 2.1