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
57 /*****************************************************************************
59 * Include all the headers we need here:
61 ****************************************************************************/
65 # ifndef BOOST_REGEX_USER_CONFIG
66 # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
69 # include BOOST_REGEX_USER_CONFIG
81 # include <boost/config.hpp>
82 # include <boost/cstdint.hpp>
83 # include <boost/detail/allocator.hpp>
87 // don't include <boost/config.hpp> because that may
88 // do C++ specific things in future...
93 # define BOOST_MSVC _MSC_VER
97 /*****************************************************************************
99 * Boilerplate regex config options:
101 ****************************************************************************/
103 /* Obsolete macro, use BOOST_VERSION instead: */
104 #define BOOST_RE_VERSION 320
107 #if defined(_UNICODE) && !defined(UNICODE)
112 // If there isn't good enough wide character support then there will
113 // be no wide character regular expressions:
115 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) && !defined(BOOST_NO_WREGEX)
116 # define BOOST_NO_WREGEX
118 # if defined(__sgi) && defined(__SGI_STL_PORT)
119 // STLPort on IRIX is misconfigured: <cwctype> does not compile
120 // as a temporary fix include <wctype.h> instead and prevent inclusion
121 // of STLPort version of <cwctype>
123 # define __STLPORT_CWCTYPE
124 # define _STLP_CWCTYPE
135 // If Win32 support has been disabled for boost in general, then
136 // it is for regex in particular:
138 #ifdef BOOST_DISABLE_WIN32
139 # define BOOST_REGEX_NO_W32
142 // some versions of gcc can't merge template instances:
143 #if defined(__CYGWIN__)
144 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
147 // fix problems with bool as a macro,
148 // this probably doesn't affect any current compilers:
149 #if defined(bool) || defined(true) || defined(false)
150 # define BOOST_REGEX_NO_BOOL
153 // We don't make our templates external if the compiler
155 #if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__MWERKS__) || defined(__COMO__) || defined(__ICL) || defined(__ICC))\
156 && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
157 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
160 // disable our own file-iterators and mapfiles if we can't
162 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
163 # define BOOST_REGEX_NO_FILEITER
169 // better make a conservative guess!
170 #define MB_CUR_MAX 10
173 namespace boost{ namespace re_detail{
174 #ifdef BOOST_NO_STD_DISTANCE
176 std::ptrdiff_t distance(const T& x, const T& y)
184 #ifdef BOOST_REGEX_NO_BOOL
185 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
188 // warning suppression with VC6:
189 # pragma warning(disable: 4800)
191 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
193 #endif // __cplusplus
195 // backwards compatibitity:
196 #if defined(BOOST_RE_NO_LIB)
197 # define BOOST_REGEX_NO_LIB
200 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
201 // gcc on win32 has problems merging switch statements in templates:
202 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
203 // gcc on win32 has problems if you include <windows.h>
204 // (sporadically generates bad code).
205 # define BOOST_REGEX_USE_C_LOCALE
206 # define BOOST_REGEX_NO_W32
210 /*****************************************************************************
212 * Set up dll import/export options:
214 ****************************************************************************/
216 // backwards compatibility:
217 #ifdef BOOST_RE_STATIC_LIB
218 # define BOOST_REGEX_STATIC_LINK
221 #if defined(BOOST_MSVC) && defined(_DLL)
222 # define BOOST_REGEX_HAS_DLL_RUNTIME
225 #if defined(__BORLANDC__) && defined(_RTLDLL)
226 # define BOOST_REGEX_HAS_DLL_RUNTIME
229 #if defined(__ICL) && defined(_DLL)
230 # define BOOST_REGEX_HAS_DLL_RUNTIME
233 #if defined(BOOST_REGEX_HAS_DLL_RUNTIME) && !defined(BOOST_REGEX_STATIC_LINK)
234 # if defined(BOOST_REGEX_SOURCE)
235 # define BOOST_REGEX_DECL __declspec(dllexport)
236 # define BOOST_REGEX_BUILD_DLL
238 # define BOOST_REGEX_DECL __declspec(dllimport)
242 #ifndef BOOST_REGEX_DECL
243 # define BOOST_REGEX_DECL
246 #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE)
247 # include <boost/regex/detail/regex_library_include.hpp>
250 /*****************************************************************************
252 * Set up function call type:
254 ****************************************************************************/
256 #if defined(BOOST_MSVC) || defined(__ICL)
258 # define BOOST_REGEX_CALL __cdecl
260 # define BOOST_REGEX_CALL __fastcall
262 # define BOOST_REGEX_CCALL __stdcall
265 #if defined(__BORLANDC__)
266 # define BOOST_REGEX_CALL __fastcall
267 # define BOOST_REGEX_CCALL __stdcall
270 #ifndef BOOST_REGEX_CALL
271 # define BOOST_REGEX_CALL
273 #ifndef BOOST_REGEX_CCALL
274 #define BOOST_REGEX_CCALL
277 /*****************************************************************************
279 * Set up localisation model:
281 ****************************************************************************/
283 // backwards compatibility:
284 #ifdef BOOST_RE_LOCALE_C
285 # define BOOST_REGEX_USE_C_LOCALE
288 #ifdef BOOST_RE_LOCALE_CPP
289 # define BOOST_REGEX_USE_CPP_LOCALE
292 // Win32 defaults to native Win32 locale:
293 #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)
294 # define BOOST_REGEX_USE_WIN32_LOCALE
296 // otherwise use C locale:
297 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
298 # define BOOST_REGEX_USE_C_LOCALE
301 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
302 # include <windows.h>
306 # define BOOST_REGEX_MAX_PATH MAXPATH
307 #elif defined(MAX_PATH)
308 # define BOOST_REGEX_MAX_PATH MAX_PATH
309 #elif defined(FILENAME_MAX)
310 # define BOOST_REGEX_MAX_PATH FILENAME_MAX
312 # define BOOST_REGEX_MAX_PATH 200
317 /*****************************************************************************
319 * Error Handling for exception free compilers:
321 ****************************************************************************/
323 #ifdef BOOST_NO_EXCEPTIONS
325 // If there are no exceptions then we must report critical-errors
326 // the only way we know how; by terminating.
329 // <cstdio> seems not to make stderr usable with Borland:
332 # define BOOST_REGEX_NOEH_ASSERT(x)\
335 std::fprintf(stderr, "Error: critical regex++ failure in \"%s\"", #x);\
340 // With exceptions then error handling is taken care of and
341 // there is no need for these checks:
343 # define BOOST_REGEX_NOEH_ASSERT(x)
346 /*****************************************************************************
348 * Debugging / tracing support:
350 ****************************************************************************/
352 #if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus)
363 # define jm_assert(x) assert(x)
366 # define jm_trace(x) cerr << x << endl;
368 # ifndef jm_instrument
369 # define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
383 debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
387 # define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
388 # 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);
390 } // namespace re_detail
395 # define jm_assert(x)
397 # define BOOST_RE_GUARD_STACK
398 # define BOOST_RE_GUARD_GLOBAL(x)
399 # ifndef jm_instrument
400 # define jm_instrument
404 /*****************************************************************************
406 * Fix broken compilers that wrongly #define some symbols:
408 ****************************************************************************/
412 #ifdef BOOST_NO_CTYPE_FUNCTIONS
414 // Make functions out of the macros.
415 // Use parentheses so the macros don't screw us up.
416 inline int (isalpha)(int c) { return isalpha(c); }
417 inline int (iscntrl)(int c) { return iscntrl(c); }
418 inline int (isdigit)(int c) { return isdigit(c); }
419 inline int (islower)(int c) { return islower(c); }
420 inline int (ispunct)(int c) { return ispunct(c); }
421 inline int (isspace)(int c) { return isspace(c); }
422 inline int (isupper)(int c) { return isupper(c); }
423 inline int (isxdigit)(int c) { return isxdigit(c); }
427 // the following may be defined as macros; this is
428 // incompatable with std::something syntax, we have
429 // no choice but to undef them?
528 /*****************************************************************************
530 * Fix broken broken namespace support:
532 ****************************************************************************/
534 #if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus)
560 # ifndef BOOST_NO_WREGEX
561 # ifndef BOOST_NO_SWPRINTF
579 # if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T)
582 # endif // BOOST_NO_WREGEX
589 #ifdef BOOST_NO_EXCEPTIONS
597 /*****************************************************************************
599 * helper functions pointer_construct/pointer_destroy:
601 ****************************************************************************/
604 namespace boost{ namespace re_detail{
607 #pragma warning (push)
608 #pragma warning (disable : 4100)
612 inline void pointer_destroy(T* p)
613 { p->~T(); (void)p; }
616 #pragma warning (pop)
620 inline void pointer_construct(T* p, const T& t)