1 #ifndef BOOST_METAPARSE_V1_ONE_OF_C_HPP
2 #define BOOST_METAPARSE_V1_ONE_OF_C_HPP
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
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)
9 #include <boost/metaparse/v1/one_of.hpp>
10 #include <boost/metaparse/v1/lit_c.hpp>
12 #include <boost/preprocessor/arithmetic/sub.hpp>
13 #include <boost/preprocessor/cat.hpp>
14 #include <boost/preprocessor/punctuation/comma_if.hpp>
15 #include <boost/preprocessor/repetition/enum.hpp>
16 #include <boost/preprocessor/repetition/enum_params.hpp>
17 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
18 #include <boost/preprocessor/repetition/repeat.hpp>
19 #include <boost/preprocessor/tuple/eat.hpp>
29 #ifdef BOOST_NO_SCALAR_VALUE
30 # error BOOST_NO_SCALAR_VALUE already defined
32 #define BOOST_NO_SCALAR_VALUE LONG_MAX
35 BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
36 BOOST_METAPARSE_LIMIT_ONE_OF_SIZE,
43 #ifdef BOOST_METAPARSE_ONE_OF_C_LIT
44 # error BOOST_METAPARSE_ONE_OF_C_LIT already defined
46 #define BOOST_METAPARSE_ONE_OF_C_LIT(z, n, unused) lit_c<BOOST_PP_CAT(C, n)>
48 #ifdef BOOST_METAPARSE_ONE_OF_C_CASE
49 # error BOOST_METAPARSE_ONE_OF_C_CASE already defined
51 #define BOOST_METAPARSE_ONE_OF_C_CASE(z, n, unused) \
52 template <BOOST_PP_ENUM_PARAMS(n, long C)> \
55 BOOST_PP_ENUM_PARAMS(n, C) \
56 BOOST_PP_COMMA_IF(n) \
58 BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_ONE_OF_SIZE, n), \
59 BOOST_NO_SCALAR_VALUE BOOST_PP_TUPLE_EAT(3), \
63 one_of< BOOST_PP_ENUM(n, BOOST_METAPARSE_ONE_OF_C_LIT, ~) > \
67 BOOST_METAPARSE_LIMIT_ONE_OF_SIZE,
68 BOOST_METAPARSE_ONE_OF_C_CASE,
72 #undef BOOST_METAPARSE_ONE_OF_C_CASE
73 #undef BOOST_METAPARSE_ONE_OF_C_LIT
74 #undef BOOST_NO_SCALAR_VALUE