-
Notifications
You must be signed in to change notification settings - Fork 50
/
digit_chars.hpp
112 lines (95 loc) · 2.4 KB
/
digit_chars.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_GRAMMAR_DIGIT_CHARS_HPP
#define BOOST_URL_GRAMMAR_DIGIT_CHARS_HPP
#include <boost/url/detail/config.hpp>
#include <boost/url/grammar/detail/charset.hpp>
namespace boost {
namespace urls {
namespace grammar {
/** The set of decimal digits
@par Example
Character sets are used with rules and the
functions @ref find_if and @ref find_if_not.
@code
system::result< core::string_view > rv = parse( "2022", token_rule( digit_chars ) );
@endcode
@par BNF
@code
DIGIT = %x30-39
; 0-9
@endcode
@par Specification
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1"
>B.1. Core Rules (rfc5234)</a>
@see
@ref find_if,
@ref find_if_not,
@ref parse,
@ref token_rule.
*/
#ifdef BOOST_URL_DOCS
constexpr __implementation_defined__ digit_chars;
#else
namespace implementation_defined {
struct digit_chars_t
{
constexpr
bool
operator()(char c) const noexcept
{
return c >= '0' && c <= '9';
}
#ifdef BOOST_URL_USE_SSE2
char const*
find_if(
char const* first,
char const* last) const noexcept
{
return detail::find_if_pred(
*this, first, last);
}
char const*
find_if_not(
char const* first,
char const* last) const noexcept
{
return detail::find_if_not_pred(
*this, first, last);
}
#endif
};
}
/** The set of decimal digits
@par Example
Character sets are used with rules and the
functions @ref find_if and @ref find_if_not.
@code
system::result< core::string_view > rv = parse( "2022", token_rule( digit_chars ) );
@endcode
@par BNF
@code
DIGIT = %x30-39
; 0-9
@endcode
@par Specification
@li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1"
>B.1. Core Rules (rfc5234)</a>
@see
@ref find_if,
@ref find_if_not,
@ref parse,
@ref token_rule.
*/
constexpr implementation_defined::digit_chars_t digit_chars{};
#endif
} // grammar
} // urls
} // boost
#endif