language_support.hpp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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_cpp0x = support_option_variadics | support_option_long_long | 0x10,
  31. support_cpp11 = support_cpp0x,
  32. #endif
  33. support_option_mask = 0xFFC0,
  34. support_option_emit_contnewlines = 0x0040,
  35. support_option_insert_whitespace = 0x0080,
  36. support_option_preserve_comments = 0x0100,
  37. support_option_no_character_validation = 0x0200,
  38. support_option_convert_trigraphs = 0x0400,
  39. support_option_single_line = 0x0800,
  40. support_option_prefer_pp_numbers = 0x1000,
  41. support_option_emit_line_directives = 0x2000,
  42. support_option_include_guard_detection = 0x4000,
  43. support_option_emit_pragma_directives = 0x8000
  44. };
  45. ///////////////////////////////////////////////////////////////////////////////
  46. //
  47. // need_cpp
  48. //
  49. // Extract, if the language to support is C++98
  50. //
  51. ///////////////////////////////////////////////////////////////////////////////
  52. inline bool
  53. need_cpp(language_support language)
  54. {
  55. return (language & ~support_option_mask) == support_cpp;
  56. }
  57. ///////////////////////////////////////////////////////////////////////////////
  58. //
  59. // need_cpp0x
  60. //
  61. // Extract, if the language to support is C++11
  62. //
  63. ///////////////////////////////////////////////////////////////////////////////
  64. #if BOOST_WAVE_SUPPORT_CPP0X != 0
  65. inline bool
  66. need_cpp0x(language_support language)
  67. {
  68. return (language & ~support_option_mask) == support_cpp0x;
  69. }
  70. #else
  71. inline bool
  72. need_cpp0x(language_support language)
  73. {
  74. return false;
  75. }
  76. #endif
  77. #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  78. ///////////////////////////////////////////////////////////////////////////////
  79. //
  80. // need_c99
  81. //
  82. // Extract, if the language to support is C99
  83. //
  84. ///////////////////////////////////////////////////////////////////////////////
  85. inline bool
  86. need_c99(language_support language)
  87. {
  88. return (language & ~support_option_mask) == support_c99;
  89. }
  90. #else // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  91. ///////////////////////////////////////////////////////////////////////////////
  92. inline bool
  93. need_variadics(language_support language)
  94. {
  95. return false;
  96. }
  97. ///////////////////////////////////////////////////////////////////////////////
  98. inline language_support
  99. enable_variadics(language_support language, bool enable = true)
  100. {
  101. return language;
  102. }
  103. //////////////////////////////////////////////////////////////////////////////
  104. inline bool
  105. need_c99(language_support language)
  106. {
  107. return false;
  108. }
  109. #endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  110. ///////////////////////////////////////////////////////////////////////////////
  111. //
  112. // get_support_options
  113. //
  114. // Set preserve comments support in the language to support
  115. //
  116. ///////////////////////////////////////////////////////////////////////////////
  117. inline language_support
  118. get_support_options(language_support language)
  119. {
  120. return static_cast<language_support>(language & support_option_mask);
  121. }
  122. ///////////////////////////////////////////////////////////////////////////////
  123. //
  124. // set_support_options
  125. //
  126. // Set language option (for fine tuning of lexer behavior)
  127. //
  128. ///////////////////////////////////////////////////////////////////////////////
  129. inline language_support
  130. set_support_options(language_support language, language_support option)
  131. {
  132. return static_cast<language_support>(
  133. (language & ~support_option_mask) | (option & support_option_mask));
  134. }
  135. ///////////////////////////////////////////////////////////////////////////////
  136. // Get and set different language options
  137. #define BOOST_WAVE_NEED_OPTION(option) \
  138. inline bool need_ ## option(language_support language) \
  139. { \
  140. return (language & support_option_ ## option) ? true : false; \
  141. } \
  142. /**/
  143. #define BOOST_WAVE_ENABLE_OPTION(option) \
  144. inline language_support \
  145. enable_ ## option(language_support language, bool enable = true) \
  146. { \
  147. if (enable) \
  148. return static_cast<language_support>(language | support_option_ ## option); \
  149. return static_cast<language_support>(language & ~support_option_ ## option); \
  150. } \
  151. /**/
  152. #define BOOST_WAVE_OPTION(option) \
  153. BOOST_WAVE_NEED_OPTION(option) \
  154. BOOST_WAVE_ENABLE_OPTION(option) \
  155. /**/
  156. ///////////////////////////////////////////////////////////////////////////////
  157. BOOST_WAVE_OPTION(long_long) // support_option_long_long
  158. BOOST_WAVE_OPTION(no_character_validation) // support_option_no_character_validation
  159. BOOST_WAVE_OPTION(preserve_comments) // support_option_preserve_comments
  160. BOOST_WAVE_OPTION(prefer_pp_numbers) // support_option_prefer_pp_numbers
  161. BOOST_WAVE_OPTION(emit_line_directives) // support_option_emit_line_directives
  162. BOOST_WAVE_OPTION(single_line) // support_option_single_line
  163. BOOST_WAVE_OPTION(convert_trigraphs) // support_option_convert_trigraphs
  164. #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
  165. BOOST_WAVE_OPTION(include_guard_detection) // support_option_include_guard_detection
  166. #endif
  167. #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
  168. BOOST_WAVE_OPTION(variadics) // support_option_variadics
  169. #endif
  170. #if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
  171. BOOST_WAVE_OPTION(emit_pragma_directives) // support_option_emit_pragma_directives
  172. #endif
  173. BOOST_WAVE_OPTION(insert_whitespace) // support_option_insert_whitespace
  174. BOOST_WAVE_OPTION(emit_contnewlines) // support_option_emit_contnewlines
  175. #undef BOOST_WAVE_NEED_OPTION
  176. #undef BOOST_WAVE_ENABLE_OPTION
  177. #undef BOOST_WAVE_OPTION
  178. ///////////////////////////////////////////////////////////////////////////////
  179. } // namespace wave
  180. } // namespace boost
  181. // the suffix header occurs after all of the code
  182. #ifdef BOOST_HAS_ABI_HEADERS
  183. #include BOOST_ABI_SUFFIX
  184. #endif
  185. #endif // !defined(LANGUAGE_SUPPORT_HPP_93EDD057_2DEF_44BC_BC9F_FDABB9F51AFA_INCLUDED)