adapt_base_assoc_attr_filler.hpp 3.3 KB

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