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)) && !defined(BOOST_NO_WREGEX)
129 # define BOOST_NO_WREGEX
131 # if defined(__sgi) && defined(__SGI_STL_PORT)
132 // STLPort on IRIX is misconfigured: <cwctype> does not compile
133 // as a temporary fix include <wctype.h> instead and prevent inclusion
134 // of STLPort version of <cwctype>
136 # define __STLPORT_CWCTYPE
137 # define _STLP_CWCTYPE
148 // If Win32 support has been disabled for boost in general, then
149 // it is for regex in particular:
151 #ifdef BOOST_DISABLE_WIN32
152 # define BOOST_REGEX_NO_W32
155 // some versions of gcc can't merge template instances:
156 #if defined(__CYGWIN__)
157 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
160 // fix problems with bool as a macro,
161 // this probably doesn't affect any current compilers:
162 #if defined(bool) || defined(true) || defined(false)
163 # define BOOST_REGEX_NO_BOOL
166 // We don't make our templates external if the compiler
168 #if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__MWERKS__) || defined(__COMO__) || defined(__ICL) || defined(__ICC))\
169 && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
170 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
173 // disable our own file-iterators and mapfiles if we can't
175 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
176 # define BOOST_REGEX_NO_FILEITER
182 // better make a conservative guess!
183 #define MB_CUR_MAX 10
186 namespace boost{ namespace re_detail{
187 #ifdef BOOST_NO_STD_DISTANCE
189 std::ptrdiff_t distance(const T& x, const T& y)
197 #ifdef BOOST_REGEX_NO_BOOL
198 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
201 // warning suppression with VC6:
202 # pragma warning(disable: 4800)
204 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
206 #endif // __cplusplus
208 // backwards compatibitity:
209 #if defined(BOOST_RE_NO_LIB)
210 # define BOOST_REGEX_NO_LIB
213 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
214 // gcc on win32 has problems merging switch statements in templates:
215 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
216 // gcc on win32 has problems if you include <windows.h>
217 // (sporadically generates bad code).
218 # define BOOST_REGEX_USE_C_LOCALE
219 # define BOOST_REGEX_NO_W32
223 /*****************************************************************************
225 * Set up dll import/export options:
227 ****************************************************************************/
229 // backwards compatibility:
230 #ifdef BOOST_RE_STATIC_LIB
231 # define BOOST_REGEX_STATIC_LINK
234 #if defined(BOOST_MSVC) && defined(_DLL)
235 # define BOOST_REGEX_HAS_DLL_RUNTIME
238 #if defined(__BORLANDC__) && defined(_RTLDLL)
239 # define BOOST_REGEX_HAS_DLL_RUNTIME
242 #if defined(__ICL) && defined(_DLL)
243 # define BOOST_REGEX_HAS_DLL_RUNTIME
246 #if defined(BOOST_REGEX_HAS_DLL_RUNTIME) && !defined(BOOST_REGEX_STATIC_LINK)
247 # if defined(BOOST_REGEX_SOURCE)
248 # define BOOST_REGEX_DECL __declspec(dllexport)
249 # define BOOST_REGEX_BUILD_DLL
251 # define BOOST_REGEX_DECL __declspec(dllimport)
255 #ifndef BOOST_REGEX_DECL
256 # define BOOST_REGEX_DECL
259 #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE)
260 # include <boost/regex/detail/regex_library_include.hpp>
263 /*****************************************************************************
265 * Set up function call type:
267 ****************************************************************************/
269 #if defined(BOOST_MSVC) || defined(__ICL)
271 # define BOOST_REGEX_CALL __cdecl
273 # define BOOST_REGEX_CALL __fastcall
275 # define BOOST_REGEX_CCALL __stdcall
278 #if defined(__BORLANDC__)
279 # define BOOST_REGEX_CALL __fastcall
280 # define BOOST_REGEX_CCALL __stdcall
283 #ifndef BOOST_REGEX_CALL
284 # define BOOST_REGEX_CALL
286 #ifndef BOOST_REGEX_CCALL
287 #define BOOST_REGEX_CCALL
290 /*****************************************************************************
292 * Set up localisation model:
294 ****************************************************************************/
296 // backwards compatibility:
297 #ifdef BOOST_RE_LOCALE_C
298 # define BOOST_REGEX_USE_C_LOCALE
301 #ifdef BOOST_RE_LOCALE_CPP
302 # define BOOST_REGEX_USE_CPP_LOCALE
305 // Win32 defaults to native Win32 locale:
306 #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)
307 # define BOOST_REGEX_USE_WIN32_LOCALE
309 // otherwise use C locale:
310 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
311 # define BOOST_REGEX_USE_C_LOCALE
314 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
315 # include <windows.h>
319 # define BOOST_REGEX_MAX_PATH MAXPATH
320 #elif defined(MAX_PATH)
321 # define BOOST_REGEX_MAX_PATH MAX_PATH
322 #elif defined(FILENAME_MAX)
323 # define BOOST_REGEX_MAX_PATH FILENAME_MAX
325 # define BOOST_REGEX_MAX_PATH 200
330 /*****************************************************************************
332 * Error Handling for exception free compilers:
334 ****************************************************************************/
336 #ifdef BOOST_NO_EXCEPTIONS
338 // If there are no exceptions then we must report critical-errors
339 // the only way we know how; by terminating.
342 // <cstdio> seems not to make stderr usable with Borland:
345 # define BOOST_REGEX_NOEH_ASSERT(x)\
348 std::fprintf(stderr, "Error: critical regex++ failure in \"%s\"", #x);\
353 // With exceptions then error handling is taken care of and
354 // there is no need for these checks:
356 # define BOOST_REGEX_NOEH_ASSERT(x)
359 /*****************************************************************************
361 * Debugging / tracing support:
363 ****************************************************************************/
365 #if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus)
376 # define jm_assert(x) assert(x)
379 # define jm_trace(x) cerr << x << endl;
381 # ifndef jm_instrument
382 # define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
396 debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
400 # define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
401 # 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);
403 } // namespace re_detail
408 # define jm_assert(x)
410 # define BOOST_RE_GUARD_STACK
411 # define BOOST_RE_GUARD_GLOBAL(x)
412 # ifndef jm_instrument
413 # define jm_instrument
417 /*****************************************************************************
419 * Fix broken compilers that wrongly #define some symbols:
421 ****************************************************************************/
425 #ifdef BOOST_NO_CTYPE_FUNCTIONS
427 // Make functions out of the macros.
428 // Use parentheses so the macros don't screw us up.
429 inline int (isalpha)(int c) { return isalpha(c); }
430 inline int (iscntrl)(int c) { return iscntrl(c); }
431 inline int (isdigit)(int c) { return isdigit(c); }
432 inline int (islower)(int c) { return islower(c); }
433 inline int (ispunct)(int c) { return ispunct(c); }
434 inline int (isspace)(int c) { return isspace(c); }
435 inline int (isupper)(int c) { return isupper(c); }
436 inline int (isxdigit)(int c) { return isxdigit(c); }
440 // the following may be defined as macros; this is
441 // incompatable with std::something syntax, we have
442 // no choice but to undef them?
541 /*****************************************************************************
543 * Fix broken broken namespace support:
545 ****************************************************************************/
547 #if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus)
573 # ifndef BOOST_NO_WREGEX
574 # ifndef BOOST_NO_SWPRINTF
592 # if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T)
595 # endif // BOOST_NO_WREGEX
602 #ifdef BOOST_NO_EXCEPTIONS
610 /*****************************************************************************
612 * helper functions pointer_construct/pointer_destroy:
614 ****************************************************************************/
617 namespace boost{ namespace re_detail{
620 #pragma warning (push)
621 #pragma warning (disable : 4100)
625 inline void pointer_destroy(T* p)
626 { p->~T(); (void)p; }
629 #pragma warning (pop)
633 inline void pointer_construct(T* p, const T& t)