GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/origin_form_rule.cpp
Date: 2024-02-29 20:02:56
Exec Total Coverage
Lines: 19 20 95.0%
Functions: 1 1 100.0%
Branches: 5 6 83.3%

Line Branch Exec Source
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_RFC_IMPL_ORIGIN_FORM_RULE_IPP
11 #define BOOST_URL_RFC_IMPL_ORIGIN_FORM_RULE_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/rfc/origin_form_rule.hpp>
15 #include <boost/url/rfc/query_rule.hpp>
16 #include "boost/url/rfc/detail/path_rules.hpp"
17 #include "detail/query_part_rule.hpp"
18 #include <boost/url/grammar/delim_rule.hpp>
19 #include <boost/url/grammar/range_rule.hpp>
20 #include <boost/url/grammar/tuple_rule.hpp>
21
22 namespace boost {
23 namespace urls {
24
25 auto
26 17 origin_form_rule_t::
27 parse(
28 char const*& it,
29 char const* end
30 ) const noexcept ->
31 system::result<value_type>
32 {
33 17 detail::url_impl u(detail::url_impl::from::string);
34 17 u.cs_ = it;
35
36 {
37 auto rv = grammar::parse(it, end,
38 17 grammar::range_rule(
39 17 grammar::tuple_rule(
40 17 grammar::delim_rule('/'),
41 17 detail::segment_rule),
42 17 1));
43
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 13 times.
17 if(! rv)
44 4 return rv.error();
45 13 u.apply_path(
46 rv->string(),
47 rv->size());
48 }
49
50 // [ "?" query ]
51 {
52 auto rv = grammar::parse(
53 13 it, end, detail::query_part_rule);
54
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
13 if(! rv)
55 return rv.error();
56
2/2
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
13 if(rv->has_query)
57 {
58 // map "?" to { {} }
59 8 u.apply_query(
60 8 rv->query,
61 8 rv->count +
62 8 rv->query.empty());
63 }
64 }
65
66 13 return u.construct();
67 }
68
69 } // urls
70 } // boost
71
72 #endif
73