1 | /*============================================================================= |
2 | Copyright (c) 2001-2007 Joel de Guzman |
3 | Copyright (c) 2009-2011 Christopher Schmidt |
4 | Copyright (c) 2013-2014 Damien Buhl |
5 | |
6 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
7 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
8 | ==============================================================================*/ |
9 | |
10 | #ifndef BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP |
11 | #define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP |
12 | |
13 | #include <boost/fusion/support/config.hpp> |
14 | #include <boost/preprocessor/config/config.hpp> |
15 | #include <boost/preprocessor/cat.hpp> |
16 | #include <boost/preprocessor/empty.hpp> |
17 | #include <boost/preprocessor/control/if.hpp> |
18 | #include <boost/preprocessor/comparison/less.hpp> |
19 | #include <boost/preprocessor/comparison/equal.hpp> |
20 | #include <boost/preprocessor/seq/seq.hpp> |
21 | #include <boost/preprocessor/variadic/to_seq.hpp> |
22 | #include <boost/type_traits/add_reference.hpp> |
23 | #include <boost/type_traits/is_const.hpp> |
24 | #include <boost/type_traits/add_const.hpp> |
25 | #include <boost/type_traits/remove_const.hpp> |
26 | |
27 | #include <boost/fusion/adapted/struct/detail/extension.hpp> |
28 | #include <boost/fusion/adapted/struct/detail/adapt_base.hpp> |
29 | #include <boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp> |
30 | #include <boost/fusion/adapted/struct/detail/at_impl.hpp> |
31 | #include <boost/fusion/adapted/struct/detail/is_view_impl.hpp> |
32 | #include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp> |
33 | #include <boost/fusion/adapted/struct/detail/value_at_impl.hpp> |
34 | #include <boost/fusion/adapted/struct/detail/category_of_impl.hpp> |
35 | #include <boost/fusion/adapted/struct/detail/size_impl.hpp> |
36 | #include <boost/fusion/adapted/struct/detail/begin_impl.hpp> |
37 | #include <boost/fusion/adapted/struct/detail/end_impl.hpp> |
38 | #include <boost/fusion/adapted/struct/detail/value_of_impl.hpp> |
39 | #include <boost/fusion/adapted/struct/detail/deref_impl.hpp> |
40 | |
41 | #define BOOST_FUSION_ADAPT_STRUCT_C( \ |
42 | TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \ |
43 | BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ |
44 | TEMPLATE_PARAMS_SEQ, \ |
45 | NAME_SEQ, \ |
46 | IS_VIEW, \ |
47 | I, \ |
48 | BOOST_PP_IF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \ |
49 | BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE), \ |
50 | BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ |
51 | BOOST_PP_IF( \ |
52 | BOOST_PP_LESS( \ |
53 | BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), 2) \ |
54 | , 1, 0)) |
55 | |
56 | |
57 | |
58 | #if BOOST_PP_VARIADICS |
59 | |
60 | # define BOOST_FUSION_ADAPT_TPL_STRUCT(TEMPLATE_PARAMS_SEQ,NAME_SEQ, ...) \ |
61 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ |
62 | (1)TEMPLATE_PARAMS_SEQ, \ |
63 | (1)NAME_SEQ, \ |
64 | struct_tag, \ |
65 | 0, \ |
66 | BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \ |
67 | BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), \ |
68 | BOOST_FUSION_ADAPT_STRUCT_C) |
69 | |
70 | # define BOOST_FUSION_ADAPT_STRUCT(...) \ |
71 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ |
72 | (0), \ |
73 | (0)(BOOST_PP_SEQ_HEAD(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ |
74 | struct_tag, \ |
75 | 0, \ |
76 | BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \ |
77 | BOOST_PP_SEQ_TAIL(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ |
78 | BOOST_FUSION_ADAPT_STRUCT_C) |
79 | |
80 | # define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(...) \ |
81 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ |
82 | (0), \ |
83 | (0)(BOOST_PP_SEQ_HEAD(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ |
84 | struct_tag, \ |
85 | 1, \ |
86 | BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \ |
87 | BOOST_PP_SEQ_TAIL(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ |
88 | BOOST_FUSION_ADAPT_STRUCT_C) |
89 | |
90 | #else // BOOST_PP_VARIADICS |
91 | |
92 | # define BOOST_FUSION_ADAPT_TPL_STRUCT( \ |
93 | TEMPLATE_PARAMS_SEQ,NAME_SEQ, ATTRIBUTES) \ |
94 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ |
95 | (1)TEMPLATE_PARAMS_SEQ, \ |
96 | (1)NAME_SEQ, \ |
97 | struct_tag, \ |
98 | 0, \ |
99 | BOOST_PP_CAT( \ |
100 | BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ |
101 | BOOST_FUSION_ADAPT_STRUCT_C) |
102 | |
103 | # define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \ |
104 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ |
105 | (0), \ |
106 | (0)(NAME), \ |
107 | struct_tag, \ |
108 | 0, \ |
109 | BOOST_PP_CAT( \ |
110 | BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \ |
111 | _END), \ |
112 | BOOST_FUSION_ADAPT_STRUCT_C) |
113 | |
114 | # define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(NAME, ATTRIBUTES) \ |
115 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ |
116 | (0), \ |
117 | (0)(NAME), \ |
118 | struct_tag, \ |
119 | 1, \ |
120 | BOOST_PP_CAT( \ |
121 | BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \ |
122 | _END), \ |
123 | BOOST_FUSION_ADAPT_STRUCT_C) |
124 | |
125 | |
126 | #endif // BOOST_PP_VARIADICS |
127 | |
128 | #endif |
129 | |