]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_METAPARSE_V1_IMPL_AT_C_HPP |
2 | #define BOOST_METAPARSE_V1_IMPL_AT_C_HPP | |
3 | ||
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) | |
8 | ||
9 | #include <boost/metaparse/config.hpp> | |
10 | #include <boost/metaparse/v1/fwd/string.hpp> | |
11 | ||
12 | #include <boost/mpl/char.hpp> | |
13 | ||
14 | #include <boost/preprocessor/repetition/enum_params.hpp> | |
15 | #include <boost/preprocessor/repetition/repeat.hpp> | |
16 | ||
17 | namespace boost | |
18 | { | |
19 | namespace metaparse | |
20 | { | |
21 | namespace v1 | |
22 | { | |
23 | namespace impl | |
24 | { | |
25 | template <class S, int N> | |
26 | struct at_c; | |
27 | ||
28 | #ifdef BOOST_METAPARSE_VARIADIC_STRING | |
29 | template <char C, char... Cs, int N> | |
30 | struct at_c<string<C, Cs...>, N> : at_c<string<Cs...>, N - 1> {}; | |
31 | ||
32 | template <char C, char... Cs> | |
33 | struct at_c<string<C, Cs...>, 0> : boost::mpl::char_<C> {}; | |
34 | #else | |
35 | #ifdef BOOST_METAPARSE_STRING_CASE | |
36 | # error BOOST_METAPARSE_STRING_CASE is already defined | |
37 | #endif | |
38 | #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \ | |
39 | template < \ | |
40 | BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C) \ | |
41 | > \ | |
42 | struct \ | |
43 | at_c< \ | |
44 | string< \ | |
45 | BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) \ | |
46 | >, \ | |
47 | n \ | |
48 | > : \ | |
49 | boost::mpl::char_<BOOST_PP_CAT(C, n)> \ | |
50 | {}; | |
51 | ||
52 | BOOST_PP_REPEAT( | |
53 | BOOST_METAPARSE_LIMIT_STRING_SIZE, | |
54 | BOOST_METAPARSE_STRING_CASE, | |
55 | ~ | |
56 | ) | |
57 | ||
58 | #undef BOOST_METAPARSE_STRING_CASE | |
59 | #endif | |
60 | } | |
61 | } | |
62 | } | |
63 | } | |
64 | ||
65 | #endif | |
66 |