Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:27

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/url
0008 //
0009 
0010 #ifndef BOOST_URL_GRAMMAR_NOT_EMPTY_RULE_HPP
0011 #define BOOST_URL_GRAMMAR_NOT_EMPTY_RULE_HPP
0012 
0013 #include <boost/url/detail/config.hpp>
0014 #include <boost/url/error_types.hpp>
0015 #include <boost/url/grammar/type_traits.hpp>
0016 
0017 namespace boost {
0018 namespace urls {
0019 namespace grammar {
0020 
0021 /** Match another rule, if the result is not empty
0022 
0023     This adapts another rule such that
0024     when an empty string is successfully
0025     parsed, the result is an error.
0026 
0027     @par Value Type
0028     @code
0029     using value_type = typename Rule::value_type;
0030     @endcode
0031 
0032     @par Example
0033     Rules are used with the function @ref parse.
0034     @code
0035     system::result< decode_view > rv = parse( "Program%20Files",
0036         not_empty_rule( pct_encoded_rule( unreserved_chars ) ) );
0037     @endcode
0038 
0039     @param r The rule to match
0040 
0041     @see
0042         @ref parse,
0043         @ref pct_encoded_rule,
0044         @ref unreserved_chars.
0045 */
0046 #ifdef BOOST_URL_DOCS
0047 template<class Rule>
0048 constexpr
0049 __implementation_defined__
0050 not_empty_rule( Rule r );
0051 #else
0052 template<class R>
0053 struct not_empty_rule_t
0054 {
0055     using value_type =
0056         typename R::value_type;
0057 
0058     auto
0059     parse(
0060         char const*& it,
0061         char const* end) const ->
0062             system::result<value_type>;
0063 
0064     template<class R_>
0065     friend
0066     constexpr
0067     auto
0068     not_empty_rule(
0069         R_ const& r) ->
0070             not_empty_rule_t<R_>;
0071 
0072 private:
0073     constexpr
0074     not_empty_rule_t(
0075         R const& r) noexcept
0076         : r_(r)
0077     {
0078     }
0079 
0080     R r_;
0081 };
0082 
0083 template<class Rule>
0084 auto
0085 constexpr
0086 not_empty_rule(
0087     Rule const& r) ->
0088         not_empty_rule_t<Rule>
0089 {
0090     // If you get a compile error here it
0091     // means that your rule does not meet
0092     // the type requirements. Please check
0093     // the documentation.
0094     static_assert(
0095         is_rule<Rule>::value,
0096         "Rule requirements not met");
0097 
0098     return { r };
0099 }
0100 #endif
0101 
0102 } // grammar
0103 } // urls
0104 } // boost
0105 
0106 #include <boost/url/grammar/impl/not_empty_rule.hpp>
0107 
0108 #endif