language_support.hpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*=============================================================================
  2. Boost.Wave: A Standard compliant C++ preprocessor library
  3. Definition of the various language support constants
  4. http://www.boost.org/
  5. Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
  6. Software License, Version 1.0. (See accompanying file
  7. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. =============================================================================*/
  9. #if !defined(LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)
  10. #define LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED
  11. #include <boost/wave/wave_config.hpp>
  12. // this must occur after all of the includes and before any code appears
  13. #ifdef BOOST_HAS_ABI_HEADERS
  14. #include BOOST_ABI_PREFIX
  15. #endif
  16. ///////////////////////////////////////////////////////////////////////////////
  17. namespace boost {
  18. namespace wave {
  19. enum language_support {
  20. // support flags for C++98
  21. support_normal = 0x01,
  22. support_cpp = support_normal,
  23. support_option_long_long = 0x02,
  24. #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  25. // support flags for C99
  26. support_option_variadics = 0x04,
  27. support_c99 = support_option_variadics | support_option_long_long | 0x08,
  28. #endif
  29. #if BOOST_WAVE_SUPPORT_CPP0X != 0
  30. support_option_no_newline_at_end_of_file = 0x20,
  31. support_cpp0x = support_option_variadics | support_option_long_long |
  32. support_option_no_newline_at_end_of_file | 0x10,
  33. support_cpp11 = support_cpp0x,
  34. #endif
  35. support_option_mask = 0xFFC0,
  36. support_option_emit_contnewlines = 0x0040,
  37. support_option_insert_whitespace = 0x0080,
  38. support_option_preserve_comments = 0x0100,
  39. support_option_no_character_validation = 0x0200,
  40. support_option_convert_trigraphs = 0x0400,
  41. support_option_single_line = 0x0800,
  42. support_option_prefer_pp_numbers = 0x1000,
  43. support_option_emit_line_directives = 0x2000,
  44. support_option_include_guard_detection = 0x4000,
  45. support_option_emit_pragma_directives = 0x8000
  46. };
  47. ///////////////////////////////////////////////////////////////////////////////
  48. //
  49. // need_cpp
  50. //
  51. // Extract, if the language to support is C++98
  52. //
  53. ///////////////////////////////////////////////////////////////////////////////
  54. inline bool
  55. need_cpp(language_support language)
  56. {
  57. return (language & ~support_option_mask) == support_cpp;
  58. }
  59. ///////////////////////////////////////////////////////////////////////////////
  60. //
  61. // need_cpp0x
  62. //
  63. // Extract, if the language to support is C++11
  64. //
  65. ///////////////////////////////////////////////////////////////////////////////
  66. #if BOOST_WAVE_SUPPORT_CPP0X != 0
  67. inline bool
  68. need_cpp0x(language_support language)
  69. {
  70. return (language & ~support_option_mask) == support_cpp0x;
  71. }
  72. #else
  73. inline bool
  74. need_cpp0x(language_support language)
  75. {
  76. return false;
  77. }
  78. #endif
  79. #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  80. ///////////////////////////////////////////////////////////////////////////////
  81. //
  82. // need_c99
  83. //
  84. // Extract, if the language to support is C99
  85. //
  86. ///////////////////////////////////////////////////////////////////////////////
  87. inline bool
  88. need_c99(language_support language)
  89. {
  90. return (language & ~support_option_mask) == support_c99;
  91. }
  92. #else // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  93. ///////////////////////////////////////////////////////////////////////////////
  94. inline bool
  95. need_variadics(language_support language)
  96. {
  97. return false;
  98. }
  99. ///////////////////////////////////////////////////////////////////////////////
  100. inline language_support
  101. enable_variadics(language_support language, bool enable = true)
  102. {
  103. return language;
  104. }
  105. //////////////////////////////////////////////////////////////////////////////
  106. inline bool
  107. need_c99(language_support language)
  108. {
  109. return false;
  110. }
  111. #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  112. ///////////////////////////////////////////////////////////////////////////////
  113. //
  114. // get_support_options
  115. //
  116. // Set preserve comments support in the language to support
  117. //
  118. ///////////////////////////////////////////////////////////////////////////////
  119. inline language_support
  120. get_support_options(language_support language)
  121. {
  122. return static_cast<language_support>(language & support_option_mask);
  123. }
  124. ///////////////////////////////////////////////////////////////////////////////
  125. //
  126. // set_support_options
  127. //
  128. // Set language option (for fine tuning of lexer behavior)
  129. //
  130. ///////////////////////////////////////////////////////////////////////////////
  131. inline language_support
  132. set_support_options(language_support language, language_support option)
  133. {
  134. return static_cast<language_support>(
  135. (language & ~support_option_mask) | (option & support_option_mask));
  136. }
  137. ///////////////////////////////////////////////////////////////////////////////
  138. // Get and set different language options
  139. #define BOOST_WAVE_NEED_OPTION(option) \
  140. inline bool need_ ## option(language_support language) \
  141. { \
  142. return (language & support_option_ ## option) ? true : false; \
  143. } \
  144. /**/
  145. #define BOOST_WAVE_ENABLE_OPTION(option) \
  146. inline language_support \
  147. enable_ ## option(language_support language, bool enable = true) \
  148. { \
  149. if (enable) \
  150. return static_cast<language_support>(language | support_option_ ## option); \
  151. return static_cast<language_support>(language & ~support_option_ ## option); \
  152. } \
  153. /**/
  154. #define BOOST_WAVE_OPTION(option) \
  155. BOOST_WAVE_NEED_OPTION(option) \
  156. BOOST_WAVE_ENABLE_OPTION(option) \
  157. /**/
  158. ///////////////////////////////////////////////////////////////////////////////
  159. BOOST_WAVE_OPTION(long_long) // support_option_long_long
  160. BOOST_WAVE_OPTION(no_character_validation) // support_option_no_character_validation
  161. BOOST_WAVE_OPTION(preserve_comments) // support_option_preserve_comments
  162. BOOST_WAVE_OPTION(prefer_pp_numbers) // support_option_prefer_pp_numbers
  163. BOOST_WAVE_OPTION(emit_line_directives) // support_option_emit_line_directives
  164. BOOST_WAVE_OPTION(single_line) // support_option_single_line
  165. BOOST_WAVE_OPTION(convert_trigraphs) // support_option_convert_trigraphs
  166. #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
  167. BOOST_WAVE_OPTION(include_guard_detection) // support_option_include_guard_detection
  168. #endif
  169. #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  170. BOOST_WAVE_OPTION(variadics) // support_option_variadics
  171. #endif
  172. #if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
  173. BOOST_WAVE_OPTION(emit_pragma_directives) // support_option_emit_pragma_directives
  174. #endif
  175. BOOST_WAVE_OPTION(insert_whitespace) // support_option_insert_whitespace
  176. BOOST_WAVE_OPTION(emit_contnewlines) // support_option_emit_contnewlines
  177. #if BOOST_WAVE_SUPPORT_CPP0X != 0
  178. BOOST_WAVE_OPTION(no_newline_at_end_of_file) // support_no_newline_at_end_of_file
  179. #endif
  180. #undef BOOST_WAVE_NEED_OPTION
  181. #undef BOOST_WAVE_ENABLE_OPTION
  182. #undef BOOST_WAVE_OPTION
  183. ///////////////////////////////////////////////////////////////////////////////
  184. } // namespace wave
  185. } // namespace boost
  186. // the suffix header occurs after all of the code
  187. #ifdef BOOST_HAS_ABI_HEADERS
  188. #include BOOST_ABI_SUFFIX
  189. #endif
  190. #endif // !defined(LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)