Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:51:37

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/http_proto
0008 //
0009 
0010 #ifndef BOOST_URL_GRAMMAR_TOKEN_RULE_HPP
0011 #define BOOST_URL_GRAMMAR_TOKEN_RULE_HPP
0012 
0013 #include <boost/url/detail/config.hpp>
0014 #include <boost/url/grammar/charset.hpp>
0015 #include <boost/url/error_types.hpp>
0016 #include <boost/core/detail/string_view.hpp>
0017 
0018 namespace boost {
0019 namespace urls {
0020 namespace grammar {
0021 
0022 namespace implementation_defined {
0023 template<class CharSet>
0024 struct token_rule_t
0025 {
0026     using value_type = core::string_view;
0027 
0028     static_assert(
0029         is_charset<CharSet>::value,
0030         "CharSet requirements not met");
0031 
0032     auto
0033     parse(
0034         char const*& it,
0035         char const* end
0036             ) const noexcept ->
0037         system::result<value_type>;
0038 
0039     constexpr
0040     token_rule_t(
0041         CharSet const& cs) noexcept
0042         : cs_(cs)
0043     {
0044     }
0045 
0046 private:
0047     CharSet const cs_;
0048 };
0049 }
0050 
0051 /** Match a non-empty string of characters from a set
0052 
0053     If there is no more input, the error code
0054     @ref error::need_more is returned.
0055 
0056     @par Value Type
0057     @code
0058     using value_type = core::string_view;
0059     @endcode
0060 
0061     @par Example
0062     Rules are used with the function @ref parse.
0063     @code
0064     system::result< core::string_view > rv = parse( "abcdef", token_rule( alpha_chars ) );
0065     @endcode
0066 
0067     @par BNF
0068     @code
0069     token     = 1*( ch )
0070     @endcode
0071 
0072     @param cs The character set to use
0073     @return The token rule
0074 
0075     @see
0076         @ref alpha_chars,
0077         @ref parse.
0078 */
0079 template<BOOST_URL_CONSTRAINT(CharSet) CS>
0080 constexpr
0081 auto
0082 token_rule(
0083     CS const& cs) noexcept ->
0084         implementation_defined::token_rule_t<CS>
0085 {
0086     return {cs};
0087 }
0088 
0089 } // grammar
0090 } // urls
0091 } // boost
0092 
0093 #include <boost/url/grammar/impl/token_rule.hpp>
0094 
0095 #endif