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 | struct digit_chars_t | ||
49 | { | ||
50 | constexpr | ||
51 | bool | ||
52 | 14629 | operator()(char c) const noexcept | |
53 | { | ||
54 |
4/4✓ Branch 0 taken 7646 times.
✓ Branch 1 taken 6983 times.
✓ Branch 2 taken 2810 times.
✓ Branch 3 taken 4836 times.
|
14629 | return c >= '0' && c <= '9'; |
55 | } | ||
56 | |||
57 | #ifdef BOOST_URL_USE_SSE2 | ||
58 | char const* | ||
59 | 256 | find_if( | |
60 | char const* first, | ||
61 | char const* last) const noexcept | ||
62 | { | ||
63 | 256 | return detail::find_if_pred( | |
64 | 256 | *this, first, last); | |
65 | } | ||
66 | |||
67 | char const* | ||
68 | 287 | find_if_not( | |
69 | char const* first, | ||
70 | char const* last) const noexcept | ||
71 | { | ||
72 | 287 | return detail::find_if_not_pred( | |
73 | 287 | *this, first, last); | |
74 | } | ||
75 | #endif | ||
76 | }; | ||
77 | |||
78 | constexpr digit_chars_t digit_chars{}; | ||
79 | #endif | ||
80 | |||
81 | } // grammar | ||
82 | } // urls | ||
83 | } // boost | ||
84 | |||
85 | #endif | ||
86 |