config.hpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /*
  2. *
  3. * Copyright (c) 1998-2002
  4. * John Maddock
  5. *
  6. * Use, modification and distribution are subject to the
  7. * Boost Software License, Version 1.0. (See accompanying file
  8. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. *
  10. */
  11. /*
  12. * LOCATION: see http://www.boost.org for most recent version.
  13. * FILE config.hpp
  14. * VERSION see <boost/version.hpp>
  15. * DESCRIPTION: regex extended config setup.
  16. */
  17. #ifndef BOOST_REGEX_CONFIG_HPP
  18. #define BOOST_REGEX_CONFIG_HPP
  19. #if defined(BOOST_REGEX_RECURSIVE)
  20. #error "All support for the C++03 recursive engine has been removed, this define has no effect anymore."
  21. #endif
  22. #if defined(__has_include)
  23. #if !defined(BOOST_REGEX_STANDALONE) && !__has_include(<boost/version.hpp>)
  24. #define BOOST_REGEX_STANDALONE
  25. #endif
  26. #endif
  27. #ifndef BOOST_REGEX_MODULE_EXPORT
  28. #define BOOST_REGEX_MODULE_EXPORT
  29. #define BOOST_REGEX_STATIC_CONST static const
  30. #else
  31. #define BOOST_REGEX_STATIC_CONST inline constexpr
  32. #define BOOST_REGEX_STANDALONE
  33. #endif
  34. /*
  35. * Borland C++ Fix/error check
  36. * this has to go *before* we include any std lib headers:
  37. */
  38. #if defined(__BORLANDC__) && !defined(__clang__)
  39. # include <boost/regex/config/borland.hpp>
  40. #endif
  41. #ifndef BOOST_REGEX_STANDALONE
  42. #include <boost/version.hpp>
  43. #endif
  44. /*************************************************************************
  45. *
  46. * Asserts:
  47. *
  48. *************************************************************************/
  49. #ifdef BOOST_REGEX_STANDALONE
  50. #ifndef BOOST_REGEX_AS_MODULE
  51. #include <cassert>
  52. # define BOOST_REGEX_ASSERT(x) assert(x)
  53. #else
  54. # define BOOST_REGEX_ASSERT(x) do{ if(x == 0) { std::printf("%s:%d Assertion Failed", __FILE__, __LINE__); std::abort(); } }while(0)
  55. #endif
  56. #else
  57. #include <boost/assert.hpp>
  58. # define BOOST_REGEX_ASSERT(x) BOOST_ASSERT(x)
  59. #endif
  60. /*****************************************************************************
  61. *
  62. * Include all the headers we need here:
  63. *
  64. ****************************************************************************/
  65. #ifdef __cplusplus
  66. # ifndef BOOST_REGEX_USER_CONFIG
  67. # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
  68. # endif
  69. # include BOOST_REGEX_USER_CONFIG
  70. #ifndef BOOST_REGEX_STANDALONE
  71. # include <boost/config.hpp>
  72. # include <boost/predef.h>
  73. #endif
  74. #else
  75. /*
  76. * C build,
  77. * don't include <boost/config.hpp> because that may
  78. * do C++ specific things in future...
  79. */
  80. # include <stdlib.h>
  81. # include <stddef.h>
  82. # ifdef _MSC_VER
  83. # define BOOST_MSVC _MSC_VER
  84. # endif
  85. #endif
  86. #define BOOST_REGEX_MAX_RECURSION_DEPTH 100
  87. /*****************************************************************************
  88. *
  89. * Boilerplate regex config options:
  90. *
  91. ****************************************************************************/
  92. /* Obsolete macro, use BOOST_VERSION instead: */
  93. #define BOOST_RE_VERSION 600
  94. /* fix: */
  95. #if defined(_UNICODE) && !defined(UNICODE)
  96. #define UNICODE
  97. #endif
  98. #define BOOST_REGEX_JOIN(X, Y) BOOST_REGEX_DO_JOIN(X, Y)
  99. #define BOOST_REGEX_DO_JOIN(X, Y) BOOST_REGEX_DO_JOIN2(X,Y)
  100. #define BOOST_REGEX_DO_JOIN2(X, Y) X##Y
  101. #ifdef BOOST_FALLTHROUGH
  102. # define BOOST_REGEX_FALLTHROUGH BOOST_FALLTHROUGH
  103. #else
  104. #if defined(__clang__) && (__cplusplus >= 201103L) && defined(__has_warning)
  105. # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
  106. # define BOOST_REGEX_FALLTHROUGH [[clang::fallthrough]]
  107. # endif
  108. #endif
  109. #if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1800) && (__cplusplus >= 201703)
  110. # define BOOST_REGEX_FALLTHROUGH [[fallthrough]]
  111. #endif
  112. #if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__GNUC__) && (__GNUC__ >= 7)
  113. # define BOOST_REGEX_FALLTHROUGH __attribute__((fallthrough))
  114. #endif
  115. #if !defined(BOOST_REGEX_FALLTHROUGH)
  116. # define BOOST_REGEX_FALLTHROUGH
  117. #endif
  118. #endif
  119. #ifdef BOOST_NORETURN
  120. # define BOOST_REGEX_NORETURN BOOST_NORETURN
  121. #else
  122. # define BOOST_REGEX_NORETURN
  123. #endif
  124. /*
  125. * Define a macro for the namespace that details are placed in, this includes the Boost
  126. * version number to avoid mismatched header and library versions:
  127. */
  128. #define BOOST_REGEX_DETAIL_NS BOOST_REGEX_JOIN(re_detail_, BOOST_RE_VERSION)
  129. /*
  130. * If Win32 support has been disabled for boost in general, then
  131. * it is for regex in particular:
  132. */
  133. #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
  134. # define BOOST_REGEX_NO_W32
  135. #endif
  136. /* disable our own file-iterators and mapfiles if we can't
  137. * support them: */
  138. #if defined(_WIN32)
  139. # if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_RUNTIME
  140. # define BOOST_REGEX_NO_FILEITER
  141. # endif
  142. #else /* defined(_WIN32) */
  143. # if !defined(BOOST_HAS_DIRENT_H)
  144. # define BOOST_REGEX_NO_FILEITER
  145. # endif
  146. #endif
  147. /* backwards compatibitity: */
  148. #if defined(BOOST_RE_NO_LIB)
  149. # define BOOST_REGEX_NO_LIB
  150. #endif
  151. #if defined(__GNUC__) && !defined(_MSC_VER) && (defined(_WIN32) || defined(__CYGWIN__))
  152. /* gcc on win32 has problems if you include <windows.h>
  153. (sporadically generates bad code). */
  154. # define BOOST_REGEX_NO_W32
  155. #endif
  156. #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
  157. # define BOOST_REGEX_NO_W32
  158. #endif
  159. #ifdef BOOST_REGEX_STANDALONE
  160. # if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__)
  161. # define BOOST_REGEX_MSVC _MSC_VER
  162. #endif
  163. #elif defined(BOOST_MSVC)
  164. # define BOOST_REGEX_MSVC BOOST_MSVC
  165. #endif
  166. /*****************************************************************************
  167. *
  168. * Set up dll import/export options:
  169. *
  170. ****************************************************************************/
  171. #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK) && defined(BOOST_SYMBOL_IMPORT)
  172. # if defined(BOOST_REGEX_SOURCE)
  173. # define BOOST_REGEX_BUILD_DLL
  174. # define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
  175. # else
  176. # define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
  177. # endif
  178. #else
  179. # define BOOST_REGEX_DECL
  180. #endif
  181. /*****************************************************************************
  182. *
  183. * Set up function call type:
  184. *
  185. ****************************************************************************/
  186. #if defined(_MSC_VER) && defined(_MSC_EXTENSIONS)
  187. #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL)
  188. # define BOOST_REGEX_CALL __cdecl
  189. #else
  190. # define BOOST_REGEX_CALL __fastcall
  191. #endif
  192. # define BOOST_REGEX_CCALL __cdecl
  193. #endif
  194. #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
  195. #if defined(__clang__)
  196. # define BOOST_REGEX_CALL __cdecl
  197. # define BOOST_REGEX_CCALL __cdecl
  198. #else
  199. # define BOOST_REGEX_CALL __fastcall
  200. # define BOOST_REGEX_CCALL __stdcall
  201. #endif
  202. #endif
  203. #ifndef BOOST_REGEX_CALL
  204. # define BOOST_REGEX_CALL
  205. #endif
  206. #ifndef BOOST_REGEX_CCALL
  207. #define BOOST_REGEX_CCALL
  208. #endif
  209. /*****************************************************************************
  210. *
  211. * Set up localisation model:
  212. *
  213. ****************************************************************************/
  214. /* backwards compatibility: */
  215. #ifdef BOOST_RE_LOCALE_C
  216. # define BOOST_REGEX_USE_C_LOCALE
  217. #endif
  218. #ifdef BOOST_RE_LOCALE_CPP
  219. # define BOOST_REGEX_USE_CPP_LOCALE
  220. #endif
  221. #if defined(__CYGWIN__)
  222. # define BOOST_REGEX_USE_C_LOCALE
  223. #endif
  224. /* use C++ locale when targeting windows store */
  225. #if BOOST_PLAT_WINDOWS_RUNTIME
  226. # define BOOST_REGEX_USE_CPP_LOCALE
  227. # define BOOST_REGEX_NO_WIN32_LOCALE
  228. #endif
  229. /* Win32 defaults to native Win32 locale: */
  230. #if defined(_WIN32) && \
  231. !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \
  232. !defined(BOOST_REGEX_USE_C_LOCALE) && \
  233. !defined(BOOST_REGEX_USE_CPP_LOCALE) && \
  234. !defined(BOOST_REGEX_NO_W32) && \
  235. !defined(BOOST_REGEX_NO_WIN32_LOCALE)
  236. # define BOOST_REGEX_USE_WIN32_LOCALE
  237. #endif
  238. /* otherwise use C++ locale if supported: */
  239. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
  240. # define BOOST_REGEX_USE_CPP_LOCALE
  241. #endif
  242. /* otherwise use C locale: */
  243. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
  244. # define BOOST_REGEX_USE_C_LOCALE
  245. #endif
  246. #ifndef BOOST_REGEX_MAX_STATE_COUNT
  247. # define BOOST_REGEX_MAX_STATE_COUNT 100000000
  248. #endif
  249. /*****************************************************************************
  250. *
  251. * Error Handling for exception free compilers:
  252. *
  253. ****************************************************************************/
  254. #ifdef BOOST_NO_EXCEPTIONS
  255. /*
  256. * If there are no exceptions then we must report critical-errors
  257. * the only way we know how; by terminating.
  258. */
  259. # define BOOST_REGEX_NOEH_ASSERT(x) assert(x);
  260. #else
  261. /*
  262. * With exceptions then error handling is taken care of and
  263. * there is no need for these checks:
  264. */
  265. # define BOOST_REGEX_NOEH_ASSERT(x)
  266. #endif
  267. /*****************************************************************************
  268. *
  269. * Stack protection under MS Windows:
  270. *
  271. ****************************************************************************/
  272. #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
  273. # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
  274. && !(defined(__GNUC__) || defined(__BORLANDC__) && defined(__clang__)) \
  275. && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
  276. && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
  277. # define BOOST_REGEX_HAS_MS_STACK_GUARD
  278. # endif
  279. #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  280. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  281. #endif
  282. #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  283. namespace boost{
  284. namespace BOOST_REGEX_DETAIL_NS{
  285. BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
  286. }
  287. }
  288. #endif
  289. # ifndef BOOST_REGEX_BLOCKSIZE
  290. # define BOOST_REGEX_BLOCKSIZE 4096
  291. # endif
  292. # if BOOST_REGEX_BLOCKSIZE < 512
  293. # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
  294. # endif
  295. # ifndef BOOST_REGEX_MAX_BLOCKS
  296. # define BOOST_REGEX_MAX_BLOCKS 1024
  297. # endif
  298. # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
  299. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  300. # endif
  301. # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
  302. # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
  303. # endif
  304. /*****************************************************************************
  305. *
  306. * Diagnostics:
  307. *
  308. ****************************************************************************/
  309. #ifdef BOOST_REGEX_CONFIG_INFO
  310. BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
  311. #endif
  312. #if defined(BOOST_REGEX_DIAG)
  313. # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
  314. # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
  315. # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
  316. #ifdef BOOST_REGEX_USE_C_LOCALE
  317. # pragma message ("Using C locale in regex traits class")
  318. #elif BOOST_REGEX_USE_CPP_LOCALE
  319. # pragma message ("Using C++ locale in regex traits class")
  320. #else
  321. # pragma message ("Using Win32 locale in regex traits class")
  322. #endif
  323. #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  324. # pragma message ("Dynamic linking enabled")
  325. #endif
  326. #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
  327. # pragma message ("Auto-linking disabled")
  328. #endif
  329. #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
  330. # pragma message ("Extern templates disabled")
  331. #endif
  332. #endif
  333. #endif