vchars.hpp 1.8 KB

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