| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
2 |
|
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
|
| 3 |
|
|
3 |
|
|
| 4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 6 |
|
|
6 |
|
|
| 7 |
|
// Official repository: https://github.com/boostorg/url
|
7 |
|
// Official repository: https://github.com/boostorg/url
|
| 8 |
|
|
8 |
|
|
| 9 |
|
|
9 |
|
|
| 10 |
|
#ifndef BOOST_URL_GRAMMAR_VARIANT_RULE_HPP
|
10 |
|
#ifndef BOOST_URL_GRAMMAR_VARIANT_RULE_HPP
|
| 11 |
|
#define BOOST_URL_GRAMMAR_VARIANT_RULE_HPP
|
11 |
|
#define BOOST_URL_GRAMMAR_VARIANT_RULE_HPP
|
| 12 |
|
|
12 |
|
|
| 13 |
|
#include <boost/url/detail/config.hpp>
|
13 |
|
#include <boost/url/detail/config.hpp>
|
| 14 |
|
#include <boost/url/error_types.hpp>
|
14 |
|
#include <boost/url/error_types.hpp>
|
| 15 |
|
#include <boost/url/variant.hpp>
|
15 |
|
#include <boost/url/variant.hpp>
|
| 16 |
|
#include <boost/url/grammar/detail/tuple.hpp>
|
16 |
|
#include <boost/url/grammar/detail/tuple.hpp>
|
| 17 |
|
#include <boost/url/grammar/type_traits.hpp>
|
17 |
|
#include <boost/url/grammar/type_traits.hpp>
|
| 18 |
|
|
18 |
|
|
| 19 |
|
|
19 |
|
|
| 20 |
|
|
20 |
|
|
| 21 |
|
|
21 |
|
|
| 22 |
|
|
22 |
|
|
| 23 |
|
namespace implementation_defined {
|
23 |
|
namespace implementation_defined {
|
| 24 |
|
|
24 |
|
|
| 25 |
|
|
25 |
|
|
| 26 |
|
|
26 |
|
|
| 27 |
|
|
27 |
|
|
| 28 |
|
|
28 |
|
|
| 29 |
|
using value_type = variant2::variant<
|
29 |
|
using value_type = variant2::variant<
|
| 30 |
|
|
30 |
|
|
| 31 |
|
typename Rn::value_type...>;
|
31 |
|
typename Rn::value_type...>;
|
| 32 |
|
|
32 |
|
|
| 33 |
|
|
33 |
|
|
| 34 |
|
|
34 |
|
|
| 35 |
|
|
35 |
|
|
| 36 |
|
char const* end) const ->
|
36 |
|
char const* end) const ->
|
| 37 |
|
system::result<value_type>;
|
37 |
|
system::result<value_type>;
|
| 38 |
|
|
38 |
|
|
| 39 |
|
|
39 |
|
|
| 40 |
|
|
40 |
|
|
| 41 |
|
|
41 |
|
|
| 42 |
|
Rn const&... rn) noexcept
|
42 |
|
Rn const&... rn) noexcept
|
| 43 |
|
|
43 |
|
|
| 44 |
|
|
44 |
|
|
| 45 |
|
|
45 |
|
|
| 46 |
|
|
46 |
|
|
| 47 |
|
|
47 |
|
|
| 48 |
|
|
48 |
|
|
| 49 |
|
detail::tuple<R0, Rn...> rn_;
|
49 |
|
detail::tuple<R0, Rn...> rn_;
|
| 50 |
|
|
50 |
|
|
| 51 |
|
} // implementation_defined
|
51 |
|
} // implementation_defined
|
| 52 |
|
|
52 |
|
|
| 53 |
|
/** Match one of a set of rules
|
53 |
|
/** Match one of a set of rules
|
| 54 |
|
|
54 |
|
|
| 55 |
|
Each specified rule is tried in sequence.
|
55 |
|
Each specified rule is tried in sequence.
|
| 56 |
|
When the first match occurs, the result
|
56 |
|
When the first match occurs, the result
|
| 57 |
|
is stored and returned in the variant. If
|
57 |
|
is stored and returned in the variant. If
|
| 58 |
|
no match occurs, an error is returned.
|
58 |
|
no match occurs, an error is returned.
|
| 59 |
|
|
59 |
|
|
| 60 |
|
@param r0 The first rule to match
|
60 |
|
@param r0 The first rule to match
|
| 61 |
|
@param rn A list of one or more rules to match
|
61 |
|
@param rn A list of one or more rules to match
|
| 62 |
|
|
62 |
|
|
| 63 |
|
|
63 |
|
|
| 64 |
|
|
64 |
|
|
| 65 |
|
|
65 |
|
|
| 66 |
|
using value_type = variant< typename Rules::value_type... >;
|
66 |
|
using value_type = variant< typename Rules::value_type... >;
|
| 67 |
|
|
67 |
|
|
| 68 |
|
|
68 |
|
|
| 69 |
|
|
69 |
|
|
| 70 |
|
Rules are used with the function @ref parse.
|
70 |
|
Rules are used with the function @ref parse.
|
| 71 |
|
|
71 |
|
|
| 72 |
|
// request-target = origin-form
|
72 |
|
// request-target = origin-form
|
| 73 |
|
|
73 |
|
|
| 74 |
|
|
74 |
|
|
| 75 |
|
|
75 |
|
|
| 76 |
|
|
76 |
|
|
| 77 |
|
system::result< variant< url_view, url_view, authority_view, core::string_view > > rv = grammar::parse(
|
77 |
|
system::result< variant< url_view, url_view, authority_view, core::string_view > > rv = grammar::parse(
|
| 78 |
|
"/index.html?width=full",
|
78 |
|
"/index.html?width=full",
|
| 79 |
|
|
79 |
|
|
| 80 |
|
|
80 |
|
|
| 81 |
|
|
81 |
|
|
| 82 |
|
|
82 |
|
|
| 83 |
|
|
83 |
|
|
| 84 |
|
|
84 |
|
|
| 85 |
|
|
85 |
|
|
| 86 |
|
|
86 |
|
|
| 87 |
|
|
87 |
|
|
| 88 |
|
variant = rule1 / rule2 / rule3...
|
88 |
|
variant = rule1 / rule2 / rule3...
|
| 89 |
|
|
89 |
|
|
| 90 |
|
|
90 |
|
|
| 91 |
|
|
91 |
|
|
| 92 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#section-3.2"
|
92 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#section-3.2"
|
| 93 |
|
>3.2. Alternatives (rfc5234)</a>
|
93 |
|
>3.2. Alternatives (rfc5234)</a>
|
| 94 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-5.3"
|
94 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-5.3"
|
| 95 |
|
>5.3. Request Target (rfc7230)</a>
|
95 |
|
>5.3. Request Target (rfc7230)</a>
|
| 96 |
|
|
96 |
|
|
| 97 |
|
|
97 |
|
|
| 98 |
|
|
98 |
|
|
| 99 |
|
|
99 |
|
|
| 100 |
|
|
100 |
|
|
| 101 |
|
|
101 |
|
|
| 102 |
|
|
102 |
|
|
| 103 |
|
|
103 |
|
|
| 104 |
|
|
104 |
|
|
| 105 |
|
|
105 |
|
|
| 106 |
|
BOOST_URL_CONSTRAINT(Rule) R0,
|
106 |
|
BOOST_URL_CONSTRAINT(Rule) R0,
|
| 107 |
|
BOOST_URL_CONSTRAINT(Rule)... Rn>
|
107 |
|
BOOST_URL_CONSTRAINT(Rule)... Rn>
|
| 108 |
|
|
108 |
|
|
| 109 |
|
|
109 |
|
|
| 110 |
|
|
110 |
|
|
| 111 |
|
|
111 |
|
|
| 112 |
|
Rn const&... rn) noexcept ->
|
112 |
|
Rn const&... rn) noexcept ->
|
| 113 |
|
implementation_defined::variant_rule_t<R0, Rn...>;
|
113 |
|
implementation_defined::variant_rule_t<R0, Rn...>;
|
| 114 |
|
|
114 |
|
|
| 115 |
|
|
115 |
|
|
| 116 |
|
|
116 |
|
|
| 117 |
|
|
117 |
|
|
| 118 |
|
|
118 |
|
|
| 119 |
|
#include <boost/url/grammar/impl/variant_rule.hpp>
|
119 |
|
#include <boost/url/grammar/impl/variant_rule.hpp>
|
| 120 |
|
|
120 |
|
|
| 121 |
|
|
121 |
|
|