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_ALPHA_CHARS_HPP | ||
11 | #define BOOST_URL_GRAMMAR_ALPHA_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 all letters | ||
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 > rv = parse( "JohnDoe", token_rule( alpha_chars ) ); | ||
27 | @endcode | ||
28 | |||
29 | @par BNF | ||
30 | @code | ||
31 | ALPHA = %x41-5A / %x61-7A | ||
32 | ; A-Z / a-z | ||
33 | @endcode | ||
34 | |||
35 | @par Specification | ||
36 | @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1" | ||
37 | >B.1. Core Rules (rfc5234)</a> | ||
38 | |||
39 | @see | ||
40 | @ref find_if, | ||
41 | @ref find_if_not, | ||
42 | @ref parse, | ||
43 | @ref token_rule. | ||
44 | */ | ||
45 | #ifdef BOOST_URL_DOCS | ||
46 | constexpr __implementation_defined__ alpha_chars; | ||
47 | #else | ||
48 | struct alpha_chars_t | ||
49 | { | ||
50 | constexpr | ||
51 | alpha_chars_t() noexcept = default; | ||
52 | |||
53 | constexpr | ||
54 | bool | ||
55 | 35972 | operator()(char c) const noexcept | |
56 | { | ||
57 | return | ||
58 |
6/6✓ Branch 0 taken 11547 times.
✓ Branch 1 taken 24425 times.
✓ Branch 2 taken 7818 times.
✓ Branch 3 taken 3729 times.
✓ Branch 4 taken 7138 times.
✓ Branch 5 taken 25105 times.
|
43110 | (c >= 'A' && c <= 'Z') || |
59 |
2/2✓ Branch 0 taken 6368 times.
✓ Branch 1 taken 770 times.
|
43110 | (c >= 'a' && c <= 'z'); |
60 | } | ||
61 | |||
62 | #ifdef BOOST_URL_USE_SSE2 | ||
63 | char const* | ||
64 | 256 | find_if( | |
65 | char const* first, | ||
66 | char const* last) const noexcept | ||
67 | { | ||
68 | 256 | return detail::find_if_pred( | |
69 | 256 | *this, first, last); | |
70 | } | ||
71 | |||
72 | char const* | ||
73 | 325 | find_if_not( | |
74 | char const* first, | ||
75 | char const* last) const noexcept | ||
76 | { | ||
77 | 325 | return detail::find_if_not_pred( | |
78 | 325 | *this, first, last); | |
79 | } | ||
80 | #endif | ||
81 | }; | ||
82 | |||
83 | /** A character set containing the alphabetical characters. | ||
84 | |||
85 | @see | ||
86 | @ref alpha_chars_t | ||
87 | */ | ||
88 | constexpr alpha_chars_t alpha_chars{}; | ||
89 | #endif | ||
90 | |||
91 | } // grammar | ||
92 | } // urls | ||
93 | } // boost | ||
94 | |||
95 | #endif | ||
96 |