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_VCHARS_HPP | ||
11 | #define BOOST_URL_GRAMMAR_VCHARS_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 visible characters | ||
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( vchars ) ); | ||
27 | @endcode | ||
28 | |||
29 | @par BNF | ||
30 | @code | ||
31 | VCHAR = 0x21-0x7E | ||
32 | ; visible (printing) characters | ||
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__ vchars; | ||
47 | #else | ||
48 | struct vchars_t | ||
49 | { | ||
50 | constexpr | ||
51 | bool | ||
52 | 7 | operator()(char c) const noexcept | |
53 | { | ||
54 |
2/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | return c >= 0x21 && c <= 0x7e; |
55 | } | ||
56 | |||
57 | #ifdef BOOST_URL_USE_SSE2 | ||
58 | char const* | ||
59 | find_if( | ||
60 | char const* first, | ||
61 | char const* last) const noexcept | ||
62 | { | ||
63 | return detail::find_if_pred( | ||
64 | *this, first, last); | ||
65 | } | ||
66 | |||
67 | char const* | ||
68 | 1 | find_if_not( | |
69 | char const* first, | ||
70 | char const* last) const noexcept | ||
71 | { | ||
72 | 1 | return detail::find_if_not_pred( | |
73 | 1 | *this, first, last); | |
74 | } | ||
75 | #endif | ||
76 | }; | ||
77 | |||
78 | constexpr vchars_t vchars{}; | ||
79 | #endif | ||
80 | |||
81 | } // grammar | ||
82 | } // urls | ||
83 | } // boost | ||
84 | |||
85 | #endif | ||
86 |