config.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. * If there isn't good enough wide character support then there will
  84. * be no wide character regular expressions:
  85. */
  86. #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
  87. # if !defined(BOOST_NO_WREGEX)
  88. # define BOOST_NO_WREGEX
  89. # endif
  90. #else
  91. # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
  92. /* STLPort on IRIX is misconfigured: <cwctype> does not compile
  93. * as a temporary fix include <wctype.h> instead and prevent inclusion
  94. * of STLPort version of <cwctype> */
  95. # include <wctype.h>
  96. # define __STLPORT_CWCTYPE
  97. # define _STLP_CWCTYPE
  98. # endif
  99. #ifdef __cplusplus
  100. # include <boost/regex/config/cwchar.hpp>
  101. #endif
  102. #endif
  103. /*
  104. * If Win32 support has been disabled for boost in general, then
  105. * it is for regex in particular:
  106. */
  107. #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
  108. # define BOOST_REGEX_NO_W32
  109. #endif
  110. /* disable our own file-iterators and mapfiles if we can't
  111. * support them: */
  112. #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
  113. # define BOOST_REGEX_NO_FILEITER
  114. #endif
  115. /* backwards compatibitity: */
  116. #if defined(BOOST_RE_NO_LIB)
  117. # define BOOST_REGEX_NO_LIB
  118. #endif
  119. #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
  120. /* gcc on win32 has problems if you include <windows.h>
  121. (sporadically generates bad code). */
  122. # define BOOST_REGEX_NO_W32
  123. #endif
  124. #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
  125. # define BOOST_REGEX_NO_W32
  126. #endif
  127. /*****************************************************************************
  128. *
  129. * Wide character workarounds:
  130. *
  131. ****************************************************************************/
  132. /*
  133. * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
  134. * code may be built with wchar_t as unsigned short: basically when we're building
  135. * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
  136. * of the non-inline functions in the library, so that users can still link to the lib,
  137. * irrespective of whether their own code is built with /Zc:wchar_t.
  138. */
  139. #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)
  140. # define BOOST_REGEX_HAS_OTHER_WCHAR_T
  141. # ifdef BOOST_MSVC
  142. # pragma warning(push)
  143. # pragma warning(disable : 4251 4231 4660)
  144. # endif
  145. # if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
  146. # include <string>
  147. extern template class __declspec(dllimport) std::basic_string<unsigned short>;
  148. # endif
  149. # ifdef BOOST_MSVC
  150. # pragma warning(pop)
  151. # endif
  152. #endif
  153. /*****************************************************************************
  154. *
  155. * Set up dll import/export options:
  156. *
  157. ****************************************************************************/
  158. #if defined(BOOST_HAS_DECLSPEC) && (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
  159. # if defined(BOOST_REGEX_SOURCE)
  160. # define BOOST_REGEX_DECL __declspec(dllexport)
  161. # define BOOST_REGEX_BUILD_DLL
  162. # else
  163. # define BOOST_REGEX_DECL __declspec(dllimport)
  164. # endif
  165. #endif
  166. #ifndef BOOST_REGEX_DECL
  167. # define BOOST_REGEX_DECL
  168. #endif
  169. #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
  170. # define BOOST_LIB_NAME boost_regex
  171. # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  172. # define BOOST_DYN_LINK
  173. # endif
  174. # ifdef BOOST_REGEX_DIAG
  175. # define BOOST_LIB_DIAGNOSTIC
  176. # endif
  177. # include <boost/config/auto_link.hpp>
  178. #endif
  179. /*****************************************************************************
  180. *
  181. * Set up function call type:
  182. *
  183. ****************************************************************************/
  184. #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS)
  185. #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED)
  186. # define BOOST_REGEX_CALL __cdecl
  187. #else
  188. # define BOOST_REGEX_CALL __fastcall
  189. #endif
  190. # define BOOST_REGEX_CCALL __cdecl
  191. #endif
  192. #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
  193. # define BOOST_REGEX_CALL __fastcall
  194. # define BOOST_REGEX_CCALL __stdcall
  195. #endif
  196. #ifndef BOOST_REGEX_CALL
  197. # define BOOST_REGEX_CALL
  198. #endif
  199. #ifndef BOOST_REGEX_CCALL
  200. #define BOOST_REGEX_CCALL
  201. #endif
  202. /*****************************************************************************
  203. *
  204. * Set up localisation model:
  205. *
  206. ****************************************************************************/
  207. /* backwards compatibility: */
  208. #ifdef BOOST_RE_LOCALE_C
  209. # define BOOST_REGEX_USE_C_LOCALE
  210. #endif
  211. #ifdef BOOST_RE_LOCALE_CPP
  212. # define BOOST_REGEX_USE_CPP_LOCALE
  213. #endif
  214. /* Win32 defaults to native Win32 locale: */
  215. #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)
  216. # define BOOST_REGEX_USE_WIN32_LOCALE
  217. #endif
  218. /* otherwise use C++ locale if supported: */
  219. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
  220. # define BOOST_REGEX_USE_CPP_LOCALE
  221. #endif
  222. /* otherwise use C+ locale: */
  223. #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
  224. # define BOOST_REGEX_USE_C_LOCALE
  225. #endif
  226. #ifndef BOOST_REGEX_MAX_STATE_COUNT
  227. # define BOOST_REGEX_MAX_STATE_COUNT 100000000
  228. #endif
  229. /*****************************************************************************
  230. *
  231. * Error Handling for exception free compilers:
  232. *
  233. ****************************************************************************/
  234. #ifdef BOOST_NO_EXCEPTIONS
  235. /*
  236. * If there are no exceptions then we must report critical-errors
  237. * the only way we know how; by terminating.
  238. */
  239. #include <stdexcept>
  240. #include <string>
  241. #include <boost/throw_exception.hpp>
  242. # define BOOST_REGEX_NOEH_ASSERT(x)\
  243. if(0 == (x))\
  244. {\
  245. std::string s("Error: critical regex++ failure in: ");\
  246. s.append(#x);\
  247. std::runtime_error e(s);\
  248. boost::throw_exception(e);\
  249. }
  250. #else
  251. /*
  252. * With exceptions then error handling is taken care of and
  253. * there is no need for these checks:
  254. */
  255. # define BOOST_REGEX_NOEH_ASSERT(x)
  256. #endif
  257. /*****************************************************************************
  258. *
  259. * Stack protection under MS Windows:
  260. *
  261. ****************************************************************************/
  262. #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
  263. # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
  264. && !defined(__GNUC__) \
  265. && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
  266. && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
  267. # define BOOST_REGEX_HAS_MS_STACK_GUARD
  268. # endif
  269. #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  270. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  271. #endif
  272. #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
  273. namespace boost{
  274. namespace re_detail{
  275. BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
  276. }
  277. }
  278. #endif
  279. /*****************************************************************************
  280. *
  281. * Algorithm selection and configuration:
  282. *
  283. ****************************************************************************/
  284. #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
  285. # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400))
  286. # define BOOST_REGEX_RECURSIVE
  287. # else
  288. # define BOOST_REGEX_NON_RECURSIVE
  289. # endif
  290. #endif
  291. #ifdef BOOST_REGEX_NON_RECURSIVE
  292. # ifdef BOOST_REGEX_RECURSIVE
  293. # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
  294. # endif
  295. # ifndef BOOST_REGEX_BLOCKSIZE
  296. # define BOOST_REGEX_BLOCKSIZE 4096
  297. # endif
  298. # if BOOST_REGEX_BLOCKSIZE < 512
  299. # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
  300. # endif
  301. # ifndef BOOST_REGEX_MAX_BLOCKS
  302. # define BOOST_REGEX_MAX_BLOCKS 1024
  303. # endif
  304. # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
  305. # undef BOOST_REGEX_HAS_MS_STACK_GUARD
  306. # endif
  307. # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
  308. # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
  309. # endif
  310. #endif
  311. /*****************************************************************************
  312. *
  313. * helper memory allocation functions:
  314. *
  315. ****************************************************************************/
  316. #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
  317. namespace boost{ namespace re_detail{
  318. BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
  319. BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
  320. }} /* namespaces */
  321. #endif
  322. /*****************************************************************************
  323. *
  324. * Diagnostics:
  325. *
  326. ****************************************************************************/
  327. #ifdef BOOST_REGEX_CONFIG_INFO
  328. BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
  329. #endif
  330. #if defined(BOOST_REGEX_DIAG)
  331. # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
  332. # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
  333. # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
  334. #ifdef BOOST_REGEX_USE_C_LOCALE
  335. # pragma message ("Using C locale in regex traits class")
  336. #elif BOOST_REGEX_USE_CPP_LOCALE
  337. # pragma message ("Using C++ locale in regex traits class")
  338. #else
  339. # pragma message ("Using Win32 locale in regex traits class")
  340. #endif
  341. #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
  342. # pragma message ("Dynamic linking enabled")
  343. #endif
  344. #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
  345. # pragma message ("Auto-linking disabled")
  346. #endif
  347. #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
  348. # pragma message ("Extern templates disabled")
  349. #endif
  350. #endif
  351. #endif