Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:07:54

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 namespace implementation_defined {
0022 template<class R>
0023 struct not_empty_rule_t
0024 {
0025     using value_type =
0026         typename R::value_type;
0027 
0028     auto
0029     parse(
0030         char const*& it,
0031         char const* end) const ->
0032             system::result<value_type>;
0033 
0034     constexpr
0035     not_empty_rule_t(
0036         R const& r) noexcept
0037         : r_(r)
0038     {
0039     }
0040 
0041 private:
0042     R r_;
0043 };
0044 } // implementation_defined
0045 
0046 /** Match another rule, if the result is not empty
0047 
0048     This adapts another rule such that
0049     when an empty string is successfully
0050     parsed, the result is an error.
0051 
0052     @par Value Type
0053     @code
0054     using value_type = typename Rule::value_type;
0055     @endcode
0056 
0057     @par Example
0058     Rules are used with the function @ref parse.
0059     @code
0060     system::result< decode_view > rv = parse( "Program%20Files",
0061         not_empty_rule( pct_encoded_rule( unreserved_chars ) ) );
0062     @endcode
0063 
0064     @param r The rule to match
0065     @return The adapted rule
0066 
0067     @see
0068         @ref parse,
0069         @ref pct_encoded_rule,
0070         @ref unreserved_chars.
0071 */
0072 template<BOOST_URL_CONSTRAINT(Rule) R>
0073 auto
0074 constexpr
0075 not_empty_rule(
0076     R const& r) ->
0077         implementation_defined::not_empty_rule_t<R>
0078 {
0079     // If you get a compile error here it
0080     // means that your rule does not meet
0081     // the type requirements. Please check
0082     // the documentation.
0083     static_assert(
0084         is_rule<R>::value,
0085         "Rule requirements not met");
0086 
0087     return { r };
0088 }
0089 
0090 } // grammar
0091 } // urls
0092 } // boost
0093 
0094 #include <boost/url/grammar/impl/not_empty_rule.hpp>
0095 
0096 #endif