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