config.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. */
  145. #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)
  146. # define BOOST_REGEX_HAS_OTHER_WCHAR_T
  147. # ifdef BOOST_MSVC
  148. # pragma warning(push)
  149. # pragma warning(disable : 4251 4231 4660)
  150. # endif
  151. # if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
  152. # include <string>
  153. extern template class __declspec(dllimport) std::basic_string<unsigned short>;
  154. # endif
  155. # ifdef BOOST_MSVC
  156. # pragma warning(pop)
  157. # endif
  158. #endif
  159. /*****************************************************************************
  160. *
  161. * Set up dll import/export options:
  162. *
  163. ****************************************************************************/
  164. #ifndef BOOST_SYMBOL_EXPORT
  165. # define BOOST_SYMBOL_EXPORT
  166. # define BOOST_SYMBOL_IMPORT
  167. #endif
  168. #if (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
  169. # if defined(BOOST_REGEX_SOURCE)
  170. # define BOOST_REGEX_DECL BOOST_SYMBOL_EXPORT
  171. # define BOOST_REGEX_BUILD_DLL
  172. # else
  173. # define BOOST_REGEX_DECL BOOST_SYMBOL_IMPORT
  174. # endif
  175. #else
  176. # define BOOST_REGEX_DECL
  177. #endif
  178. #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
  179. # define BOOST_LIB_NAME boost_regex
  180. # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  181. # define BOOST_DYN_LINK
  182. # endif
  183. # ifdef BOOST_REGEX_DIAG
  184. # define BOOST_LIB_DIAGNOSTIC
  185. # endif
  186. # include <boost/config/auto_link.hpp>
  187. #endif
  188. /*****************************************************************************
  189. *
  190. * Set up function call type:
  191. *
  192. ****************************************************************************/
  193. #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS)
  194. #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED)
  195. # define BOOST_REGEX_CALL __cdecl
  196. #else
  197. # define BOOST_REGEX_CALL __fastcall
  198. #endif
  199. # define BOOST_REGEX_CCALL __cdecl
  200. #endif
  201. #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
  202. # define BOOST_REGEX_CALL __fastcall
  203. # define BOOST_REGEX_CCALL __stdcall
  204. #endif
  205. #ifndef BOOST_REGEX_CALL
  206. # define BOOST_REGEX_CALL
  207. #endif
  208. #ifndef BOOST_REGEX_CCALL
  209. #define BOOST_REGEX_CCALL
  210. #endif
  211. /*****************************************************************************
  212. *
  213. * Set up localisation model:
  214. *
  215. ****************************************************************************/
  216. /* backwards compatibility: */
  217. #ifdef BOOST_RE_LOCALE_C
  218. # define BOOST_REGEX_USE_C_LOCALE
  219. #endif
  220. #ifdef BOOST_RE_LOCALE_CPP
  221. # define BOOST_REGEX_USE_CPP_LOCALE
  222. #endif
  223. /* Win32 defaults to native Win32 locale: */
  224. #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)
  225. # define BOOST_REGEX_USE_WIN32_LOCALE
  226. #endif
  227. /* otherwise use C++ locale if supported: */
  228. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
  229. # define BOOST_REGEX_USE_CPP_LOCALE
  230. #endif
  231. /* otherwise use C+ locale: */
  232. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
  233. # define BOOST_REGEX_USE_C_LOCALE
  234. #endif
  235. #ifndef BOOST_REGEX_MAX_STATE_COUNT
  236. # define BOOST_REGEX_MAX_STATE_COUNT 100000000
  237. #endif
  238. /*****************************************************************************
  239. *
  240. * Error Handling for exception free compilers:
  241. *
  242. ****************************************************************************/
  243. #ifdef BOOST_NO_EXCEPTIONS
  244. /*
  245. * If there are no exceptions then we must report critical-errors
  246. * the only way we know how; by terminating.
  247. */
  248. #include <stdexcept>
  249. #include <string>
  250. #include <boost/throw_exception.hpp>
  251. # define BOOST_REGEX_NOEH_ASSERT(x)\
  252. if(0 == (x))\
  253. {\
  254. std::string s("Error: critical regex++ failure in: ");\
  255. s.append(#x);\
  256. std::runtime_error e(s);\
  257. boost::throw_exception(e);\
  258. }
  259. #else
  260. /*
  261. * With exceptions then error handling is taken care of and
  262. * there is no need for these checks:
  263. */
  264. # define BOOST_REGEX_NOEH_ASSERT(x)
  265. #endif
  266. /*****************************************************************************
  267. *
  268. * Stack protection under MS Windows:
  269. *
  270. ****************************************************************************/
  271. #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
  272. # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
  273. && !defined(__GNUC__) \
  274. && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
  275. && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
  276. # define BOOST_REGEX_HAS_MS_STACK_GUARD
  277. # endif
  278. #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  279. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  280. #endif
  281. #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  282. namespace boost{
  283. namespace re_detail{
  284. BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
  285. }
  286. }
  287. #endif
  288. /*****************************************************************************
  289. *
  290. * Algorithm selection and configuration:
  291. *
  292. ****************************************************************************/
  293. #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
  294. # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400))
  295. # define BOOST_REGEX_RECURSIVE
  296. # else
  297. # define BOOST_REGEX_NON_RECURSIVE
  298. # endif
  299. #endif
  300. #ifdef BOOST_REGEX_NON_RECURSIVE
  301. # ifdef BOOST_REGEX_RECURSIVE
  302. # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
  303. # endif
  304. # ifndef BOOST_REGEX_BLOCKSIZE
  305. # define BOOST_REGEX_BLOCKSIZE 4096
  306. # endif
  307. # if BOOST_REGEX_BLOCKSIZE < 512
  308. # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
  309. # endif
  310. # ifndef BOOST_REGEX_MAX_BLOCKS
  311. # define BOOST_REGEX_MAX_BLOCKS 1024
  312. # endif
  313. # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
  314. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  315. # endif
  316. # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
  317. # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
  318. # endif
  319. #endif
  320. /*****************************************************************************
  321. *
  322. * helper memory allocation functions:
  323. *
  324. ****************************************************************************/
  325. #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
  326. namespace boost{ namespace re_detail{
  327. BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
  328. BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
  329. }} /* namespaces */
  330. #endif
  331. /*****************************************************************************
  332. *
  333. * Diagnostics:
  334. *
  335. ****************************************************************************/
  336. #ifdef BOOST_REGEX_CONFIG_INFO
  337. BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
  338. #endif
  339. #if defined(BOOST_REGEX_DIAG)
  340. # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
  341. # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
  342. # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
  343. #ifdef BOOST_REGEX_USE_C_LOCALE
  344. # pragma message ("Using C locale in regex traits class")
  345. #elif BOOST_REGEX_USE_CPP_LOCALE
  346. # pragma message ("Using C++ locale in regex traits class")
  347. #else
  348. # pragma message ("Using Win32 locale in regex traits class")
  349. #endif
  350. #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  351. # pragma message ("Dynamic linking enabled")
  352. #endif
  353. #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
  354. # pragma message ("Auto-linking disabled")
  355. #endif
  356. #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
  357. # pragma message ("Extern templates disabled")
  358. #endif
  359. #endif
  360. #endif