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