3 * Copyright (c) 1998-2002
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation. Dr John Maddock makes no representations
11 * about the suitability of this software for any purpose.
12 * It is provided "as is" without express or implied warranty.
17 * LOCATION: see http://www.boost.org for most recent version.
19 * VERSION see <boost/version.hpp>
20 * DESCRIPTION: regex extended config setup.
23 #ifndef BOOST_REGEX_CONFIG_HPP
24 #define BOOST_REGEX_CONFIG_HPP
26 // Borland C++ Fix/error check
27 // this has to go *before* we include any std lib headers:
29 #if defined(__BORLANDC__)
30 # if (__BORLANDC__ == 0x550) || (__BORLANDC__ == 0x551)
31 // problems with std::basic_string and dll RTL:
32 # if defined(_RTLDLL) && defined(_RWSTD_COMPILE_INSTANTIATE)
33 # ifdef BOOST_REGEX_BUILD_DLL
34 # error _RWSTD_COMPILE_INSTANTIATE must not be defined when building regex++ as a DLL
36 # pragma message("Defining _RWSTD_COMPILE_INSTANTIATE when linking to the DLL version of the RTL may produce memory corruption problems in std::basic_string, as a result of separate versions of basic_string's static data in the RTL and you're exe/dll: be warned!!")
40 // this is harmless for a staic link:
41 # define _RWSTD_COMPILE_INSTANTIATE
44 # if (__BORLANDC__ <= 0x540) && !defined(BOOST_REGEX_NO_LIB) && !defined(_NO_VCL)
45 // C++ Builder 4 and earlier, we can't tell whether we should be using
46 // the VCL runtime or not, do a static link instead:
47 # define BOOST_REGEX_STATIC_LINK
51 // if we're building a console app then there can't be any VCL (can there?)
52 # if !defined(__CONSOLE__) && !defined(_NO_VCL)
53 # define BOOST_REGEX_USE_VCL
56 // if this isn't Win32 then don't automatically select link
60 # ifndef BOOST_REGEX_NO_LIB
61 # define BOOST_REGEX_NO_LIB
63 # ifndef BOOST_REGEX_STATIC_LINK
64 # define BOOST_REGEX_STATIC_LINK
70 /*****************************************************************************
72 * Include all the headers we need here:
74 ****************************************************************************/
78 # ifndef BOOST_REGEX_USER_CONFIG
79 # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
82 # include BOOST_REGEX_USER_CONFIG
94 # include <boost/config.hpp>
95 # include <boost/cstdint.hpp>
96 # include <boost/detail/allocator.hpp>
100 // don't include <boost/config.hpp> because that may
101 // do C++ specific things in future...
106 # define BOOST_MSVC _MSC_VER
110 /*****************************************************************************
112 * Boilerplate regex config options:
114 ****************************************************************************/
116 /* Obsolete macro, use BOOST_VERSION instead: */
117 #define BOOST_RE_VERSION 320
120 #if defined(_UNICODE) && !defined(UNICODE)
125 // If there isn't good enough wide character support then there will
126 // be no wide character regular expressions:
128 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
129 # if !defined(BOOST_NO_WREGEX)
130 # define BOOST_NO_WREGEX
133 # if defined(__sgi) && defined(__SGI_STL_PORT)
134 // STLPort on IRIX is misconfigured: <cwctype> does not compile
135 // as a temporary fix include <wctype.h> instead and prevent inclusion
136 // of STLPort version of <cwctype>
138 # define __STLPORT_CWCTYPE
139 # define _STLP_CWCTYPE
150 // If Win32 support has been disabled for boost in general, then
151 // it is for regex in particular:
153 #ifdef BOOST_DISABLE_WIN32
154 # define BOOST_REGEX_NO_W32
157 // some versions of gcc can't merge template instances:
158 #if defined(__CYGWIN__)
159 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
162 // fix problems with bool as a macro,
163 // this probably doesn't affect any current compilers:
164 #if defined(bool) || defined(true) || defined(false)
165 # define BOOST_REGEX_NO_BOOL
168 // We don't make our templates external if the compiler
170 #if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__HP_aCC) || defined(__MWERKS__) || defined(__COMO__) || defined(__ICL) || defined(__ICC))\
171 && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
172 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
175 // disable our own file-iterators and mapfiles if we can't
177 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
178 # define BOOST_REGEX_NO_FILEITER
184 // better make a conservative guess!
185 #define MB_CUR_MAX 10
188 namespace boost{ namespace re_detail{
189 #ifdef BOOST_NO_STD_DISTANCE
191 std::ptrdiff_t distance(const T& x, const T& y)
199 #ifdef BOOST_REGEX_NO_BOOL
200 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
203 // warning suppression with VC6:
204 # pragma warning(disable: 4800)
206 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
208 #endif // __cplusplus
210 // backwards compatibitity:
211 #if defined(BOOST_RE_NO_LIB)
212 # define BOOST_REGEX_NO_LIB
215 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
216 // gcc on win32 has problems merging switch statements in templates:
217 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
218 // gcc on win32 has problems if you include <windows.h>
219 // (sporadically generates bad code).
220 # define BOOST_REGEX_USE_C_LOCALE
221 # define BOOST_REGEX_NO_W32
225 /*****************************************************************************
227 * Set up dll import/export options:
229 ****************************************************************************/
231 // backwards compatibility:
232 #ifdef BOOST_RE_STATIC_LIB
233 # define BOOST_REGEX_STATIC_LINK
236 #if defined(BOOST_MSVC) && defined(_DLL)
237 # define BOOST_REGEX_HAS_DLL_RUNTIME
240 #if defined(__BORLANDC__) && defined(_RTLDLL)
241 # define BOOST_REGEX_HAS_DLL_RUNTIME
244 #if defined(__ICL) && defined(_DLL)
245 # define BOOST_REGEX_HAS_DLL_RUNTIME
248 #if defined(BOOST_REGEX_HAS_DLL_RUNTIME) && !defined(BOOST_REGEX_STATIC_LINK)
249 # if defined(BOOST_REGEX_SOURCE)
250 # define BOOST_REGEX_DECL __declspec(dllexport)
251 # define BOOST_REGEX_BUILD_DLL
253 # define BOOST_REGEX_DECL __declspec(dllimport)
257 #ifndef BOOST_REGEX_DECL
258 # define BOOST_REGEX_DECL
261 #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE)
262 # include <boost/regex/v3/regex_library_include.hpp>
265 /*****************************************************************************
267 * Set up function call type:
269 ****************************************************************************/
271 #if defined(BOOST_MSVC) || defined(__ICL)
273 # define BOOST_REGEX_CALL __cdecl
275 # define BOOST_REGEX_CALL __fastcall
277 # define BOOST_REGEX_CCALL __stdcall
280 #if defined(__BORLANDC__)
281 # define BOOST_REGEX_CALL __fastcall
282 # define BOOST_REGEX_CCALL __stdcall
285 #ifndef BOOST_REGEX_CALL
286 # define BOOST_REGEX_CALL
288 #ifndef BOOST_REGEX_CCALL
289 #define BOOST_REGEX_CCALL
292 /*****************************************************************************
294 * Set up localisation model:
296 ****************************************************************************/
298 // backwards compatibility:
299 #ifdef BOOST_RE_LOCALE_C
300 # define BOOST_REGEX_USE_C_LOCALE
303 #ifdef BOOST_RE_LOCALE_CPP
304 # define BOOST_REGEX_USE_CPP_LOCALE
307 // Win32 defaults to native Win32 locale:
308 #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)
309 # define BOOST_REGEX_USE_WIN32_LOCALE
311 // otherwise use C locale:
312 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
313 # define BOOST_REGEX_USE_C_LOCALE
316 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
317 # include <windows.h>
321 # define BOOST_REGEX_MAX_PATH MAXPATH
322 #elif defined(MAX_PATH)
323 # define BOOST_REGEX_MAX_PATH MAX_PATH
324 #elif defined(FILENAME_MAX)
325 # define BOOST_REGEX_MAX_PATH FILENAME_MAX
327 # define BOOST_REGEX_MAX_PATH 200
332 /*****************************************************************************
334 * Error Handling for exception free compilers:
336 ****************************************************************************/
338 #ifdef BOOST_NO_EXCEPTIONS
340 // If there are no exceptions then we must report critical-errors
341 // the only way we know how; by terminating.
344 // <cstdio> seems not to make stderr usable with Borland:
347 # define BOOST_REGEX_NOEH_ASSERT(x)\
350 std::fprintf(stderr, "Error: critical regex++ failure in \"%s\"", #x);\
355 // With exceptions then error handling is taken care of and
356 // there is no need for these checks:
358 # define BOOST_REGEX_NOEH_ASSERT(x)
361 /*****************************************************************************
363 * Debugging / tracing support:
365 ****************************************************************************/
367 #if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus)
378 # define jm_assert(x) assert(x)
381 # define jm_trace(x) cerr << x << endl;
383 # ifndef jm_instrument
384 # define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
398 debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
402 # define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
403 # define BOOST_RE_GUARD_GLOBAL(x) const char g1##x[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, }; char g2##x[32]; boost::debug_guard g3##x(__FILE__, __LINE__, g1##x, g2##x);
405 } // namespace re_detail
410 # define jm_assert(x)
412 # define BOOST_RE_GUARD_STACK
413 # define BOOST_RE_GUARD_GLOBAL(x)
414 # ifndef jm_instrument
415 # define jm_instrument
419 /*****************************************************************************
421 * Fix broken compilers that wrongly #define some symbols:
423 ****************************************************************************/
427 #ifdef BOOST_NO_CTYPE_FUNCTIONS
429 // Make functions out of the macros.
430 // Use parentheses so the macros don't screw us up.
431 inline int (isalpha)(int c) { return isalpha(c); }
432 inline int (iscntrl)(int c) { return iscntrl(c); }
433 inline int (isdigit)(int c) { return isdigit(c); }
434 inline int (islower)(int c) { return islower(c); }
435 inline int (ispunct)(int c) { return ispunct(c); }
436 inline int (isspace)(int c) { return isspace(c); }
437 inline int (isupper)(int c) { return isupper(c); }
438 inline int (isxdigit)(int c) { return isxdigit(c); }
442 // the following may be defined as macros; this is
443 // incompatable with std::something syntax, we have
444 // no choice but to undef them?
543 /*****************************************************************************
545 * Fix broken broken namespace support:
547 ****************************************************************************/
549 #if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus)
575 # ifndef BOOST_NO_WREGEX
576 # ifndef BOOST_NO_SWPRINTF
594 # if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T)
597 # endif // BOOST_NO_WREGEX
604 #ifdef BOOST_NO_EXCEPTIONS
612 /*****************************************************************************
614 * helper functions pointer_construct/pointer_destroy:
616 ****************************************************************************/
619 namespace boost{ namespace re_detail{
622 #pragma warning (push)
623 #pragma warning (disable : 4100)
627 inline void pointer_destroy(T* p)
628 { p->~T(); (void)p; }
631 #pragma warning (pop)
635 inline void pointer_construct(T* p, const T& t)