attributes_fwd.hpp 12 KB

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