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 "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 | 3525 | scheme_rule:: | |
27 | parse( | ||
28 | char const*& it, | ||
29 | char const* end) const noexcept -> | ||
30 | system::result<value_type> | ||
31 | { | ||
32 | 3525 | auto const start = it; | |
33 |
2/2✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3401 times.
|
3525 | if(it == end) |
34 | { | ||
35 | // end | ||
36 | 124 | BOOST_URL_RETURN_EC( | |
37 | grammar::error::mismatch); | ||
38 | } | ||
39 |
2/2✓ Branch 1 taken 842 times.
✓ Branch 2 taken 2559 times.
|
3401 | if(! grammar::alpha_chars(*it)) |
40 | { | ||
41 | // expected alpha | ||
42 | 842 | 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 | 5118 | it = grammar::find_if_not( | |
53 | 2559 | it + 1, end, scheme_chars); | |
54 | 2559 | value_type t; | |
55 | 5118 | t.scheme = core::string_view( | |
56 | 2559 | start, it - start); | |
57 | 2559 | t.scheme_id = string_to_scheme( | |
58 | t.scheme); | ||
59 | 2559 | return t; | |
60 | } | ||
61 | |||
62 | } // detail | ||
63 | } // urls | ||
64 | } // boost | ||
65 | |||
66 | #endif | ||
67 |