LCOV - code coverage report
Current view: top level - url/rfc/impl - uri_rule.hpp (source / functions) Coverage Total Hit Missed
Test: coverage_remapped.info Lines: 97.0 % 33 32 1
Test Date: 2026-02-25 21:00:01 Functions: 100.0 % 1 1

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
       3                 : // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
       4                 : //
       5                 : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       6                 : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       7                 : //
       8                 : // Official repository: https://github.com/boostorg/url
       9                 : //
      10                 : 
      11                 : #ifndef BOOST_URL_RFC_IMPL_URI_RULE_HPP
      12                 : #define BOOST_URL_RFC_IMPL_URI_RULE_HPP
      13                 : 
      14                 : #include <boost/url/detail/config.hpp>
      15                 : #include <boost/url/url_view.hpp>
      16                 : #include <boost/url/grammar/delim_rule.hpp>
      17                 : #include <boost/url/grammar/tuple_rule.hpp>
      18                 : #include <boost/url/grammar/optional_rule.hpp>
      19                 : #include <boost/url/grammar/parse.hpp>
      20                 : #include <boost/url/rfc/detail/fragment_part_rule.hpp>
      21                 : #include <boost/url/rfc/detail/hier_part_rule.hpp>
      22                 : #include <boost/url/rfc/detail/query_part_rule.hpp>
      23                 : #include <boost/url/rfc/detail/scheme_rule.hpp>
      24                 : 
      25                 : namespace boost {
      26                 : namespace urls {
      27                 : 
      28                 : BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
      29                 : auto
      30 HIT        3591 : implementation_defined::uri_rule_t::
      31                 : parse(
      32                 :     char const*& it,
      33                 :     char const* const end
      34                 :         ) const noexcept ->
      35                 :     system::result<value_type>
      36                 : {
      37            3591 :     detail::url_impl u(detail::url_impl::from::string);
      38            3591 :     u.cs_ = it;
      39                 : 
      40                 :     // scheme
      41                 :     {
      42            3591 :         auto rv = grammar::parse(
      43                 :             it, end,
      44            3591 :             grammar::tuple_rule(
      45            3591 :                 detail::scheme_rule(),
      46            3591 :                 grammar::squelch(
      47            3591 :                     grammar::delim_rule(':'))));
      48            3591 :         if(! rv)
      49            1185 :             return rv.error();
      50            2406 :         u.apply_scheme(rv->scheme);
      51                 :     }
      52                 : 
      53                 :     // hier_part
      54                 :     {
      55                 :         auto rv = grammar::parse(
      56                 :             it, end,
      57            2406 :             detail::hier_part_rule);
      58            2406 :         if(! rv)
      59              36 :             return rv.error();
      60            2370 :         if(rv->has_authority)
      61            1589 :             u.apply_authority(rv->authority.u_);
      62            4740 :         u.apply_path(
      63            2370 :             rv->path,
      64            2370 :             rv->segment_count);
      65            2406 :     }
      66                 : 
      67                 :     // [ "?" query ]
      68                 :     {
      69            2370 :         auto rv = grammar::parse(
      70                 :             it, end, detail::query_part_rule);
      71            2370 :         if(! rv)
      72 MIS           0 :             return rv.error();
      73 HIT        2370 :         if(rv->has_query)
      74                 :         {
      75                 :             // map "?" to { {} }
      76             470 :             u.apply_query(
      77             235 :                 rv->query,
      78             235 :                 rv->count);
      79                 :         }
      80                 :     }
      81                 : 
      82                 :     // [ "#" fragment ]
      83                 :     {
      84            2370 :         auto rv = grammar::parse(
      85                 :             it, end, detail::fragment_part_rule);
      86            2370 :         if(! rv)
      87               1 :             return rv.error();
      88            2369 :         if(rv->has_fragment)
      89             181 :             u.apply_frag(rv->fragment);
      90                 :     }
      91                 : 
      92            2369 :     return url_view(u);
      93                 : }
      94                 : 
      95                 : } // urls
      96                 : } // boost
      97                 : 
      98                 : 
      99                 : #endif
        

Generated by: LCOV version 2.3