LCOV - code coverage report
Current view: top level - boost/url/grammar/not_empty_rule.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 5 5
Test Date: 2024-08-20 16:05:53 Functions: 100.0 % 2 2

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

Generated by: LCOV version 2.1