]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_METAPARSE_V1_IMPL_SIZE_HPP |
2 | #define BOOST_METAPARSE_V1_IMPL_SIZE_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/int.hpp> | |
13 | ||
14 | #include <boost/preprocessor/arithmetic/sub.hpp> | |
15 | #include <boost/preprocessor/punctuation/comma_if.hpp> | |
16 | #include <boost/preprocessor/repetition/enum.hpp> | |
17 | #include <boost/preprocessor/repetition/enum_params.hpp> | |
18 | #include <boost/preprocessor/repetition/repeat.hpp> | |
19 | #include <boost/preprocessor/tuple/eat.hpp> | |
20 | ||
21 | namespace boost | |
22 | { | |
23 | namespace metaparse | |
24 | { | |
25 | namespace v1 | |
26 | { | |
27 | namespace impl | |
28 | { | |
29 | template <class S> | |
30 | struct size; | |
31 | ||
32 | #ifdef BOOST_METAPARSE_VARIADIC_STRING | |
33 | template <char... Cs> | |
34 | struct size<string<Cs...>> : boost::mpl::int_<sizeof...(Cs)> {}; | |
35 | #else | |
36 | #ifdef BOOST_METAPARSE_STRING_CASE | |
37 | # error BOOST_METAPARSE_STRING_CASE | |
38 | #endif | |
39 | #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \ | |
40 | template <BOOST_PP_ENUM_PARAMS(n, int C)> \ | |
41 | struct \ | |
42 | size< \ | |
43 | string< \ | |
44 | BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ | |
45 | BOOST_PP_ENUM( \ | |
46 | BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ | |
47 | BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ | |
48 | ~ \ | |
49 | ) \ | |
50 | > \ | |
51 | > : \ | |
52 | boost::mpl::int_<n> \ | |
53 | {}; | |
54 | ||
55 | BOOST_PP_REPEAT( | |
56 | BOOST_METAPARSE_LIMIT_STRING_SIZE, | |
57 | BOOST_METAPARSE_STRING_CASE, | |
58 | ~ | |
59 | ) | |
60 | ||
61 | #undef BOOST_METAPARSE_STRING_CASE | |
62 | #endif | |
63 | } | |
64 | } | |
65 | } | |
66 | } | |
67 | ||
68 | #endif | |
69 |