• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2013-2014 Damien Buhl
3 
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 
8 #ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP
9 #define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_ASSOC_ATTR_FILLER_HPP
10 
11 #include <boost/config.hpp>
12 
13 #include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
14 #include <boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp>
15 
16 #include <boost/mpl/aux_/preprocessor/token_equal.hpp>
17 
18 #include <boost/preprocessor/config/config.hpp>
19 #include <boost/preprocessor/control/iif.hpp>
20 #include <boost/preprocessor/arithmetic/dec.hpp>
21 #include <boost/preprocessor/variadic/size.hpp>
22 #include <boost/preprocessor/variadic/elem.hpp>
23 
24 #if BOOST_PP_VARIADICS
25 
26 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(...)                           \
27     BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(__VA_ARGS__)                      \
28     BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1
29 
30 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(...)                           \
31     BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(__VA_ARGS__)                      \
32     BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0
33 
34 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(...)                          \
35   BOOST_PP_IIF(                                                                 \
36       BOOST_MPL_PP_TOKEN_EQUAL(auto, BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__)),   \
37       ((2,                                                                      \
38           (BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__),                              \
39            BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__)))),                           \
40       ((BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),                                    \
41           (__VA_ARGS__)))                                                       \
42     )
43 
44 #else // BOOST_PP_VARIADICS
45 
46 
47 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(X, Y, Z)                       \
48     BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z)                          \
49     BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1
50 
51 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1(X, Y, Z)                       \
52     BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z)                          \
53     BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0
54 
55 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAP_ATTR(X, Y, Z)                      \
56     BOOST_PP_IIF(BOOST_MPL_PP_TOKEN_EQUAL(auto, X),                             \
57       ((2, (Y,Z))),                                                             \
58       ((3, (X,Y,Z)))                                                            \
59     )
60 
61 #endif // BOOST_PP_VARIADICS
62 
63 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0_END
64 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_1_END
65 
66 
67 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAPPEDATTR_GET_KEY(ATTRIBUTE)          \
68     BOOST_PP_TUPLE_ELEM(                                                        \
69         BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE),                  \
70         BOOST_PP_DEC(BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE)),    \
71         BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE))
72 
73 #endif
74