adapt_struct.hpp 7.1 KB

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