alpha_chars.hpp 1.9 KB

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