Back to home page

EIC code displayed by LXR

 
 

    


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

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 /** Match a non-empty string of characters from a set
0023 
0024     If there is no more input, the error code
0025     @ref error::need_more is returned.
0026 
0027     @par Value Type
0028     @code
0029     using value_type = core::string_view;
0030     @endcode
0031 
0032     @par Example
0033     Rules are used with the function @ref parse.
0034     @code
0035     system::result< core::string_view > rv = parse( "abcdef", token_rule( alpha_chars ) );
0036     @endcode
0037 
0038     @par BNF
0039     @code
0040     token     = 1*( ch )
0041     @endcode
0042 
0043     @param cs The character set to use
0044 
0045     @see
0046         @ref alpha_chars,
0047         @ref parse.
0048 */
0049 #ifdef BOOST_URL_DOCS
0050 template<class CharSet>
0051 constexpr
0052 __implementation_defined__
0053 token_rule(
0054     CharSet cs) noexcept;
0055 #else
0056 template<class CharSet>
0057 struct token_rule_t
0058 {
0059     using value_type = core::string_view;
0060 
0061     static_assert(
0062         is_charset<CharSet>::value,
0063         "CharSet requirements not met");
0064 
0065     auto
0066     parse(
0067         char const*& it,
0068         char const* end
0069             ) const noexcept ->
0070         system::result<value_type>;
0071 
0072 private:
0073     template<class CharSet_>
0074     friend
0075     constexpr
0076     auto
0077     token_rule(
0078         CharSet_ const&) noexcept ->
0079             token_rule_t<CharSet_>;
0080 
0081     constexpr
0082     token_rule_t(
0083         CharSet const& cs) noexcept
0084         : cs_(cs)
0085     {
0086     }
0087 
0088     CharSet const cs_;
0089 };
0090 
0091 template<class CharSet>
0092 constexpr
0093 auto
0094 token_rule(
0095     CharSet const& cs) noexcept ->
0096         token_rule_t<CharSet>
0097 {
0098     return {cs};
0099 }
0100 #endif
0101 
0102 } // grammar
0103 } // urls
0104 } // boost
0105 
0106 #include <boost/url/grammar/impl/token_rule.hpp>
0107 
0108 #endif