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 | namespace implementation_defined { | ||
49 | struct alpha_chars_t | ||
50 | { | ||
51 | constexpr | ||
52 | alpha_chars_t() noexcept = default; | ||
53 | |||
54 | constexpr | ||
55 | bool | ||
56 | 36017 | operator()(char c) const noexcept | |
57 | { | ||
58 | return | ||
59 |
6/6✓ Branch 0 taken 11583 times.
✓ Branch 1 taken 24434 times.
✓ Branch 2 taken 7853 times.
✓ Branch 3 taken 3730 times.
✓ Branch 4 taken 7173 times.
✓ Branch 5 taken 25114 times.
|
43190 | (c >= 'A' && c <= 'Z') || |
60 |
2/2✓ Branch 0 taken 6403 times.
✓ Branch 1 taken 770 times.
|
43190 | (c >= 'a' && c <= 'z'); |
61 | } | ||
62 | |||
63 | #ifdef BOOST_URL_USE_SSE2 | ||
64 | char const* | ||
65 | 256 | find_if( | |
66 | char const* first, | ||
67 | char const* last) const noexcept | ||
68 | { | ||
69 | 256 | return detail::find_if_pred( | |
70 | 256 | *this, first, last); | |
71 | } | ||
72 | |||
73 | char const* | ||
74 | 325 | find_if_not( | |
75 | char const* first, | ||
76 | char const* last) const noexcept | ||
77 | { | ||
78 | 325 | return detail::find_if_not_pred( | |
79 | 325 | *this, first, last); | |
80 | } | ||
81 | #endif | ||
82 | }; | ||
83 | } // implementation_defined | ||
84 | |||
85 | /** The set of all letters | ||
86 | |||
87 | @par Example | ||
88 | Character sets are used with rules and the | ||
89 | functions @ref find_if and @ref find_if_not. | ||
90 | @code | ||
91 | system::result< core::string_view > rv = parse( "JohnDoe", token_rule( alpha_chars ) ); | ||
92 | @endcode | ||
93 | |||
94 | @par BNF | ||
95 | @code | ||
96 | ALPHA = %x41-5A / %x61-7A | ||
97 | ; A-Z / a-z | ||
98 | @endcode | ||
99 | |||
100 | @par Specification | ||
101 | @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1" | ||
102 | >B.1. Core Rules (rfc5234)</a> | ||
103 | |||
104 | @see | ||
105 | @ref find_if, | ||
106 | @ref find_if_not, | ||
107 | @ref parse, | ||
108 | @ref token_rule. | ||
109 | */ | ||
110 | constexpr implementation_defined::alpha_chars_t alpha_chars{}; | ||
111 | #endif | ||
112 | |||
113 | } // grammar | ||
114 | } // urls | ||
115 | } // boost | ||
116 | |||
117 | #endif | ||
118 |