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_DIGIT_CHARS_HPP | ||
11 | #define BOOST_URL_GRAMMAR_DIGIT_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 decimal 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 > rv = parse( "2022", token_rule( digit_chars ) ); | ||
27 | @endcode | ||
28 | |||
29 | @par BNF | ||
30 | @code | ||
31 | DIGIT = %x30-39 | ||
32 | ; 0-9 | ||
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__ digit_chars; | ||
47 | #else | ||
48 | namespace implementation_defined { | ||
49 | struct digit_chars_t | ||
50 | { | ||
51 | constexpr | ||
52 | bool | ||
53 | 14640 | operator()(char c) const noexcept | |
54 | { | ||
55 |
4/4✓ Branch 0 taken 7657 times.
✓ Branch 1 taken 6983 times.
✓ Branch 2 taken 2814 times.
✓ Branch 3 taken 4843 times.
|
14640 | return c >= '0' && c <= '9'; |
56 | } | ||
57 | |||
58 | #ifdef BOOST_URL_USE_SSE2 | ||
59 | char const* | ||
60 | 256 | find_if( | |
61 | char const* first, | ||
62 | char const* last) const noexcept | ||
63 | { | ||
64 | 256 | return detail::find_if_pred( | |
65 | 256 | *this, first, last); | |
66 | } | ||
67 | |||
68 | char const* | ||
69 | 287 | find_if_not( | |
70 | char const* first, | ||
71 | char const* last) const noexcept | ||
72 | { | ||
73 | 287 | return detail::find_if_not_pred( | |
74 | 287 | *this, first, last); | |
75 | } | ||
76 | #endif | ||
77 | }; | ||
78 | } | ||
79 | |||
80 | /** The set of decimal digits | ||
81 | |||
82 | @par Example | ||
83 | Character sets are used with rules and the | ||
84 | functions @ref find_if and @ref find_if_not. | ||
85 | @code | ||
86 | system::result< core::string_view > rv = parse( "2022", token_rule( digit_chars ) ); | ||
87 | @endcode | ||
88 | |||
89 | @par BNF | ||
90 | @code | ||
91 | DIGIT = %x30-39 | ||
92 | ; 0-9 | ||
93 | @endcode | ||
94 | |||
95 | @par Specification | ||
96 | @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1" | ||
97 | >B.1. Core Rules (rfc5234)</a> | ||
98 | |||
99 | @see | ||
100 | @ref find_if, | ||
101 | @ref find_if_not, | ||
102 | @ref parse, | ||
103 | @ref token_rule. | ||
104 | */ | ||
105 | constexpr implementation_defined::digit_chars_t digit_chars{}; | ||
106 | #endif | ||
107 | |||
108 | } // grammar | ||
109 | } // urls | ||
110 | } // boost | ||
111 | |||
112 | #endif | ||
113 |