vchars.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_VCHARS_HPP
  10. #define BOOST_URL_GRAMMAR_VCHARS_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 vchars_t
  18. {
  19. constexpr
  20. bool
  21. operator()(char c) const noexcept
  22. {
  23. return c >= 0x21 && c <= 0x7e;
  24. }
  25. #ifdef BOOST_URL_USE_SSE2
  26. char const*
  27. find_if(
  28. char const* first,
  29. char const* last) const noexcept
  30. {
  31. return detail::find_if_pred(
  32. *this, first, last);
  33. }
  34. char const*
  35. find_if_not(
  36. char const* first,
  37. char const* last) const noexcept
  38. {
  39. return detail::find_if_not_pred(
  40. *this, first, last);
  41. }
  42. #endif
  43. };
  44. } // implementation_defined
  45. /** The set of visible characters
  46. @par Example
  47. Character sets are used with rules and the
  48. functions @ref find_if and @ref find_if_not.
  49. @code
  50. system::result< core::string_view > rv = parse( "JohnDoe", token_rule( vchars ) );
  51. @endcode
  52. @par BNF
  53. @code
  54. VCHAR = 0x21-0x7E
  55. ; visible (printing) characters
  56. @endcode
  57. @par Specification
  58. @li <a href="https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1"
  59. >B.1. Core Rules (rfc5234)</a>
  60. @see
  61. @ref find_if,
  62. @ref find_if_not,
  63. @ref parse,
  64. @ref token_rule.
  65. */
  66. constexpr implementation_defined::vchars_t vchars{};
  67. } // grammar
  68. } // urls
  69. } // boost
  70. #endif