File indexing completed on 2025-09-18 09:07:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
0011 #define BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
0012
0013 #include <boost/url/detail/config.hpp>
0014 #include <boost/url/error_types.hpp>
0015 #include <boost/url/grammar/error.hpp>
0016 #include <boost/url/grammar/detail/tuple.hpp>
0017 #include <boost/url/grammar/type_traits.hpp>
0018 #include <boost/mp11/algorithm.hpp>
0019 #include <boost/static_assert.hpp>
0020 #include <boost/core/empty_value.hpp>
0021 #include <tuple>
0022
0023 namespace boost {
0024 namespace urls {
0025 namespace grammar {
0026
0027 namespace implementation_defined {
0028 template<
0029 class R0,
0030 class... Rn>
0031 class tuple_rule_t
0032 : empty_value<
0033 detail::tuple<R0, Rn...>>
0034 {
0035 using T = mp11::mp_remove<
0036 std::tuple<
0037 typename R0::value_type,
0038 typename Rn::value_type...>,
0039 void>;
0040 static constexpr bool IsList =
0041 mp11::mp_size<T>::value != 1;
0042
0043 public:
0044 using value_type =
0045 mp11::mp_eval_if_c<IsList,
0046 T, mp11::mp_first, T>;
0047
0048 constexpr
0049 tuple_rule_t(
0050 R0 const& r0,
0051 Rn const&... rn) noexcept
0052 : empty_value<
0053 detail::tuple<R0, Rn...>>(
0054 empty_init,
0055 r0, rn...)
0056 {
0057 }
0058
0059 system::result<value_type>
0060 parse(
0061 char const*& it,
0062 char const* end) const;
0063
0064 };
0065 }
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 template<
0125 BOOST_URL_CONSTRAINT(Rule) R0,
0126 BOOST_URL_CONSTRAINT(Rule)... Rn>
0127 constexpr
0128 auto
0129 tuple_rule(
0130 R0 const& r0,
0131 Rn const&... rn) noexcept ->
0132 implementation_defined::tuple_rule_t<
0133 R0, Rn...>
0134 {
0135 BOOST_STATIC_ASSERT(
0136 mp11::mp_all<
0137 is_rule<R0>,
0138 is_rule<Rn>...>::value);
0139 return { r0, rn... };
0140 }
0141
0142 namespace implementation_defined {
0143
0144 template<class Rule>
0145 struct squelch_rule_t
0146 : empty_value<Rule>
0147 {
0148 using value_type = void;
0149
0150 constexpr
0151 squelch_rule_t(
0152 Rule const& r) noexcept
0153 : empty_value<Rule>(
0154 empty_init, r)
0155 {
0156 }
0157
0158 system::result<value_type>
0159 parse(
0160 char const*& it,
0161 char const* end) const
0162 {
0163 auto rv = this->get().parse(it, end);
0164 if(rv.error())
0165 return rv.error();
0166 return {};
0167 }
0168 };
0169
0170 }
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221 template<BOOST_URL_CONSTRAINT(Rule) R>
0222 constexpr
0223 BOOST_URL_IMPLEMENTATION_DEFINED(implementation_defined::squelch_rule_t<R>)
0224 squelch( R const& r ) noexcept
0225 {
0226 BOOST_STATIC_ASSERT(is_rule<R>::value);
0227 return { r };
0228 }
0229
0230 }
0231 }
0232 }
0233
0234 #include <boost/url/grammar/impl/tuple_rule.hpp>
0235
0236 #endif