Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2021 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_GRAMMAR_ALNUM_CHARS_HPP | ||
11 | #define BOOST_URL_GRAMMAR_ALNUM_CHARS_HPP | ||
12 | |||
13 | #include <boost/url/detail/config.hpp> | ||
14 | #include <boost/url/grammar/detail/charset.hpp> | ||
15 | |||
16 | namespace boost { | ||
17 | namespace urls { | ||
18 | namespace grammar { | ||
19 | |||
20 | /** The set of letters and digits | ||
21 | |||
22 | @par Example | ||
23 | Character sets are used with rules and the | ||
24 | functions @ref find_if and @ref find_if_not. | ||
25 | @code | ||
26 | system::result< core::string_view > = parse( "Johnny42", token_rule( alnumchars ) ); | ||
27 | @endcode | ||
28 | |||
29 | @par BNF | ||
30 | @code | ||
31 | ALNUM = ALPHA / DIGIT | ||
32 | |||
33 | ALPHA = %x41-5A / %x61-7A | ||
34 | ; A-Z / a-z | ||
35 | |||
36 | DIGIT = %x30-39 | ||
37 | ; 0-9 | ||
38 | @endcode | ||
39 | |||
40 | @par Specification | ||
41 | @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1" | ||
42 | >B.1. Core Rules (rfc5234)</a> | ||
43 | |||
44 | @see | ||
45 | @ref find_if, | ||
46 | @ref find_if_not, | ||
47 | @ref parse, | ||
48 | @ref token_rule. | ||
49 | */ | ||
50 | #ifdef BOOST_URL_DOCS | ||
51 | constexpr __implementation_defined__ alnum_chars; | ||
52 | #else | ||
53 | struct alnum_chars_t | ||
54 | { | ||
55 | constexpr | ||
56 | bool | ||
57 | 5496 | operator()(char c) const noexcept | |
58 | { | ||
59 | return | ||
60 |
4/4✓ Branch 0 taken 2018 times.
✓ Branch 1 taken 352 times.
✓ Branch 2 taken 1977 times.
✓ Branch 3 taken 3167 times.
|
5496 | (c >= '0' && c <= '9') || |
61 |
6/6✓ Branch 0 taken 2370 times.
✓ Branch 1 taken 3126 times.
✓ Branch 2 taken 1066 times.
✓ Branch 3 taken 911 times.
✓ Branch 4 taken 1036 times.
✓ Branch 5 taken 3197 times.
|
12028 | (c >= 'A' && c <= 'Z') || |
62 |
2/2✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 25 times.
|
6532 | (c >= 'a' && c <= 'z'); |
63 | } | ||
64 | |||
65 | #ifdef BOOST_URL_USE_SSE2 | ||
66 | char const* | ||
67 | 256 | find_if( | |
68 | char const* first, | ||
69 | char const* last) const noexcept | ||
70 | { | ||
71 | 256 | return detail::find_if_pred( | |
72 | 256 | *this, first, last); | |
73 | } | ||
74 | |||
75 | char const* | ||
76 | 269 | find_if_not( | |
77 | char const* first, | ||
78 | char const* last) const noexcept | ||
79 | { | ||
80 | 269 | return detail::find_if_not_pred( | |
81 | 269 | *this, first, last); | |
82 | } | ||
83 | #endif | ||
84 | }; | ||
85 | |||
86 | constexpr alnum_chars_t alnum_chars{}; | ||
87 | #endif | ||
88 | |||
89 | } // grammar | ||
90 | } // urls | ||
91 | } // boost | ||
92 | |||
93 | #endif | ||
94 |