]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_METAPARSE_V1_IMPL_UPDATE_C_HPP |
2 | #define BOOST_METAPARSE_V1_IMPL_UPDATE_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 | #include <boost/metaparse/v1/impl/split_at_c.hpp> | |
12 | #include <boost/metaparse/v1/impl/concat.hpp> | |
13 | ||
14 | #include <boost/preprocessor/arithmetic/dec.hpp> | |
15 | #include <boost/preprocessor/arithmetic/inc.hpp> | |
16 | #include <boost/preprocessor/cat.hpp> | |
17 | #include <boost/preprocessor/punctuation/comma_if.hpp> | |
18 | #include <boost/preprocessor/repetition/enum_params.hpp> | |
19 | #include <boost/preprocessor/repetition/repeat.hpp> | |
20 | #include <boost/preprocessor/repetition/repeat_from_to.hpp> | |
21 | ||
22 | namespace boost | |
23 | { | |
24 | namespace metaparse | |
25 | { | |
26 | namespace v1 | |
27 | { | |
28 | namespace impl | |
29 | { | |
30 | #ifndef BOOST_METAPARSE_VARIADIC_STRING | |
31 | template <class S, int N, int C> | |
32 | struct update_c; | |
33 | ||
34 | #ifdef BOOST_METAPARSE_ARGN | |
35 | # error BOOST_METAPARSE_ARGN already defined | |
36 | #endif | |
37 | #define BOOST_METAPARSE_ARGN(z, n, unused) , BOOST_PP_CAT(C, n) | |
38 | ||
39 | #ifdef BOOST_METAPARSE_UPDATE | |
40 | # error BOOST_METAPARSE_UPDATE already defined | |
41 | #endif | |
42 | #define BOOST_METAPARSE_UPDATE(z, n, unused) \ | |
43 | template < \ | |
44 | BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C), \ | |
45 | int Ch \ | |
46 | > \ | |
47 | struct update_c< \ | |
48 | string<BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C)>,\ | |
49 | n, \ | |
50 | Ch \ | |
51 | > : \ | |
52 | string< \ | |
53 | BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ | |
54 | Ch \ | |
55 | BOOST_PP_REPEAT_FROM_TO( \ | |
56 | BOOST_PP_INC(n), \ | |
57 | BOOST_PP_DEC(BOOST_METAPARSE_LIMIT_STRING_SIZE), \ | |
58 | BOOST_METAPARSE_ARGN, \ | |
59 | ~ \ | |
60 | ) \ | |
61 | > \ | |
62 | {}; | |
63 | ||
64 | BOOST_PP_REPEAT( | |
65 | BOOST_METAPARSE_LIMIT_STRING_SIZE, | |
66 | BOOST_METAPARSE_UPDATE, | |
67 | ~ | |
68 | ) | |
69 | ||
70 | #undef BOOST_METAPARSE_UPDATE | |
71 | #undef BOOST_METAPARSE_ARGN | |
72 | #else | |
73 | template <class S, int N, char C> | |
74 | struct update_c : | |
75 | concat< | |
76 | typename split_at_c<N, S>::type::first, | |
77 | typename | |
78 | update_c<typename split_at_c<N, S>::type::second, 0, C>::type | |
79 | > | |
80 | {}; | |
81 | ||
82 | template <char... Cs, char C, char NewChar> | |
83 | struct update_c<string<C, Cs...>, 0, NewChar> : | |
84 | string<NewChar, Cs...> | |
85 | {}; | |
86 | #endif | |
87 | } | |
88 | } | |
89 | } | |
90 | } | |
91 | ||
92 | #endif | |
93 |