LCOV - code coverage report
Current view: top level - boost/url/grammar/variant_rule.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 3 3
Test Date: 2025-01-10 18:07:09 Functions: 100.0 % 2 2

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
       3              : //
       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)
       6              : //
       7              : // Official repository: https://github.com/boostorg/url
       8              : //
       9              : 
      10              : #ifndef BOOST_URL_GRAMMAR_VARIANT_RULE_HPP
      11              : #define BOOST_URL_GRAMMAR_VARIANT_RULE_HPP
      12              : 
      13              : #include <boost/url/detail/config.hpp>
      14              : #include <boost/url/error_types.hpp>
      15              : #include <boost/url/variant.hpp>
      16              : #include <boost/url/grammar/detail/tuple.hpp>
      17              : #include <boost/url/grammar/type_traits.hpp>
      18              : 
      19              : namespace boost {
      20              : namespace urls {
      21              : namespace grammar {
      22              : 
      23              : namespace implementation_defined {
      24              : template<
      25              :     class R0, class... Rn>
      26              : class variant_rule_t
      27              : {
      28              : public:
      29              :     using value_type = variant2::variant<
      30              :         typename R0::value_type,
      31              :         typename Rn::value_type...>;
      32              : 
      33              :     auto
      34              :     parse(
      35              :         char const*& it,
      36              :         char const* end) const ->
      37              :             system::result<value_type>;
      38              : 
      39              :     constexpr
      40         2497 :     variant_rule_t(
      41              :         R0 const& r0,
      42              :         Rn const&... rn) noexcept
      43         2497 :         : rn_(r0, rn...)
      44              :     {
      45         2497 :     }
      46              : 
      47              : private:
      48              : 
      49              :     detail::tuple<R0, Rn...> rn_;
      50              : };
      51              : } // implementation_defined
      52              : 
      53              : /** Match one of a set of rules
      54              : 
      55              :     Each specified rule is tried in sequence.
      56              :     When the first match occurs, the result
      57              :     is stored and returned in the variant. If
      58              :     no match occurs, an error is returned.
      59              : 
      60              :     @par Value Type
      61              :     @code
      62              :     using value_type = variant< typename Rules::value_type... >;
      63              :     @endcode
      64              : 
      65              :     @par Example
      66              :     Rules are used with the function @ref parse.
      67              :     @code
      68              :     // request-target = origin-form
      69              :     //                / absolute-form
      70              :     //                / authority-form
      71              :     //                / asterisk-form
      72              : 
      73              :     system::result< variant< url_view, url_view, authority_view, core::string_view > > rv = grammar::parse(
      74              :         "/index.html?width=full",
      75              :         variant_rule(
      76              :             origin_form_rule,
      77              :             absolute_uri_rule,
      78              :             authority_rule,
      79              :             delim_rule('*') ) );
      80              :     @endcode
      81              : 
      82              :     @par BNF
      83              :     @code
      84              :     variant     = rule1 / rule2 / rule3...
      85              :     @endcode
      86              : 
      87              :     @par Specification
      88              :     @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#section-3.2"
      89              :         >3.2.  Alternatives (rfc5234)</a>
      90              :     @li <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-5.3"
      91              :         >5.3.  Request Target (rfc7230)</a>
      92              : 
      93              :     @see
      94              :         @ref absolute_uri_rule,
      95              :         @ref authority_rule,
      96              :         @ref delim_rule,
      97              :         @ref parse,
      98              :         @ref origin_form_rule,
      99              :         @ref url_view.
     100              : */
     101              : template<
     102              :     BOOST_URL_CONSTRAINT(Rule) R0,
     103              :     BOOST_URL_CONSTRAINT(Rule)... Rn>
     104              : constexpr
     105              : auto
     106              : variant_rule(
     107              :     R0 const& r0,
     108              :     Rn const&... rn) noexcept ->
     109              :         implementation_defined::variant_rule_t<R0, Rn...>;
     110              : 
     111              : } // grammar
     112              : } // urls
     113              : } // boost
     114              : 
     115              : #include <boost/url/grammar/impl/variant_rule.hpp>
     116              : 
     117              : #endif
        

Generated by: LCOV version 2.1