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