| 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_OPTIONAL_RULE_HPP
|
10 |
|
#ifndef BOOST_URL_GRAMMAR_OPTIONAL_RULE_HPP
|
| 11 |
|
#define BOOST_URL_GRAMMAR_OPTIONAL_RULE_HPP
|
11 |
|
#define BOOST_URL_GRAMMAR_OPTIONAL_RULE_HPP
|
| 12 |
|
|
12 |
|
|
| 13 |
|
#include <boost/url/detail/config.hpp>
|
13 |
|
#include <boost/url/detail/config.hpp>
|
| 14 |
|
#include <boost/url/optional.hpp>
|
14 |
|
#include <boost/url/optional.hpp>
|
| 15 |
|
#include <boost/url/error_types.hpp>
|
15 |
|
#include <boost/url/error_types.hpp>
|
| 16 |
|
#include <boost/url/grammar/type_traits.hpp>
|
16 |
|
#include <boost/url/grammar/type_traits.hpp>
|
| 17 |
|
#include <boost/core/empty_value.hpp>
|
17 |
|
#include <boost/core/empty_value.hpp>
|
| 18 |
|
#include <boost/core/detail/static_assert.hpp>
|
18 |
|
#include <boost/core/detail/static_assert.hpp>
|
| 19 |
|
#include <boost/assert.hpp>
|
19 |
|
#include <boost/assert.hpp>
|
| 20 |
|
|
20 |
|
|
| 21 |
|
|
21 |
|
|
| 22 |
|
|
22 |
|
|
| 23 |
|
|
23 |
|
|
| 24 |
|
|
24 |
|
|
| 25 |
|
namespace implementation_defined {
|
25 |
|
namespace implementation_defined {
|
| 26 |
|
|
26 |
|
|
| 27 |
|
|
27 |
|
|
| 28 |
|
: private empty_value<Rule>
|
28 |
|
: private empty_value<Rule>
|
| 29 |
|
|
29 |
|
|
| 30 |
|
using value_type = boost::optional<
|
30 |
|
using value_type = boost::optional<
|
| 31 |
|
typename Rule::value_type>;
|
31 |
|
typename Rule::value_type>;
|
| 32 |
|
|
32 |
|
|
| 33 |
|
system::result<value_type>
|
33 |
|
system::result<value_type>
|
| 34 |
|
|
34 |
|
|
| 35 |
|
|
35 |
|
|
| 36 |
|
|
36 |
|
|
| 37 |
|
|
37 |
|
|
| 38 |
|
|
38 |
|
|
| 39 |
|
|
39 |
|
|
| 40 |
|
|
40 |
|
|
| 41 |
|
|
41 |
|
|
| 42 |
|
|
42 |
|
|
| 43 |
|
|
43 |
|
|
| 44 |
|
|
44 |
|
|
| 45 |
|
|
45 |
|
|
| 46 |
|
|
46 |
|
|
| 47 |
|
} // implementation_defined
|
47 |
|
} // implementation_defined
|
| 48 |
|
|
48 |
|
|
| 49 |
|
/** Match a rule, or the empty string
|
49 |
|
/** Match a rule, or the empty string
|
| 50 |
|
|
50 |
|
|
| 51 |
|
Optional BNF elements are denoted with
|
51 |
|
Optional BNF elements are denoted with
|
| 52 |
|
square brackets. If the specified rule
|
52 |
|
square brackets. If the specified rule
|
| 53 |
|
returns any error it is treated as if
|
53 |
|
returns any error it is treated as if
|
| 54 |
|
|
54 |
|
|
| 55 |
|
|
55 |
|
|
| 56 |
|
|
56 |
|
|
| 57 |
|
|
57 |
|
|
| 58 |
|
using value_type = optional< typename Rule::value_type >;
|
58 |
|
using value_type = optional< typename Rule::value_type >;
|
| 59 |
|
|
59 |
|
|
| 60 |
|
|
60 |
|
|
| 61 |
|
|
61 |
|
|
| 62 |
|
Rules are used with the function @ref grammar::parse.
|
62 |
|
Rules are used with the function @ref grammar::parse.
|
| 63 |
|
|
63 |
|
|
| 64 |
|
system::result< optional< core::string_view > > rv = parse( "", optional_rule( token_rule( alpha_chars ) ) );
|
64 |
|
system::result< optional< core::string_view > > rv = parse( "", optional_rule( token_rule( alpha_chars ) ) );
|
| 65 |
|
|
65 |
|
|
| 66 |
|
|
66 |
|
|
| 67 |
|
|
67 |
|
|
| 68 |
|
|
68 |
|
|
| 69 |
|
|
69 |
|
|
| 70 |
|
|
70 |
|
|
| 71 |
|
|
71 |
|
|
| 72 |
|
|
72 |
|
|
| 73 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#section-3.8"
|
73 |
|
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#section-3.8"
|
| 74 |
|
>3.8. Optional Sequence (rfc5234)</a>
|
74 |
|
>3.8. Optional Sequence (rfc5234)</a>
|
| 75 |
|
|
75 |
|
|
| 76 |
|
@param r The rule to match
|
76 |
|
@param r The rule to match
|
| 77 |
|
|
77 |
|
|
| 78 |
|
|
78 |
|
|
| 79 |
|
|
79 |
|
|
| 80 |
|
|
80 |
|
|
| 81 |
|
|
81 |
|
|
| 82 |
|
|
82 |
|
|
| 83 |
|
|
83 |
|
|
| 84 |
|
|
84 |
|
|
| 85 |
|
template<BOOST_URL_CONSTRAINT(Rule) R>
|
85 |
|
template<BOOST_URL_CONSTRAINT(Rule) R>
|
| 86 |
|
|
86 |
|
|
| 87 |
|
|
87 |
|
|
| 88 |
|
|
88 |
|
|
| 89 |
|
|
89 |
|
|
| 90 |
|
implementation_defined::optional_rule_t<R>
|
90 |
|
implementation_defined::optional_rule_t<R>
|
| 91 |
|
|
91 |
|
|
| 92 |
|
BOOST_CORE_STATIC_ASSERT(grammar::is_rule<R>::value);
|
92 |
|
BOOST_CORE_STATIC_ASSERT(grammar::is_rule<R>::value);
|
| 93 |
|
|
93 |
|
|
| 94 |
|
|
94 |
|
|
| 95 |
|
|
95 |
|
|
| 96 |
|
|
96 |
|
|
| 97 |
|
|
97 |
|
|
| 98 |
|
|
98 |
|
|
| 99 |
|
|
99 |
|
|
| 100 |
|
#include <boost/url/grammar/impl/optional_rule.hpp>
|
100 |
|
#include <boost/url/grammar/impl/optional_rule.hpp>
|
| 101 |
|
|
101 |
|
|
| 102 |
|
|
102 |
|
|