config.hpp 14 KB

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