LCOV - code coverage report
Current view: top level - url/grammar - not_empty_rule.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 5 5
Test Date: 2026-02-25 21:00:01 Functions: 100.0 % 2 2

           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_GRAMMAR_NOT_EMPTY_RULE_HPP
      12                 : #define BOOST_URL_GRAMMAR_NOT_EMPTY_RULE_HPP
      13                 : 
      14                 : #include <boost/url/detail/config.hpp>
      15                 : #include <boost/url/error_types.hpp>
      16                 : #include <boost/url/grammar/type_traits.hpp>
      17                 : 
      18                 : namespace boost {
      19                 : namespace urls {
      20                 : namespace grammar {
      21                 : 
      22                 : namespace implementation_defined {
      23                 : template<class R>
      24                 : struct not_empty_rule_t
      25                 : {
      26                 :     using value_type =
      27                 :         typename R::value_type;
      28                 : 
      29                 :     BOOST_URL_CXX20_CONSTEXPR
      30                 :     auto
      31                 :     parse(
      32                 :         char const*& it,
      33                 :         char const* end) const ->
      34                 :             system::result<value_type>;
      35                 : 
      36                 :     constexpr
      37 HIT           1 :     not_empty_rule_t(
      38                 :         R const& r) noexcept
      39               1 :         : r_(r)
      40                 :     {
      41               1 :     }
      42                 : 
      43                 : private:
      44                 :     R r_;
      45                 : };
      46                 : } // implementation_defined
      47                 : 
      48                 : /** Match another rule, if the result is not empty
      49                 : 
      50                 :     This adapts another rule such that
      51                 :     when an empty string is successfully
      52                 :     parsed, the result is an error.
      53                 : 
      54                 :     @par Value Type
      55                 :     @code
      56                 :     using value_type = typename Rule::value_type;
      57                 :     @endcode
      58                 : 
      59                 :     @par Example
      60                 :     Rules are used with the function @ref parse.
      61                 :     @code
      62                 :     system::result< decode_view > rv = parse( "Program%20Files",
      63                 :         not_empty_rule( pct_encoded_rule( unreserved_chars ) ) );
      64                 :     @endcode
      65                 : 
      66                 :     @param r The rule to match
      67                 :     @return The adapted rule
      68                 : 
      69                 :     @see
      70                 :         @ref parse,
      71                 :         @ref pct_encoded_rule,
      72                 :         @ref unreserved_chars.
      73                 : */
      74                 : template<BOOST_URL_CONSTRAINT(Rule) R>
      75                 : auto
      76                 : constexpr
      77               1 : not_empty_rule(
      78                 :     R const& r) ->
      79                 :         implementation_defined::not_empty_rule_t<R>
      80                 : {
      81                 :     // If you get a compile error here it
      82                 :     // means that your rule does not meet
      83                 :     // the type requirements. Please check
      84                 :     // the documentation.
      85                 :     static_assert(
      86                 :         is_rule<R>::value,
      87                 :         "Rule requirements not met");
      88                 : 
      89               1 :     return { r };
      90                 : }
      91                 : 
      92                 : } // grammar
      93                 : } // urls
      94                 : } // boost
      95                 : 
      96                 : #include <boost/url/grammar/impl/not_empty_rule.hpp>
      97                 : 
      98                 : #endif
        

Generated by: LCOV version 2.3