LCOV - code coverage report
Current view: top level - boost/url/grammar - parse.hpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 4 4 100.0 %
Date: 2024-03-13 19:32:03 Functions: 2 2 100.0 %

          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             :     @see
      38             :         @ref result.
      39             : */
      40             : template<class Rule>
      41             : system::result<typename Rule::value_type>
      42             : parse(
      43             :     char const*& it,
      44             :     char const* end,
      45             :     Rule const& r);       
      46             : 
      47             : /** Parse a character buffer using a rule
      48             : 
      49             :     This function parses a complete string into
      50             :     the specified sequence of rules. If the
      51             :     string is not completely consumed, an
      52             :     error is returned instead.
      53             : 
      54             :     @param s The input string
      55             : 
      56             :     @param r The rule to use
      57             : 
      58             :     @return The parsed value upon success,
      59             :     otherwise an error.
      60             : 
      61             :     @see
      62             :         @ref result.
      63             : */
      64             : template<class Rule>
      65             : system::result<typename Rule::value_type>
      66             : parse(
      67             :     core::string_view s,
      68             :     Rule const& r);
      69             : 
      70             : //------------------------------------------------
      71             : 
      72             : #ifndef BOOST_URL_DOCS
      73             : namespace detail {
      74             : 
      75             : template<class Rule>
      76             : struct rule_ref
      77             : {
      78             :     Rule const& r_;
      79             : 
      80             :     using value_type =
      81             :         typename Rule::value_type;
      82             : 
      83             :     system::result<value_type>
      84           1 :     parse(
      85             :         char const*& it,
      86             :         char const* end) const
      87             :     {
      88           1 :         return r_.parse(it, end);
      89             :     }
      90             : };
      91             : 
      92             : } // detail
      93             : #endif
      94             : 
      95             : /** Return a reference to a rule
      96             : 
      97             :     This function returns a rule which
      98             :     references the specified object. This is
      99             :     used to reduce the number of bytes of
     100             :     storage (`sizeof`) required by a combinator
     101             :     when it stores a copy of the object.
     102             :     <br>
     103             :     Ownership of the object is not transferred;
     104             :     the caller is responsible for ensuring the
     105             :     lifetime of the object is extended until it
     106             :     is no longer referenced. For best results,
     107             :     `ref` should only be used with compile-time
     108             :     constants.
     109             : 
     110             :     @param r The rule to use
     111             : */
     112             : template<class Rule>
     113             : constexpr
     114             : #ifdef BOOST_URL_DOCS
     115             : __implementation_defined__
     116             : #else
     117             : typename std::enable_if<
     118             :     is_rule<Rule>::value &&
     119             :     ! std::is_same<Rule,
     120             :         detail::rule_ref<Rule> >::value,
     121             :     detail::rule_ref<Rule> >::type
     122             : #endif
     123           1 : ref(Rule const& r) noexcept
     124             : {
     125             :     return detail::rule_ref<
     126           1 :         Rule>{r};
     127             : }
     128             : 
     129             : #ifndef BOOST_URL_DOCS
     130             : // If you get a compile error here it
     131             : // means you called ref with something
     132             : // that is not a CharSet or Rule!
     133             : constexpr
     134             : void
     135             : ref(...) = delete;
     136             : #endif
     137             : 
     138             : } // grammar
     139             : } // urls
     140             : } // boost
     141             : 
     142             : #include <boost/url/grammar/impl/parse.hpp>
     143             : 
     144             : #endif

Generated by: LCOV version 1.15