]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/regex/v4/regex_traits_defaults.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / regex / v4 / regex_traits_defaults.hpp
1 /*
2 *
3 * Copyright (c) 2004
4 * John Maddock
5 *
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)
9 *
10 */
11
12 /*
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE regex_traits_defaults.hpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Declares API's for access to regex_traits default properties.
17 */
18
19 #ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
20 #define BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
21
22 #ifdef BOOST_MSVC
23 #pragma warning(push)
24 #pragma warning(disable: 4103)
25 #endif
26 #ifdef BOOST_HAS_ABI_HEADERS
27 # include BOOST_ABI_PREFIX
28 #endif
29 #ifdef BOOST_MSVC
30 #pragma warning(pop)
31 #endif
32
33 #include <boost/regex/config.hpp>
34 #include <boost/cstdint.hpp>
35
36 #include <cctype>
37 #include <cwctype>
38 #include <locale>
39
40 #ifndef BOOST_REGEX_SYNTAX_TYPE_HPP
41 #include <boost/regex/v4/syntax_type.hpp>
42 #endif
43 #ifndef BOOST_REGEX_ERROR_TYPE_HPP
44 #include <boost/regex/v4/error_type.hpp>
45 #endif
46 #include <boost/regex/v4/regex_workaround.hpp>
47 #include <boost/type_traits/make_unsigned.hpp>
48 #include <boost/utility/enable_if.hpp>
49
50 #ifdef BOOST_NO_STDC_NAMESPACE
51 namespace std{
52 using ::strlen;
53 }
54 #endif
55
56 namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
57
58
59 //
60 // helpers to suppress warnings:
61 //
62 template <class charT>
63 inline bool is_extended(charT c)
64 {
65 typedef typename make_unsigned<charT>::type unsigned_type;
66 return (sizeof(charT) > 1) && (static_cast<unsigned_type>(c) >= 256u);
67 }
68 inline bool is_extended(char)
69 { return false; }
70
71 inline const char* BOOST_REGEX_CALL get_default_syntax(regex_constants::syntax_type n)
72 {
73 // if the user hasn't supplied a message catalog, then this supplies
74 // default "messages" for us to load in the range 1-100.
75 const char* messages[] = {
76 "",
77 "(",
78 ")",
79 "$",
80 "^",
81 ".",
82 "*",
83 "+",
84 "?",
85 "[",
86 "]",
87 "|",
88 "\\",
89 "#",
90 "-",
91 "{",
92 "}",
93 "0123456789",
94 "b",
95 "B",
96 "<",
97 ">",
98 "",
99 "",
100 "A`",
101 "z'",
102 "\n",
103 ",",
104 "a",
105 "f",
106 "n",
107 "r",
108 "t",
109 "v",
110 "x",
111 "c",
112 ":",
113 "=",
114 "e",
115 "",
116 "",
117 "",
118 "",
119 "",
120 "",
121 "",
122 "",
123 "E",
124 "Q",
125 "X",
126 "C",
127 "Z",
128 "G",
129 "!",
130 "p",
131 "P",
132 "N",
133 "gk",
134 "K",
135 "R",
136 };
137
138 return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]);
139 }
140
141 inline const char* BOOST_REGEX_CALL get_default_error_string(regex_constants::error_type n)
142 {
143 static const char* const s_default_error_messages[] = {
144 "Success", /* REG_NOERROR 0 error_ok */
145 "No match", /* REG_NOMATCH 1 error_no_match */
146 "Invalid regular expression.", /* REG_BADPAT 2 error_bad_pattern */
147 "Invalid collation character.", /* REG_ECOLLATE 3 error_collate */
148 "Invalid character class name, collating name, or character range.", /* REG_ECTYPE 4 error_ctype */
149 "Invalid or unterminated escape sequence.", /* REG_EESCAPE 5 error_escape */
150 "Invalid back reference: specified capturing group does not exist.", /* REG_ESUBREG 6 error_backref */
151 "Unmatched [ or [^ in character class declaration.", /* REG_EBRACK 7 error_brack */
152 "Unmatched marking parenthesis ( or \\(.", /* REG_EPAREN 8 error_paren */
153 "Unmatched quantified repeat operator { or \\{.", /* REG_EBRACE 9 error_brace */
154 "Invalid content of repeat range.", /* REG_BADBR 10 error_badbrace */
155 "Invalid range end in character class", /* REG_ERANGE 11 error_range */
156 "Out of memory.", /* REG_ESPACE 12 error_space NOT USED */
157 "Invalid preceding regular expression prior to repetition operator.", /* REG_BADRPT 13 error_badrepeat */
158 "Premature end of regular expression", /* REG_EEND 14 error_end NOT USED */
159 "Regular expression is too large.", /* REG_ESIZE 15 error_size NOT USED */
160 "Unmatched ) or \\)", /* REG_ERPAREN 16 error_right_paren NOT USED */
161 "Empty regular expression.", /* REG_EMPTY 17 error_empty */
162 "The complexity of matching the regular expression exceeded predefined bounds. "
163 "Try refactoring the regular expression to make each choice made by the state machine unambiguous. "
164 "This exception is thrown to prevent \"eternal\" matches that take an "
165 "indefinite period time to locate.", /* REG_ECOMPLEXITY 18 error_complexity */
166 "Ran out of stack space trying to match the regular expression.", /* REG_ESTACK 19 error_stack */
167 "Invalid or unterminated Perl (?...) sequence.", /* REG_E_PERL 20 error_perl */
168 "Unknown error.", /* REG_E_UNKNOWN 21 error_unknown */
169 };
170
171 return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[::boost::regex_constants::error_unknown] : s_default_error_messages[n];
172 }
173
174 inline regex_constants::syntax_type BOOST_REGEX_CALL get_default_syntax_type(char c)
175 {
176 //
177 // char_syntax determines how the compiler treats a given character
178 // in a regular expression.
179 //
180 static regex_constants::syntax_type char_syntax[] = {
181 regex_constants::syntax_char, /**/
182 regex_constants::syntax_char, /**/
183 regex_constants::syntax_char, /**/
184 regex_constants::syntax_char, /**/
185 regex_constants::syntax_char, /**/
186 regex_constants::syntax_char, /**/
187 regex_constants::syntax_char, /**/
188 regex_constants::syntax_char, /**/
189 regex_constants::syntax_char, /**/
190 regex_constants::syntax_char, /**/
191 regex_constants::syntax_newline, /**/
192 regex_constants::syntax_char, /**/
193 regex_constants::syntax_char, /**/
194 regex_constants::syntax_char, /**/
195 regex_constants::syntax_char, /**/
196 regex_constants::syntax_char, /**/
197 regex_constants::syntax_char, /**/
198 regex_constants::syntax_char, /**/
199 regex_constants::syntax_char, /**/
200 regex_constants::syntax_char, /**/
201 regex_constants::syntax_char, /**/
202 regex_constants::syntax_char, /**/
203 regex_constants::syntax_char, /**/
204 regex_constants::syntax_char, /**/
205 regex_constants::syntax_char, /**/
206 regex_constants::syntax_char, /**/
207 regex_constants::syntax_char, /**/
208 regex_constants::syntax_char, /**/
209 regex_constants::syntax_char, /**/
210 regex_constants::syntax_char, /**/
211 regex_constants::syntax_char, /**/
212 regex_constants::syntax_char, /**/
213 regex_constants::syntax_char, /* */ // 32
214 regex_constants::syntax_not, /*!*/
215 regex_constants::syntax_char, /*"*/
216 regex_constants::syntax_hash, /*#*/
217 regex_constants::syntax_dollar, /*$*/
218 regex_constants::syntax_char, /*%*/
219 regex_constants::syntax_char, /*&*/
220 regex_constants::escape_type_end_buffer, /*'*/
221 regex_constants::syntax_open_mark, /*(*/
222 regex_constants::syntax_close_mark, /*)*/
223 regex_constants::syntax_star, /***/
224 regex_constants::syntax_plus, /*+*/
225 regex_constants::syntax_comma, /*,*/
226 regex_constants::syntax_dash, /*-*/
227 regex_constants::syntax_dot, /*.*/
228 regex_constants::syntax_char, /*/*/
229 regex_constants::syntax_digit, /*0*/
230 regex_constants::syntax_digit, /*1*/
231 regex_constants::syntax_digit, /*2*/
232 regex_constants::syntax_digit, /*3*/
233 regex_constants::syntax_digit, /*4*/
234 regex_constants::syntax_digit, /*5*/
235 regex_constants::syntax_digit, /*6*/
236 regex_constants::syntax_digit, /*7*/
237 regex_constants::syntax_digit, /*8*/
238 regex_constants::syntax_digit, /*9*/
239 regex_constants::syntax_colon, /*:*/
240 regex_constants::syntax_char, /*;*/
241 regex_constants::escape_type_left_word, /*<*/
242 regex_constants::syntax_equal, /*=*/
243 regex_constants::escape_type_right_word, /*>*/
244 regex_constants::syntax_question, /*?*/
245 regex_constants::syntax_char, /*@*/
246 regex_constants::syntax_char, /*A*/
247 regex_constants::syntax_char, /*B*/
248 regex_constants::syntax_char, /*C*/
249 regex_constants::syntax_char, /*D*/
250 regex_constants::syntax_char, /*E*/
251 regex_constants::syntax_char, /*F*/
252 regex_constants::syntax_char, /*G*/
253 regex_constants::syntax_char, /*H*/
254 regex_constants::syntax_char, /*I*/
255 regex_constants::syntax_char, /*J*/
256 regex_constants::syntax_char, /*K*/
257 regex_constants::syntax_char, /*L*/
258 regex_constants::syntax_char, /*M*/
259 regex_constants::syntax_char, /*N*/
260 regex_constants::syntax_char, /*O*/
261 regex_constants::syntax_char, /*P*/
262 regex_constants::syntax_char, /*Q*/
263 regex_constants::syntax_char, /*R*/
264 regex_constants::syntax_char, /*S*/
265 regex_constants::syntax_char, /*T*/
266 regex_constants::syntax_char, /*U*/
267 regex_constants::syntax_char, /*V*/
268 regex_constants::syntax_char, /*W*/
269 regex_constants::syntax_char, /*X*/
270 regex_constants::syntax_char, /*Y*/
271 regex_constants::syntax_char, /*Z*/
272 regex_constants::syntax_open_set, /*[*/
273 regex_constants::syntax_escape, /*\*/
274 regex_constants::syntax_close_set, /*]*/
275 regex_constants::syntax_caret, /*^*/
276 regex_constants::syntax_char, /*_*/
277 regex_constants::syntax_char, /*`*/
278 regex_constants::syntax_char, /*a*/
279 regex_constants::syntax_char, /*b*/
280 regex_constants::syntax_char, /*c*/
281 regex_constants::syntax_char, /*d*/
282 regex_constants::syntax_char, /*e*/
283 regex_constants::syntax_char, /*f*/
284 regex_constants::syntax_char, /*g*/
285 regex_constants::syntax_char, /*h*/
286 regex_constants::syntax_char, /*i*/
287 regex_constants::syntax_char, /*j*/
288 regex_constants::syntax_char, /*k*/
289 regex_constants::syntax_char, /*l*/
290 regex_constants::syntax_char, /*m*/
291 regex_constants::syntax_char, /*n*/
292 regex_constants::syntax_char, /*o*/
293 regex_constants::syntax_char, /*p*/
294 regex_constants::syntax_char, /*q*/
295 regex_constants::syntax_char, /*r*/
296 regex_constants::syntax_char, /*s*/
297 regex_constants::syntax_char, /*t*/
298 regex_constants::syntax_char, /*u*/
299 regex_constants::syntax_char, /*v*/
300 regex_constants::syntax_char, /*w*/
301 regex_constants::syntax_char, /*x*/
302 regex_constants::syntax_char, /*y*/
303 regex_constants::syntax_char, /*z*/
304 regex_constants::syntax_open_brace, /*{*/
305 regex_constants::syntax_or, /*|*/
306 regex_constants::syntax_close_brace, /*}*/
307 regex_constants::syntax_char, /*~*/
308 regex_constants::syntax_char, /**/
309 regex_constants::syntax_char, /**/
310 regex_constants::syntax_char, /**/
311 regex_constants::syntax_char, /**/
312 regex_constants::syntax_char, /**/
313 regex_constants::syntax_char, /**/
314 regex_constants::syntax_char, /**/
315 regex_constants::syntax_char, /**/
316 regex_constants::syntax_char, /**/
317 regex_constants::syntax_char, /**/
318 regex_constants::syntax_char, /**/
319 regex_constants::syntax_char, /**/
320 regex_constants::syntax_char, /**/
321 regex_constants::syntax_char, /**/
322 regex_constants::syntax_char, /**/
323 regex_constants::syntax_char, /**/
324 regex_constants::syntax_char, /**/
325 regex_constants::syntax_char, /**/
326 regex_constants::syntax_char, /**/
327 regex_constants::syntax_char, /**/
328 regex_constants::syntax_char, /**/
329 regex_constants::syntax_char, /**/
330 regex_constants::syntax_char, /**/
331 regex_constants::syntax_char, /**/
332 regex_constants::syntax_char, /**/
333 regex_constants::syntax_char, /**/
334 regex_constants::syntax_char, /**/
335 regex_constants::syntax_char, /**/
336 regex_constants::syntax_char, /**/
337 regex_constants::syntax_char, /**/
338 regex_constants::syntax_char, /**/
339 regex_constants::syntax_char, /**/
340 regex_constants::syntax_char, /**/
341 regex_constants::syntax_char, /**/
342 regex_constants::syntax_char, /**/
343 regex_constants::syntax_char, /**/
344 regex_constants::syntax_char, /**/
345 regex_constants::syntax_char, /**/
346 regex_constants::syntax_char, /**/
347 regex_constants::syntax_char, /**/
348 regex_constants::syntax_char, /**/
349 regex_constants::syntax_char, /**/
350 regex_constants::syntax_char, /**/
351 regex_constants::syntax_char, /**/
352 regex_constants::syntax_char, /**/
353 regex_constants::syntax_char, /**/
354 regex_constants::syntax_char, /**/
355 regex_constants::syntax_char, /**/
356 regex_constants::syntax_char, /**/
357 regex_constants::syntax_char, /**/
358 regex_constants::syntax_char, /**/
359 regex_constants::syntax_char, /**/
360 regex_constants::syntax_char, /**/
361 regex_constants::syntax_char, /**/
362 regex_constants::syntax_char, /**/
363 regex_constants::syntax_char, /**/
364 };
365
366 return char_syntax[(unsigned char)c];
367 }
368
369 inline regex_constants::escape_syntax_type BOOST_REGEX_CALL get_default_escape_syntax_type(char c)
370 {
371 //
372 // char_syntax determines how the compiler treats a given character
373 // in a regular expression.
374 //
375 static regex_constants::escape_syntax_type char_syntax[] = {
376 regex_constants::escape_type_identity, /**/
377 regex_constants::escape_type_identity, /**/
378 regex_constants::escape_type_identity, /**/
379 regex_constants::escape_type_identity, /**/
380 regex_constants::escape_type_identity, /**/
381 regex_constants::escape_type_identity, /**/
382 regex_constants::escape_type_identity, /**/
383 regex_constants::escape_type_identity, /**/
384 regex_constants::escape_type_identity, /**/
385 regex_constants::escape_type_identity, /**/
386 regex_constants::escape_type_identity, /**/
387 regex_constants::escape_type_identity, /**/
388 regex_constants::escape_type_identity, /**/
389 regex_constants::escape_type_identity, /**/
390 regex_constants::escape_type_identity, /**/
391 regex_constants::escape_type_identity, /**/
392 regex_constants::escape_type_identity, /**/
393 regex_constants::escape_type_identity, /**/
394 regex_constants::escape_type_identity, /**/
395 regex_constants::escape_type_identity, /**/
396 regex_constants::escape_type_identity, /**/
397 regex_constants::escape_type_identity, /**/
398 regex_constants::escape_type_identity, /**/
399 regex_constants::escape_type_identity, /**/
400 regex_constants::escape_type_identity, /**/
401 regex_constants::escape_type_identity, /**/
402 regex_constants::escape_type_identity, /**/
403 regex_constants::escape_type_identity, /**/
404 regex_constants::escape_type_identity, /**/
405 regex_constants::escape_type_identity, /**/
406 regex_constants::escape_type_identity, /**/
407 regex_constants::escape_type_identity, /**/
408 regex_constants::escape_type_identity, /* */ // 32
409 regex_constants::escape_type_identity, /*!*/
410 regex_constants::escape_type_identity, /*"*/
411 regex_constants::escape_type_identity, /*#*/
412 regex_constants::escape_type_identity, /*$*/
413 regex_constants::escape_type_identity, /*%*/
414 regex_constants::escape_type_identity, /*&*/
415 regex_constants::escape_type_end_buffer, /*'*/
416 regex_constants::syntax_open_mark, /*(*/
417 regex_constants::syntax_close_mark, /*)*/
418 regex_constants::escape_type_identity, /***/
419 regex_constants::syntax_plus, /*+*/
420 regex_constants::escape_type_identity, /*,*/
421 regex_constants::escape_type_identity, /*-*/
422 regex_constants::escape_type_identity, /*.*/
423 regex_constants::escape_type_identity, /*/*/
424 regex_constants::escape_type_decimal, /*0*/
425 regex_constants::escape_type_backref, /*1*/
426 regex_constants::escape_type_backref, /*2*/
427 regex_constants::escape_type_backref, /*3*/
428 regex_constants::escape_type_backref, /*4*/
429 regex_constants::escape_type_backref, /*5*/
430 regex_constants::escape_type_backref, /*6*/
431 regex_constants::escape_type_backref, /*7*/
432 regex_constants::escape_type_backref, /*8*/
433 regex_constants::escape_type_backref, /*9*/
434 regex_constants::escape_type_identity, /*:*/
435 regex_constants::escape_type_identity, /*;*/
436 regex_constants::escape_type_left_word, /*<*/
437 regex_constants::escape_type_identity, /*=*/
438 regex_constants::escape_type_right_word, /*>*/
439 regex_constants::syntax_question, /*?*/
440 regex_constants::escape_type_identity, /*@*/
441 regex_constants::escape_type_start_buffer, /*A*/
442 regex_constants::escape_type_not_word_assert, /*B*/
443 regex_constants::escape_type_C, /*C*/
444 regex_constants::escape_type_not_class, /*D*/
445 regex_constants::escape_type_E, /*E*/
446 regex_constants::escape_type_not_class, /*F*/
447 regex_constants::escape_type_G, /*G*/
448 regex_constants::escape_type_not_class, /*H*/
449 regex_constants::escape_type_not_class, /*I*/
450 regex_constants::escape_type_not_class, /*J*/
451 regex_constants::escape_type_reset_start_mark, /*K*/
452 regex_constants::escape_type_not_class, /*L*/
453 regex_constants::escape_type_not_class, /*M*/
454 regex_constants::escape_type_named_char, /*N*/
455 regex_constants::escape_type_not_class, /*O*/
456 regex_constants::escape_type_not_property, /*P*/
457 regex_constants::escape_type_Q, /*Q*/
458 regex_constants::escape_type_line_ending, /*R*/
459 regex_constants::escape_type_not_class, /*S*/
460 regex_constants::escape_type_not_class, /*T*/
461 regex_constants::escape_type_not_class, /*U*/
462 regex_constants::escape_type_not_class, /*V*/
463 regex_constants::escape_type_not_class, /*W*/
464 regex_constants::escape_type_X, /*X*/
465 regex_constants::escape_type_not_class, /*Y*/
466 regex_constants::escape_type_Z, /*Z*/
467 regex_constants::escape_type_identity, /*[*/
468 regex_constants::escape_type_identity, /*\*/
469 regex_constants::escape_type_identity, /*]*/
470 regex_constants::escape_type_identity, /*^*/
471 regex_constants::escape_type_identity, /*_*/
472 regex_constants::escape_type_start_buffer, /*`*/
473 regex_constants::escape_type_control_a, /*a*/
474 regex_constants::escape_type_word_assert, /*b*/
475 regex_constants::escape_type_ascii_control, /*c*/
476 regex_constants::escape_type_class, /*d*/
477 regex_constants::escape_type_e, /*e*/
478 regex_constants::escape_type_control_f, /*f*/
479 regex_constants::escape_type_extended_backref, /*g*/
480 regex_constants::escape_type_class, /*h*/
481 regex_constants::escape_type_class, /*i*/
482 regex_constants::escape_type_class, /*j*/
483 regex_constants::escape_type_extended_backref, /*k*/
484 regex_constants::escape_type_class, /*l*/
485 regex_constants::escape_type_class, /*m*/
486 regex_constants::escape_type_control_n, /*n*/
487 regex_constants::escape_type_class, /*o*/
488 regex_constants::escape_type_property, /*p*/
489 regex_constants::escape_type_class, /*q*/
490 regex_constants::escape_type_control_r, /*r*/
491 regex_constants::escape_type_class, /*s*/
492 regex_constants::escape_type_control_t, /*t*/
493 regex_constants::escape_type_class, /*u*/
494 regex_constants::escape_type_control_v, /*v*/
495 regex_constants::escape_type_class, /*w*/
496 regex_constants::escape_type_hex, /*x*/
497 regex_constants::escape_type_class, /*y*/
498 regex_constants::escape_type_end_buffer, /*z*/
499 regex_constants::syntax_open_brace, /*{*/
500 regex_constants::syntax_or, /*|*/
501 regex_constants::syntax_close_brace, /*}*/
502 regex_constants::escape_type_identity, /*~*/
503 regex_constants::escape_type_identity, /**/
504 regex_constants::escape_type_identity, /**/
505 regex_constants::escape_type_identity, /**/
506 regex_constants::escape_type_identity, /**/
507 regex_constants::escape_type_identity, /**/
508 regex_constants::escape_type_identity, /**/
509 regex_constants::escape_type_identity, /**/
510 regex_constants::escape_type_identity, /**/
511 regex_constants::escape_type_identity, /**/
512 regex_constants::escape_type_identity, /**/
513 regex_constants::escape_type_identity, /**/
514 regex_constants::escape_type_identity, /**/
515 regex_constants::escape_type_identity, /**/
516 regex_constants::escape_type_identity, /**/
517 regex_constants::escape_type_identity, /**/
518 regex_constants::escape_type_identity, /**/
519 regex_constants::escape_type_identity, /**/
520 regex_constants::escape_type_identity, /**/
521 regex_constants::escape_type_identity, /**/
522 regex_constants::escape_type_identity, /**/
523 regex_constants::escape_type_identity, /**/
524 regex_constants::escape_type_identity, /**/
525 regex_constants::escape_type_identity, /**/
526 regex_constants::escape_type_identity, /**/
527 regex_constants::escape_type_identity, /**/
528 regex_constants::escape_type_identity, /**/
529 regex_constants::escape_type_identity, /**/
530 regex_constants::escape_type_identity, /**/
531 regex_constants::escape_type_identity, /**/
532 regex_constants::escape_type_identity, /**/
533 regex_constants::escape_type_identity, /**/
534 regex_constants::escape_type_identity, /**/
535 regex_constants::escape_type_identity, /**/
536 regex_constants::escape_type_identity, /**/
537 regex_constants::escape_type_identity, /**/
538 regex_constants::escape_type_identity, /**/
539 regex_constants::escape_type_identity, /**/
540 regex_constants::escape_type_identity, /**/
541 regex_constants::escape_type_identity, /**/
542 regex_constants::escape_type_identity, /**/
543 regex_constants::escape_type_identity, /**/
544 regex_constants::escape_type_identity, /**/
545 regex_constants::escape_type_identity, /**/
546 regex_constants::escape_type_identity, /**/
547 regex_constants::escape_type_identity, /**/
548 regex_constants::escape_type_identity, /**/
549 regex_constants::escape_type_identity, /**/
550 regex_constants::escape_type_identity, /**/
551 regex_constants::escape_type_identity, /**/
552 regex_constants::escape_type_identity, /**/
553 regex_constants::escape_type_identity, /**/
554 regex_constants::escape_type_identity, /**/
555 regex_constants::escape_type_identity, /**/
556 regex_constants::escape_type_identity, /**/
557 regex_constants::escape_type_identity, /**/
558 regex_constants::escape_type_identity, /**/
559 };
560
561 return char_syntax[(unsigned char)c];
562 }
563
564 // is charT c a combining character?
565 inline bool BOOST_REGEX_CALL is_combining_implementation(boost::uint_least16_t c)
566 {
567 const boost::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
568 0x0483, 0x0486,
569 0x0903, 0x0903,
570 0x093E, 0x0940,
571 0x0949, 0x094C,
572 0x0982, 0x0983,
573 0x09BE, 0x09C0,
574 0x09C7, 0x09CC,
575 0x09D7, 0x09D7,
576 0x0A3E, 0x0A40,
577 0x0A83, 0x0A83,
578 0x0ABE, 0x0AC0,
579 0x0AC9, 0x0ACC,
580 0x0B02, 0x0B03,
581 0x0B3E, 0x0B3E,
582 0x0B40, 0x0B40,
583 0x0B47, 0x0B4C,
584 0x0B57, 0x0B57,
585 0x0B83, 0x0B83,
586 0x0BBE, 0x0BBF,
587 0x0BC1, 0x0BCC,
588 0x0BD7, 0x0BD7,
589 0x0C01, 0x0C03,
590 0x0C41, 0x0C44,
591 0x0C82, 0x0C83,
592 0x0CBE, 0x0CBE,
593 0x0CC0, 0x0CC4,
594 0x0CC7, 0x0CCB,
595 0x0CD5, 0x0CD6,
596 0x0D02, 0x0D03,
597 0x0D3E, 0x0D40,
598 0x0D46, 0x0D4C,
599 0x0D57, 0x0D57,
600 0x0F7F, 0x0F7F,
601 0x20D0, 0x20E1,
602 0x3099, 0x309A,
603 0xFE20, 0xFE23,
604 0xffff, 0xffff, };
605
606 const boost::uint_least16_t* p = combining_ranges + 1;
607 while (*p < c) p += 2;
608 --p;
609 if ((c >= *p) && (c <= *(p + 1)))
610 return true;
611 return false;
612 }
613
614 template <class charT>
615 inline bool is_combining(charT c)
616 {
617 return (c <= static_cast<charT>(0)) ? false : ((c >= static_cast<charT>((std::numeric_limits<uint_least16_t>::max)())) ? false : is_combining_implementation(static_cast<unsigned short>(c)));
618 }
619 template <>
620 inline bool is_combining<char>(char)
621 {
622 return false;
623 }
624 template <>
625 inline bool is_combining<signed char>(signed char)
626 {
627 return false;
628 }
629 template <>
630 inline bool is_combining<unsigned char>(unsigned char)
631 {
632 return false;
633 }
634 #if !defined(__hpux) && !defined(__WINSCW__) // can't use WCHAR_MAX/MIN in pp-directives
635 #ifdef _MSC_VER
636 template<>
637 inline bool is_combining<wchar_t>(wchar_t c)
638 {
639 return is_combining_implementation(static_cast<unsigned short>(c));
640 }
641 #elif !defined(__DECCXX) && !defined(__osf__) && !defined(__OSF__) && defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
642 #if defined(WCHAR_MAX) && (WCHAR_MAX <= USHRT_MAX)
643 template<>
644 inline bool is_combining<wchar_t>(wchar_t c)
645 {
646 return is_combining_implementation(static_cast<unsigned short>(c));
647 }
648 #else
649 template<>
650 inline bool is_combining<wchar_t>(wchar_t c)
651 {
652 return (c >= (std::numeric_limits<uint_least16_t>::max)()) ? false : is_combining_implementation(static_cast<unsigned short>(c));
653 }
654 #endif
655 #endif
656 #endif
657
658 //
659 // is a charT c a line separator?
660 //
661 template <class charT>
662 inline bool is_separator(charT c)
663 {
664 return BOOST_REGEX_MAKE_BOOL(
665 (c == static_cast<charT>('\n'))
666 || (c == static_cast<charT>('\r'))
667 || (c == static_cast<charT>('\f'))
668 || (static_cast<boost::uint16_t>(c) == 0x2028u)
669 || (static_cast<boost::uint16_t>(c) == 0x2029u)
670 || (static_cast<boost::uint16_t>(c) == 0x85u));
671 }
672 template <>
673 inline bool is_separator<char>(char c)
674 {
675 return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r') || (c == '\f'));
676 }
677
678 //
679 // get a default collating element:
680 //
681 inline std::string BOOST_REGEX_CALL lookup_default_collate_name(const std::string& name)
682 {
683 //
684 // these are the POSIX collating names:
685 //
686 static const char* def_coll_names[] = {
687 "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline",
688 "vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK",
689 "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark",
690 "quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe",
691 "left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen",
692 "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
693 "colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign",
694 "question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
695 "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash",
696 "right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f",
697 "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket",
698 "vertical-line", "right-curly-bracket", "tilde", "DEL", "",
699 };
700
701 // these multi-character collating elements
702 // should keep most Western-European locales
703 // happy - we should really localise these a
704 // little more - but this will have to do for
705 // now:
706
707 static const char* def_multi_coll[] = {
708 "ae",
709 "Ae",
710 "AE",
711 "ch",
712 "Ch",
713 "CH",
714 "ll",
715 "Ll",
716 "LL",
717 "ss",
718 "Ss",
719 "SS",
720 "nj",
721 "Nj",
722 "NJ",
723 "dz",
724 "Dz",
725 "DZ",
726 "lj",
727 "Lj",
728 "LJ",
729 "",
730 };
731
732 unsigned int i = 0;
733 while (*def_coll_names[i])
734 {
735 if (def_coll_names[i] == name)
736 {
737 return std::string(1, char(i));
738 }
739 ++i;
740 }
741 i = 0;
742 while (*def_multi_coll[i])
743 {
744 if (def_multi_coll[i] == name)
745 {
746 return def_multi_coll[i];
747 }
748 ++i;
749 }
750 return std::string();
751 }
752
753 //
754 // get the state_id of a character classification, the individual
755 // traits classes then transform that state_id into a bitmask:
756 //
757 template <class charT>
758 struct character_pointer_range
759 {
760 const charT* p1;
761 const charT* p2;
762
763 bool operator < (const character_pointer_range& r)const
764 {
765 return std::lexicographical_compare(p1, p2, r.p1, r.p2);
766 }
767 bool operator == (const character_pointer_range& r)const
768 {
769 // Not only do we check that the ranges are of equal size before
770 // calling std::equal, but there is no other algorithm available:
771 // not even a non-standard MS one. So forward to unchecked_equal
772 // in the MS case.
773 return ((p2 - p1) == (r.p2 - r.p1)) && BOOST_REGEX_DETAIL_NS::equal(p1, p2, r.p1);
774 }
775 };
776 template <class charT>
777 int get_default_class_id(const charT* p1, const charT* p2)
778 {
779 static const charT data[73] = {
780 'a', 'l', 'n', 'u', 'm',
781 'a', 'l', 'p', 'h', 'a',
782 'b', 'l', 'a', 'n', 'k',
783 'c', 'n', 't', 'r', 'l',
784 'd', 'i', 'g', 'i', 't',
785 'g', 'r', 'a', 'p', 'h',
786 'l', 'o', 'w', 'e', 'r',
787 'p', 'r', 'i', 'n', 't',
788 'p', 'u', 'n', 'c', 't',
789 's', 'p', 'a', 'c', 'e',
790 'u', 'n', 'i', 'c', 'o', 'd', 'e',
791 'u', 'p', 'p', 'e', 'r',
792 'v',
793 'w', 'o', 'r', 'd',
794 'x', 'd', 'i', 'g', 'i', 't',
795 };
796
797 static const character_pointer_range<charT> ranges[21] =
798 {
799 {data+0, data+5,}, // alnum
800 {data+5, data+10,}, // alpha
801 {data+10, data+15,}, // blank
802 {data+15, data+20,}, // cntrl
803 {data+20, data+21,}, // d
804 {data+20, data+25,}, // digit
805 {data+25, data+30,}, // graph
806 {data+29, data+30,}, // h
807 {data+30, data+31,}, // l
808 {data+30, data+35,}, // lower
809 {data+35, data+40,}, // print
810 {data+40, data+45,}, // punct
811 {data+45, data+46,}, // s
812 {data+45, data+50,}, // space
813 {data+57, data+58,}, // u
814 {data+50, data+57,}, // unicode
815 {data+57, data+62,}, // upper
816 {data+62, data+63,}, // v
817 {data+63, data+64,}, // w
818 {data+63, data+67,}, // word
819 {data+67, data+73,}, // xdigit
820 };
821 const character_pointer_range<charT>* ranges_begin = ranges;
822 const character_pointer_range<charT>* ranges_end = ranges + (sizeof(ranges)/sizeof(ranges[0]));
823
824 character_pointer_range<charT> t = { p1, p2, };
825 const character_pointer_range<charT>* p = std::lower_bound(ranges_begin, ranges_end, t);
826 if((p != ranges_end) && (t == *p))
827 return static_cast<int>(p - ranges);
828 return -1;
829 }
830
831 //
832 // helper functions:
833 //
834 template <class charT>
835 std::ptrdiff_t global_length(const charT* p)
836 {
837 std::ptrdiff_t n = 0;
838 while(*p)
839 {
840 ++p;
841 ++n;
842 }
843 return n;
844 }
845 template<>
846 inline std::ptrdiff_t global_length<char>(const char* p)
847 {
848 return (std::strlen)(p);
849 }
850 #ifndef BOOST_NO_WREGEX
851 template<>
852 inline std::ptrdiff_t global_length<wchar_t>(const wchar_t* p)
853 {
854 return (std::ptrdiff_t)(std::wcslen)(p);
855 }
856 #endif
857 template <class charT>
858 inline charT BOOST_REGEX_CALL global_lower(charT c)
859 {
860 return c;
861 }
862 template <class charT>
863 inline charT BOOST_REGEX_CALL global_upper(charT c)
864 {
865 return c;
866 }
867
868 inline char BOOST_REGEX_CALL do_global_lower(char c)
869 {
870 return static_cast<char>((std::tolower)((unsigned char)c));
871 }
872
873 inline char BOOST_REGEX_CALL do_global_upper(char c)
874 {
875 return static_cast<char>((std::toupper)((unsigned char)c));
876 }
877 #ifndef BOOST_NO_WREGEX
878 inline wchar_t BOOST_REGEX_CALL do_global_lower(wchar_t c)
879 {
880 return (std::towlower)(c);
881 }
882
883 inline wchar_t BOOST_REGEX_CALL do_global_upper(wchar_t c)
884 {
885 return (std::towupper)(c);
886 }
887 #endif
888 //
889 // This sucks: declare template specialisations of global_lower/global_upper
890 // that just forward to the non-template implementation functions. We do
891 // this because there is one compiler (Compaq Tru64 C++) that doesn't seem
892 // to differentiate between templates and non-template overloads....
893 // what's more, the primary template, plus all overloads have to be
894 // defined in the same translation unit (if one is inline they all must be)
895 // otherwise the "local template instantiation" compiler option can pick
896 // the wrong instantiation when linking:
897 //
898 template<> inline char BOOST_REGEX_CALL global_lower<char>(char c) { return do_global_lower(c); }
899 template<> inline char BOOST_REGEX_CALL global_upper<char>(char c) { return do_global_upper(c); }
900 #ifndef BOOST_NO_WREGEX
901 template<> inline wchar_t BOOST_REGEX_CALL global_lower<wchar_t>(wchar_t c) { return do_global_lower(c); }
902 template<> inline wchar_t BOOST_REGEX_CALL global_upper<wchar_t>(wchar_t c) { return do_global_upper(c); }
903 #endif
904
905 template <class charT>
906 int global_value(charT c)
907 {
908 static const charT zero = '0';
909 static const charT nine = '9';
910 static const charT a = 'a';
911 static const charT f = 'f';
912 static const charT A = 'A';
913 static const charT F = 'F';
914
915 if(c > f) return -1;
916 if(c >= a) return 10 + (c - a);
917 if(c > F) return -1;
918 if(c >= A) return 10 + (c - A);
919 if(c > nine) return -1;
920 if(c >= zero) return c - zero;
921 return -1;
922 }
923 template <class charT, class traits>
924 boost::intmax_t global_toi(const charT*& p1, const charT* p2, int radix, const traits& t)
925 {
926 (void)t; // warning suppression
927 boost::intmax_t limit = (std::numeric_limits<boost::intmax_t>::max)() / radix;
928 boost::intmax_t next_value = t.value(*p1, radix);
929 if((p1 == p2) || (next_value < 0) || (next_value >= radix))
930 return -1;
931 boost::intmax_t result = 0;
932 while(p1 != p2)
933 {
934 next_value = t.value(*p1, radix);
935 if((next_value < 0) || (next_value >= radix))
936 break;
937 result *= radix;
938 result += next_value;
939 ++p1;
940 if (result > limit)
941 return -1;
942 }
943 return result;
944 }
945
946 template <class charT>
947 inline typename boost::enable_if_c<(sizeof(charT) > 1), const charT*>::type get_escape_R_string()
948 {
949 #ifdef BOOST_MSVC
950 # pragma warning(push)
951 # pragma warning(disable:4309 4245)
952 #endif
953 static const charT e1[] = { '(', '?', '-', 'x', ':', '(', '?', '>', '\x0D', '\x0A', '?',
954 '|', '[', '\x0A', '\x0B', '\x0C', static_cast<charT>(0x85), static_cast<charT>(0x2028),
955 static_cast<charT>(0x2029), ']', ')', ')', '\0' };
956 static const charT e2[] = { '(', '?', '-', 'x', ':', '(', '?', '>', '\x0D', '\x0A', '?',
957 '|', '[', '\x0A', '\x0B', '\x0C', static_cast<charT>(0x85), ']', ')', ')', '\0' };
958
959 charT c = static_cast<charT>(0x2029u);
960 bool b = (static_cast<unsigned>(c) == 0x2029u);
961
962 return (b ? e1 : e2);
963 #ifdef BOOST_MSVC
964 # pragma warning(pop)
965 #endif
966 }
967
968 template <class charT>
969 inline typename boost::disable_if_c<(sizeof(charT) > 1), const charT*>::type get_escape_R_string()
970 {
971 #ifdef BOOST_MSVC
972 # pragma warning(push)
973 # pragma warning(disable:4309)
974 #endif
975 static const charT e2[] = { '(', '?', '-', 'x', ':', '(', '?', '>', '\x0D', '\x0A', '?',
976 '|', '[', '\x0A', '\x0B', '\x0C', '\x85', ']', ')', ')', '\0' };
977 return e2;
978 #ifdef BOOST_MSVC
979 # pragma warning(pop)
980 #endif
981 }
982
983 } // BOOST_REGEX_DETAIL_NS
984 } // boost
985
986 #ifdef BOOST_MSVC
987 #pragma warning(push)
988 #pragma warning(disable: 4103)
989 #endif
990 #ifdef BOOST_HAS_ABI_HEADERS
991 # include BOOST_ABI_SUFFIX
992 #endif
993 #ifdef BOOST_MSVC
994 #pragma warning(pop)
995 #endif
996
997 #endif