Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:32:58

0001 /*
0002  *
0003  * Copyright (c) 2004
0004  * John Maddock
0005  *
0006  * Use, modification and distribution are subject to the
0007  * Boost Software License, Version 1.0. (See accompanying file
0008  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009  *
0010  */
0011 
0012  /*
0013   *   LOCATION:    see http://www.boost.org for most recent version.
0014   *   FILE         regex_traits_defaults.hpp
0015   *   VERSION      see <boost/version.hpp>
0016   *   DESCRIPTION: Declares API's for access to regex_traits default properties.
0017   */
0018 
0019 #ifndef BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
0020 #define BOOST_REGEX_TRAITS_DEFAULTS_HPP_INCLUDED
0021 
0022 #include <boost/regex/config.hpp>
0023 
0024 #include <boost/regex/v5/syntax_type.hpp>
0025 #include <boost/regex/v5/error_type.hpp>
0026 #include <boost/regex/v5/regex_workaround.hpp>
0027 #include <type_traits>
0028 #include <cstdint>
0029 #include <cctype>
0030 #include <locale>
0031 #include <cwctype>
0032 #include <limits>
0033 
0034 namespace boost{ namespace BOOST_REGEX_DETAIL_NS{
0035 
0036 
0037 //
0038 // helpers to suppress warnings:
0039 //
0040 template <class charT>
0041 inline bool is_extended(charT c)
0042 {
0043    typedef typename std::make_unsigned<charT>::type unsigned_type; 
0044    return (sizeof(charT) > 1) && (static_cast<unsigned_type>(c) >= 256u); 
0045 }
0046 inline bool is_extended(char)
0047 { return false; }
0048 
0049 inline const char*  get_default_syntax(regex_constants::syntax_type n)
0050 {
0051    // if the user hasn't supplied a message catalog, then this supplies
0052    // default "messages" for us to load in the range 1-100.
0053    const char* messages[] = {
0054          "",
0055          "(",
0056          ")",
0057          "$",
0058          "^",
0059          ".",
0060          "*",
0061          "+",
0062          "?",
0063          "[",
0064          "]",
0065          "|",
0066          "\\",
0067          "#",
0068          "-",
0069          "{",
0070          "}",
0071          "0123456789",
0072          "b",
0073          "B",
0074          "<",
0075          ">",
0076          "",
0077          "",
0078          "A`",
0079          "z'",
0080          "\n",
0081          ",",
0082          "a",
0083          "f",
0084          "n",
0085          "r",
0086          "t",
0087          "v",
0088          "x",
0089          "c",
0090          ":",
0091          "=",
0092          "e",
0093          "",
0094          "",
0095          "",
0096          "",
0097          "",
0098          "",
0099          "",
0100          "",
0101          "E",
0102          "Q",
0103          "X",
0104          "C",
0105          "Z",
0106          "G",
0107          "!",
0108          "p",
0109          "P",
0110          "N",
0111          "gk",
0112          "K",
0113          "R",
0114    };
0115 
0116    return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]);
0117 }
0118 
0119 inline const char*  get_default_error_string(regex_constants::error_type n)
0120 {
0121    static const char* const s_default_error_messages[] = {
0122       "Success",                                                            /* REG_NOERROR 0 error_ok */
0123       "No match",                                                           /* REG_NOMATCH 1 error_no_match */
0124       "Invalid regular expression.",                                        /* REG_BADPAT 2 error_bad_pattern */
0125       "Invalid collation character.",                                       /* REG_ECOLLATE 3 error_collate */
0126       "Invalid character class name, collating name, or character range.",  /* REG_ECTYPE 4 error_ctype */
0127       "Invalid or unterminated escape sequence.",                           /* REG_EESCAPE 5 error_escape */
0128       "Invalid back reference: specified capturing group does not exist.",  /* REG_ESUBREG 6 error_backref */
0129       "Unmatched [ or [^ in character class declaration.",                  /* REG_EBRACK 7 error_brack */
0130       "Unmatched marking parenthesis ( or \\(.",                            /* REG_EPAREN 8 error_paren */
0131       "Unmatched quantified repeat operator { or \\{.",                     /* REG_EBRACE 9 error_brace */
0132       "Invalid content of repeat range.",                                   /* REG_BADBR 10 error_badbrace */
0133       "Invalid range end in character class",                               /* REG_ERANGE 11 error_range */
0134       "Out of memory.",                                                     /* REG_ESPACE 12 error_space NOT USED */
0135       "Invalid preceding regular expression prior to repetition operator.", /* REG_BADRPT 13 error_badrepeat */
0136       "Premature end of regular expression",                                /* REG_EEND 14 error_end NOT USED */
0137       "Regular expression is too large.",                                   /* REG_ESIZE 15 error_size NOT USED */
0138       "Unmatched ) or \\)",                                                 /* REG_ERPAREN 16 error_right_paren NOT USED */
0139       "Empty regular expression.",                                          /* REG_EMPTY 17 error_empty */
0140       "The complexity of matching the regular expression exceeded predefined bounds.  "
0141       "Try refactoring the regular expression to make each choice made by the state machine unambiguous.  "
0142       "This exception is thrown to prevent \"eternal\" matches that take an "
0143       "indefinite period time to locate.",                                  /* REG_ECOMPLEXITY 18 error_complexity */
0144       "Ran out of stack space trying to match the regular expression.",     /* REG_ESTACK 19 error_stack */
0145       "Invalid or unterminated Perl (?...) sequence.",                      /* REG_E_PERL 20 error_perl */
0146       "Unknown error.",                                                     /* REG_E_UNKNOWN 21 error_unknown */
0147    };
0148 
0149    return (n > ::boost::regex_constants::error_unknown) ? s_default_error_messages[::boost::regex_constants::error_unknown] : s_default_error_messages[n];
0150 }
0151 
0152 inline regex_constants::syntax_type  get_default_syntax_type(char c)
0153 {
0154    //
0155    // char_syntax determines how the compiler treats a given character
0156    // in a regular expression.
0157    //
0158    static regex_constants::syntax_type char_syntax[] = {
0159       regex_constants::syntax_char,        /**/
0160       regex_constants::syntax_char,        /**/
0161       regex_constants::syntax_char,        /**/
0162       regex_constants::syntax_char,        /**/
0163       regex_constants::syntax_char,        /**/
0164       regex_constants::syntax_char,        /**/
0165       regex_constants::syntax_char,        /**/
0166       regex_constants::syntax_char,        /**/
0167       regex_constants::syntax_char,        /**/
0168       regex_constants::syntax_char,        /**/
0169       regex_constants::syntax_newline,     /**/
0170       regex_constants::syntax_char,        /**/
0171       regex_constants::syntax_char,        /**/
0172       regex_constants::syntax_char,        /**/
0173       regex_constants::syntax_char,        /**/
0174       regex_constants::syntax_char,        /**/
0175       regex_constants::syntax_char,        /**/
0176       regex_constants::syntax_char,        /**/
0177       regex_constants::syntax_char,        /**/
0178       regex_constants::syntax_char,        /**/
0179       regex_constants::syntax_char,        /**/
0180       regex_constants::syntax_char,        /**/
0181       regex_constants::syntax_char,        /**/
0182       regex_constants::syntax_char,        /**/
0183       regex_constants::syntax_char,        /**/
0184       regex_constants::syntax_char,        /**/
0185       regex_constants::syntax_char,        /**/
0186       regex_constants::syntax_char,        /**/
0187       regex_constants::syntax_char,        /**/
0188       regex_constants::syntax_char,        /**/
0189       regex_constants::syntax_char,        /**/
0190       regex_constants::syntax_char,        /**/
0191       regex_constants::syntax_char,        /* */    // 32
0192       regex_constants::syntax_not,        /*!*/
0193       regex_constants::syntax_char,        /*"*/
0194       regex_constants::syntax_hash,        /*#*/
0195       regex_constants::syntax_dollar,        /*$*/
0196       regex_constants::syntax_char,        /*%*/
0197       regex_constants::syntax_char,        /*&*/
0198       regex_constants::escape_type_end_buffer,  /*'*/
0199       regex_constants::syntax_open_mark,        /*(*/
0200       regex_constants::syntax_close_mark,        /*)*/
0201       regex_constants::syntax_star,        /***/
0202       regex_constants::syntax_plus,        /*+*/
0203       regex_constants::syntax_comma,        /*,*/
0204       regex_constants::syntax_dash,        /*-*/
0205       regex_constants::syntax_dot,        /*.*/
0206       regex_constants::syntax_char,        /*/*/
0207       regex_constants::syntax_digit,        /*0*/
0208       regex_constants::syntax_digit,        /*1*/
0209       regex_constants::syntax_digit,        /*2*/
0210       regex_constants::syntax_digit,        /*3*/
0211       regex_constants::syntax_digit,        /*4*/
0212       regex_constants::syntax_digit,        /*5*/
0213       regex_constants::syntax_digit,        /*6*/
0214       regex_constants::syntax_digit,        /*7*/
0215       regex_constants::syntax_digit,        /*8*/
0216       regex_constants::syntax_digit,        /*9*/
0217       regex_constants::syntax_colon,        /*:*/
0218       regex_constants::syntax_char,        /*;*/
0219       regex_constants::escape_type_left_word, /*<*/
0220       regex_constants::syntax_equal,        /*=*/
0221       regex_constants::escape_type_right_word, /*>*/
0222       regex_constants::syntax_question,        /*?*/
0223       regex_constants::syntax_char,        /*@*/
0224       regex_constants::syntax_char,        /*A*/
0225       regex_constants::syntax_char,        /*B*/
0226       regex_constants::syntax_char,        /*C*/
0227       regex_constants::syntax_char,        /*D*/
0228       regex_constants::syntax_char,        /*E*/
0229       regex_constants::syntax_char,        /*F*/
0230       regex_constants::syntax_char,        /*G*/
0231       regex_constants::syntax_char,        /*H*/
0232       regex_constants::syntax_char,        /*I*/
0233       regex_constants::syntax_char,        /*J*/
0234       regex_constants::syntax_char,        /*K*/
0235       regex_constants::syntax_char,        /*L*/
0236       regex_constants::syntax_char,        /*M*/
0237       regex_constants::syntax_char,        /*N*/
0238       regex_constants::syntax_char,        /*O*/
0239       regex_constants::syntax_char,        /*P*/
0240       regex_constants::syntax_char,        /*Q*/
0241       regex_constants::syntax_char,        /*R*/
0242       regex_constants::syntax_char,        /*S*/
0243       regex_constants::syntax_char,        /*T*/
0244       regex_constants::syntax_char,        /*U*/
0245       regex_constants::syntax_char,        /*V*/
0246       regex_constants::syntax_char,        /*W*/
0247       regex_constants::syntax_char,        /*X*/
0248       regex_constants::syntax_char,        /*Y*/
0249       regex_constants::syntax_char,        /*Z*/
0250       regex_constants::syntax_open_set,        /*[*/
0251       regex_constants::syntax_escape,        /*\*/
0252       regex_constants::syntax_close_set,        /*]*/
0253       regex_constants::syntax_caret,        /*^*/
0254       regex_constants::syntax_char,        /*_*/
0255       regex_constants::syntax_char,        /*`*/
0256       regex_constants::syntax_char,        /*a*/
0257       regex_constants::syntax_char,        /*b*/
0258       regex_constants::syntax_char,        /*c*/
0259       regex_constants::syntax_char,        /*d*/
0260       regex_constants::syntax_char,        /*e*/
0261       regex_constants::syntax_char,        /*f*/
0262       regex_constants::syntax_char,        /*g*/
0263       regex_constants::syntax_char,        /*h*/
0264       regex_constants::syntax_char,        /*i*/
0265       regex_constants::syntax_char,        /*j*/
0266       regex_constants::syntax_char,        /*k*/
0267       regex_constants::syntax_char,        /*l*/
0268       regex_constants::syntax_char,        /*m*/
0269       regex_constants::syntax_char,        /*n*/
0270       regex_constants::syntax_char,        /*o*/
0271       regex_constants::syntax_char,        /*p*/
0272       regex_constants::syntax_char,        /*q*/
0273       regex_constants::syntax_char,        /*r*/
0274       regex_constants::syntax_char,        /*s*/
0275       regex_constants::syntax_char,        /*t*/
0276       regex_constants::syntax_char,        /*u*/
0277       regex_constants::syntax_char,        /*v*/
0278       regex_constants::syntax_char,        /*w*/
0279       regex_constants::syntax_char,        /*x*/
0280       regex_constants::syntax_char,        /*y*/
0281       regex_constants::syntax_char,        /*z*/
0282       regex_constants::syntax_open_brace,        /*{*/
0283       regex_constants::syntax_or,        /*|*/
0284       regex_constants::syntax_close_brace,        /*}*/
0285       regex_constants::syntax_char,        /*~*/
0286       regex_constants::syntax_char,        /**/
0287       regex_constants::syntax_char,        /**/
0288       regex_constants::syntax_char,        /**/
0289       regex_constants::syntax_char,        /**/
0290       regex_constants::syntax_char,        /**/
0291       regex_constants::syntax_char,        /**/
0292       regex_constants::syntax_char,        /**/
0293       regex_constants::syntax_char,        /**/
0294       regex_constants::syntax_char,        /**/
0295       regex_constants::syntax_char,        /**/
0296       regex_constants::syntax_char,        /**/
0297       regex_constants::syntax_char,        /**/
0298       regex_constants::syntax_char,        /**/
0299       regex_constants::syntax_char,        /**/
0300       regex_constants::syntax_char,        /**/
0301       regex_constants::syntax_char,        /**/
0302       regex_constants::syntax_char,        /**/
0303       regex_constants::syntax_char,        /**/
0304       regex_constants::syntax_char,        /**/
0305       regex_constants::syntax_char,        /**/
0306       regex_constants::syntax_char,        /**/
0307       regex_constants::syntax_char,        /**/
0308       regex_constants::syntax_char,        /**/
0309       regex_constants::syntax_char,        /**/
0310       regex_constants::syntax_char,        /**/
0311       regex_constants::syntax_char,        /**/
0312       regex_constants::syntax_char,        /**/
0313       regex_constants::syntax_char,        /**/
0314       regex_constants::syntax_char,        /**/
0315       regex_constants::syntax_char,        /**/
0316       regex_constants::syntax_char,        /**/
0317       regex_constants::syntax_char,        /**/
0318       regex_constants::syntax_char,        /**/
0319       regex_constants::syntax_char,        /**/
0320       regex_constants::syntax_char,        /**/
0321       regex_constants::syntax_char,        /**/
0322       regex_constants::syntax_char,        /**/
0323       regex_constants::syntax_char,        /**/
0324       regex_constants::syntax_char,        /**/
0325       regex_constants::syntax_char,        /**/
0326       regex_constants::syntax_char,        /**/
0327       regex_constants::syntax_char,        /**/
0328       regex_constants::syntax_char,        /**/
0329       regex_constants::syntax_char,        /**/
0330       regex_constants::syntax_char,        /**/
0331       regex_constants::syntax_char,        /**/
0332       regex_constants::syntax_char,        /**/
0333       regex_constants::syntax_char,        /**/
0334       regex_constants::syntax_char,        /**/
0335       regex_constants::syntax_char,        /**/
0336       regex_constants::syntax_char,        /**/
0337       regex_constants::syntax_char,        /**/
0338       regex_constants::syntax_char,        /**/
0339       regex_constants::syntax_char,        /**/
0340       regex_constants::syntax_char,        /**/
0341       regex_constants::syntax_char,        /**/
0342    };
0343 
0344    return char_syntax[(unsigned char)c];
0345 }
0346 
0347 inline regex_constants::escape_syntax_type  get_default_escape_syntax_type(char c)
0348 {
0349    //
0350    // char_syntax determines how the compiler treats a given character
0351    // in a regular expression.
0352    //
0353    static regex_constants::escape_syntax_type char_syntax[] = {
0354       regex_constants::escape_type_identity,        /**/
0355       regex_constants::escape_type_identity,        /**/
0356       regex_constants::escape_type_identity,        /**/
0357       regex_constants::escape_type_identity,        /**/
0358       regex_constants::escape_type_identity,        /**/
0359       regex_constants::escape_type_identity,        /**/
0360       regex_constants::escape_type_identity,        /**/
0361       regex_constants::escape_type_identity,        /**/
0362       regex_constants::escape_type_identity,        /**/
0363       regex_constants::escape_type_identity,        /**/
0364       regex_constants::escape_type_identity,     /**/
0365       regex_constants::escape_type_identity,        /**/
0366       regex_constants::escape_type_identity,        /**/
0367       regex_constants::escape_type_identity,        /**/
0368       regex_constants::escape_type_identity,        /**/
0369       regex_constants::escape_type_identity,        /**/
0370       regex_constants::escape_type_identity,        /**/
0371       regex_constants::escape_type_identity,        /**/
0372       regex_constants::escape_type_identity,        /**/
0373       regex_constants::escape_type_identity,        /**/
0374       regex_constants::escape_type_identity,        /**/
0375       regex_constants::escape_type_identity,        /**/
0376       regex_constants::escape_type_identity,        /**/
0377       regex_constants::escape_type_identity,        /**/
0378       regex_constants::escape_type_identity,        /**/
0379       regex_constants::escape_type_identity,        /**/
0380       regex_constants::escape_type_identity,        /**/
0381       regex_constants::escape_type_identity,        /**/
0382       regex_constants::escape_type_identity,        /**/
0383       regex_constants::escape_type_identity,        /**/
0384       regex_constants::escape_type_identity,        /**/
0385       regex_constants::escape_type_identity,        /**/
0386       regex_constants::escape_type_identity,        /* */    // 32
0387       regex_constants::escape_type_identity,        /*!*/
0388       regex_constants::escape_type_identity,        /*"*/
0389       regex_constants::escape_type_identity,        /*#*/
0390       regex_constants::escape_type_identity,        /*$*/
0391       regex_constants::escape_type_identity,        /*%*/
0392       regex_constants::escape_type_identity,        /*&*/
0393       regex_constants::escape_type_end_buffer,        /*'*/
0394       regex_constants::syntax_open_mark,        /*(*/
0395       regex_constants::syntax_close_mark,        /*)*/
0396       regex_constants::escape_type_identity,        /***/
0397       regex_constants::syntax_plus,                 /*+*/
0398       regex_constants::escape_type_identity,        /*,*/
0399       regex_constants::escape_type_identity,        /*-*/
0400       regex_constants::escape_type_identity,        /*.*/
0401       regex_constants::escape_type_identity,        /*/*/
0402       regex_constants::escape_type_decimal,        /*0*/
0403       regex_constants::escape_type_backref,        /*1*/
0404       regex_constants::escape_type_backref,        /*2*/
0405       regex_constants::escape_type_backref,        /*3*/
0406       regex_constants::escape_type_backref,        /*4*/
0407       regex_constants::escape_type_backref,        /*5*/
0408       regex_constants::escape_type_backref,        /*6*/
0409       regex_constants::escape_type_backref,        /*7*/
0410       regex_constants::escape_type_backref,        /*8*/
0411       regex_constants::escape_type_backref,        /*9*/
0412       regex_constants::escape_type_identity,        /*:*/
0413       regex_constants::escape_type_identity,        /*;*/
0414       regex_constants::escape_type_left_word,        /*<*/
0415       regex_constants::escape_type_identity,        /*=*/
0416       regex_constants::escape_type_right_word,        /*>*/
0417       regex_constants::syntax_question,              /*?*/
0418       regex_constants::escape_type_identity,         /*@*/
0419       regex_constants::escape_type_start_buffer,     /*A*/
0420       regex_constants::escape_type_not_word_assert,  /*B*/
0421       regex_constants::escape_type_C,                /*C*/
0422       regex_constants::escape_type_not_class,        /*D*/
0423       regex_constants::escape_type_E,                /*E*/
0424       regex_constants::escape_type_not_class,        /*F*/
0425       regex_constants::escape_type_G,                /*G*/
0426       regex_constants::escape_type_not_class,        /*H*/
0427       regex_constants::escape_type_not_class,        /*I*/
0428       regex_constants::escape_type_not_class,        /*J*/
0429       regex_constants::escape_type_reset_start_mark, /*K*/
0430       regex_constants::escape_type_not_class,        /*L*/
0431       regex_constants::escape_type_not_class,        /*M*/
0432       regex_constants::escape_type_named_char,       /*N*/
0433       regex_constants::escape_type_not_class,        /*O*/
0434       regex_constants::escape_type_not_property,     /*P*/
0435       regex_constants::escape_type_Q,                /*Q*/
0436       regex_constants::escape_type_line_ending,      /*R*/
0437       regex_constants::escape_type_not_class,        /*S*/
0438       regex_constants::escape_type_not_class,        /*T*/
0439       regex_constants::escape_type_not_class,        /*U*/
0440       regex_constants::escape_type_not_class,        /*V*/
0441       regex_constants::escape_type_not_class,        /*W*/
0442       regex_constants::escape_type_X,                /*X*/
0443       regex_constants::escape_type_not_class,        /*Y*/
0444       regex_constants::escape_type_Z,                /*Z*/
0445       regex_constants::escape_type_identity,        /*[*/
0446       regex_constants::escape_type_identity,        /*\*/
0447       regex_constants::escape_type_identity,        /*]*/
0448       regex_constants::escape_type_identity,        /*^*/
0449       regex_constants::escape_type_identity,        /*_*/
0450       regex_constants::escape_type_start_buffer,        /*`*/
0451       regex_constants::escape_type_control_a,        /*a*/
0452       regex_constants::escape_type_word_assert,        /*b*/
0453       regex_constants::escape_type_ascii_control,        /*c*/
0454       regex_constants::escape_type_class,        /*d*/
0455       regex_constants::escape_type_e,        /*e*/
0456       regex_constants::escape_type_control_f,       /*f*/
0457       regex_constants::escape_type_extended_backref,  /*g*/
0458       regex_constants::escape_type_class,        /*h*/
0459       regex_constants::escape_type_class,        /*i*/
0460       regex_constants::escape_type_class,        /*j*/
0461       regex_constants::escape_type_extended_backref, /*k*/
0462       regex_constants::escape_type_class,        /*l*/
0463       regex_constants::escape_type_class,        /*m*/
0464       regex_constants::escape_type_control_n,       /*n*/
0465       regex_constants::escape_type_class,           /*o*/
0466       regex_constants::escape_type_property,        /*p*/
0467       regex_constants::escape_type_class,           /*q*/
0468       regex_constants::escape_type_control_r,       /*r*/
0469       regex_constants::escape_type_class,           /*s*/
0470       regex_constants::escape_type_control_t,       /*t*/
0471       regex_constants::escape_type_class,         /*u*/
0472       regex_constants::escape_type_control_v,       /*v*/
0473       regex_constants::escape_type_class,           /*w*/
0474       regex_constants::escape_type_hex,             /*x*/
0475       regex_constants::escape_type_class,           /*y*/
0476       regex_constants::escape_type_end_buffer,      /*z*/
0477       regex_constants::syntax_open_brace,           /*{*/
0478       regex_constants::syntax_or,                   /*|*/
0479       regex_constants::syntax_close_brace,          /*}*/
0480       regex_constants::escape_type_identity,        /*~*/
0481       regex_constants::escape_type_identity,        /**/
0482       regex_constants::escape_type_identity,        /**/
0483       regex_constants::escape_type_identity,        /**/
0484       regex_constants::escape_type_identity,        /**/
0485       regex_constants::escape_type_identity,        /**/
0486       regex_constants::escape_type_identity,        /**/
0487       regex_constants::escape_type_identity,        /**/
0488       regex_constants::escape_type_identity,        /**/
0489       regex_constants::escape_type_identity,        /**/
0490       regex_constants::escape_type_identity,        /**/
0491       regex_constants::escape_type_identity,        /**/
0492       regex_constants::escape_type_identity,        /**/
0493       regex_constants::escape_type_identity,        /**/
0494       regex_constants::escape_type_identity,        /**/
0495       regex_constants::escape_type_identity,        /**/
0496       regex_constants::escape_type_identity,        /**/
0497       regex_constants::escape_type_identity,        /**/
0498       regex_constants::escape_type_identity,        /**/
0499       regex_constants::escape_type_identity,        /**/
0500       regex_constants::escape_type_identity,        /**/
0501       regex_constants::escape_type_identity,        /**/
0502       regex_constants::escape_type_identity,        /**/
0503       regex_constants::escape_type_identity,        /**/
0504       regex_constants::escape_type_identity,        /**/
0505       regex_constants::escape_type_identity,        /**/
0506       regex_constants::escape_type_identity,        /**/
0507       regex_constants::escape_type_identity,        /**/
0508       regex_constants::escape_type_identity,        /**/
0509       regex_constants::escape_type_identity,        /**/
0510       regex_constants::escape_type_identity,        /**/
0511       regex_constants::escape_type_identity,        /**/
0512       regex_constants::escape_type_identity,        /**/
0513       regex_constants::escape_type_identity,        /**/
0514       regex_constants::escape_type_identity,        /**/
0515       regex_constants::escape_type_identity,        /**/
0516       regex_constants::escape_type_identity,        /**/
0517       regex_constants::escape_type_identity,        /**/
0518       regex_constants::escape_type_identity,        /**/
0519       regex_constants::escape_type_identity,        /**/
0520       regex_constants::escape_type_identity,        /**/
0521       regex_constants::escape_type_identity,        /**/
0522       regex_constants::escape_type_identity,        /**/
0523       regex_constants::escape_type_identity,        /**/
0524       regex_constants::escape_type_identity,        /**/
0525       regex_constants::escape_type_identity,        /**/
0526       regex_constants::escape_type_identity,        /**/
0527       regex_constants::escape_type_identity,        /**/
0528       regex_constants::escape_type_identity,        /**/
0529       regex_constants::escape_type_identity,        /**/
0530       regex_constants::escape_type_identity,        /**/
0531       regex_constants::escape_type_identity,        /**/
0532       regex_constants::escape_type_identity,        /**/
0533       regex_constants::escape_type_identity,        /**/
0534       regex_constants::escape_type_identity,        /**/
0535       regex_constants::escape_type_identity,        /**/
0536       regex_constants::escape_type_identity,        /**/
0537    };
0538 
0539    return char_syntax[(unsigned char)c];
0540 }
0541 
0542 // is charT c a combining character?
0543 inline bool  is_combining_implementation(std::uint_least16_t c)
0544 {
0545    const std::uint_least16_t combining_ranges[] = { 0x0300, 0x0361,
0546                            0x0483, 0x0486,
0547                            0x0903, 0x0903,
0548                            0x093E, 0x0940,
0549                            0x0949, 0x094C,
0550                            0x0982, 0x0983,
0551                            0x09BE, 0x09C0,
0552                            0x09C7, 0x09CC,
0553                            0x09D7, 0x09D7,
0554                            0x0A3E, 0x0A40,
0555                            0x0A83, 0x0A83,
0556                            0x0ABE, 0x0AC0,
0557                            0x0AC9, 0x0ACC,
0558                            0x0B02, 0x0B03,
0559                            0x0B3E, 0x0B3E,
0560                            0x0B40, 0x0B40,
0561                            0x0B47, 0x0B4C,
0562                            0x0B57, 0x0B57,
0563                            0x0B83, 0x0B83,
0564                            0x0BBE, 0x0BBF,
0565                            0x0BC1, 0x0BCC,
0566                            0x0BD7, 0x0BD7,
0567                            0x0C01, 0x0C03,
0568                            0x0C41, 0x0C44,
0569                            0x0C82, 0x0C83,
0570                            0x0CBE, 0x0CBE,
0571                            0x0CC0, 0x0CC4,
0572                            0x0CC7, 0x0CCB,
0573                            0x0CD5, 0x0CD6,
0574                            0x0D02, 0x0D03,
0575                            0x0D3E, 0x0D40,
0576                            0x0D46, 0x0D4C,
0577                            0x0D57, 0x0D57,
0578                            0x0F7F, 0x0F7F,
0579                            0x20D0, 0x20E1,
0580                            0x3099, 0x309A,
0581                            0xFE20, 0xFE23,
0582                            0xffff, 0xffff, };
0583 
0584    const std::uint_least16_t* p = combining_ranges + 1;
0585    while (*p < c) p += 2;
0586    --p;
0587    if ((c >= *p) && (c <= *(p + 1)))
0588       return true;
0589    return false;
0590 }
0591 
0592 template <class charT>
0593 inline bool is_combining(charT c)
0594 {
0595    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)));
0596 }
0597 template <>
0598 inline bool is_combining<char>(char)
0599 {
0600    return false;
0601 }
0602 template <>
0603 inline bool is_combining<signed char>(signed char)
0604 {
0605    return false;
0606 }
0607 template <>
0608 inline bool is_combining<unsigned char>(unsigned char)
0609 {
0610    return false;
0611 }
0612 #ifdef _MSC_VER
0613 template<>
0614 inline bool is_combining<wchar_t>(wchar_t c)
0615 {
0616    return is_combining_implementation(static_cast<unsigned short>(c));
0617 }
0618 #elif !defined(__DECCXX) && !defined(__osf__) && !defined(__OSF__) && defined(WCHAR_MIN) && (WCHAR_MIN == 0) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
0619 #if defined(WCHAR_MAX) && (WCHAR_MAX <= USHRT_MAX)
0620 template<>
0621 inline bool is_combining<wchar_t>(wchar_t c)
0622 {
0623    return is_combining_implementation(static_cast<unsigned short>(c));
0624 }
0625 #else
0626 template<>
0627 inline bool is_combining<wchar_t>(wchar_t c)
0628 {
0629    return (c >= (std::numeric_limits<uint_least16_t>::max)()) ? false : is_combining_implementation(static_cast<unsigned short>(c));
0630 }
0631 #endif
0632 #endif
0633 
0634 //
0635 // is a charT c a line separator?
0636 //
0637 template <class charT>
0638 inline bool is_separator(charT c)
0639 {
0640    return BOOST_REGEX_MAKE_BOOL(
0641       (c == static_cast<charT>('\n'))
0642       || (c == static_cast<charT>('\r'))
0643       || (c == static_cast<charT>('\f'))
0644       || (static_cast<std::uint16_t>(c) == 0x2028u)
0645       || (static_cast<std::uint16_t>(c) == 0x2029u)
0646       || (static_cast<std::uint16_t>(c) == 0x85u));
0647 }
0648 template <>
0649 inline bool is_separator<char>(char c)
0650 {
0651    return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r') || (c == '\f'));
0652 }
0653 
0654 //
0655 // get a default collating element:
0656 //
0657 inline std::string  lookup_default_collate_name(const std::string& name)
0658 {
0659    //
0660    // these are the POSIX collating names:
0661    //
0662    static const char* def_coll_names[] = {
0663    "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "alert", "backspace", "tab", "newline",
0664    "vertical-tab", "form-feed", "carriage-return", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK",
0665    "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "IS4", "IS3", "IS2", "IS1", "space", "exclamation-mark",
0666    "quotation-mark", "number-sign", "dollar-sign", "percent-sign", "ampersand", "apostrophe",
0667    "left-parenthesis", "right-parenthesis", "asterisk", "plus-sign", "comma", "hyphen",
0668    "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
0669    "colon", "semicolon", "less-than-sign", "equals-sign", "greater-than-sign",
0670    "question-mark", "commercial-at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
0671    "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "left-square-bracket", "backslash",
0672    "right-square-bracket", "circumflex", "underscore", "grave-accent", "a", "b", "c", "d", "e", "f",
0673    "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "left-curly-bracket",
0674    "vertical-line", "right-curly-bracket", "tilde", "DEL", "",
0675    };
0676 
0677    // these multi-character collating elements
0678    // should keep most Western-European locales
0679    // happy - we should really localise these a
0680    // little more - but this will have to do for
0681    // now:
0682 
0683    static const char* def_multi_coll[] = {
0684       "ae",
0685       "Ae",
0686       "AE",
0687       "ch",
0688       "Ch",
0689       "CH",
0690       "ll",
0691       "Ll",
0692       "LL",
0693       "ss",
0694       "Ss",
0695       "SS",
0696       "nj",
0697       "Nj",
0698       "NJ",
0699       "dz",
0700       "Dz",
0701       "DZ",
0702       "lj",
0703       "Lj",
0704       "LJ",
0705       "",
0706    };
0707 
0708    unsigned int i = 0;
0709    while (*def_coll_names[i])
0710    {
0711       if (def_coll_names[i] == name)
0712       {
0713          return std::string(1, char(i));
0714       }
0715       ++i;
0716    }
0717    i = 0;
0718    while (*def_multi_coll[i])
0719    {
0720       if (def_multi_coll[i] == name)
0721       {
0722          return def_multi_coll[i];
0723       }
0724       ++i;
0725    }
0726    return std::string();
0727 }
0728 
0729 //
0730 // get the state_id of a character classification, the individual
0731 // traits classes then transform that state_id into a bitmask:
0732 //
0733 template <class charT>
0734 struct character_pointer_range
0735 {
0736    const charT* p1;
0737    const charT* p2;
0738 
0739    bool operator < (const character_pointer_range& r)const
0740    {
0741       return std::lexicographical_compare(p1, p2, r.p1, r.p2);
0742    }
0743    bool operator == (const character_pointer_range& r)const
0744    {
0745       // Not only do we check that the ranges are of equal size before
0746       // calling std::equal, but there is no other algorithm available:
0747       // not even a non-standard MS one.  So forward to unchecked_equal
0748       // in the MS case.
0749 #ifdef __cpp_lib_robust_nonmodifying_seq_ops
0750       return std::equal(p1, p2, r.p1, r.p2);
0751 #elif defined(BOOST_REGEX_MSVC)
0752       if (((p2 - p1) != (r.p2 - r.p1)))
0753          return false;
0754       const charT* with = r.p1;
0755       const charT* pos = p1;
0756       while (pos != p2)
0757          if (*pos++ != *with++) return false;
0758       return true;
0759 
0760 #else
0761       return ((p2 - p1) == (r.p2 - r.p1)) && std::equal(p1, p2, r.p1);
0762 #endif
0763    }
0764 };
0765 template <class charT>
0766 int get_default_class_id(const charT* p1, const charT* p2)
0767 {
0768    static const charT data[73] = {
0769       'a', 'l', 'n', 'u', 'm',
0770       'a', 'l', 'p', 'h', 'a',
0771       'b', 'l', 'a', 'n', 'k',
0772       'c', 'n', 't', 'r', 'l',
0773       'd', 'i', 'g', 'i', 't',
0774       'g', 'r', 'a', 'p', 'h',
0775       'l', 'o', 'w', 'e', 'r',
0776       'p', 'r', 'i', 'n', 't',
0777       'p', 'u', 'n', 'c', 't',
0778       's', 'p', 'a', 'c', 'e',
0779       'u', 'n', 'i', 'c', 'o', 'd', 'e',
0780       'u', 'p', 'p', 'e', 'r',
0781       'v',
0782       'w', 'o', 'r', 'd',
0783       'x', 'd', 'i', 'g', 'i', 't',
0784    };
0785 
0786    static const character_pointer_range<charT> ranges[21] =
0787    {
0788       {data+0, data+5,}, // alnum
0789       {data+5, data+10,}, // alpha
0790       {data+10, data+15,}, // blank
0791       {data+15, data+20,}, // cntrl
0792       {data+20, data+21,}, // d
0793       {data+20, data+25,}, // digit
0794       {data+25, data+30,}, // graph
0795       {data+29, data+30,}, // h
0796       {data+30, data+31,}, // l
0797       {data+30, data+35,}, // lower
0798       {data+35, data+40,}, // print
0799       {data+40, data+45,}, // punct
0800       {data+45, data+46,}, // s
0801       {data+45, data+50,}, // space
0802       {data+57, data+58,}, // u
0803       {data+50, data+57,}, // unicode
0804       {data+57, data+62,}, // upper
0805       {data+62, data+63,}, // v
0806       {data+63, data+64,}, // w
0807       {data+63, data+67,}, // word
0808       {data+67, data+73,}, // xdigit
0809    };
0810    const character_pointer_range<charT>* ranges_begin = ranges;
0811    const character_pointer_range<charT>* ranges_end = ranges + (sizeof(ranges)/sizeof(ranges[0]));
0812 
0813    character_pointer_range<charT> t = { p1, p2, };
0814    const character_pointer_range<charT>* p = std::lower_bound(ranges_begin, ranges_end, t);
0815    if((p != ranges_end) && (t == *p))
0816       return static_cast<int>(p - ranges);
0817    return -1;
0818 }
0819 
0820 //
0821 // helper functions:
0822 //
0823 template <class charT>
0824 std::ptrdiff_t global_length(const charT* p)
0825 {
0826    std::ptrdiff_t n = 0;
0827    while(*p)
0828    {
0829       ++p;
0830       ++n;
0831    }
0832    return n;
0833 }
0834 template<>
0835 inline std::ptrdiff_t global_length<char>(const char* p)
0836 {
0837    return (std::strlen)(p);
0838 }
0839 #ifndef BOOST_NO_WREGEX
0840 template<>
0841 inline std::ptrdiff_t global_length<wchar_t>(const wchar_t* p)
0842 {
0843    return (std::ptrdiff_t)(std::wcslen)(p);
0844 }
0845 #endif
0846 template <class charT>
0847 inline charT  global_lower(charT c)
0848 {
0849    return c;
0850 }
0851 template <class charT>
0852 inline charT  global_upper(charT c)
0853 {
0854    return c;
0855 }
0856 
0857 inline char  do_global_lower(char c)
0858 {
0859    return static_cast<char>((std::tolower)((unsigned char)c));
0860 }
0861 
0862 inline char  do_global_upper(char c)
0863 {
0864    return static_cast<char>((std::toupper)((unsigned char)c));
0865 }
0866 #ifndef BOOST_NO_WREGEX
0867 inline wchar_t  do_global_lower(wchar_t c)
0868 {
0869    return (std::towlower)(c);
0870 }
0871 
0872 inline wchar_t  do_global_upper(wchar_t c)
0873 {
0874    return (std::towupper)(c);
0875 }
0876 #endif
0877 //
0878 // This sucks: declare template specialisations of global_lower/global_upper
0879 // that just forward to the non-template implementation functions.  We do
0880 // this because there is one compiler (Compaq Tru64 C++) that doesn't seem
0881 // to differentiate between templates and non-template overloads....
0882 // what's more, the primary template, plus all overloads have to be
0883 // defined in the same translation unit (if one is inline they all must be)
0884 // otherwise the "local template instantiation" compiler option can pick
0885 // the wrong instantiation when linking:
0886 //
0887 template<> inline char  global_lower<char>(char c) { return do_global_lower(c); }
0888 template<> inline char  global_upper<char>(char c) { return do_global_upper(c); }
0889 #ifndef BOOST_NO_WREGEX
0890 template<> inline wchar_t  global_lower<wchar_t>(wchar_t c) { return do_global_lower(c); }
0891 template<> inline wchar_t  global_upper<wchar_t>(wchar_t c) { return do_global_upper(c); }
0892 #endif
0893 
0894 template <class charT>
0895 int global_value(charT c)
0896 {
0897    static const charT zero = '0';
0898    static const charT nine = '9';
0899    static const charT a = 'a';
0900    static const charT f = 'f';
0901    static const charT A = 'A';
0902    static const charT F = 'F';
0903 
0904    if(c > f) return -1;
0905    if(c >= a) return 10 + (c - a);
0906    if(c > F) return -1;
0907    if(c >= A) return 10 + (c - A);
0908    if(c > nine) return -1;
0909    if(c >= zero) return c - zero;
0910    return -1;
0911 }
0912 template <class charT, class traits>
0913 std::intmax_t global_toi(const charT*& p1, const charT* p2, int radix, const traits& t)
0914 {
0915    (void)t; // warning suppression
0916    std::intmax_t limit = (std::numeric_limits<std::intmax_t>::max)() / radix;
0917    std::intmax_t next_value = t.value(*p1, radix);
0918    if((p1 == p2) || (next_value < 0) || (next_value >= radix))
0919       return -1;
0920    std::intmax_t result = 0;
0921    while(p1 != p2)
0922    {
0923       next_value = t.value(*p1, radix);
0924       if((next_value < 0) || (next_value >= radix))
0925          break;
0926       result *= radix;
0927       result += next_value;
0928       ++p1;
0929       if (result > limit)
0930          return -1;
0931    }
0932    return result;
0933 }
0934 
0935 template <class charT>
0936 inline typename std::enable_if<(sizeof(charT) > 1), const charT*>::type get_escape_R_string()
0937 {
0938 #ifdef BOOST_REGEX_MSVC
0939 #  pragma warning(push)
0940 #  pragma warning(disable:4309 4245)
0941 #endif
0942    static const charT e1[] = { '(', '?', '-', 'x', ':', '(', '?', '>', '\x0D', '\x0A', '?',
0943       '|', '[', '\x0A', '\x0B', '\x0C', static_cast<charT>(0x85), static_cast<charT>(0x2028),
0944       static_cast<charT>(0x2029), ']', ')', ')', '\0' };
0945    static const charT e2[] = { '(', '?', '-', 'x', ':', '(', '?', '>', '\x0D', '\x0A', '?',
0946       '|', '[', '\x0A', '\x0B', '\x0C', static_cast<charT>(0x85), ']', ')', ')', '\0' };
0947 
0948    charT c = static_cast<charT>(0x2029u);
0949    bool b = (static_cast<unsigned>(c) == 0x2029u);
0950 
0951    return (b ? e1 : e2);
0952 #ifdef BOOST_REGEX_MSVC
0953 #  pragma warning(pop)
0954 #endif
0955 }
0956 
0957 template <class charT>
0958 inline typename std::enable_if<(sizeof(charT) == 1), const charT*>::type get_escape_R_string()
0959 {
0960 #ifdef BOOST_REGEX_MSVC
0961 #  pragma warning(push)
0962 #  pragma warning(disable:4309 4245)
0963 #endif
0964    static const charT e2[] = { 
0965       static_cast<charT>('('), 
0966       static_cast<charT>('?'), 
0967       static_cast<charT>('-'), 
0968       static_cast<charT>('x'), 
0969       static_cast<charT>(':'), 
0970       static_cast<charT>('('), 
0971       static_cast<charT>('?'), 
0972       static_cast<charT>('>'), 
0973       static_cast<charT>('\x0D'), 
0974       static_cast<charT>('\x0A'), 
0975       static_cast<charT>('?'),
0976       static_cast<charT>('|'), 
0977       static_cast<charT>('['), 
0978       static_cast<charT>('\x0A'), 
0979       static_cast<charT>('\x0B'), 
0980       static_cast<charT>('\x0C'), 
0981       static_cast<charT>('\x85'), 
0982       static_cast<charT>(']'), 
0983       static_cast<charT>(')'), 
0984       static_cast<charT>(')'), 
0985       static_cast<charT>('\0') 
0986    };
0987    return e2;
0988 #ifdef BOOST_REGEX_MSVC
0989 #  pragma warning(pop)
0990 #endif
0991 }
0992 
0993 } // BOOST_REGEX_DETAIL_NS
0994 } // boost
0995 
0996 #endif