one_char_except_c.hpp 2.9 KB

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