config.hpp 13 KB

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