| 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 |
|
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
3 |
|
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
|
| 4 |
|
|
4 |
|
|
| 5 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
5 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 6 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
6 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 7 |
|
|
7 |
|
|
| 8 |
|
// Official repository: https://github.com/boostorg/url
|
8 |
|
// Official repository: https://github.com/boostorg/url
|
| 9 |
|
|
9 |
|
|
| 10 |
|
|
10 |
|
|
| 11 |
|
#ifndef BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
|
11 |
|
#ifndef BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
|
| 12 |
|
#define BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
|
12 |
|
#define BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
|
| 13 |
|
|
13 |
|
|
| 14 |
|
#include <boost/url/detail/config.hpp>
|
14 |
|
#include <boost/url/detail/config.hpp>
|
| 15 |
|
#include <boost/url/error_types.hpp>
|
15 |
|
#include <boost/url/error_types.hpp>
|
| 16 |
|
#include <boost/url/grammar/error.hpp>
|
16 |
|
#include <boost/url/grammar/error.hpp>
|
| 17 |
|
#include <boost/url/grammar/detail/tuple.hpp>
|
17 |
|
#include <boost/url/grammar/detail/tuple.hpp>
|
| 18 |
|
#include <boost/url/grammar/type_traits.hpp>
|
18 |
|
#include <boost/url/grammar/type_traits.hpp>
|
| 19 |
|
#include <boost/mp11/algorithm.hpp>
|
19 |
|
#include <boost/mp11/algorithm.hpp>
|
| 20 |
|
#include <boost/core/detail/static_assert.hpp>
|
20 |
|
#include <boost/core/detail/static_assert.hpp>
|
| 21 |
|
#include <boost/core/empty_value.hpp>
|
21 |
|
#include <boost/core/empty_value.hpp>
|
| 22 |
|
|
22 |
|
|
| 23 |
|
|
23 |
|
|
| 24 |
|
|
24 |
|
|
| 25 |
|
|
25 |
|
|
| 26 |
|
|
26 |
|
|
| 27 |
|
|
27 |
|
|
| 28 |
|
namespace implementation_defined {
|
28 |
|
namespace implementation_defined {
|
| 29 |
|
|
29 |
|
|
| 30 |
|
|
30 |
|
|
| 31 |
|
|
31 |
|
|
| 32 |
|
|
32 |
|
|
| 33 |
|
|
33 |
|
|
| 34 |
|
detail::tuple<R0, Rn...>>
|
34 |
|
detail::tuple<R0, Rn...>>
|
| 35 |
|
|
35 |
|
|
| 36 |
|
using T = mp11::mp_remove<
|
36 |
|
using T = mp11::mp_remove<
|
| 37 |
|
|
37 |
|
|
| 38 |
|
|
38 |
|
|
| 39 |
|
typename Rn::value_type...>,
|
39 |
|
typename Rn::value_type...>,
|
| 40 |
|
|
40 |
|
|
| 41 |
|
static constexpr bool IsList =
|
41 |
|
static constexpr bool IsList =
|
| 42 |
|
mp11::mp_size<T>::value != 1;
|
42 |
|
mp11::mp_size<T>::value != 1;
|
| 43 |
|
|
43 |
|
|
| 44 |
|
|
44 |
|
|
| 45 |
|
|
45 |
|
|
| 46 |
|
mp11::mp_eval_if_c<IsList,
|
46 |
|
mp11::mp_eval_if_c<IsList,
|
| 47 |
|
|
47 |
|
|
| 48 |
|
|
48 |
|
|
| 49 |
|
|
49 |
|
|
| 50 |
|
|
50 |
|
|
| 51 |
|
|
51 |
|
|
| 52 |
|
Rn const&... rn) noexcept
|
52 |
|
Rn const&... rn) noexcept
|
| 53 |
|
|
53 |
|
|
| 54 |
|
detail::tuple<R0, Rn...>>(
|
54 |
|
detail::tuple<R0, Rn...>>(
|
| 55 |
|
|
55 |
|
|
| 56 |
|
|
56 |
|
|
| 57 |
|
|
57 |
|
|
| 58 |
|
|
58 |
|
|
| 59 |
|
|
59 |
|
|
| 60 |
|
BOOST_URL_CXX14_CONSTEXPR
|
60 |
|
BOOST_URL_CXX14_CONSTEXPR
|
| 61 |
|
system::result<value_type>
|
61 |
|
system::result<value_type>
|
| 62 |
|
|
62 |
|
|
| 63 |
|
|
63 |
|
|
| 64 |
|
|
64 |
|
|
| 65 |
|
|
65 |
|
|
| 66 |
|
|
66 |
|
|
| 67 |
|
} // implementation_defined
|
67 |
|
} // implementation_defined
|
| 68 |
|
|
68 |
|
|
| 69 |
|
/** Match a series of rules in order
|
69 |
|
/** Match a series of rules in order
|
| 70 |
|
|
70 |
|
|
| 71 |
|
This matches a series of rules in the
|
71 |
|
This matches a series of rules in the
|
| 72 |
|
order specified. Upon success the input
|
72 |
|
order specified. Upon success the input
|
| 73 |
|
is adjusted to point to the first
|
73 |
|
is adjusted to point to the first
|
| 74 |
|
unconsumed character. There is no
|
74 |
|
unconsumed character. There is no
|
| 75 |
|
implicit specification of linear white
|
75 |
|
implicit specification of linear white
|
| 76 |
|
|
76 |
|
|
| 77 |
|
|
77 |
|
|
| 78 |
|
|
78 |
|
|
| 79 |
|
|
79 |
|
|
| 80 |
|
using value_type = __see_below__;
|
80 |
|
using value_type = __see_below__;
|
| 81 |
|
|
81 |
|
|
| 82 |
|
|
82 |
|
|
| 83 |
|
The sequence rule usually returns a
|
83 |
|
The sequence rule usually returns a
|
| 84 |
|
`std::tuple` containing the the `value_type`
|
84 |
|
`std::tuple` containing the the `value_type`
|
| 85 |
|
of each corresponding rule in the sequence,
|
85 |
|
of each corresponding rule in the sequence,
|
| 86 |
|
except that `void` values are removed.
|
86 |
|
except that `void` values are removed.
|
| 87 |
|
However, if there is exactly one non-void
|
87 |
|
However, if there is exactly one non-void
|
| 88 |
|
value type `T`, then the sequence rule
|
88 |
|
value type `T`, then the sequence rule
|
| 89 |
|
returns `system::result<T>` instead of
|
89 |
|
returns `system::result<T>` instead of
|
| 90 |
|
`system::result<tuple<...>>`.
|
90 |
|
`system::result<tuple<...>>`.
|
| 91 |
|
|
91 |
|
|
| 92 |
|
|
92 |
|
|
| 93 |
|
Rules are used with the function @ref parse.
|
93 |
|
Rules are used with the function @ref parse.
|
| 94 |
|
|
94 |
|
|
| 95 |
|
system::result< std::tuple< unsigned char, unsigned char, unsigned char, unsigned char > > rv =
|
95 |
|
system::result< std::tuple< unsigned char, unsigned char, unsigned char, unsigned char > > rv =
|
| 96 |
|
|
96 |
|
|
| 97 |
|
|
97 |
|
|
| 98 |
|
|
98 |
|
|
| 99 |
|
squelch( delim_rule('.') ),
|
99 |
|
squelch( delim_rule('.') ),
|
| 100 |
|
|
100 |
|
|
| 101 |
|
squelch( delim_rule('.') ),
|
101 |
|
squelch( delim_rule('.') ),
|
| 102 |
|
|
102 |
|
|
| 103 |
|
squelch( delim_rule('.') ),
|
103 |
|
squelch( delim_rule('.') ),
|
| 104 |
|
|
104 |
|
|
| 105 |
|
|
105 |
|
|
| 106 |
|
|
106 |
|
|
| 107 |
|
|
107 |
|
|
| 108 |
|
|
108 |
|
|
| 109 |
|
sequence = rule1 rule2 rule3...
|
109 |
|
sequence = rule1 rule2 rule3...
|
| 110 |
|
|
110 |
|
|
| 111 |
|
|
111 |
|
|
| 112 |
|
|
112 |
|
|
| 113 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#section-3.1"
|
113 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#section-3.1"
|
| 114 |
|
>3.1. Concatenation (rfc5234)</a>
|
114 |
|
>3.1. Concatenation (rfc5234)</a>
|
| 115 |
|
|
115 |
|
|
| 116 |
|
@param r0 The first rule to match
|
116 |
|
@param r0 The first rule to match
|
| 117 |
|
@param rn A list of one or more rules to match
|
117 |
|
@param rn A list of one or more rules to match
|
| 118 |
|
@return The sequence rule
|
118 |
|
@return The sequence rule
|
| 119 |
|
|
119 |
|
|
| 120 |
|
|
120 |
|
|
| 121 |
|
|
121 |
|
|
| 122 |
|
|
122 |
|
|
| 123 |
|
|
123 |
|
|
| 124 |
|
|
124 |
|
|
| 125 |
|
|
125 |
|
|
| 126 |
|
|
126 |
|
|
| 127 |
|
BOOST_URL_CONSTRAINT(Rule) R0,
|
127 |
|
BOOST_URL_CONSTRAINT(Rule) R0,
|
| 128 |
|
BOOST_URL_CONSTRAINT(Rule)... Rn>
|
128 |
|
BOOST_URL_CONSTRAINT(Rule)... Rn>
|
| 129 |
|
|
129 |
|
|
| 130 |
|
|
130 |
|
|
| 131 |
|
|
131 |
|
|
| 132 |
|
|
132 |
|
|
| 133 |
|
Rn const&... rn) noexcept ->
|
133 |
|
Rn const&... rn) noexcept ->
|
| 134 |
|
implementation_defined::tuple_rule_t<
|
134 |
|
implementation_defined::tuple_rule_t<
|
| 135 |
|
|
135 |
|
|
| 136 |
|
|
136 |
|
|
| 137 |
|
BOOST_CORE_STATIC_ASSERT(
|
137 |
|
BOOST_CORE_STATIC_ASSERT(
|
| 138 |
|
|
138 |
|
|
| 139 |
|
|
139 |
|
|
| 140 |
|
|
140 |
|
|
| 141 |
|
|
141 |
|
|
| 142 |
|
|
142 |
|
|
| 143 |
|
|
143 |
|
|
| 144 |
|
namespace implementation_defined {
|
144 |
|
namespace implementation_defined {
|
| 145 |
|
|
145 |
|
|
| 146 |
|
|
146 |
|
|
| 147 |
|
|
147 |
|
|
| 148 |
|
|
148 |
|
|
| 149 |
|
|
149 |
|
|
| 150 |
|
|
150 |
|
|
| 151 |
|
|
151 |
|
|
| 152 |
|
|
152 |
|
|
| 153 |
|
|
153 |
|
|
| 154 |
|
|
154 |
|
|
| 155 |
|
|
155 |
|
|
| 156 |
|
|
156 |
|
|
| 157 |
|
|
157 |
|
|
| 158 |
|
|
158 |
|
|
| 159 |
|
|
159 |
|
|
| 160 |
|
BOOST_URL_CXX14_CONSTEXPR
|
160 |
|
BOOST_URL_CXX14_CONSTEXPR
|
| 161 |
|
system::result<value_type>
|
161 |
|
system::result<value_type>
|
| 162 |
|
|
162 |
|
|
| 163 |
|
|
163 |
|
|
| 164 |
|
|
164 |
|
|
| 165 |
|
|
165 |
|
|
| 166 |
|
auto rv = this->get().parse(it, end);
|
166 |
|
auto rv = this->get().parse(it, end);
|
| 167 |
|
|
167 |
|
|
| 168 |
|
|
168 |
|
|
| 169 |
|
|
169 |
|
|
| 170 |
|
|
170 |
|
|
| 171 |
|
|
171 |
|
|
| 172 |
|
|
172 |
|
|
| 173 |
|
} // implementation_defined
|
173 |
|
} // implementation_defined
|
| 174 |
|
|
174 |
|
|
| 175 |
|
/** Squelch the value of a rule
|
175 |
|
/** Squelch the value of a rule
|
| 176 |
|
|
176 |
|
|
| 177 |
|
This function returns a new rule which
|
177 |
|
This function returns a new rule which
|
| 178 |
|
matches the specified rule, and converts
|
178 |
|
matches the specified rule, and converts
|
| 179 |
|
its value type to `void`. This is useful
|
179 |
|
its value type to `void`. This is useful
|
| 180 |
|
for matching delimiters in a grammar,
|
180 |
|
for matching delimiters in a grammar,
|
| 181 |
|
where the value for the delimiter is not
|
181 |
|
where the value for the delimiter is not
|
| 182 |
|
|
182 |
|
|
| 183 |
|
|
183 |
|
|
| 184 |
|
|
184 |
|
|
| 185 |
|
|
185 |
|
|
| 186 |
|
|
186 |
|
|
| 187 |
|
|
187 |
|
|
| 188 |
|
|
188 |
|
|
| 189 |
|
|
189 |
|
|
| 190 |
|
|
190 |
|
|
| 191 |
|
|
191 |
|
|
| 192 |
|
system::result< std::tuple< decode_view, core::string_view > > rv = parse(
|
192 |
|
system::result< std::tuple< decode_view, core::string_view > > rv = parse(
|
| 193 |
|
|
193 |
|
|
| 194 |
|
|
194 |
|
|
| 195 |
|
pct_encoded_rule(unreserved_chars + '-' + '.'),
|
195 |
|
pct_encoded_rule(unreserved_chars + '-' + '.'),
|
| 196 |
|
squelch( delim_rule( ':' ) ),
|
196 |
|
squelch( delim_rule( ':' ) ),
|
| 197 |
|
token_rule( digit_chars ) ) );
|
197 |
|
token_rule( digit_chars ) ) );
|
| 198 |
|
|
198 |
|
|
| 199 |
|
|
199 |
|
|
| 200 |
|
|
200 |
|
|
| 201 |
|
|
201 |
|
|
| 202 |
|
|
202 |
|
|
| 203 |
|
system::result< std::tuple< decode_view, core::string_view, core::string_view > > rv = parse(
|
203 |
|
system::result< std::tuple< decode_view, core::string_view, core::string_view > > rv = parse(
|
| 204 |
|
|
204 |
|
|
| 205 |
|
|
205 |
|
|
| 206 |
|
pct_encoded_rule(unreserved_chars + '-' + '.'),
|
206 |
|
pct_encoded_rule(unreserved_chars + '-' + '.'),
|
| 207 |
|
|
207 |
|
|
| 208 |
|
token_rule( digit_chars ) ) );
|
208 |
|
token_rule( digit_chars ) ) );
|
| 209 |
|
|
209 |
|
|
| 210 |
|
|
210 |
|
|
| 211 |
|
@param r The rule to squelch
|
211 |
|
@param r The rule to squelch
|
| 212 |
|
@return The squelched rule
|
212 |
|
@return The squelched rule
|
| 213 |
|
|
213 |
|
|
| 214 |
|
|
214 |
|
|
| 215 |
|
|
215 |
|
|
| 216 |
|
|
216 |
|
|
| 217 |
|
|
217 |
|
|
| 218 |
|
|
218 |
|
|
| 219 |
|
|
219 |
|
|
| 220 |
|
|
220 |
|
|
| 221 |
|
|
221 |
|
|
| 222 |
|
|
222 |
|
|
| 223 |
|
|
223 |
|
|
| 224 |
|
template<BOOST_URL_CONSTRAINT(Rule) R>
|
224 |
|
template<BOOST_URL_CONSTRAINT(Rule) R>
|
| 225 |
|
|
225 |
|
|
| 226 |
|
BOOST_URL_IMPLEMENTATION_DEFINED(implementation_defined::squelch_rule_t<R>)
|
226 |
|
BOOST_URL_IMPLEMENTATION_DEFINED(implementation_defined::squelch_rule_t<R>)
|
| 227 |
|
squelch( R const& r ) noexcept
|
227 |
|
squelch( R const& r ) noexcept
|
| 228 |
|
|
228 |
|
|
| 229 |
|
BOOST_CORE_STATIC_ASSERT(is_rule<R>::value);
|
229 |
|
BOOST_CORE_STATIC_ASSERT(is_rule<R>::value);
|
| 230 |
|
|
230 |
|
|
| 231 |
|
|
231 |
|
|
| 232 |
|
|
232 |
|
|
| 233 |
|
|
233 |
|
|
| 234 |
|
|
234 |
|
|
| 235 |
|
|
235 |
|
|
| 236 |
|
|
236 |
|
|
| 237 |
|
#include <boost/url/grammar/impl/tuple_rule.hpp>
|
237 |
|
#include <boost/url/grammar/impl/tuple_rule.hpp>
|
| 238 |
|
|
238 |
|
|
| 239 |
|
|
239 |
|
|