GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/rfc/detail/scheme_rule.cpp
Date: 2023-12-15 15:31:49
Exec Total Coverage
Lines: 13 13 100.0%
Functions: 1 1 100.0%
Branches: 4 4 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_IMPL_SCHEME_RULE_IPP
11 #define BOOST_URL_IMPL_SCHEME_RULE_IPP
12
13 #include <boost/url/detail/config.hpp>
14 #include <boost/url/rfc/detail/scheme_rule.hpp>
15 #include <boost/url/grammar/alpha_chars.hpp>
16 #include <boost/url/grammar/delim_rule.hpp>
17 #include <boost/url/grammar/lut_chars.hpp>
18 #include <boost/url/grammar/parse.hpp>
19 #include <boost/url/grammar/tuple_rule.hpp>
20
21 namespace boost {
22 namespace urls {
23 namespace detail {
24
25 auto
26 3501 scheme_rule::
27 parse(
28 char const*& it,
29 char const* end) const noexcept ->
30 system::result<value_type>
31 {
32 3501 auto const start = it;
33
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3377 times.
3501 if(it == end)
34 {
35 // end
36 124 BOOST_URL_RETURN_EC(
37 grammar::error::mismatch);
38 }
39
2/2
✓ Branch 1 taken 834 times.
✓ Branch 2 taken 2543 times.
3377 if(! grammar::alpha_chars(*it))
40 {
41 // expected alpha
42 834 BOOST_URL_RETURN_EC(
43 grammar::error::mismatch);
44 }
45
46 static
47 constexpr
48 grammar::lut_chars scheme_chars(
49 "0123456789" "+-."
50 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
51 "abcdefghijklmnopqrstuvwxyz");
52 5086 it = grammar::find_if_not(
53 2543 it + 1, end, scheme_chars);
54 2543 value_type t;
55 5086 t.scheme = core::string_view(
56 2543 start, it - start);
57 2543 t.scheme_id = string_to_scheme(
58 t.scheme);
59 2543 return t;
60 }
61
62 } // detail
63 } // urls
64 } // boost
65
66 #endif
67