fix doc example typo
[boost.git] / boost / regex / config.hpp
blob8c8f5248fb374cb111c97016d60970970c66020f
1 /*
3 * Copyright (c) 1998-2002
4 * John Maddock
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.
14 * FILE config.hpp
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>
27 #endif
29 /*****************************************************************************
31 * Include all the headers we need here:
33 ****************************************************************************/
35 #ifdef __cplusplus
37 # ifndef BOOST_REGEX_USER_CONFIG
38 # define BOOST_REGEX_USER_CONFIG <boost/regex/user.hpp>
39 # endif
41 # include BOOST_REGEX_USER_CONFIG
43 # include <boost/config.hpp>
45 #else
47 * C build,
48 * don't include <boost/config.hpp> because that may
49 * do C++ specific things in future...
51 # include <stdlib.h>
52 # include <stddef.h>
53 # ifdef _MSC_VER
54 # define BOOST_MSVC _MSC_VER
55 # endif
56 #endif
58 /*****************************************************************************
60 * Boilerplate regex config options:
62 ****************************************************************************/
64 /* Obsolete macro, use BOOST_VERSION instead: */
65 #define BOOST_RE_VERSION 320
67 /* fix: */
68 #if defined(_UNICODE) && !defined(UNICODE)
69 #define UNICODE
70 #endif
73 * Fix for gcc prior to 3.4: std::ctype<wchar_t> doesn't allow
74 * masks to be combined, for example:
75 * std::use_facet<std::ctype<wchar_t> >.is(std::ctype_base::lower|std::ctype_base::upper, L'a');
76 * returns *false*.
78 #ifdef __GLIBCPP__
79 # define BOOST_REGEX_BUGGY_CTYPE_FACET
80 #endif
83 * Intel C++ before 8.0 ends up with unresolved externals unless we turn off
84 * extern template support:
86 #if defined(BOOST_INTEL) && defined(__cplusplus) && (BOOST_INTEL <= 800)
87 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
88 #endif
90 * Visual C++ doesn't support external templates with C++ extensions turned off:
92 #if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
93 # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES
94 #endif
97 * If there isn't good enough wide character support then there will
98 * be no wide character regular expressions:
100 #if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING))
101 # if !defined(BOOST_NO_WREGEX)
102 # define BOOST_NO_WREGEX
103 # endif
104 #else
105 # if defined(__sgi) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
106 /* STLPort on IRIX is misconfigured: <cwctype> does not compile
107 * as a temporary fix include <wctype.h> instead and prevent inclusion
108 * of STLPort version of <cwctype> */
109 # include <wctype.h>
110 # define __STLPORT_CWCTYPE
111 # define _STLP_CWCTYPE
112 # endif
114 #ifdef __cplusplus
115 # include <boost/regex/config/cwchar.hpp>
116 #endif
118 #endif
121 * If Win32 support has been disabled for boost in general, then
122 * it is for regex in particular:
124 #if defined(BOOST_DISABLE_WIN32) && !defined(BOOST_REGEX_NO_W32)
125 # define BOOST_REGEX_NO_W32
126 #endif
128 /* disable our own file-iterators and mapfiles if we can't
129 * support them: */
130 #if !defined(BOOST_HAS_DIRENT_H) && !(defined(_WIN32) && !defined(BOOST_REGEX_NO_W32))
131 # define BOOST_REGEX_NO_FILEITER
132 #endif
134 /* backwards compatibitity: */
135 #if defined(BOOST_RE_NO_LIB)
136 # define BOOST_REGEX_NO_LIB
137 #endif
139 #if defined(__GNUC__) && (defined(_WIN32) || defined(__CYGWIN__))
140 /* gcc on win32 has problems if you include <windows.h>
141 (sporadically generates bad code). */
142 # define BOOST_REGEX_NO_W32
143 #endif
144 #if defined(__COMO__) && !defined(BOOST_REGEX_NO_W32) && !defined(_MSC_EXTENSIONS)
145 # define BOOST_REGEX_NO_W32
146 #endif
148 /*****************************************************************************
150 * Wide character workarounds:
152 ****************************************************************************/
155 * define BOOST_REGEX_HAS_OTHER_WCHAR_T when wchar_t is a native type, but the users
156 * code may be built with wchar_t as unsigned short: basically when we're building
157 * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions
158 * of the non-inline functions in the library, so that users can still link to the lib,
159 * irrespective of whether their own code is built with /Zc:wchar_t.
161 #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)
162 # define BOOST_REGEX_HAS_OTHER_WCHAR_T
163 # ifdef BOOST_MSVC
164 # pragma warning(push)
165 # pragma warning(disable : 4251 4231 4660)
166 # endif
167 # ifdef _DLL
168 # include <string>
169 extern template class __declspec(dllimport) std::basic_string<unsigned short>;
170 # endif
171 # ifdef BOOST_MSVC
172 # pragma warning(pop)
173 # endif
174 #endif
177 /*****************************************************************************
179 * Set up dll import/export options:
181 ****************************************************************************/
183 #if defined(BOOST_HAS_DECLSPEC) && (defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)) && !defined(BOOST_REGEX_STATIC_LINK)
184 # if defined(BOOST_REGEX_SOURCE)
185 # define BOOST_REGEX_DECL __declspec(dllexport)
186 # define BOOST_REGEX_BUILD_DLL
187 # else
188 # define BOOST_REGEX_DECL __declspec(dllimport)
189 # endif
190 #endif
192 #ifndef BOOST_REGEX_DECL
193 # define BOOST_REGEX_DECL
194 #endif
196 #if !defined(BOOST_REGEX_NO_LIB) && !defined(BOOST_REGEX_SOURCE) && !defined(BOOST_ALL_NO_LIB) && defined(__cplusplus)
197 # define BOOST_LIB_NAME boost_regex
198 # if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
199 # define BOOST_DYN_LINK
200 # endif
201 # ifdef BOOST_REGEX_DIAG
202 # define BOOST_LIB_DIAGNOSTIC
203 # endif
204 # include <boost/config/auto_link.hpp>
205 #endif
207 /*****************************************************************************
209 * Set up function call type:
211 ****************************************************************************/
213 #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS)
214 #if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED)
215 # define BOOST_REGEX_CALL __cdecl
216 #else
217 # define BOOST_REGEX_CALL __fastcall
218 #endif
219 # define BOOST_REGEX_CCALL __cdecl
220 #endif
222 #if defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)
223 # define BOOST_REGEX_CALL __fastcall
224 # define BOOST_REGEX_CCALL __stdcall
225 #endif
227 #ifndef BOOST_REGEX_CALL
228 # define BOOST_REGEX_CALL
229 #endif
230 #ifndef BOOST_REGEX_CCALL
231 #define BOOST_REGEX_CCALL
232 #endif
234 /*****************************************************************************
236 * Set up localisation model:
238 ****************************************************************************/
240 /* backwards compatibility: */
241 #ifdef BOOST_RE_LOCALE_C
242 # define BOOST_REGEX_USE_C_LOCALE
243 #endif
245 #ifdef BOOST_RE_LOCALE_CPP
246 # define BOOST_REGEX_USE_CPP_LOCALE
247 #endif
249 /* Win32 defaults to native Win32 locale: */
250 #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)
251 # define BOOST_REGEX_USE_WIN32_LOCALE
252 #endif
253 /* otherwise use C++ locale if supported: */
254 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE) && !defined(BOOST_NO_STD_LOCALE)
255 # define BOOST_REGEX_USE_CPP_LOCALE
256 #endif
257 /* otherwise use C+ locale: */
258 #if !defined(BOOST_REGEX_USE_WIN32_LOCALE) && !defined(BOOST_REGEX_USE_C_LOCALE) && !defined(BOOST_REGEX_USE_CPP_LOCALE)
259 # define BOOST_REGEX_USE_C_LOCALE
260 #endif
262 #ifndef BOOST_REGEX_MAX_STATE_COUNT
263 # define BOOST_REGEX_MAX_STATE_COUNT 100000000
264 #endif
267 /*****************************************************************************
269 * Error Handling for exception free compilers:
271 ****************************************************************************/
273 #ifdef BOOST_NO_EXCEPTIONS
275 * If there are no exceptions then we must report critical-errors
276 * the only way we know how; by terminating.
278 #include <stdexcept>
279 #include <string>
280 #include <boost/throw_exception.hpp>
282 # define BOOST_REGEX_NOEH_ASSERT(x)\
283 if(0 == (x))\
285 std::string s("Error: critical regex++ failure in: ");\
286 s.append(#x);\
287 std::runtime_error e(s);\
288 boost::throw_exception(e);\
290 #else
292 * With exceptions then error handling is taken care of and
293 * there is no need for these checks:
295 # define BOOST_REGEX_NOEH_ASSERT(x)
296 #endif
299 /*****************************************************************************
301 * Stack protection under MS Windows:
303 ****************************************************************************/
305 #if !defined(BOOST_REGEX_NO_W32) && !defined(BOOST_REGEX_V3)
306 # if(defined(_WIN32) || defined(_WIN64) || defined(_WINCE)) \
307 && !defined(__GNUC__) \
308 && !(defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)) \
309 && !(defined(__MWERKS__) && (__MWERKS__ <= 0x3003))
310 # define BOOST_REGEX_HAS_MS_STACK_GUARD
311 # endif
312 #elif defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
313 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
314 #endif
316 #if defined(__cplusplus) && defined(BOOST_REGEX_HAS_MS_STACK_GUARD)
318 namespace boost{
319 namespace re_detail{
321 BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page();
326 #endif
329 /*****************************************************************************
331 * Algorithm selection and configuration:
333 ****************************************************************************/
335 #if !defined(BOOST_REGEX_RECURSIVE) && !defined(BOOST_REGEX_NON_RECURSIVE)
336 # if defined(BOOST_REGEX_HAS_MS_STACK_GUARD) && !defined(_STLP_DEBUG) && !defined(__STL_DEBUG) && !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1400))
337 # define BOOST_REGEX_RECURSIVE
338 # else
339 # define BOOST_REGEX_NON_RECURSIVE
340 # endif
341 #endif
343 #ifdef BOOST_REGEX_NON_RECURSIVE
344 # ifdef BOOST_REGEX_RECURSIVE
345 # error "Can't set both BOOST_REGEX_RECURSIVE and BOOST_REGEX_NON_RECURSIVE"
346 # endif
347 # ifndef BOOST_REGEX_BLOCKSIZE
348 # define BOOST_REGEX_BLOCKSIZE 4096
349 # endif
350 # if BOOST_REGEX_BLOCKSIZE < 512
351 # error "BOOST_REGEX_BLOCKSIZE must be at least 512"
352 # endif
353 # ifndef BOOST_REGEX_MAX_BLOCKS
354 # define BOOST_REGEX_MAX_BLOCKS 1024
355 # endif
356 # ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
357 # undef BOOST_REGEX_HAS_MS_STACK_GUARD
358 # endif
359 # ifndef BOOST_REGEX_MAX_CACHE_BLOCKS
360 # define BOOST_REGEX_MAX_CACHE_BLOCKS 16
361 # endif
362 #endif
365 /*****************************************************************************
367 * helper memory allocation functions:
369 ****************************************************************************/
371 #if defined(__cplusplus) && defined(BOOST_REGEX_NON_RECURSIVE)
372 namespace boost{ namespace re_detail{
374 BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block();
375 BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void*);
377 }} /* namespaces */
378 #endif
380 /*****************************************************************************
382 * Diagnostics:
384 ****************************************************************************/
386 #ifdef BOOST_REGEX_CONFIG_INFO
387 BOOST_REGEX_DECL void BOOST_REGEX_CALL print_regex_library_info();
388 #endif
390 #if defined(BOOST_REGEX_DIAG)
391 # pragma message ("BOOST_REGEX_DECL" BOOST_STRINGIZE(=BOOST_REGEX_DECL))
392 # pragma message ("BOOST_REGEX_CALL" BOOST_STRINGIZE(=BOOST_REGEX_CALL))
393 # pragma message ("BOOST_REGEX_CCALL" BOOST_STRINGIZE(=BOOST_REGEX_CCALL))
394 #ifdef BOOST_REGEX_USE_C_LOCALE
395 # pragma message ("Using C locale in regex traits class")
396 #elif BOOST_REGEX_USE_CPP_LOCALE
397 # pragma message ("Using C++ locale in regex traits class")
398 #else
399 # pragma message ("Using Win32 locale in regex traits class")
400 #endif
401 #if defined(BOOST_REGEX_DYN_LINK) || defined(BOOST_ALL_DYN_LINK)
402 # pragma message ("Dynamic linking enabled")
403 #endif
404 #if defined(BOOST_REGEX_NO_LIB) || defined(BOOST_ALL_NO_LIB)
405 # pragma message ("Auto-linking disabled")
406 #endif
407 #ifdef BOOST_REGEX_NO_EXTERNAL_TEMPLATES
408 # pragma message ("Extern templates disabled")
409 #endif
411 #endif
413 #endif