1 /*============================================================================= 2 Copyright (c) 2001-2007 Joel de Guzman 3 Copyright (c) 2007 Dan Marsden 4 Copyright (c) 2009-2011 Christopher Schmidt 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_ASSOC_STRUCT_HPP 11 #define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_ASSOC_STRUCT_HPP 12 13 #include <boost/fusion/support/config.hpp> 14 #include <boost/preprocessor/cat.hpp> 15 #include <boost/preprocessor/empty.hpp> 16 #include <boost/preprocessor/control/iif.hpp> 17 #include <boost/preprocessor/comparison/less.hpp> 18 19 #include <boost/fusion/adapted/struct/detail/extension.hpp> 20 #include <boost/fusion/adapted/struct/detail/adapt_base.hpp> 21 #include <boost/fusion/adapted/struct/detail/adapt_base_assoc_attr_filler.hpp> 22 #include <boost/fusion/adapted/struct/detail/at_impl.hpp> 23 #include <boost/fusion/adapted/struct/detail/is_view_impl.hpp> 24 #include <boost/fusion/adapted/struct/detail/is_sequence_impl.hpp> 25 #include <boost/fusion/adapted/struct/detail/value_at_impl.hpp> 26 #include <boost/fusion/adapted/struct/detail/category_of_impl.hpp> 27 #include <boost/fusion/adapted/struct/detail/size_impl.hpp> 28 #include <boost/fusion/adapted/struct/detail/begin_impl.hpp> 29 #include <boost/fusion/adapted/struct/detail/end_impl.hpp> 30 #include <boost/fusion/adapted/struct/detail/value_of_impl.hpp> 31 #include <boost/fusion/adapted/struct/detail/deref_impl.hpp> 32 #include <boost/fusion/adapted/struct/detail/deref_data_impl.hpp> 33 #include <boost/fusion/adapted/struct/detail/key_of_impl.hpp> 34 #include <boost/fusion/adapted/struct/detail/value_of_data_impl.hpp> 35 36 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ 37 TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW,I,PREFIX,ATTRIBUTE) \ 38 \ 39 BOOST_FUSION_ADAPT_STRUCT_C_BASE( \ 40 TEMPLATE_PARAMS_SEQ, \ 41 NAME_SEQ, \ 42 IS_VIEW, \ 43 I, \ 44 BOOST_PP_IIF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \ 45 BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE), \ 46 BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \ 47 BOOST_PP_LESS( \ 48 BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE),3)) \ 49 \ 50 template< \ 51 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \ 52 > \ 53 struct struct_assoc_key<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ), I> \ 54 { \ 55 typedef \ 56 BOOST_FUSION_ADAPT_ASSOC_STRUCT_WRAPPEDATTR_GET_KEY(ATTRIBUTE) type; \ 57 }; 58 59 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_C( \ 60 TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW, I, ATTRIBUTE) \ 61 \ 62 BOOST_FUSION_ADAPT_ASSOC_STRUCT_C_BASE( \ 63 TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW,I,BOOST_PP_EMPTY,ATTRIBUTE) 64 65 66 #define BOOST_FUSION_ADAPT_ASSOC_TPL_STRUCT( \ 67 TEMPLATE_PARAMS_SEQ, NAME_SEQ, ATTRIBUTES) \ 68 \ 69 BOOST_FUSION_ADAPT_STRUCT_BASE( \ 70 (1)TEMPLATE_PARAMS_SEQ, \ 71 (1)NAME_SEQ, \ 72 assoc_struct_tag, \ 73 0, \ 74 BOOST_PP_CAT( \ 75 BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ 76 BOOST_FUSION_ADAPT_ASSOC_STRUCT_C) 77 78 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT(NAME, ATTRIBUTES) \ 79 BOOST_FUSION_ADAPT_STRUCT_BASE( \ 80 (0), \ 81 (0)(NAME), \ 82 assoc_struct_tag, \ 83 0, \ 84 BOOST_PP_CAT( \ 85 BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ 86 BOOST_FUSION_ADAPT_ASSOC_STRUCT_C) 87 88 #define BOOST_FUSION_ADAPT_ASSOC_STRUCT_AS_VIEW(NAME, ATTRIBUTES) \ 89 BOOST_FUSION_ADAPT_STRUCT_BASE( \ 90 (0), \ 91 (0)(NAME), \ 92 assoc_struct_tag, \ 93 1, \ 94 BOOST_PP_CAT( \ 95 BOOST_FUSION_ADAPT_ASSOC_STRUCT_FILLER_0(0,0,0)ATTRIBUTES,_END), \ 96 BOOST_FUSION_ADAPT_ASSOC_STRUCT_C) 97 98 #endif 99