one_char_except.hpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef BOOST_METAPARSE_V1_ONE_CHAR_EXCEPT_HPP
  2. #define BOOST_METAPARSE_V1_ONE_CHAR_EXCEPT_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2011.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/metaparse/v1/error/unexpected_character.hpp>
  8. #include <boost/metaparse/v1/impl/is_any.hpp>
  9. #include <boost/metaparse/v1/impl/one_char_except_not_used.hpp>
  10. #include <boost/metaparse/v1/one_char.hpp>
  11. #include <boost/metaparse/v1/accept_when.hpp>
  12. #include <boost/metaparse/v1/define_error.hpp>
  13. #include <boost/metaparse/limit_one_char_except_size.hpp>
  14. #include <boost/preprocessor/cat.hpp>
  15. #include <boost/preprocessor/arithmetic/dec.hpp>
  16. #include <boost/preprocessor/arithmetic/mul.hpp>
  17. #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
  18. #include <boost/preprocessor/repetition/repeat.hpp>
  19. #include <boost/preprocessor/repetition/enum.hpp>
  20. #include <boost/preprocessor/punctuation/comma_if.hpp>
  21. #include <boost/preprocessor/tuple/eat.hpp>
  22. namespace boost
  23. {
  24. namespace metaparse
  25. {
  26. namespace v1
  27. {
  28. template <
  29. BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
  30. BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE,
  31. class C,
  32. impl::one_char_except_not_used
  33. )
  34. >
  35. struct one_char_except;
  36. #ifdef MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE
  37. # error MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE already defined
  38. #endif
  39. #define MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE(z, n, unused) \
  40. template <BOOST_PP_ENUM_PARAMS(n, class T)> \
  41. struct one_char_except< \
  42. BOOST_PP_ENUM_PARAMS(n, T) \
  43. BOOST_PP_COMMA_IF( \
  44. BOOST_PP_MUL( \
  45. n, \
  46. BOOST_PP_SUB( \
  47. BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE), \
  48. n \
  49. ) \
  50. ) \
  51. ) \
  52. BOOST_PP_ENUM( \
  53. BOOST_PP_SUB( \
  54. BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE), \
  55. n \
  56. ), \
  57. impl::one_char_except_not_used BOOST_PP_TUPLE_EAT(3), \
  58. ~ \
  59. ) \
  60. > :\
  61. accept_when< \
  62. one_char, \
  63. impl::BOOST_PP_CAT(is_any, n)<BOOST_PP_ENUM_PARAMS(n, T)>, \
  64. error::unexpected_character \
  65. > \
  66. {};
  67. BOOST_PP_REPEAT(
  68. BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE,
  69. MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE,
  70. ~
  71. )
  72. #undef MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE
  73. }
  74. }
  75. }
  76. #endif