100.00% Lines (9/9) 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_ALPHA_CHARS_HPP 10   #ifndef BOOST_URL_GRAMMAR_ALPHA_CHARS_HPP
11   #define BOOST_URL_GRAMMAR_ALPHA_CHARS_HPP 11   #define BOOST_URL_GRAMMAR_ALPHA_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 alpha_chars_t 20   struct alpha_chars_t
21   { 21   {
22   constexpr 22   constexpr
23   alpha_chars_t() noexcept = default; 23   alpha_chars_t() noexcept = default;
24   24  
25   constexpr 25   constexpr
26   bool 26   bool
HITCBC 27   59841 operator()(char c) const noexcept 27   59845 operator()(char c) const noexcept
28   { 28   {
29   return 29   return
HITCBC 30   76708 (c >= 'A' && c <= 'Z') || 30   76712 (c >= 'A' && c <= 'Z') ||
HITCBC 31   76708 (c >= 'a' && c <= 'z'); 31   76712 (c >= 'a' && c <= 'z');
32   } 32   }
33   33  
34   #ifdef BOOST_URL_USE_SSE2 34   #ifdef BOOST_URL_USE_SSE2
35   char const* 35   char const*
HITCBC 36   256 find_if( 36   256 find_if(
37   char const* first, 37   char const* first,
38   char const* last) const noexcept 38   char const* last) const noexcept
39   { 39   {
HITCBC 40   256 return detail::find_if_pred( 40   256 return detail::find_if_pred(
HITCBC 41   256 *this, first, last); 41   256 *this, first, last);
42   } 42   }
43   43  
44   char const* 44   char const*
HITCBC 45   333 find_if_not( 45   333 find_if_not(
46   char const* first, 46   char const* first,
47   char const* last) const noexcept 47   char const* last) const noexcept
48   { 48   {
HITCBC 49   333 return detail::find_if_not_pred( 49   333 return detail::find_if_not_pred(
HITCBC 50   333 *this, first, last); 50   333 *this, first, last);
51   } 51   }
52   #endif 52   #endif
53   }; 53   };
54   } // implementation_defined 54   } // implementation_defined
55   55  
56   /** The set of all letters 56   /** The set of all letters
57   57  
58   @par Example 58   @par Example
59   Character sets are used with rules and the 59   Character sets are used with rules and the
60   functions @ref find_if and @ref find_if_not. 60   functions @ref find_if and @ref find_if_not.
61   @code 61   @code
62   system::result< core::string_view > rv = parse( "JohnDoe", token_rule( alpha_chars ) ); 62   system::result< core::string_view > rv = parse( "JohnDoe", token_rule( alpha_chars ) );
63   @endcode 63   @endcode
64   64  
65   @par BNF 65   @par BNF
66   @code 66   @code
67   ALPHA = %x41-5A / %x61-7A 67   ALPHA = %x41-5A / %x61-7A
68   ; A-Z / a-z 68   ; A-Z / a-z
69   @endcode 69   @endcode
70   70  
71   @par Specification 71   @par Specification
72   @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1" 72   @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1"
73   >B.1. Core Rules (rfc5234)</a> 73   >B.1. Core Rules (rfc5234)</a>
74   74  
75   @see 75   @see
76   @ref find_if, 76   @ref find_if,
77   @ref find_if_not, 77   @ref find_if_not,
78   @ref parse, 78   @ref parse,
79   @ref token_rule. 79   @ref token_rule.
80   */ 80   */
81   constexpr implementation_defined::alpha_chars_t alpha_chars{}; 81   constexpr implementation_defined::alpha_chars_t alpha_chars{};
82   82  
83   } // grammar 83   } // grammar
84   } // urls 84   } // urls
85   } // boost 85   } // boost
86   86  
87   #endif 87   #endif