95.65% Lines (22/23) 100.00% Functions (1/1)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) 2   // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3   // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com) 3   // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
4   // 4   //
5   // Distributed under the Boost Software License, Version 1.0. (See accompanying 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) 6   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7   // 7   //
8   // Official repository: https://github.com/boostorg/url 8   // Official repository: https://github.com/boostorg/url
9   // 9   //
10   10  
11   #ifndef BOOST_URL_RFC_IMPL_RELATIVE_REF_RULE_HPP 11   #ifndef BOOST_URL_RFC_IMPL_RELATIVE_REF_RULE_HPP
12   #define BOOST_URL_RFC_IMPL_RELATIVE_REF_RULE_HPP 12   #define BOOST_URL_RFC_IMPL_RELATIVE_REF_RULE_HPP
13   13  
14   #include <boost/url/detail/config.hpp> 14   #include <boost/url/detail/config.hpp>
15   #include <boost/url/url_view.hpp> 15   #include <boost/url/url_view.hpp>
16   #include <boost/url/grammar/delim_rule.hpp> 16   #include <boost/url/grammar/delim_rule.hpp>
17   #include <boost/url/grammar/tuple_rule.hpp> 17   #include <boost/url/grammar/tuple_rule.hpp>
18   #include <boost/url/grammar/optional_rule.hpp> 18   #include <boost/url/grammar/optional_rule.hpp>
19   #include <boost/url/grammar/parse.hpp> 19   #include <boost/url/grammar/parse.hpp>
20   #include <boost/url/rfc/detail/fragment_part_rule.hpp> 20   #include <boost/url/rfc/detail/fragment_part_rule.hpp>
21   #include <boost/url/rfc/detail/query_part_rule.hpp> 21   #include <boost/url/rfc/detail/query_part_rule.hpp>
22   #include <boost/url/rfc/detail/relative_part_rule.hpp> 22   #include <boost/url/rfc/detail/relative_part_rule.hpp>
23   23  
24   namespace boost { 24   namespace boost {
25   namespace urls { 25   namespace urls {
26   26  
27   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 27   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
28   auto 28   auto
HITCBC 29   13131 implementation_defined::relative_ref_rule_t:: 29   13135 implementation_defined::relative_ref_rule_t::
30   parse( 30   parse(
31   char const*& it, 31   char const*& it,
32   char const* const end 32   char const* const end
33   ) const noexcept -> 33   ) const noexcept ->
34   system::result<value_type> 34   system::result<value_type>
35   { 35   {
HITCBC 36   13131 detail::url_impl u(detail::url_impl::from::string); 36   13135 detail::url_impl u(detail::url_impl::from::string);
HITCBC 37   13131 u.cs_ = it; 37   13135 u.cs_ = it;
38   38  
39   // relative-part 39   // relative-part
40   { 40   {
41   auto rv = grammar::parse( 41   auto rv = grammar::parse(
42   it, end, 42   it, end,
HITCBC 43   13131 detail::relative_part_rule); 43   13135 detail::relative_part_rule);
HITCBC 44   13131 if(! rv) 44   13135 if(! rv)
HITCBC 45   540 return rv.error(); 45   540 return rv.error();
HITCBC 46   12591 if(rv->has_authority) 46   12595 if(rv->has_authority)
HITCBC 47   254 u.apply_authority(rv->authority.u_); 47   254 u.apply_authority(rv->authority.u_);
HITCBC 48   25182 u.apply_path( 48   25190 u.apply_path(
HITCBC 49   12591 rv->path, rv->segment_count); 49   12595 rv->path, rv->segment_count);
HITCBC 50   13131 } 50   13135 }
51   51  
52   // [ "?" query ] 52   // [ "?" query ]
53   { 53   {
HITCBC 54   12591 auto rv = grammar::parse( 54   12595 auto rv = grammar::parse(
55   it, end, detail::query_part_rule); 55   it, end, detail::query_part_rule);
HITCBC 56   12591 if(! rv) 56   12595 if(! rv)
MISUBC 57   return rv.error(); 57   return rv.error();
HITCBC 58   12591 auto& v = *rv; 58   12595 auto& v = *rv;
HITCBC 59   12591 if(v.has_query) 59   12595 if(v.has_query)
60   { 60   {
61   // map "?" to { {} } 61   // map "?" to { {} }
HITCBC 62   968 u.apply_query( 62   972 u.apply_query(
63   v.query, 63   v.query,
64   v.count); 64   v.count);
65   } 65   }
66   } 66   }
67   67  
68   // [ "#" fragment ] 68   // [ "#" fragment ]
69   { 69   {
HITCBC 70   12591 auto rv = grammar::parse( 70   12595 auto rv = grammar::parse(
71   it, end, detail::fragment_part_rule); 71   it, end, detail::fragment_part_rule);
HITCBC 72   12591 if(! rv) 72   12595 if(! rv)
HITCBC 73   9 return rv.error(); 73   9 return rv.error();
HITCBC 74   12582 if(rv->has_fragment) 74   12586 if(rv->has_fragment)
HITCBC 75   742 u.apply_frag(rv->fragment); 75   742 u.apply_frag(rv->fragment);
76   } 76   }
77   77  
HITCBC 78   12582 return url_view(u); 78   12586 return url_view(u);
79   } 79   }
80   80  
81   } // urls 81   } // urls
82   } // boost 82   } // boost
83   83  
84   84  
85   #endif 85   #endif