LCOV - code coverage report
Current view: top level - url/rfc/impl - relative_ref_rule.hpp (source / functions) Coverage Total Hit Missed
Test: coverage_remapped.info Lines: 95.7 % 23 22 1
Test Date: 2026-03-02 22:26:03 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_RELATIVE_REF_RULE_HPP
      12                 : #define BOOST_URL_RFC_IMPL_RELATIVE_REF_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/query_part_rule.hpp>
      22                 : #include <boost/url/rfc/detail/relative_part_rule.hpp>
      23                 : 
      24                 : namespace boost {
      25                 : namespace urls {
      26                 : 
      27                 : BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
      28                 : auto
      29 HIT       13091 : implementation_defined::relative_ref_rule_t::
      30                 : parse(
      31                 :     char const*& it,
      32                 :     char const* const end
      33                 :         ) const noexcept ->
      34                 :     system::result<value_type>
      35                 : {
      36           13091 :     detail::url_impl u(detail::url_impl::from::string);
      37           13091 :     u.cs_ = it;
      38                 : 
      39                 :     // relative-part
      40                 :     {
      41                 :         auto rv = grammar::parse(
      42                 :             it, end,
      43           13091 :             detail::relative_part_rule);
      44           13091 :         if(! rv)
      45             540 :             return rv.error();
      46           12551 :         if(rv->has_authority)
      47             254 :             u.apply_authority(rv->authority.u_);
      48           25102 :         u.apply_path(
      49           12551 :             rv->path, rv->segment_count);
      50           13091 :     }
      51                 : 
      52                 :     // [ "?" query ]
      53                 :     {
      54           12551 :         auto rv = grammar::parse(
      55                 :             it, end, detail::query_part_rule);
      56           12551 :         if(! rv)
      57 MIS           0 :             return rv.error();
      58 HIT       12551 :         auto& v = *rv;
      59           12551 :         if(v.has_query)
      60                 :         {
      61                 :             // map "?" to { {} }
      62             968 :             u.apply_query(
      63                 :                 v.query,
      64                 :                 v.count);
      65                 :         }
      66                 :     }
      67                 : 
      68                 :     // [ "#" fragment ]
      69                 :     {
      70           12551 :         auto rv = grammar::parse(
      71                 :             it, end, detail::fragment_part_rule);
      72           12551 :         if(! rv)
      73               9 :             return rv.error();
      74           12542 :         if(rv->has_fragment)
      75             742 :             u.apply_frag(rv->fragment);
      76                 :     }
      77                 : 
      78           12542 :     return url_view(u);
      79                 : }
      80                 : 
      81                 : } // urls
      82                 : } // boost
      83                 : 
      84                 : 
      85                 : #endif
        

Generated by: LCOV version 2.3