LCOV - code coverage report
Current view: top level - boost/url/grammar/parse.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 4 4
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_PARSE_HPP
      11              : #define BOOST_URL_GRAMMAR_PARSE_HPP
      12              : 
      13              : #include <boost/url/detail/config.hpp>
      14              : #include <boost/url/error_types.hpp>
      15              : #include <boost/core/detail/string_view.hpp>
      16              : #include <boost/url/grammar/type_traits.hpp>
      17              : 
      18              : namespace boost {
      19              : namespace urls {
      20              : namespace grammar {
      21              : 
      22              : //------------------------------------------------
      23              : 
      24              : /** Parse a character buffer using a rule
      25              : 
      26              :     @param it A pointer to the start. The
      27              :     caller's variable is changed to
      28              :     reflect the amount of input consumed.
      29              : 
      30              :     @param end A pointer to the end.
      31              : 
      32              :     @param r The rule to use
      33              : 
      34              :     @return The parsed value upon success,
      35              :     otherwise an error.
      36              : */
      37              : template<BOOST_URL_CONSTRAINT(Rule) R>
      38              : system::result<typename R::value_type>
      39              : parse(
      40              :     char const*& it,
      41              :     char const* end,
      42              :     R const& r);
      43              : 
      44              : /** Parse a character buffer using a rule
      45              : 
      46              :     This function parses a complete string into
      47              :     the specified sequence of rules. If the
      48              :     string is not completely consumed, an
      49              :     error is returned instead.
      50              : 
      51              :     @param s The input string
      52              : 
      53              :     @param r The rule to use
      54              : 
      55              :     @return The parsed value upon success,
      56              :     otherwise an error.
      57              : */
      58              : template<BOOST_URL_CONSTRAINT(Rule) R>
      59              : system::result<typename R::value_type>
      60              : parse(
      61              :     core::string_view s,
      62              :     R const& r);
      63              : 
      64              : //------------------------------------------------
      65              : 
      66              : namespace implementation_defined {
      67              : template<class Rule>
      68              : struct rule_ref
      69              : {
      70              :     Rule const& r_;
      71              : 
      72              :     using value_type =
      73              :         typename Rule::value_type;
      74              : 
      75              :     system::result<value_type>
      76            1 :     parse(
      77              :         char const*& it,
      78              :         char const* end) const
      79              :     {
      80            1 :         return r_.parse(it, end);
      81              :     }
      82              : };
      83              : } // implementation_defined
      84              : 
      85              : /** Return a reference to a rule
      86              : 
      87              :     This function returns a rule which
      88              :     references the specified object. This is
      89              :     used to reduce the number of bytes of
      90              :     storage (`sizeof`) required by a combinator
      91              :     when it stores a copy of the object.
      92              :     <br>
      93              :     Ownership of the object is not transferred;
      94              :     the caller is responsible for ensuring the
      95              :     lifetime of the object is extended until it
      96              :     is no longer referenced. For best results,
      97              :     `ref` should only be used with compile-time
      98              :     constants.
      99              : 
     100              :     @param r The rule to use
     101              : */
     102              : template<BOOST_URL_CONSTRAINT(Rule) R>
     103              : constexpr
     104              : typename std::enable_if<
     105              :     is_rule<R>::value &&
     106              :     ! std::is_same<R,
     107              :         implementation_defined::rule_ref<R> >::value,
     108              :     implementation_defined::rule_ref<R> >::type
     109            1 : ref(R const& r) noexcept
     110              : {
     111            1 :     return implementation_defined::rule_ref<R>{r};
     112              : }
     113              : 
     114              : #ifndef BOOST_URL_DOCS
     115              : #ifndef BOOST_URL_MRDOCS
     116              : // If you get a compile error here it
     117              : // means you called ref with something
     118              : // that is not a CharSet or Rule!
     119              : constexpr
     120              : void
     121              : ref(...) = delete;
     122              : #endif
     123              : #endif
     124              : 
     125              : } // grammar
     126              : } // urls
     127              : } // boost
     128              : 
     129              : #include <boost/url/grammar/impl/parse.hpp>
     130              : 
     131              : #endif
        

Generated by: LCOV version 2.1