attributes_fwd.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Hartmut Kaiser
  3. Copyright (c) 2001-2011 Joel de Guzman
  4. Copyright (c) 2010 Bryce Lelbach
  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. #if !defined(BOOST_SPIRIT_ATTRIBUTES_FWD_OCT_01_2009_0715AM)
  9. #define BOOST_SPIRIT_ATTRIBUTES_FWD_OCT_01_2009_0715AM
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp>
  14. #if (defined(__GNUC__) && (__GNUC__ < 4)) || \
  15. (defined(__APPLE__) && defined(__INTEL_COMPILER))
  16. #include <boost/utility/enable_if.hpp>
  17. #endif
  18. #include <boost/spirit/home/support/unused.hpp>
  19. ///////////////////////////////////////////////////////////////////////////////
  20. namespace boost { namespace spirit { namespace result_of
  21. {
  22. // forward declaration only
  23. template <typename Exposed, typename Attribute>
  24. struct extract_from;
  25. template <typename T, typename Attribute>
  26. struct attribute_as;
  27. template <typename Exposed, typename Transformed, typename Domain>
  28. struct pre_transform;
  29. template <typename T>
  30. struct optional_value;
  31. template <typename Container>
  32. struct begin;
  33. template <typename Container>
  34. struct end;
  35. template <typename Iterator>
  36. struct deref;
  37. }}}
  38. ///////////////////////////////////////////////////////////////////////////////
  39. namespace boost { namespace spirit { namespace traits
  40. {
  41. ///////////////////////////////////////////////////////////////////////////
  42. // Find out if T can be a strong substitute for Expected attribute
  43. ///////////////////////////////////////////////////////////////////////////
  44. template <typename T, typename Expected, typename Enable = void>
  45. struct is_substitute;
  46. ///////////////////////////////////////////////////////////////////////////
  47. // Find out if T can be a weak substitute for Expected attribute
  48. ///////////////////////////////////////////////////////////////////////////
  49. template <typename T, typename Expected, typename Enable = void>
  50. struct is_weak_substitute;
  51. ///////////////////////////////////////////////////////////////////////////
  52. // Determine if T is a proxy
  53. ///////////////////////////////////////////////////////////////////////////
  54. template <typename T, typename Enable = void>
  55. struct is_proxy;
  56. ///////////////////////////////////////////////////////////////////////////
  57. // Retrieve the attribute type to use from the given type
  58. //
  59. // This is needed to extract the correct attribute type from proxy classes
  60. // as utilized in FUSION_ADAPT_ADT et. al.
  61. ///////////////////////////////////////////////////////////////////////////
  62. template <typename Attribute, typename Enable = void>
  63. struct attribute_type;
  64. ///////////////////////////////////////////////////////////////////////////
  65. // Retrieve the size of a fusion sequence (compile time)
  66. ///////////////////////////////////////////////////////////////////////////
  67. template <typename T>
  68. struct sequence_size;
  69. ///////////////////////////////////////////////////////////////////////////
  70. // Retrieve the size of an attribute (runtime)
  71. ///////////////////////////////////////////////////////////////////////////
  72. template <typename Attribute, typename Enable = void>
  73. struct attribute_size;
  74. template <typename Attribute>
  75. typename attribute_size<Attribute>::type
  76. size(Attribute const& attr);
  77. ///////////////////////////////////////////////////////////////////////////
  78. // Determines how we pass attributes to semantic actions. This
  79. // may be specialized. By default, all attributes are wrapped in
  80. // a fusion sequence, because the attribute has to be treated as being
  81. // a single value in any case (even if it actually already is a fusion
  82. // sequence in its own).
  83. ///////////////////////////////////////////////////////////////////////////
  84. template <typename Component, typename Attribute, typename Enable = void>
  85. struct pass_attribute;
  86. ///////////////////////////////////////////////////////////////////////////
  87. template <typename T, typename Enable = void>
  88. struct optional_attribute;
  89. ///////////////////////////////////////////////////////////////////////////
  90. // Sometimes the user needs to transform the attribute types for certain
  91. // attributes. This template can be used as a customization point, where
  92. // the user is able specify specific transformation rules for any attribute
  93. // type.
  94. ///////////////////////////////////////////////////////////////////////////
  95. template <typename Exposed, typename Transformed, typename Domain
  96. , typename Enable = void>
  97. struct transform_attribute;
  98. ///////////////////////////////////////////////////////////////////////////
  99. // Qi only
  100. template <typename Attribute, typename Iterator, typename Enable = void>
  101. struct assign_to_attribute_from_iterators;
  102. template <typename Iterator, typename Attribute>
  103. void assign_to(Iterator const& first, Iterator const& last, Attribute& attr);
  104. template <typename Iterator>
  105. void assign_to(Iterator const&, Iterator const&, unused_type);
  106. template <typename Attribute, typename T, typename Enable = void>
  107. struct assign_to_attribute_from_value;
  108. template <typename Attribute, typename T, typename Enable = void>
  109. struct assign_to_container_from_value;
  110. template <typename T, typename Attribute>
  111. void assign_to(T const& val, Attribute& attr);
  112. template <typename T>
  113. void assign_to(T const&, unused_type);
  114. ///////////////////////////////////////////////////////////////////////////
  115. // Karma only
  116. template <typename Attribute, typename Exposed, typename Enable = void>
  117. struct extract_from_attribute;
  118. template <typename Attribute, typename Exposed, typename Enable = void>
  119. struct extract_from_container;
  120. template <typename Exposed, typename Attribute, typename Context>
  121. typename spirit::result_of::extract_from<Exposed, Attribute>::type
  122. extract_from(Attribute const& attr, Context& ctx
  123. #if (defined(__GNUC__) && (__GNUC__ < 4)) || \
  124. (defined(__APPLE__) && defined(__INTEL_COMPILER))
  125. , typename enable_if<traits::not_is_unused<Attribute> >::type* = NULL
  126. #endif
  127. );
  128. ///////////////////////////////////////////////////////////////////////////
  129. // Karma only
  130. template <typename T, typename Attribute, typename Enable = void>
  131. struct attribute_as;
  132. template <typename T, typename Attribute>
  133. typename spirit::result_of::attribute_as<T, Attribute>::type
  134. as(Attribute const& attr);
  135. template <typename T, typename Attribute>
  136. bool valid_as(Attribute const& attr);
  137. ///////////////////////////////////////////////////////////////////////////
  138. // return the type currently stored in the given variant
  139. ///////////////////////////////////////////////////////////////////////////
  140. template <typename T, typename Enable = void>
  141. struct variant_which;
  142. template <typename T>
  143. int which(T const& v);
  144. ///////////////////////////////////////////////////////////////////////////
  145. // Determine, whether T is a variant like type
  146. ///////////////////////////////////////////////////////////////////////////
  147. template <typename T, typename Domain = unused_type, typename Enable = void>
  148. struct not_is_variant;
  149. ///////////////////////////////////////////////////////////////////////////
  150. // Determine, whether T is a variant like type
  151. ///////////////////////////////////////////////////////////////////////////
  152. template <typename T, typename Domain = unused_type, typename Enable = void>
  153. struct not_is_optional;
  154. ///////////////////////////////////////////////////////////////////////////
  155. // Clear data efficiently
  156. ///////////////////////////////////////////////////////////////////////////
  157. template <typename T, typename Enable = void>
  158. struct clear_value;
  159. ///////////////////////////////////////////////////////////////////////
  160. // Determine the value type of the given container type
  161. ///////////////////////////////////////////////////////////////////////
  162. template <typename Container, typename Enable = void>
  163. struct container_value;
  164. template <typename Container, typename Enable = void>
  165. struct container_iterator;
  166. template <typename T, typename Enable = void>
  167. struct is_container;
  168. template <typename T, typename Enable = void>
  169. struct is_iterator_range;
  170. ///////////////////////////////////////////////////////////////////////////
  171. template <typename T, typename Attribute, typename Context = unused_type
  172. , typename Iterator = unused_type, typename Enable = void>
  173. struct handles_container;
  174. template <typename Container, typename ValueType, typename Attribute
  175. , typename Sequence, typename Domain, typename Enable = void>
  176. struct pass_through_container;
  177. ///////////////////////////////////////////////////////////////////////////
  178. // Qi only
  179. template <typename Container, typename T, typename Enable = void>
  180. struct push_back_container;
  181. template <typename Container, typename Enable = void>
  182. struct is_empty_container;
  183. template <typename Container, typename Enable = void>
  184. struct make_container_attribute;
  185. ///////////////////////////////////////////////////////////////////////
  186. // Determine the iterator type of the given container type
  187. // Karma only
  188. ///////////////////////////////////////////////////////////////////////
  189. template <typename Container, typename Enable = void>
  190. struct begin_container;
  191. template <typename Container, typename Enable = void>
  192. struct end_container;
  193. template <typename Iterator, typename Enable = void>
  194. struct deref_iterator;
  195. template <typename Iterator, typename Enable = void>
  196. struct next_iterator;
  197. template <typename Iterator, typename Enable = void>
  198. struct compare_iterators;
  199. ///////////////////////////////////////////////////////////////////////////
  200. // Print the given attribute of type T to the stream given as Out
  201. ///////////////////////////////////////////////////////////////////////////
  202. template <typename Out, typename T, typename Enable = void>
  203. struct print_attribute_debug;
  204. template <typename Out, typename T>
  205. void print_attribute(Out&, T const&);
  206. template <typename Out>
  207. void print_attribute(Out&, unused_type);
  208. ///////////////////////////////////////////////////////////////////////////
  209. template <typename Char, typename Enable = void>
  210. struct token_printer_debug;
  211. template<typename Out, typename T>
  212. void print_token(Out&, T const&);
  213. ///////////////////////////////////////////////////////////////////////////
  214. // Access attributes from a karma symbol table
  215. ///////////////////////////////////////////////////////////////////////////
  216. template <typename T, typename Attribute, typename Enable = void>
  217. struct symbols_lookup;
  218. template <typename Attribute, typename T, typename Enable = void>
  219. struct symbols_value;
  220. ///////////////////////////////////////////////////////////////////////////
  221. // transform attribute types exposed from compound operator components
  222. ///////////////////////////////////////////////////////////////////////////
  223. template <typename Attribute, typename Domain>
  224. struct alternative_attribute_transform;
  225. template <typename Attribute, typename Domain>
  226. struct sequence_attribute_transform;
  227. template <typename Attribute, typename Domain>
  228. struct permutation_attribute_transform;
  229. template <typename Attribute, typename Domain>
  230. struct sequential_or_attribute_transform;
  231. }}}
  232. #endif