config.hpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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 !((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) || defined(BOOST_REGEX_CXX03))
  20. # define BOOST_REGEX_CXX03
  21. #endif
  22. #if defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_CXX03)
  23. # define BOOST_REGEX_CXX03
  24. #endif
  25. #if defined(__has_include)
  26. #if !defined(BOOST_REGEX_STANDALONE) && !__has_include(<boost/version.hpp>)
  27. #define BOOST_REGEX_STANDALONE
  28. #endif
  29. #endif
  30. /*
  31. * Borland C++ Fix/error check
  32. * this has to go *before* we include any std lib headers:
  33. */
  34. #if defined(__BORLANDC__) && !defined(__clang__)
  35. # include <boost/regex/config/borland.hpp>
  36. #endif
  37. #ifndef BOOST_REGEX_STANDALONE
  38. #include <boost/version.hpp>
  39. #endif
  40. /*************************************************************************
  41. *
  42. * Asserts:
  43. *
  44. *************************************************************************/
  45. #ifdef BOOST_REGEX_STANDALONE
  46. #include <cassert>
  47. # define BOOST_REGEX_ASSERT(x) assert(x)
  48. #else
  49. #include <boost/assert.hpp>
  50. # define BOOST_REGEX_ASSERT(x) BOOST_ASSERT(x)
  51. #endif
  52. /*****************************************************************************
  53. *
  54. * Include all the headers we need here:
  55. *
  56. ****************************************************************************/
  57. #ifdef __cplusplus
  58. # ifndef BOOST_REGEX_USER_CONFIG
  59. # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
  60. # endif
  61. # include BOOST_REGEX_USER_CONFIG
  62. #ifndef BOOST_REGEX_STANDALONE
  63. # include <boost/config.hpp>
  64. # include <boost/predef.h>
  65. #endif
  66. #else
  67. /*
  68. * C build,
  69. * don't include <boost/config.hpp> because that may
  70. * do C++ specific things in future...
  71. */
  72. # include <stdlib.h>
  73. # include <stddef.h>
  74. # ifdef _MSC_VER
  75. # define BOOST_MSVC _MSC_VER
  76. # endif
  77. #endif
  78. /****************************************************************************
  79. *
  80. * Legacy support:
  81. *
  82. *******************************************************************************/
  83. #if defined(BOOST_NO_STD_LOCALE) || defined(BOOST_NO_CXX11_HDR_MUTEX) || defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) \
  84. || defined(BOOST_NO_CXX11_HDR_ATOMIC) || defined(BOOST_NO_CXX11_ALLOCATOR) || defined(BOOST_NO_CXX11_SMART_PTR) \
  85. || defined(BOOST_NO_CXX11_STATIC_ASSERT) || defined(BOOST_NO_NOEXCEPT)
  86. #ifndef BOOST_REGEX_CXX03
  87. # define BOOST_REGEX_CXX03
  88. #endif
  89. #endif
  90. /*****************************************************************************
  91. *
  92. * Boilerplate regex config options:
  93. *
  94. ****************************************************************************/
  95. /* Obsolete macro, use BOOST_VERSION instead: */
  96. #define BOOST_RE_VERSION 500
  97. /* fix: */
  98. #if defined(_UNICODE) && !defined(UNICODE)
  99. #define UNICODE
  100. #endif
  101. #define BOOST_REGEX_JOIN(X, Y) BOOST_REGEX_DO_JOIN(X, Y)
  102. #define BOOST_REGEX_DO_JOIN(X, Y) BOOST_REGEX_DO_JOIN2(X,Y)
  103. #define BOOST_REGEX_DO_JOIN2(X, Y) X##Y
  104. #ifdef BOOST_FALLTHROUGH
  105. # define BOOST_REGEX_FALLTHROUGH BOOST_FALLTHROUGH
  106. #else
  107. #if defined(__clang__) && (__cplusplus >= 201103L) && defined(__has_warning)
  108. # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
  109. # define BOOST_REGEX_FALLTHROUGH [[clang::fallthrough]]
  110. # endif
  111. #endif
  112. #if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1800) && (__cplusplus >= 201703)
  113. # define BOOST_REGEX_FALLTHROUGH [[fallthrough]]
  114. #endif
  115. #if !defined(BOOST_REGEX_FALLTHROUGH) && defined(__GNUC__) && (__GNUC__ >= 7)
  116. # define BOOST_REGEX_FALLTHROUGH __attribute__((fallthrough))
  117. #endif
  118. #if !defined(BOOST_REGEX_FALLTHROUGH)
  119. # define BOOST_REGEX_FALLTHROUGH
  120. #endif
  121. #endif
  122. #ifdef BOOST_NORETURN
  123. # define BOOST_REGEX_NORETURN BOOST_NORETURN
  124. #else
  125. # define BOOST_REGEX_NORETURN
  126. #endif
  127. /*
  128. * Define a macro for the namespace that details are placed in, this includes the Boost
  129. * version number to avoid mismatched header and library versions:
  130. */
  131. #define BOOST_REGEX_DETAIL_NS BOOST_REGEX_JOIN(re_detail_, BOOST_RE_VERSION)
  132. /*
  133. * Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
  134. * masks to be combined, for example:
  135. * std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
  136. * returns *false*.
  137. */
  138. #if defined(__GLIBCPP__) && defined(BOOST_REGEX_CXX03)
  139. # define BOOST_REGEX_BUGGY_CTYPE_FACET
  140. #endif
  141. /*
  142. * If there isn't good enough wide character support then there will
  143. * be no wide character regular expressions:
  144. */
  145. #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
  146. # if !defined(BOOST_NO_WREGEX)
  147. # define BOOST_NO_WREGEX
  148. # endif
  149. #else
  150. # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
  151. /* STLPort on IRIX is misconfigured: <cwctype> does not compile
  152. * as a temporary fix include <wctype.h> instead and prevent inclusion
  153. * of STLPort version of <cwctype> */
  154. # include <wctype.h>
  155. # define __STLPORT_CWCTYPE
  156. # define _STLP_CWCTYPE
  157. # endif
  158. #if defined(__cplusplus) && defined(BOOST_REGEX_CXX03)
  159. # include <boost/regex/config/cwchar.hpp>
  160. #endif
  161. #endif
  162. /*
  163. * If Win32 support has been disabled for boost in general, then
  164. * it is for regex in particular:
  165. */
  166. #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
  167. # define BOOST_REGEX_NO_W32
  168. #endif
  169. /* disable our own file-iterators and mapfiles if we can't
  170. * support them: */
  171. #if defined(_WIN32)
  172. # if defined(BOOST_REGEX_NO_W32) || BOOST_PLAT_WINDOWS_RUNTIME
  173. # define BOOST_REGEX_NO_FILEITER
  174. # endif
  175. #else /* defined(_WIN32) */
  176. # if !defined(BOOST_HAS_DIRENT_H)
  177. # define BOOST_REGEX_NO_FILEITER
  178. # endif
  179. #endif
  180. /* backwards compatibitity: */
  181. #if defined(BOOST_RE_NO_LIB)
  182. # define BOOST_REGEX_NO_LIB
  183. #endif
  184. #if defined(__GNUC__) && !defined(_MSC_VER) && (defined(_WIN32) || defined(__CYGWIN__))
  185. /* gcc on win32 has problems if you include <windows.h>
  186. (sporadically generates bad code). */
  187. # define BOOST_REGEX_NO_W32
  188. #endif
  189. #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
  190. # define BOOST_REGEX_NO_W32
  191. #endif
  192. #ifdef BOOST_REGEX_STANDALONE
  193. # if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__)
  194. # define BOOST_REGEX_MSVC _MSC_VER
  195. #endif
  196. #elif defined(BOOST_MSVC)
  197. # define BOOST_REGEX_MSVC BOOST_MSVC
  198. #endif
  199. /*****************************************************************************
  200. *
  201. * Set up dll import/export options:
  202. *
  203. ****************************************************************************/
  204. #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK) && defined(BOOST_SYMBOL_IMPORT)
  205. # if defined(BOOST_REGEX_SOURCE)
  206. # define BOOST_REGEX_BUILD_DLL
  207. # define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
  208. # else
  209. # define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
  210. # endif
  211. #else
  212. # define BOOST_REGEX_DECL
  213. #endif
  214. #ifdef BOOST_REGEX_CXX03
  215. #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
  216. # define BOOST_LIB_NAME boost_regex
  217. # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  218. # define BOOST_DYN_LINK
  219. # endif
  220. # ifdef BOOST_REGEX_DIAG
  221. # define BOOST_LIB_DIAGNOSTIC
  222. # endif
  223. # include <boost/config/auto_link.hpp>
  224. #endif
  225. #endif
  226. /*****************************************************************************
  227. *
  228. * Set up function call type:
  229. *
  230. ****************************************************************************/
  231. #if defined(_MSC_VER) && defined(_MSC_EXTENSIONS)
  232. #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL)
  233. # define BOOST_REGEX_CALL __cdecl
  234. #else
  235. # define BOOST_REGEX_CALL __fastcall
  236. #endif
  237. # define BOOST_REGEX_CCALL __cdecl
  238. #endif
  239. #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
  240. #if defined(__clang__)
  241. # define BOOST_REGEX_CALL __cdecl
  242. # define BOOST_REGEX_CCALL __cdecl
  243. #else
  244. # define BOOST_REGEX_CALL __fastcall
  245. # define BOOST_REGEX_CCALL __stdcall
  246. #endif
  247. #endif
  248. #ifndef BOOST_REGEX_CALL
  249. # define BOOST_REGEX_CALL
  250. #endif
  251. #ifndef BOOST_REGEX_CCALL
  252. #define BOOST_REGEX_CCALL
  253. #endif
  254. /*****************************************************************************
  255. *
  256. * Set up localisation model:
  257. *
  258. ****************************************************************************/
  259. /* backwards compatibility: */
  260. #ifdef BOOST_RE_LOCALE_C
  261. # define BOOST_REGEX_USE_C_LOCALE
  262. #endif
  263. #ifdef BOOST_RE_LOCALE_CPP
  264. # define BOOST_REGEX_USE_CPP_LOCALE
  265. #endif
  266. #if defined(__CYGWIN__)
  267. # define BOOST_REGEX_USE_C_LOCALE
  268. #endif
  269. /* use C++ locale when targeting windows store */
  270. #if BOOST_PLAT_WINDOWS_RUNTIME
  271. # define BOOST_REGEX_USE_CPP_LOCALE
  272. # define BOOST_REGEX_NO_WIN32_LOCALE
  273. #endif
  274. /* Win32 defaults to native Win32 locale: */
  275. #if defined(_WIN32) && \
  276. !defined(BOOST_REGEX_USE_WIN32_LOCALE) && \
  277. !defined(BOOST_REGEX_USE_C_LOCALE) && \
  278. !defined(BOOST_REGEX_USE_CPP_LOCALE) && \
  279. !defined(BOOST_REGEX_NO_W32) && \
  280. !defined(BOOST_REGEX_NO_WIN32_LOCALE)
  281. # define BOOST_REGEX_USE_WIN32_LOCALE
  282. #endif
  283. /* otherwise use C++ locale if supported: */
  284. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
  285. # define BOOST_REGEX_USE_CPP_LOCALE
  286. #endif
  287. /* otherwise use C locale: */
  288. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
  289. # define BOOST_REGEX_USE_C_LOCALE
  290. #endif
  291. #ifndef BOOST_REGEX_MAX_STATE_COUNT
  292. # define BOOST_REGEX_MAX_STATE_COUNT 100000000
  293. #endif
  294. /*****************************************************************************
  295. *
  296. * Error Handling for exception free compilers:
  297. *
  298. ****************************************************************************/
  299. #ifdef BOOST_NO_EXCEPTIONS
  300. /*
  301. * If there are no exceptions then we must report critical-errors
  302. * the only way we know how; by terminating.
  303. */
  304. #include <stdexcept>
  305. #include <string>
  306. #include <boost/throw_exception.hpp>
  307. # define BOOST_REGEX_NOEH_ASSERT(x)\
  308. if(0 == (x))\
  309. {\
  310. std::string s("Error: critical regex++ failure in: ");\
  311. s.append(#x);\
  312. std::runtime_error e(s);\
  313. boost::throw_exception(e);\
  314. }
  315. #else
  316. /*
  317. * With exceptions then error handling is taken care of and
  318. * there is no need for these checks:
  319. */
  320. # define BOOST_REGEX_NOEH_ASSERT(x)
  321. #endif
  322. /*****************************************************************************
  323. *
  324. * Stack protection under MS Windows:
  325. *
  326. ****************************************************************************/
  327. #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
  328. # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
  329. && !(defined(__GNUC__) || defined(__BORLANDC__) && defined(__clang__)) \
  330. && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
  331. && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
  332. # define BOOST_REGEX_HAS_MS_STACK_GUARD
  333. # endif
  334. #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  335. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  336. #endif
  337. #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  338. namespace boost{
  339. namespace BOOST_REGEX_DETAIL_NS{
  340. BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
  341. }
  342. }
  343. #endif
  344. /*****************************************************************************
  345. *
  346. * Algorithm selection and configuration.
  347. * These options are now obsolete for C++11 and later (regex v5).
  348. *
  349. ****************************************************************************/
  350. #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
  351. # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(_MSC_VER) && (_MSC_VER >= 1400)) && defined(BOOST_REGEX_CXX03)
  352. # define BOOST_REGEX_RECURSIVE
  353. # else
  354. # define BOOST_REGEX_NON_RECURSIVE
  355. # endif
  356. #endif
  357. #ifdef BOOST_REGEX_NON_RECURSIVE
  358. # ifdef BOOST_REGEX_RECURSIVE
  359. # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
  360. # endif
  361. # ifndef BOOST_REGEX_BLOCKSIZE
  362. # define BOOST_REGEX_BLOCKSIZE 4096
  363. # endif
  364. # if BOOST_REGEX_BLOCKSIZE < 512
  365. # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
  366. # endif
  367. # ifndef BOOST_REGEX_MAX_BLOCKS
  368. # define BOOST_REGEX_MAX_BLOCKS 1024
  369. # endif
  370. # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
  371. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  372. # endif
  373. # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
  374. # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
  375. # endif
  376. #endif
  377. /*****************************************************************************
  378. *
  379. * Diagnostics:
  380. *
  381. ****************************************************************************/
  382. #ifdef BOOST_REGEX_CONFIG_INFO
  383. BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
  384. #endif
  385. #if defined(BOOST_REGEX_DIAG)
  386. # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
  387. # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
  388. # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
  389. #ifdef BOOST_REGEX_USE_C_LOCALE
  390. # pragma message ("Using C locale in regex traits class")
  391. #elif BOOST_REGEX_USE_CPP_LOCALE
  392. # pragma message ("Using C++ locale in regex traits class")
  393. #else
  394. # pragma message ("Using Win32 locale in regex traits class")
  395. #endif
  396. #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  397. # pragma message ("Dynamic linking enabled")
  398. #endif
  399. #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
  400. # pragma message ("Auto-linking disabled")
  401. #endif
  402. #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
  403. # pragma message ("Extern templates disabled")
  404. #endif
  405. #endif
  406. #endif