123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- #ifndef BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
- #define BOOST_URL_GRAMMAR_TUPLE_RULE_HPP
- #include <boost/url/detail/config.hpp>
- #include <boost/url/error_types.hpp>
- #include <boost/url/grammar/error.hpp>
- #include <boost/url/grammar/detail/tuple.hpp>
- #include <boost/mp11/algorithm.hpp>
- #include <boost/core/empty_value.hpp>
- #include <tuple>
- namespace boost {
- namespace urls {
- namespace grammar {
- #ifdef BOOST_URL_DOCS
- template<class... Rules>
- constexpr
- __implementation_defined__
- tuple_rule( Rules... rn ) noexcept;
- #else
- template<
- class R0,
- class... Rn>
- class tuple_rule_t
- : empty_value<
- detail::tuple<R0, Rn...>>
- {
- using T = mp11::mp_remove<
- std::tuple<
- typename R0::value_type,
- typename Rn::value_type...>,
- void>;
- static constexpr bool IsList =
- mp11::mp_size<T>::value != 1;
- public:
- using value_type =
- mp11::mp_eval_if_c<IsList,
- T, mp11::mp_first, T>;
- template<
- class R0_,
- class... Rn_>
- friend
- constexpr
- auto
- tuple_rule(
- R0_ const& r0,
- Rn_ const&... rn) noexcept ->
- tuple_rule_t<R0_, Rn_...>;
- system::result<value_type>
- parse(
- char const*& it,
- char const* end) const;
- private:
- constexpr
- tuple_rule_t(
- R0 const& r0,
- Rn const&... rn) noexcept
- : empty_value<
- detail::tuple<R0, Rn...>>(
- empty_init,
- r0, rn...)
- {
- }
- };
- template<
- class R0,
- class... Rn>
- constexpr
- auto
- tuple_rule(
- R0 const& r0,
- Rn const&... rn) noexcept ->
- tuple_rule_t<
- R0, Rn...>
- {
- return { r0, rn... };
- }
- #endif
- #ifndef BOOST_URL_DOCS
- namespace detail {
- template<class Rule>
- struct squelch_rule_t
- : empty_value<Rule>
- {
- using value_type = void;
- constexpr
- squelch_rule_t(
- Rule const& r) noexcept
- : empty_value<Rule>(
- empty_init, r)
- {
- }
- system::result<value_type>
- parse(
- char const*& it,
- char const* end) const
- {
- auto rv = this->get().parse(it, end);
- if(rv.error())
- return rv.error();
- return {};
- }
- };
- }
- #endif
- template<class Rule>
- constexpr
- #ifdef BOOST_URL_DOCS
- __implementation_defined__
- #else
- detail::squelch_rule_t<Rule>
- #endif
- squelch( Rule const& r ) noexcept
- {
- return { r };
- }
- }
- }
- }
- #include <boost/url/grammar/impl/tuple_rule.hpp>
- #endif
|