File indexing completed on 2025-01-18 09:53:28
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/mp11/algorithm.hpp>
0018 #include <boost/core/empty_value.hpp>
0019 #include <tuple>
0020
0021 namespace boost {
0022 namespace urls {
0023 namespace grammar {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 #ifdef BOOST_URL_DOCS
0081 template<class... Rules>
0082 constexpr
0083 __implementation_defined__
0084 tuple_rule( Rules... rn ) noexcept;
0085 #else
0086 template<
0087 class R0,
0088 class... Rn>
0089 class tuple_rule_t
0090 : empty_value<
0091 detail::tuple<R0, Rn...>>
0092 {
0093 using T = mp11::mp_remove<
0094 std::tuple<
0095 typename R0::value_type,
0096 typename Rn::value_type...>,
0097 void>;
0098 static constexpr bool IsList =
0099 mp11::mp_size<T>::value != 1;
0100
0101 public:
0102 using value_type =
0103 mp11::mp_eval_if_c<IsList,
0104 T, mp11::mp_first, T>;
0105
0106 template<
0107 class R0_,
0108 class... Rn_>
0109 friend
0110 constexpr
0111 auto
0112 tuple_rule(
0113 R0_ const& r0,
0114 Rn_ const&... rn) noexcept ->
0115 tuple_rule_t<R0_, Rn_...>;
0116
0117 system::result<value_type>
0118 parse(
0119 char const*& it,
0120 char const* end) const;
0121
0122 private:
0123 constexpr
0124 tuple_rule_t(
0125 R0 const& r0,
0126 Rn const&... rn) noexcept
0127 : empty_value<
0128 detail::tuple<R0, Rn...>>(
0129 empty_init,
0130 r0, rn...)
0131 {
0132 }
0133 };
0134
0135 template<
0136 class R0,
0137 class... Rn>
0138 constexpr
0139 auto
0140 tuple_rule(
0141 R0 const& r0,
0142 Rn const&... rn) noexcept ->
0143 tuple_rule_t<
0144 R0, Rn...>
0145 {
0146 return { r0, rn... };
0147 }
0148 #endif
0149
0150 #ifndef BOOST_URL_DOCS
0151 namespace detail {
0152
0153 template<class Rule>
0154 struct squelch_rule_t
0155 : empty_value<Rule>
0156 {
0157 using value_type = void;
0158
0159 constexpr
0160 squelch_rule_t(
0161 Rule const& r) noexcept
0162 : empty_value<Rule>(
0163 empty_init, r)
0164 {
0165 }
0166
0167 system::result<value_type>
0168 parse(
0169 char const*& it,
0170 char const* end) const
0171 {
0172 auto rv = this->get().parse(it, end);
0173 if(rv.error())
0174 return rv.error();
0175 return {};
0176 }
0177 };
0178
0179 }
0180 #endif
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
0222
0223
0224
0225
0226
0227
0228
0229
0230 template<class Rule>
0231 constexpr
0232 #ifdef BOOST_URL_DOCS
0233 __implementation_defined__
0234 #else
0235 detail::squelch_rule_t<Rule>
0236 #endif
0237 squelch( Rule const& r ) noexcept
0238 {
0239 return { r };
0240 }
0241
0242 }
0243 }
0244 }
0245
0246 #include <boost/url/grammar/impl/tuple_rule.hpp>
0247
0248 #endif