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