2023-05-22 18:45:02 +10:00
|
|
|
//
|
|
|
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
// Official repository: https://github.com/boostorg/http_proto
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef BOOST_URL_GRAMMAR_TOKEN_RULE_HPP
|
|
|
|
#define BOOST_URL_GRAMMAR_TOKEN_RULE_HPP
|
|
|
|
|
|
|
|
#include <boost/url/detail/config.hpp>
|
|
|
|
#include <boost/url/grammar/charset.hpp>
|
|
|
|
#include <boost/url/error_types.hpp>
|
2023-11-04 21:30:42 +02:00
|
|
|
#include <boost/core/detail/string_view.hpp>
|
2023-05-22 18:45:02 +10:00
|
|
|
|
|
|
|
namespace boost {
|
|
|
|
namespace urls {
|
|
|
|
namespace grammar {
|
|
|
|
|
|
|
|
/** Match a non-empty string of characters from a set
|
|
|
|
|
|
|
|
If there is no more input, the error code
|
|
|
|
@ref error::need_more is returned.
|
|
|
|
|
|
|
|
@par Value Type
|
|
|
|
@code
|
2023-11-04 21:30:42 +02:00
|
|
|
using value_type = core::string_view;
|
2023-05-22 18:45:02 +10:00
|
|
|
@endcode
|
|
|
|
|
|
|
|
@par Example
|
|
|
|
Rules are used with the function @ref parse.
|
|
|
|
@code
|
2023-11-04 21:30:42 +02:00
|
|
|
system::result< core::string_view > rv = parse( "abcdef", token_rule( alpha_chars ) );
|
2023-05-22 18:45:02 +10:00
|
|
|
@endcode
|
|
|
|
|
|
|
|
@par BNF
|
|
|
|
@code
|
|
|
|
token = 1*( ch )
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
@param cs The character set to use
|
|
|
|
|
|
|
|
@see
|
|
|
|
@ref alpha_chars,
|
|
|
|
@ref parse.
|
|
|
|
*/
|
|
|
|
#ifdef BOOST_URL_DOCS
|
|
|
|
template<class CharSet>
|
|
|
|
constexpr
|
|
|
|
__implementation_defined__
|
|
|
|
token_rule(
|
|
|
|
CharSet cs) noexcept;
|
|
|
|
#else
|
|
|
|
template<class CharSet>
|
|
|
|
struct token_rule_t
|
|
|
|
{
|
2023-11-04 21:30:42 +02:00
|
|
|
using value_type = core::string_view;
|
2023-05-22 18:45:02 +10:00
|
|
|
|
|
|
|
static_assert(
|
|
|
|
is_charset<CharSet>::value,
|
|
|
|
"CharSet requirements not met");
|
|
|
|
|
|
|
|
auto
|
|
|
|
parse(
|
|
|
|
char const*& it,
|
|
|
|
char const* end
|
|
|
|
) const noexcept ->
|
2023-11-04 21:30:42 +02:00
|
|
|
system::result<value_type>;
|
2023-05-22 18:45:02 +10:00
|
|
|
|
|
|
|
private:
|
|
|
|
template<class CharSet_>
|
|
|
|
friend
|
|
|
|
constexpr
|
|
|
|
auto
|
|
|
|
token_rule(
|
|
|
|
CharSet_ const&) noexcept ->
|
|
|
|
token_rule_t<CharSet_>;
|
|
|
|
|
|
|
|
constexpr
|
|
|
|
token_rule_t(
|
|
|
|
CharSet const& cs) noexcept
|
|
|
|
: cs_(cs)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CharSet const cs_;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class CharSet>
|
|
|
|
constexpr
|
|
|
|
auto
|
|
|
|
token_rule(
|
|
|
|
CharSet const& cs) noexcept ->
|
|
|
|
token_rule_t<CharSet>
|
|
|
|
{
|
|
|
|
return {cs};
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // grammar
|
|
|
|
} // urls
|
|
|
|
} // boost
|
|
|
|
|
|
|
|
#include <boost/url/grammar/impl/token_rule.hpp>
|
|
|
|
|
|
|
|
#endif
|