all_chars.hpp 1.7 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_ALL_CHARS_HPP
  10. #define BOOST_URL_GRAMMAR_ALL_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. /** The set of all 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( all_chars ) );
  22. @endcode
  23. @par BNF
  24. @code
  25. ALL = %x00-FF
  26. @endcode
  27. @see
  28. @ref find_if,
  29. @ref find_if_not,
  30. @ref parse,
  31. @ref token_rule.
  32. */
  33. #ifdef BOOST_URL_DOCS
  34. constexpr __implementation_defined__ all_chars;
  35. #else
  36. struct all_chars_t
  37. {
  38. constexpr
  39. all_chars_t() noexcept = default;
  40. constexpr
  41. bool
  42. operator()(char) const noexcept
  43. {
  44. return true;
  45. }
  46. #ifdef BOOST_URL_USE_SSE2
  47. char const*
  48. find_if(
  49. char const* first,
  50. char const* last) const noexcept
  51. {
  52. return detail::find_if_pred(
  53. *this, first, last);
  54. }
  55. char const*
  56. find_if_not(
  57. char const* first,
  58. char const* last) const noexcept
  59. {
  60. return detail::find_if_not_pred(
  61. *this, first, last);
  62. }
  63. #endif
  64. };
  65. /** A character set containing all characters.
  66. @see
  67. @ref all_chars_t
  68. */
  69. constexpr all_chars_t all_chars{};
  70. #endif
  71. } // grammar
  72. } // urls
  73. } // boost
  74. #endif