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-07-10 02:48:26 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              : template<class R>
      53              : struct not_empty_rule_t
      54              : {
      55              :     using value_type =
      56              :         typename R::value_type;
      57              : 
      58              :     auto
      59              :     parse(
      60              :         char const*& it,
      61              :         char const* end) const ->
      62              :             system::result<value_type>;
      63              : 
      64              :     template<class R_>
      65              :     friend
      66              :     constexpr
      67              :     auto
      68              :     not_empty_rule(
      69              :         R_ const& r) ->
      70              :             not_empty_rule_t<R_>;
      71              : 
      72              : private:
      73              :     constexpr
      74            1 :     not_empty_rule_t(
      75              :         R const& r) noexcept
      76            1 :         : r_(r)
      77              :     {
      78            1 :     }
      79              : 
      80              :     R r_;
      81              : };
      82              : 
      83              : template<class Rule>
      84              : auto
      85              : constexpr
      86            1 : not_empty_rule(
      87              :     Rule const& r) ->
      88              :         not_empty_rule_t<Rule>
      89              : {
      90              :     // If you get a compile error here it
      91              :     // means that your rule does not meet
      92              :     // the type requirements. Please check
      93              :     // the documentation.
      94              :     static_assert(
      95              :         is_rule<Rule>::value,
      96              :         "Rule requirements not met");
      97              : 
      98            1 :     return { r };
      99              : }
     100              : #endif
     101              : 
     102              : } // grammar
     103              : } // urls
     104              : } // boost
     105              : 
     106              : #include <boost/url/grammar/impl/not_empty_rule.hpp>
     107              : 
     108              : #endif
        

Generated by: LCOV version 2.1