100.00% Lines (10/10) 100.00% Functions (3/3)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com) 2   // Copyright (c) 2021 Vinnie Falco (vinnie dot falco at gmail dot com)
3   // 3   //
4   // Distributed under the Boost Software License, Version 1.0. (See accompanying 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) 5   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6   // 6   //
7   // Official repository: https://github.com/boostorg/url 7   // Official repository: https://github.com/boostorg/url
8   // 8   //
9   9  
10   #ifndef BOOST_URL_GRAMMAR_ALNUM_CHARS_HPP 10   #ifndef BOOST_URL_GRAMMAR_ALNUM_CHARS_HPP
11   #define BOOST_URL_GRAMMAR_ALNUM_CHARS_HPP 11   #define BOOST_URL_GRAMMAR_ALNUM_CHARS_HPP
12   12  
13   #include <boost/url/detail/config.hpp> 13   #include <boost/url/detail/config.hpp>
14   #include <boost/url/grammar/detail/charset.hpp> 14   #include <boost/url/grammar/detail/charset.hpp>
15   15  
16   namespace boost { 16   namespace boost {
17   namespace urls { 17   namespace urls {
18   namespace grammar { 18   namespace grammar {
19   namespace implementation_defined { 19   namespace implementation_defined {
20   struct alnum_chars_t 20   struct alnum_chars_t
21   { 21   {
22   constexpr 22   constexpr
23   bool 23   bool
HITCBC 24   5496 operator()(char c) const noexcept 24   5496 operator()(char c) const noexcept
25   { 25   {
26   return 26   return
HITCBC 27   5496 (c >= '0' && c <= '9') || 27   5496 (c >= '0' && c <= '9') ||
HITCBC 28   12028 (c >= 'A' && c <= 'Z') || 28   12028 (c >= 'A' && c <= 'Z') ||
HITCBC 29   6532 (c >= 'a' && c <= 'z'); 29   6532 (c >= 'a' && c <= 'z');
30   } 30   }
31   31  
32   #ifdef BOOST_URL_USE_SSE2 32   #ifdef BOOST_URL_USE_SSE2
33   char const* 33   char const*
HITCBC 34   256 find_if( 34   256 find_if(
35   char const* first, 35   char const* first,
36   char const* last) const noexcept 36   char const* last) const noexcept
37   { 37   {
HITCBC 38   256 return detail::find_if_pred( 38   256 return detail::find_if_pred(
HITCBC 39   256 *this, first, last); 39   256 *this, first, last);
40   } 40   }
41   41  
42   char const* 42   char const*
HITCBC 43   269 find_if_not( 43   269 find_if_not(
44   char const* first, 44   char const* first,
45   char const* last) const noexcept 45   char const* last) const noexcept
46   { 46   {
HITCBC 47   269 return detail::find_if_not_pred( 47   269 return detail::find_if_not_pred(
HITCBC 48   269 *this, first, last); 48   269 *this, first, last);
49   } 49   }
50   #endif 50   #endif
51   }; 51   };
52   } // implementation_defined 52   } // implementation_defined
53   53  
54   /** The set of letters and digits 54   /** The set of letters and digits
55   55  
56   @par Example 56   @par Example
57   Character sets are used with rules and the 57   Character sets are used with rules and the
58   functions @ref find_if and @ref find_if_not. 58   functions @ref find_if and @ref find_if_not.
59   @code 59   @code
60   system::result< core::string_view > = parse( "Johnny42", token_rule( alnumchars ) ); 60   system::result< core::string_view > = parse( "Johnny42", token_rule( alnumchars ) );
61   @endcode 61   @endcode
62   62  
63   @par BNF 63   @par BNF
64   @code 64   @code
65   ALNUM = ALPHA / DIGIT 65   ALNUM = ALPHA / DIGIT
66   66  
67   ALPHA = %x41-5A / %x61-7A 67   ALPHA = %x41-5A / %x61-7A
68   ; A-Z / a-z 68   ; A-Z / a-z
69   69  
70   DIGIT = %x30-39 70   DIGIT = %x30-39
71   ; 0-9 71   ; 0-9
72   @endcode 72   @endcode
73   73  
74   @par Specification 74   @par Specification
75   @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1" 75   @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1"
76   >B.1. Core Rules (rfc5234)</a> 76   >B.1. Core Rules (rfc5234)</a>
77   77  
78   @see 78   @see
79   @ref find_if, 79   @ref find_if,
80   @ref find_if_not, 80   @ref find_if_not,
81   @ref parse, 81   @ref parse,
82   @ref token_rule. 82   @ref token_rule.
83   */ 83   */
84   constexpr implementation_defined::alnum_chars_t alnum_chars{}; 84   constexpr implementation_defined::alnum_chars_t alnum_chars{};
85   85  
86   } // grammar 86   } // grammar
87   } // urls 87   } // urls
88   } // boost 88   } // boost
89   89  
90   #endif 90   #endif