one_char_except.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef BOOST_METAPARSE_V1_CPP98_ONE_CHAR_EXCEPT_HPP
  2. #define BOOST_METAPARSE_V1_CPP98_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/cpp98/impl/is_none.hpp>
  9. #include <boost/metaparse/v1/cpp98/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/limit_one_char_except_size.hpp>
  13. #include <boost/preprocessor/cat.hpp>
  14. #include <boost/preprocessor/arithmetic/dec.hpp>
  15. #include <boost/preprocessor/arithmetic/mul.hpp>
  16. #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
  17. #include <boost/preprocessor/repetition/repeat.hpp>
  18. #include <boost/preprocessor/repetition/enum.hpp>
  19. #include <boost/preprocessor/punctuation/comma_if.hpp>
  20. #include <boost/preprocessor/tuple/eat.hpp>
  21. namespace boost
  22. {
  23. namespace metaparse
  24. {
  25. namespace v1
  26. {
  27. template <
  28. BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
  29. BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE,
  30. class C,
  31. impl::one_char_except_not_used
  32. )
  33. >
  34. struct one_char_except;
  35. #ifdef MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE
  36. # error MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE already defined
  37. #endif
  38. #define MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE(z, n, unused) \
  39. template <BOOST_PP_ENUM_PARAMS(n, class T)> \
  40. struct one_char_except< \
  41. BOOST_PP_ENUM_PARAMS(n, T) \
  42. BOOST_PP_COMMA_IF( \
  43. BOOST_PP_MUL( \
  44. n, \
  45. BOOST_PP_SUB( \
  46. BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE), \
  47. n \
  48. ) \
  49. ) \
  50. ) \
  51. BOOST_PP_ENUM( \
  52. BOOST_PP_SUB( \
  53. BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE), \
  54. n \
  55. ), \
  56. impl::one_char_except_not_used BOOST_PP_TUPLE_EAT(3), \
  57. ~ \
  58. ) \
  59. > :\
  60. accept_when< \
  61. one_char, \
  62. impl::BOOST_PP_CAT(is_none, n)<BOOST_PP_ENUM_PARAMS(n, T)>, \
  63. error::unexpected_character \
  64. > \
  65. {};
  66. BOOST_PP_REPEAT(
  67. BOOST_METAPARSE_LIMIT_ONE_CHAR_EXCEPT_SIZE,
  68. MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE,
  69. ~
  70. )
  71. #undef MPLLBIS_METAPARSE_ONE_CHAR_EXCEPT_CASE
  72. }
  73. }
  74. }
  75. #endif