GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/detail/ip_literal_rule.cpp
Date: 2024-02-29 20:02:56
Exec Total Coverage
Lines: 30 33 90.9%
Functions: 1 1 100.0%
Branches: 9 12 75.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 // Copyright (c) 2022 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_IMPL_IP_LITERAL_RULE_IPP
12 #define BOOST_URL_IMPL_IP_LITERAL_RULE_IPP
13
14 #include <boost/url/detail/config.hpp>
15 #include <boost/url/rfc/ipv6_address_rule.hpp>
16 #include "ip_literal_rule.hpp"
17 #include "ipv6_addrz_rule.hpp"
18 #include <boost/url/grammar/delim_rule.hpp>
19 #include <boost/url/grammar/parse.hpp>
20 #include <boost/url/grammar/tuple_rule.hpp>
21 #include "ipvfuture_rule.hpp"
22
23 namespace boost {
24 namespace urls {
25 namespace detail {
26
27 auto
28 61 ip_literal_rule_t::
29 parse(
30 char const*& it,
31 char const* const end
32 ) const noexcept ->
33 system::result<value_type>
34 {
35 61 value_type t;
36
37 // '['
38 {
39 auto rv = grammar::parse(
40 61 it, end, grammar::delim_rule('['));
41
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
61 if(! rv)
42 return rv.error();
43 }
44
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(it == end)
45 {
46 // end
47 BOOST_URL_RETURN_EC(
48 grammar::error::invalid);
49 }
50
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 5 times.
61 if(*it != 'v')
51 {
52 // IPv6address
53 56 auto it0 = it;
54 auto rv = grammar::parse(
55 it, end,
56 56 grammar::tuple_rule(
57 ipv6_address_rule,
58 56 grammar::squelch(
59 56 grammar::delim_rule(']'))));
60
2/2
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 29 times.
56 if(! rv)
61 {
62 // IPv6addrz
63 27 it = it0;
64 auto rv2 = grammar::parse(
65 it, end,
66 27 grammar::tuple_rule(
67 ipv6_addrz_rule,
68 27 grammar::squelch(
69 27 grammar::delim_rule(']'))));
70
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 3 times.
27 if(! rv2)
71 24 return rv2.error();
72 3 t.ipv6 = rv2->ipv6;
73 3 t.is_ipv6 = true;
74 3 return t;
75 }
76 29 t.ipv6 = *rv;
77 29 t.is_ipv6 = true;
78 29 return t;
79 }
80 {
81 // IPvFuture
82 auto rv = grammar::parse(
83 it, end,
84 5 grammar::tuple_rule(
85 ipvfuture_rule,
86 5 grammar::squelch(
87 5 grammar::delim_rule(']'))));
88
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 if(! rv)
89 return rv.error();
90 5 t.is_ipv6 = false;
91 5 t.ipvfuture = rv->str;
92 5 return t;
93 }
94 }
95
96 } // detail
97 } // urls
98 } // boost
99
100 #endif
101