]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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/iif.hpp> | |
18 | #include <boost/preprocessor/comparison/less.hpp> | |
19 | #include <boost/preprocessor/seq/seq.hpp> | |
20 | #include <boost/preprocessor/variadic/to_seq.hpp> | |
7c673cae FG |
21 | |
22 | #include <boost/fusion/adapted/struct/detail/extension.hpp> | |
23 | #include <boost/fusion/adapted/struct/detail/adapt_base.hpp> | |
24 | #include <boost/fusion/adapted/struct/detail/adapt_base_attr_filler.hpp> | |
25 | #include <boost/fusion/adapted/struct/detail/at_impl.hpp> | |
26 | #include <boost/fusion/adapted/struct/detail/is_view_impl.hpp> | |
27 | #include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp> | |
28 | #include <boost/fusion/adapted/struct/detail/value_at_impl.hpp> | |
29 | #include <boost/fusion/adapted/struct/detail/category_of_impl.hpp> | |
30 | #include <boost/fusion/adapted/struct/detail/size_impl.hpp> | |
31 | #include <boost/fusion/adapted/struct/detail/begin_impl.hpp> | |
32 | #include <boost/fusion/adapted/struct/detail/end_impl.hpp> | |
33 | #include <boost/fusion/adapted/struct/detail/value_of_impl.hpp> | |
34 | #include <boost/fusion/adapted/struct/detail/deref_impl.hpp> | |
35 | ||
36 | #define BOOST_FUSION_ADAPT_STRUCT_C( \ | |
37 | TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \ | |
38 | BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ | |
39 | TEMPLATE_PARAMS_SEQ, \ | |
40 | NAME_SEQ, \ | |
41 | IS_VIEW, \ | |
42 | I, \ | |
43 | BOOST_PP_IIF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \ | |
44 | BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE), \ | |
45 | BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ | |
46 | BOOST_PP_LESS( \ | |
47 | BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), 2)) | |
48 | ||
49 | ||
50 | ||
51 | #if BOOST_PP_VARIADICS | |
52 | ||
53 | # define BOOST_FUSION_ADAPT_TPL_STRUCT(TEMPLATE_PARAMS_SEQ,NAME_SEQ, ...) \ | |
54 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ | |
55 | (1)TEMPLATE_PARAMS_SEQ, \ | |
56 | (1)NAME_SEQ, \ | |
57 | struct_tag, \ | |
58 | 0, \ | |
59 | BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \ | |
60 | BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), \ | |
61 | BOOST_FUSION_ADAPT_STRUCT_C) | |
62 | ||
63 | # define BOOST_FUSION_ADAPT_STRUCT(...) \ | |
64 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ | |
65 | (0), \ | |
66 | (0)(BOOST_PP_SEQ_HEAD(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ | |
67 | struct_tag, \ | |
68 | 0, \ | |
69 | BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \ | |
70 | BOOST_PP_SEQ_TAIL(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ | |
71 | BOOST_FUSION_ADAPT_STRUCT_C) | |
72 | ||
73 | # define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(...) \ | |
74 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ | |
75 | (0), \ | |
76 | (0)(BOOST_PP_SEQ_HEAD(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ | |
77 | struct_tag, \ | |
78 | 1, \ | |
79 | BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \ | |
80 | BOOST_PP_SEQ_TAIL(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \ | |
81 | BOOST_FUSION_ADAPT_STRUCT_C) | |
82 | ||
83 | #else // BOOST_PP_VARIADICS | |
84 | ||
85 | # define BOOST_FUSION_ADAPT_TPL_STRUCT( \ | |
86 | TEMPLATE_PARAMS_SEQ,NAME_SEQ, ATTRIBUTES) \ | |
87 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ | |
88 | (1)TEMPLATE_PARAMS_SEQ, \ | |
89 | (1)NAME_SEQ, \ | |
90 | struct_tag, \ | |
91 | 0, \ | |
92 | BOOST_PP_CAT( \ | |
93 | BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \ | |
94 | BOOST_FUSION_ADAPT_STRUCT_C) | |
95 | ||
96 | # define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \ | |
97 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ | |
98 | (0), \ | |
99 | (0)(NAME), \ | |
100 | struct_tag, \ | |
101 | 0, \ | |
102 | BOOST_PP_CAT( \ | |
103 | BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \ | |
104 | _END), \ | |
105 | BOOST_FUSION_ADAPT_STRUCT_C) | |
106 | ||
107 | # define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(NAME, ATTRIBUTES) \ | |
108 | BOOST_FUSION_ADAPT_STRUCT_BASE( \ | |
109 | (0), \ | |
110 | (0)(NAME), \ | |
111 | struct_tag, \ | |
112 | 1, \ | |
113 | BOOST_PP_CAT( \ | |
114 | BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \ | |
115 | _END), \ | |
116 | BOOST_FUSION_ADAPT_STRUCT_C) | |
117 | ||
118 | ||
119 | #endif // BOOST_PP_VARIADICS | |
120 | ||
121 | #endif |