]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/include/boost/metaparse/v1/impl/split_at_c.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / include / boost / metaparse / v1 / impl / split_at_c.hpp
1 #ifndef BOOST_METAPARSE_V1_IMPL_SPLIT_AT_C_HPP
2 #define BOOST_METAPARSE_V1_IMPL_SPLIT_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 #include <boost/metaparse/v1/impl/push_front_c.hpp>
12
13 #include <boost/preprocessor/arithmetic/add.hpp>
14 #include <boost/preprocessor/arithmetic/sub.hpp>
15 #include <boost/preprocessor/cat.hpp>
16 #include <boost/preprocessor/repetition/enum.hpp>
17 #include <boost/preprocessor/repetition/enum_params.hpp>
18 #include <boost/preprocessor/repetition/repeat.hpp>
19
20 #include <boost/mpl/pair.hpp>
21
22 namespace boost
23 {
24 namespace metaparse
25 {
26 namespace v1
27 {
28 namespace impl
29 {
30 template <int N, class S>
31 struct split_at_c;
32
33 #ifdef BOOST_METAPARSE_VARIADIC_STRING
34 template <int N, char C, char... Cs>
35 struct split_at_c<N, string<C, Cs...>> :
36 boost::mpl::pair<
37 typename push_front_c<
38 typename split_at_c<N - 1, string<Cs...>>::type::first,
39 C
40 >::type,
41 typename split_at_c<N - 1, string<Cs...>>::type::second
42 >
43 {};
44
45 template <char C, char... Cs>
46 struct split_at_c<0, string<C, Cs...>> :
47 boost::mpl::pair<string<>, string<C, Cs...>>
48 {};
49
50 template <class S>
51 struct split_at_c<0, S> : boost::mpl::pair<string<>, S> {};
52 #else
53 #ifdef BOOST_METAPARSE_ARG
54 # error BOOST_METAPARSE_ARG already defined
55 #endif
56 #define BOOST_METAPARSE_ARG(z, n, d) BOOST_PP_CAT(C, BOOST_PP_ADD(n, d))
57
58 #ifdef BOOST_METAPARSE_SPLIT_AT
59 # error BOOST_METAPARSE_SPLIT_AT already defined
60 #endif
61 #define BOOST_METAPARSE_SPLIT_AT(z, n, unused) \
62 template < \
63 BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, int C) \
64 > \
65 struct \
66 split_at_c< \
67 n, \
68 string<BOOST_PP_ENUM_PARAMS( \
69 BOOST_METAPARSE_LIMIT_STRING_SIZE, C) \
70 > \
71 > : \
72 boost::mpl::pair< \
73 string<BOOST_PP_ENUM_PARAMS(n, C)>, \
74 string< \
75 BOOST_PP_ENUM( \
76 BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \
77 BOOST_METAPARSE_ARG, \
78 n \
79 ) \
80 > \
81 > \
82 {};
83
84 BOOST_PP_REPEAT(
85 BOOST_METAPARSE_LIMIT_STRING_SIZE,
86 BOOST_METAPARSE_SPLIT_AT,
87 ~
88 )
89
90 #undef BOOST_METAPARSE_SPLIT_AT
91 #undef BOOST_METAPARSE_ARG
92 #endif
93 }
94 }
95 }
96 }
97
98 #endif
99