3 * Copyright (c) 1998-2002
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)
13 * LOCATION: see http://www.boost.org for most recent version.
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: regex extended config setup.
19 #ifndef BOOST_REGEX_CONFIG_HPP
20 #define BOOST_REGEX_CONFIG_HPP
22 // Borland C++ Fix/error check
23 // this has to go *before* we include any std lib headers:
25 #if defined(__BORLANDC__)
26 # include <boost/regex/config/borland.hpp>
29 /*****************************************************************************
31 * Include all the headers we need here:
33 ****************************************************************************/
37 # ifndef BOOST_REGEX_USER_CONFIG
38 # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
41 # include BOOST_REGEX_USER_CONFIG
53 # include <boost/config.hpp>
54 # include <boost/cstdint.hpp>
55 # include <boost/detail/allocator.hpp>
56 # include <boost/regex/config/cstring.hpp>
57 # include <boost/throw_exception.hpp>
58 # include <boost/scoped_ptr.hpp>
59 # ifndef BOOST_NO_STD_LOCALE
65 // don't include <boost/config.hpp> because that may
66 // do C++ specific things in future...
71 # define BOOST_MSVC _MSC_VER
75 /*****************************************************************************
77 * Boilerplate regex config options:
79 ****************************************************************************/
81 /* Obsolete macro, use BOOST_VERSION instead: */
82 #define BOOST_RE_VERSION 320
85 #if defined(_UNICODE) && !defined(UNICODE)
90 // If there isn't good enough wide character support then there will
91 // be no wide character regular expressions:
93 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
94 # if !defined(BOOST_NO_WREGEX)
95 # define BOOST_NO_WREGEX
98 # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
99 // STLPort on IRIX is misconfigured: <cwctype> does not compile
100 // as a temporary fix include <wctype.h> instead and prevent inclusion
101 // of STLPort version of <cwctype>
103 # define __STLPORT_CWCTYPE
104 # define _STLP_CWCTYPE
108 # include <boost/regex/config/cwchar.hpp>
114 // If Win32 support has been disabled for boost in general, then
115 // it is for regex in particular:
117 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
118 # define BOOST_REGEX_NO_W32
121 // some versions of gcc can't merge template instances:
122 #if defined(__CYGWIN__)
123 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
126 // fix problems with bool as a macro,
127 // this probably doesn't affect any current compilers:
128 #if defined(bool) || defined(true) || defined(false)
129 # define BOOST_REGEX_NO_BOOL
132 // We don't make our templates external if the compiler
134 #if (defined(BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS) || defined(__HP_aCC) || defined(__MWERKS__) || defined(__COMO__) || defined(BOOST_INTEL))\
135 && !defined(BOOST_MSVC) && !defined(__BORLANDC__)
136 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
139 // disable our own file-iterators and mapfiles if we can't
141 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
142 # define BOOST_REGEX_NO_FILEITER
148 // better make a conservative guess!
149 #define MB_CUR_MAX 10
152 namespace boost{ namespace re_detail{
153 #ifdef BOOST_NO_STD_DISTANCE
155 std::ptrdiff_t distance(const T& x, const T& y)
163 #ifdef BOOST_REGEX_NO_BOOL
164 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>((x) ? true : false)
167 // warning suppression with VC6:
168 # pragma warning(disable: 4800)
170 # define BOOST_REGEX_MAKE_BOOL(x) static_cast<bool>(x)
172 #endif // __cplusplus
174 // backwards compatibitity:
175 #if defined(BOOST_RE_NO_LIB)
176 # define BOOST_REGEX_NO_LIB
179 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
180 // gcc on win32 has problems merging switch statements in templates:
181 # define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE
182 // gcc on win32 has problems if you include <windows.h>
183 // (sporadically generates bad code).
184 # define BOOST_REGEX_USE_C_LOCALE
185 # define BOOST_REGEX_NO_W32
187 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
188 # define BOOST_REGEX_NO_W32
191 /*****************************************************************************
193 * Wide character workarounds:
195 ****************************************************************************/
198 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1300) && !defined(BOOST_REGEX_V3) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
199 # define BOOST_REGEX_HAS_SHORT_WCHAR_T
200 namespace boost{ typedef __wchar_t regex_wchar_type; }
202 namespace boost{ typedef wchar_t regex_wchar_type; }
207 /*****************************************************************************
209 * Set up dll import/export options:
211 ****************************************************************************/
213 #if defined(BOOST_HAS_DECLSPEC) && (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
214 # if defined(BOOST_REGEX_SOURCE)
215 # define BOOST_REGEX_DECL __declspec(dllexport)
216 # define BOOST_REGEX_BUILD_DLL
218 # define BOOST_REGEX_DECL __declspec(dllimport)
222 #ifndef BOOST_REGEX_DECL
223 # define BOOST_REGEX_DECL
226 #if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
227 # define BOOST_LIB_NAME boost_regex
228 # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
229 # define BOOST_DYN_LINK
231 #ifdef BOOST_REGEX_DIAG
232 # define BOOST_LIB_DIAGNOSTIC
234 # include <boost/config/auto_link.hpp>
237 /*****************************************************************************
239 * Set up function call type:
241 ****************************************************************************/
243 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS)
244 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS)
245 # define BOOST_REGEX_CALL __cdecl
247 # define BOOST_REGEX_CALL __fastcall
249 # define BOOST_REGEX_CCALL __cdecl
252 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
253 # define BOOST_REGEX_CALL __fastcall
254 # define BOOST_REGEX_CCALL __stdcall
257 #ifndef BOOST_REGEX_CALL
258 # define BOOST_REGEX_CALL
260 #ifndef BOOST_REGEX_CCALL
261 #define BOOST_REGEX_CCALL
264 /*****************************************************************************
266 * Set up localisation model:
268 ****************************************************************************/
270 // backwards compatibility:
271 #ifdef BOOST_RE_LOCALE_C
272 # define BOOST_REGEX_USE_C_LOCALE
275 #ifdef BOOST_RE_LOCALE_CPP
276 # define BOOST_REGEX_USE_CPP_LOCALE
279 // Win32 defaults to native Win32 locale:
280 #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)
281 # define BOOST_REGEX_USE_WIN32_LOCALE
283 // otherwise use C locale:
284 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
285 # define BOOST_REGEX_USE_C_LOCALE
288 #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
289 # include <windows.h>
293 # define BOOST_REGEX_MAX_PATH MAXPATH
294 #elif defined(MAX_PATH)
295 # define BOOST_REGEX_MAX_PATH MAX_PATH
296 #elif defined(FILENAME_MAX)
297 # define BOOST_REGEX_MAX_PATH FILENAME_MAX
299 # define BOOST_REGEX_MAX_PATH 200
302 #ifndef BOOST_REGEX_MAX_STATE_COUNT
303 # define BOOST_REGEX_MAX_STATE_COUNT 100000000
307 /*****************************************************************************
309 * Error Handling for exception free compilers:
311 ****************************************************************************/
313 #ifdef BOOST_NO_EXCEPTIONS
315 // If there are no exceptions then we must report critical-errors
316 // the only way we know how; by terminating.
318 # define BOOST_REGEX_NOEH_ASSERT(x)\
321 std::string s("Error: critical regex++ failure in: ");\
323 std::runtime_error e(s);\
324 boost::throw_exception(e);\
328 // With exceptions then error handling is taken care of and
329 // there is no need for these checks:
331 # define BOOST_REGEX_NOEH_ASSERT(x)
334 /*****************************************************************************
336 * Debugging / tracing support:
338 ****************************************************************************/
340 #if defined(BOOST_REGEX_DEBUG) && defined(__cplusplus)
351 # define jm_assert(x) assert(x)
354 # define jm_trace(x) cerr << x << endl;
356 # ifndef jm_instrument
357 # define jm_instrument jm_trace(__FILE__<<"#"<<__LINE__)
371 debug_guard(const char* f, int l, const char* p1 = 0, char* p2 = 0);
375 # define BOOST_RE_GUARD_STACK boost::re_detail::debug_guard sg(__FILE__, __LINE__);
376 # 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);
378 } // namespace re_detail
383 # define jm_assert(x)
385 # define BOOST_RE_GUARD_STACK
386 # define BOOST_RE_GUARD_GLOBAL(x)
387 # ifndef jm_instrument
388 # define jm_instrument
392 /*****************************************************************************
394 * Stack protection under MS Windows:
396 ****************************************************************************/
398 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
399 # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
400 && !defined(__GNUC__) \
401 && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
402 && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
403 # define BOOST_REGEX_HAS_MS_STACK_GUARD
405 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
406 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
409 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
414 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
422 /*****************************************************************************
426 ****************************************************************************/
428 #if defined(__cplusplus)
433 BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_regex_exception(const std::string& s);
435 template <class traits>
436 void raise_error(const traits& t, unsigned code)
438 (void)t; // warning suppression
439 raise_regex_exception(t.error_string(code));
447 /*****************************************************************************
449 * Algorithm selection and configuration:
451 ****************************************************************************/
453 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
454 # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG)
455 # define BOOST_REGEX_RECURSIVE
457 # define BOOST_REGEX_NON_RECURSIVE
461 #ifdef BOOST_REGEX_NON_RECURSIVE
462 # ifdef BOOST_REGEX_RECURSIVE
463 # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
465 # ifndef BOOST_REGEX_BLOCKSIZE
466 # define BOOST_REGEX_BLOCKSIZE 4096
468 # if BOOST_REGEX_BLOCKSIZE < 512
469 # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
471 # ifndef BOOST_REGEX_MAX_BLOCKS
472 # define BOOST_REGEX_MAX_BLOCKS 1024
474 # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
475 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
477 # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
478 # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
483 /*****************************************************************************
485 * Fix broken compilers that wrongly #define some symbols:
487 ****************************************************************************/
491 // the following may be defined as macros; this is
492 // incompatable with std::something syntax, we have
493 // no choice but to undef them?
503 /*****************************************************************************
505 * Fix broken broken namespace support:
507 ****************************************************************************/
509 #if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus)
517 # ifndef BOOST_NO_WREGEX
518 # ifndef BOOST_NO_SWPRINTF
523 # if !defined(BOOST_NO_STD_LOCALE) && !defined (__STL_NO_NATIVE_MBSTATE_T) && !defined(_STLP_NO_NATIVE_MBSTATE_T)
526 # endif // BOOST_NO_WREGEX
533 #ifdef BOOST_NO_EXCEPTIONS
541 /*****************************************************************************
543 * helper functions pointer_construct/pointer_destroy:
545 ****************************************************************************/
548 namespace boost{ namespace re_detail{
551 #pragma warning (push)
552 #pragma warning (disable : 4100)
556 inline void pointer_destroy(T* p)
557 { p->~T(); (void)p; }
560 #pragma warning (pop)
564 inline void pointer_construct(T* p, const T& t)
570 /*****************************************************************************
572 * helper memory allocation functions:
574 ****************************************************************************/
576 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
577 namespace boost{ namespace re_detail{
579 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
580 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
585 /*****************************************************************************
589 ****************************************************************************/
591 #ifdef BOOST_REGEX_CONFIG_INFO
592 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
595 #if defined(BOOST_REGEX_DIAG)
596 # pragma message ("BOOST_REGEX_DECL set as: " BOOST_STRINGIZE(BOOST_REGEX_DECL))
597 # pragma message ("BOOST_REGEX_CALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CALL))
598 # pragma message ("BOOST_REGEX_CCALL set as: " BOOST_STRINGIZE(BOOST_REGEX_CCALL))
599 #ifdef BOOST_REGEX_USE_C_LOCALE
600 # pragma message ("Using C locale in regex traits class")
601 #elif BOOST_REGEX_USE_CPP_LOCALE
602 # pragma message ("Using C++ locale in regex traits class")
604 # pragma message ("Using Win32 locale in regex traits class")
606 #ifdef BOOST_REGEX_DYN_LINK
607 # pragma message ("Dynamic linking enabled")
609 #ifdef BOOST_REGEX_NO_LIB
610 # pragma message ("Auto-linking disabled")
612 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
613 # pragma message ("Extern templates disabled")
615 #ifdef BOOST_REGEX_V3
616 # pragma message ("Using Version 3 regex code")
618 # pragma message ("Using Version 4 regex code")