adapt_struct.hpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*=============================================================================
  2. Copyright (c) 2001-2007 Joel de Guzman
  3. Copyright (c) 2009-2011 Christopher Schmidt
  4. Copyright (c) 2013-2014 Damien Buhl
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #ifndef BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP
  9. #define BOOST_FUSION_ADAPTED_STRUCT_ADAPT_STRUCT_HPP
  10. #include <boost/fusion/support/config.hpp>
  11. #include <boost/preprocessor/config/config.hpp>
  12. #include <boost/preprocessor/cat.hpp>
  13. #include <boost/preprocessor/empty.hpp>
  14. #include <boost/preprocessor/control/iif.hpp>
  15. #include <boost/preprocessor/comparison/less.hpp>
  16. #include <boost/preprocessor/seq/seq.hpp>
  17. #include <boost/preprocessor/variadic/to_seq.hpp>
  18. #include <boost/type_traits/add_reference.hpp>
  19. #include <boost/type_traits/is_const.hpp>
  20. #include <boost/type_traits/add_const.hpp>
  21. #include <boost/type_traits/remove_const.hpp>
  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. #define BOOST_FUSION_ADAPT_STRUCT_C( \
  36. TEMPLATE_PARAMS_SEQ, NAME_SEQ, IS_VIEW, I, ATTRIBUTE) \
  37. BOOST_FUSION_ADAPT_STRUCT_C_BASE( \
  38. TEMPLATE_PARAMS_SEQ, \
  39. NAME_SEQ, \
  40. IS_VIEW, \
  41. I, \
  42. BOOST_PP_IIF(IS_VIEW, BOOST_FUSION_PROXY_PREFIX, BOOST_PP_EMPTY), \
  43. BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR(ATTRIBUTE), \
  44. BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), \
  45. BOOST_PP_LESS( \
  46. BOOST_FUSION_ADAPT_STRUCT_WRAPPEDATTR_SIZE(ATTRIBUTE), 2))
  47. #if BOOST_PP_VARIADICS
  48. # define BOOST_FUSION_ADAPT_TPL_STRUCT(TEMPLATE_PARAMS_SEQ,NAME_SEQ, ...) \
  49. BOOST_FUSION_ADAPT_STRUCT_BASE( \
  50. (1)TEMPLATE_PARAMS_SEQ, \
  51. (1)NAME_SEQ, \
  52. struct_tag, \
  53. 0, \
  54. BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \
  55. BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)), \
  56. BOOST_FUSION_ADAPT_STRUCT_C)
  57. # define BOOST_FUSION_ADAPT_STRUCT(...) \
  58. BOOST_FUSION_ADAPT_STRUCT_BASE( \
  59. (0), \
  60. (0)(BOOST_PP_SEQ_HEAD(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \
  61. struct_tag, \
  62. 0, \
  63. BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \
  64. BOOST_PP_SEQ_TAIL(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \
  65. BOOST_FUSION_ADAPT_STRUCT_C)
  66. # define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(...) \
  67. BOOST_FUSION_ADAPT_STRUCT_BASE( \
  68. (0), \
  69. (0)(BOOST_PP_SEQ_HEAD(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \
  70. struct_tag, \
  71. 1, \
  72. BOOST_FUSION_ADAPT_STRUCT_ATTRIBUTES_FILLER( \
  73. BOOST_PP_SEQ_TAIL(BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__))), \
  74. BOOST_FUSION_ADAPT_STRUCT_C)
  75. #else // BOOST_PP_VARIADICS
  76. # define BOOST_FUSION_ADAPT_TPL_STRUCT( \
  77. TEMPLATE_PARAMS_SEQ,NAME_SEQ, ATTRIBUTES) \
  78. BOOST_FUSION_ADAPT_STRUCT_BASE( \
  79. (1)TEMPLATE_PARAMS_SEQ, \
  80. (1)NAME_SEQ, \
  81. struct_tag, \
  82. 0, \
  83. BOOST_PP_CAT( \
  84. BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES,_END), \
  85. BOOST_FUSION_ADAPT_STRUCT_C)
  86. # define BOOST_FUSION_ADAPT_STRUCT(NAME, ATTRIBUTES) \
  87. BOOST_FUSION_ADAPT_STRUCT_BASE( \
  88. (0), \
  89. (0)(NAME), \
  90. struct_tag, \
  91. 0, \
  92. BOOST_PP_CAT( \
  93. BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \
  94. _END), \
  95. BOOST_FUSION_ADAPT_STRUCT_C)
  96. # define BOOST_FUSION_ADAPT_STRUCT_AS_VIEW(NAME, ATTRIBUTES) \
  97. BOOST_FUSION_ADAPT_STRUCT_BASE( \
  98. (0), \
  99. (0)(NAME), \
  100. struct_tag, \
  101. 1, \
  102. BOOST_PP_CAT( \
  103. BOOST_FUSION_ADAPT_STRUCT_FILLER_0(0,0)ATTRIBUTES, \
  104. _END), \
  105. BOOST_FUSION_ADAPT_STRUCT_C)
  106. #endif // BOOST_PP_VARIADICS
  107. #endif