GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/authority_rule.cpp
Date: 2023-12-15 15:31:49
Exec Total Coverage
Lines: 25 27 92.6%
Functions: 1 1 100.0%
Branches: 10 12 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_AUTHORITY_RULE_IPP
11 #define BOOST_URL_RFC_IMPL_AUTHORITY_RULE_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/rfc/authority_rule.hpp>
15 #include <boost/url/grammar/delim_rule.hpp>
16 #include <boost/url/grammar/optional_rule.hpp>
17 #include <boost/url/grammar/parse.hpp>
18 #include <boost/url/grammar/tuple_rule.hpp>
19 #include <boost/url/rfc/detail/host_rule.hpp>
20 #include <boost/url/rfc/detail/port_rule.hpp>
21 #include <boost/url/rfc/detail/userinfo_rule.hpp>
22
23 namespace boost {
24 namespace urls {
25
26 auto
27 1871 authority_rule_t::
28 parse(
29 char const*& it,
30 char const* const end
31 ) const noexcept ->
32 system::result<value_type>
33 {
34 1871 detail::url_impl u(detail::url_impl::from::authority);
35 1871 u.cs_ = it;
36
37 // [ userinfo "@" ]
38 {
39 auto rv = grammar::parse(
40 it, end,
41 1871 grammar::optional_rule(
42 1871 grammar::tuple_rule(
43 detail::userinfo_rule,
44 1871 grammar::squelch(
45 1871 grammar::delim_rule('@')))));
46
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1871 times.
1871 if(! rv)
47 return rv.error();
48
2/2
✓ Branch 2 taken 372 times.
✓ Branch 3 taken 1499 times.
1871 if(rv->has_value())
49 {
50 129 u.apply_userinfo(
51 372 (*rv)->user,
52
2/2
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 129 times.
372 (*rv)->has_password
53 243 ? &(*rv)->password
54 : nullptr);
55 }
56 }
57
58 // host
59 {
60 auto rv = grammar::parse(
61 1871 it, end, detail::host_rule);
62
2/2
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 1840 times.
1871 if(! rv)
63 31 return rv.error();
64 1840 u.apply_host(rv->host_type,
65 1840 rv->match, rv->addr);
66 }
67
68 // [ ":" port ]
69 {
70 auto rv = grammar::parse(
71 1840 it, end, detail::port_part_rule);
72
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1840 times.
1840 if(! rv)
73 return rv.error();
74
2/2
✓ Branch 1 taken 239 times.
✓ Branch 2 taken 1601 times.
1840 if(rv->has_port)
75 239 u.apply_port(
76 239 rv->port,
77 239 rv->port_number);
78 }
79
80 1840 return u.construct_authority();
81 }
82
83 } // urls
84 } // boost
85
86 #endif
87