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: 2024-08-19 20:08:54 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<class Rule>
      38              : system::result<typename Rule::value_type>
      39              : parse(
      40              :     char const*& it,
      41              :     char const* end,
      42              :     Rule 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<class Rule>
      59              : system::result<typename Rule::value_type>
      60              : parse(
      61              :     core::string_view s,
      62              :     Rule const& r);
      63              : 
      64              : //------------------------------------------------
      65              : 
      66              : #ifndef BOOST_URL_DOCS
      67              : namespace implementation_defined {
      68              : 
      69              : template<class Rule>
      70              : struct rule_ref
      71              : {
      72              :     Rule const& r_;
      73              : 
      74              :     using value_type =
      75              :         typename Rule::value_type;
      76              : 
      77              :     system::result<value_type>
      78            1 :     parse(
      79              :         char const*& it,
      80              :         char const* end) const
      81              :     {
      82            1 :         return r_.parse(it, end);
      83              :     }
      84              : };
      85              : 
      86              : } // detail
      87              : #endif
      88              : 
      89              : /** Return a reference to a rule
      90              : 
      91              :     This function returns a rule which
      92              :     references the specified object. This is
      93              :     used to reduce the number of bytes of
      94              :     storage (`sizeof`) required by a combinator
      95              :     when it stores a copy of the object.
      96              :     <br>
      97              :     Ownership of the object is not transferred;
      98              :     the caller is responsible for ensuring the
      99              :     lifetime of the object is extended until it
     100              :     is no longer referenced. For best results,
     101              :     `ref` should only be used with compile-time
     102              :     constants.
     103              : 
     104              :     @param r The rule to use
     105              : */
     106              : #ifdef BOOST_URL_DOCS
     107              : template<class Rule>
     108              : constexpr
     109              : __implementation_defined__
     110              : ref(Rule const& r) noexcept;
     111              : #else
     112              : 
     113              : /** Return a reference to a rule
     114              : 
     115              :     This function returns a rule which
     116              :     references the specified object. This is
     117              :     used to reduce the number of bytes of
     118              :     storage (`sizeof`) required by a combinator
     119              :     when it stores a copy of the object.
     120              :     <br>
     121              :     Ownership of the object is not transferred;
     122              :     the caller is responsible for ensuring the
     123              :     lifetime of the object is extended until it
     124              :     is no longer referenced. For best results,
     125              :     `ref` should only be used with compile-time
     126              :     constants.
     127              : 
     128              :     @param r The rule to use
     129              : */
     130              : template<class Rule>
     131              : constexpr
     132              : typename std::enable_if<
     133              :     is_rule<Rule>::value &&
     134              :     ! std::is_same<Rule,
     135              :         implementation_defined::rule_ref<Rule> >::value,
     136              :     implementation_defined::rule_ref<Rule> >::type
     137            1 : ref(Rule const& r) noexcept
     138              : {
     139              :     return implementation_defined::rule_ref<
     140            1 :         Rule>{r};
     141              : }
     142              : #endif
     143              : 
     144              : #ifndef BOOST_URL_DOCS
     145              : #ifndef BOOST_URL_MRDOCS
     146              : // If you get a compile error here it
     147              : // means you called ref with something
     148              : // that is not a CharSet or Rule!
     149              : constexpr
     150              : void
     151              : ref(...) = delete;
     152              : #endif
     153              : #endif
     154              : 
     155              : } // grammar
     156              : } // urls
     157              : } // boost
     158              : 
     159              : #include <boost/url/grammar/impl/parse.hpp>
     160              : 
     161              : #endif
        

Generated by: LCOV version 2.1