GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/query_rule.cpp
Date: 2023-12-15 15:31:49
Exec Total Coverage
Lines: 30 30 100.0%
Functions: 1 1 100.0%
Branches: 18 18 100.0%

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_QUERY_RULE_IPP
11 #define BOOST_URL_RFC_IMPL_QUERY_RULE_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/rfc/query_rule.hpp>
15 #include <boost/url/rfc/detail/charsets.hpp>
16 #include <boost/url/error.hpp>
17 #include <boost/url/grammar/hexdig_chars.hpp>
18
19 namespace boost {
20 namespace urls {
21
22 auto
23 553 query_rule_t::
24 parse(
25 char const*& it,
26 char const* end
27 ) const noexcept ->
28 system::result<value_type>
29 {
30
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 521 times.
553 if(it == end)
31 {
32 // empty string = 0 params
33 32 return params_encoded_view(
34 64 detail::query_ref(
35 32 core::string_view(it, 0), 0, 0));
36 }
37 521 auto const it0 = it;
38 521 std::size_t dn = 0;
39 521 std::size_t nparam = 1;
40
2/2
✓ Branch 0 taken 6551 times.
✓ Branch 1 taken 353 times.
6904 while(it != end)
41 {
42
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 6097 times.
6551 if(*it == '&')
43 {
44 454 ++nparam;
45 454 ++it;
46 454 continue;
47 }
48
2/2
✓ Branch 1 taken 5835 times.
✓ Branch 2 taken 262 times.
6097 if(detail::query_chars(*it))
49 {
50 5835 ++it;
51 5835 continue;
52 }
53
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 156 times.
262 if(*it == '%')
54 {
55
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 97 times.
106 if(end - it < 3)
56 {
57 // missing HEXDIG
58 9 BOOST_URL_RETURN_EC(
59 error::missing_pct_hexdig);
60 }
61
4/4
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 94 times.
193 if (!grammar::hexdig_chars(it[1]) ||
62
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 94 times.
96 !grammar::hexdig_chars(it[2]))
63 {
64 // expected HEXDIG
65 3 BOOST_URL_RETURN_EC(
66 error::bad_pct_hexdig);
67 }
68 94 it += 3;
69 94 dn += 2;
70 94 continue;
71 }
72 // got reserved character
73 156 break;
74 }
75 509 std::size_t const n(it - it0);
76 509 return params_encoded_view(
77 1018 detail::query_ref(
78 core::string_view(it0, n),
79 n - dn,
80 509 nparam));
81 }
82
83 } // urls
84 } // boost
85
86 #endif
87