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