Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- regex ------------------------------------===// |
| 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is distributed under the University of Illinois Open Source |
| 7 | // License. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_REGEX |
| 12 | #define _LIBCPP_REGEX |
| 13 | |
| 14 | /* |
| 15 | regex synopsis |
| 16 | |
| 17 | #include <initializer_list> |
| 18 | |
| 19 | namespace std |
| 20 | { |
| 21 | |
| 22 | namespace regex_constants |
| 23 | { |
| 24 | |
| 25 | emum syntax_option_type |
| 26 | { |
| 27 | icase = unspecified, |
| 28 | nosubs = unspecified, |
| 29 | optimize = unspecified, |
| 30 | collate = unspecified, |
| 31 | ECMAScript = unspecified, |
| 32 | basic = unspecified, |
| 33 | extended = unspecified, |
| 34 | awk = unspecified, |
| 35 | grep = unspecified, |
| 36 | egrep = unspecified |
| 37 | }; |
| 38 | |
| 39 | constexpr syntax_option_type operator~(syntax_option_type f); |
| 40 | constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs); |
| 41 | constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs); |
| 42 | |
| 43 | enum match_flag_type |
| 44 | { |
| 45 | match_default = 0, |
| 46 | match_not_bol = unspecified, |
| 47 | match_not_eol = unspecified, |
| 48 | match_not_bow = unspecified, |
| 49 | match_not_eow = unspecified, |
| 50 | match_any = unspecified, |
| 51 | match_not_null = unspecified, |
| 52 | match_continuous = unspecified, |
| 53 | match_prev_avail = unspecified, |
| 54 | format_default = 0, |
| 55 | format_sed = unspecified, |
| 56 | format_no_copy = unspecified, |
| 57 | format_first_only = unspecified |
| 58 | }; |
| 59 | |
| 60 | constexpr match_flag_type operator~(match_flag_type f); |
| 61 | constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs); |
| 62 | constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs); |
| 63 | |
| 64 | enum error_type |
| 65 | { |
| 66 | error_collate = unspecified, |
| 67 | error_ctype = unspecified, |
| 68 | error_escape = unspecified, |
| 69 | error_backref = unspecified, |
| 70 | error_brack = unspecified, |
| 71 | error_paren = unspecified, |
| 72 | error_brace = unspecified, |
| 73 | error_badbrace = unspecified, |
| 74 | error_range = unspecified, |
| 75 | error_space = unspecified, |
| 76 | error_badrepeat = unspecified, |
| 77 | error_complexity = unspecified, |
| 78 | error_stack = unspecified |
| 79 | }; |
| 80 | |
| 81 | } // regex_constants |
| 82 | |
| 83 | class regex_error |
| 84 | : public runtime_error |
| 85 | { |
| 86 | public: |
| 87 | explicit regex_error(regex_constants::error_type ecode); |
| 88 | regex_constants::error_type code() const; |
| 89 | }; |
| 90 | |
| 91 | template <class charT> |
| 92 | struct regex_traits |
| 93 | { |
| 94 | public: |
| 95 | typedef charT char_type; |
| 96 | typedef basic_string<char_type> string_type; |
| 97 | typedef locale locale_type; |
| 98 | typedef /bitmask_type/ char_class_type; |
| 99 | |
| 100 | regex_traits(); |
| 101 | |
| 102 | static size_t length(const char_type* p); |
| 103 | charT translate(charT c) const; |
| 104 | charT translate_nocase(charT c) const; |
| 105 | template <class ForwardIterator> |
| 106 | string_type |
| 107 | transform(ForwardIterator first, ForwardIterator last) const; |
| 108 | template <class ForwardIterator> |
| 109 | string_type |
| 110 | transform_primary( ForwardIterator first, ForwardIterator last) const; |
| 111 | template <class ForwardIterator> |
| 112 | string_type |
| 113 | lookup_collatename(ForwardIterator first, ForwardIterator last) const; |
| 114 | template <class ForwardIterator> |
| 115 | char_class_type |
| 116 | lookup_classname(ForwardIterator first, ForwardIterator last, |
| 117 | bool icase = false) const; |
| 118 | bool isctype(charT c, char_class_type f) const; |
| 119 | int value(charT ch, int radix) const; |
| 120 | locale_type imbue(locale_type l); |
| 121 | locale_type getloc()const; |
| 122 | }; |
| 123 | |
| 124 | template <class charT, class traits = regex_traits<charT>> |
| 125 | class basic_regex |
| 126 | { |
| 127 | public: |
| 128 | // types: |
| 129 | typedef charT value_type; |
| 130 | typedef regex_constants::syntax_option_type flag_type; |
| 131 | typedef typename traits::locale_type locale_type; |
| 132 | |
| 133 | // constants: |
| 134 | static constexpr regex_constants::syntax_option_type icase = regex_constants::icase; |
| 135 | static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs; |
| 136 | static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize; |
| 137 | static constexpr regex_constants::syntax_option_type collate = regex_constants::collate; |
| 138 | static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; |
| 139 | static constexpr regex_constants::syntax_option_type basic = regex_constants::basic; |
| 140 | static constexpr regex_constants::syntax_option_type extended = regex_constants::extended; |
| 141 | static constexpr regex_constants::syntax_option_type awk = regex_constants::awk; |
| 142 | static constexpr regex_constants::syntax_option_type grep = regex_constants::grep; |
| 143 | static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep; |
| 144 | |
| 145 | // construct/copy/destroy: |
| 146 | basic_regex(); |
| 147 | explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); |
| 148 | basic_regex(const charT* p, size_t len, flag_type f); |
| 149 | basic_regex(const basic_regex&); |
| 150 | basic_regex(basic_regex&&); |
| 151 | template <class ST, class SA> |
| 152 | explicit basic_regex(const basic_string<charT, ST, SA>& p, |
| 153 | flag_type f = regex_constants::ECMAScript); |
| 154 | template <class ForwardIterator> |
| 155 | basic_regex(ForwardIterator first, ForwardIterator last, |
| 156 | flag_type f = regex_constants::ECMAScript); |
| 157 | basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript); |
| 158 | |
| 159 | ~basic_regex(); |
| 160 | |
| 161 | basic_regex& operator=(const basic_regex&); |
| 162 | basic_regex& operator=(basic_regex&&); |
| 163 | basic_regex& operator=(const charT* ptr); |
| 164 | basic_regex& operator=(initializer_list<charT> il); |
| 165 | template <class ST, class SA> |
| 166 | basic_regex& operator=(const basic_string<charT, ST, SA>& p); |
| 167 | |
| 168 | // assign: |
| 169 | basic_regex& assign(const basic_regex& that); |
| 170 | basic_regex& assign(basic_regex&& that); |
| 171 | basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript); |
| 172 | basic_regex& assign(const charT* p, size_t len, flag_type f); |
| 173 | template <class string_traits, class A> |
| 174 | basic_regex& assign(const basic_string<charT, string_traits, A>& s, |
| 175 | flag_type f = regex_constants::ECMAScript); |
| 176 | template <class InputIterator> |
| 177 | basic_regex& assign(InputIterator first, InputIterator last, |
| 178 | flag_type f = regex_constants::ECMAScript); |
| 179 | basic_regex& assign(initializer_list<charT>, flag_type = regex_constants::ECMAScript); |
| 180 | |
| 181 | // const operations: |
| 182 | unsigned mark_count() const; |
| 183 | flag_type flags() const; |
| 184 | |
| 185 | // locale: |
| 186 | locale_type imbue(locale_type loc); |
| 187 | locale_type getloc() const; |
| 188 | |
| 189 | // swap: |
| 190 | void swap(basic_regex&); |
| 191 | }; |
| 192 | |
| 193 | typedef basic_regex<char> regex; |
| 194 | typedef basic_regex<wchar_t> wregex; |
| 195 | |
| 196 | template <class charT, class traits> |
| 197 | void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2); |
| 198 | |
| 199 | template <class BidirectionalIterator> |
| 200 | class sub_match |
| 201 | : public pair<BidirectionalIterator, BidirectionalIterator> |
| 202 | { |
| 203 | public: |
| 204 | typedef typename iterator_traits<BidirectionalIterator>::value_type value_type; |
| 205 | typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type; |
| 206 | typedef BidirectionalIterator iterator; |
| 207 | typedef basic_string<value_type> string_type; |
| 208 | |
| 209 | bool matched; |
| 210 | |
| 211 | difference_type length() const; |
| 212 | operator string_type() const; |
| 213 | string_type str() const; |
| 214 | |
| 215 | int compare(const sub_match& s) const; |
| 216 | int compare(const string_type& s) const; |
| 217 | int compare(const value_type* s) const; |
| 218 | }; |
| 219 | |
| 220 | typedef sub_match<const char*> csub_match; |
| 221 | typedef sub_match<const wchar_t*> wcsub_match; |
| 222 | typedef sub_match<string::const_iterator> ssub_match; |
| 223 | typedef sub_match<wstring::const_iterator> wssub_match; |
| 224 | |
| 225 | template <class BiIter> |
| 226 | bool |
| 227 | operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); |
| 228 | |
| 229 | template <class BiIter> |
| 230 | bool |
| 231 | operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); |
| 232 | |
| 233 | template <class BiIter> |
| 234 | bool |
| 235 | operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); |
| 236 | |
| 237 | template <class BiIter> |
| 238 | bool |
| 239 | operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); |
| 240 | |
| 241 | template <class BiIter> |
| 242 | bool |
| 243 | operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); |
| 244 | |
| 245 | template <class BiIter> |
| 246 | bool |
| 247 | operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs); |
| 248 | |
| 249 | template <class BiIter, class ST, class SA> |
| 250 | bool |
| 251 | operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, |
| 252 | const sub_match<BiIter>& rhs); |
| 253 | |
| 254 | template <class BiIter, class ST, class SA> |
| 255 | bool |
| 256 | operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, |
| 257 | const sub_match<BiIter>& rhs); |
| 258 | |
| 259 | template <class BiIter, class ST, class SA> |
| 260 | bool |
| 261 | operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, |
| 262 | const sub_match<BiIter>& rhs); |
| 263 | |
| 264 | template <class BiIter, class ST, class SA> |
| 265 | bool |
| 266 | operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, |
| 267 | const sub_match<BiIter>& rhs); |
| 268 | |
| 269 | template <class BiIter, class ST, class SA> |
| 270 | bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, |
| 271 | const sub_match<BiIter>& rhs); |
| 272 | |
| 273 | template <class BiIter, class ST, class SA> |
| 274 | bool |
| 275 | operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs, |
| 276 | const sub_match<BiIter>& rhs); |
| 277 | |
| 278 | template <class BiIter, class ST, class SA> |
| 279 | bool |
| 280 | operator==(const sub_match<BiIter>& lhs, |
| 281 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); |
| 282 | |
| 283 | template <class BiIter, class ST, class SA> |
| 284 | bool |
| 285 | operator!=(const sub_match<BiIter>& lhs, |
| 286 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); |
| 287 | |
| 288 | template <class BiIter, class ST, class SA> |
| 289 | bool |
| 290 | operator<(const sub_match<BiIter>& lhs, |
| 291 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); |
| 292 | |
| 293 | template <class BiIter, class ST, class SA> |
| 294 | bool operator>(const sub_match<BiIter>& lhs, |
| 295 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); |
| 296 | |
| 297 | template <class BiIter, class ST, class SA> |
| 298 | bool |
| 299 | operator>=(const sub_match<BiIter>& lhs, |
| 300 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); |
| 301 | |
| 302 | template <class BiIter, class ST, class SA> |
| 303 | bool |
| 304 | operator<=(const sub_match<BiIter>& lhs, |
| 305 | const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs); |
| 306 | |
| 307 | template <class BiIter> |
| 308 | bool |
| 309 | operator==(typename iterator_traits<BiIter>::value_type const* lhs, |
| 310 | const sub_match<BiIter>& rhs); |
| 311 | |
| 312 | template <class BiIter> |
| 313 | bool |
| 314 | operator!=(typename iterator_traits<BiIter>::value_type const* lhs, |
| 315 | const sub_match<BiIter>& rhs); |
| 316 | |
| 317 | template <class BiIter> |
| 318 | bool |
| 319 | operator<(typename iterator_traits<BiIter>::value_type const* lhs, |
| 320 | const sub_match<BiIter>& rhs); |
| 321 | |
| 322 | template <class BiIter> |
| 323 | bool |
| 324 | operator>(typename iterator_traits<BiIter>::value_type const* lhs, |
| 325 | const sub_match<BiIter>& rhs); |
| 326 | |
| 327 | template <class BiIter> |
| 328 | bool |
| 329 | operator>=(typename iterator_traits<BiIter>::value_type const* lhs, |
| 330 | const sub_match<BiIter>& rhs); |
| 331 | |
| 332 | template <class BiIter> |
| 333 | bool |
| 334 | operator<=(typename iterator_traits<BiIter>::value_type const* lhs, |
| 335 | const sub_match<BiIter>& rhs); |
| 336 | |
| 337 | template <class BiIter> |
| 338 | bool |
| 339 | operator==(const sub_match<BiIter>& lhs, |
| 340 | typename iterator_traits<BiIter>::value_type const* rhs); |
| 341 | |
| 342 | template <class BiIter> |
| 343 | bool |
| 344 | operator!=(const sub_match<BiIter>& lhs, |
| 345 | typename iterator_traits<BiIter>::value_type const* rhs); |
| 346 | |
| 347 | template <class BiIter> |
| 348 | bool |
| 349 | operator<(const sub_match<BiIter>& lhs, |
| 350 | typename iterator_traits<BiIter>::value_type const* rhs); |
| 351 | |
| 352 | template <class BiIter> |
| 353 | bool |
| 354 | operator>(const sub_match<BiIter>& lhs, |
| 355 | typename iterator_traits<BiIter>::value_type const* rhs); |
| 356 | |
| 357 | template <class BiIter> |
| 358 | bool |
| 359 | operator>=(const sub_match<BiIter>& lhs, |
| 360 | typename iterator_traits<BiIter>::value_type const* rhs); |
| 361 | |
| 362 | template <class BiIter> |
| 363 | bool |
| 364 | operator<=(const sub_match<BiIter>& lhs, |
| 365 | typename iterator_traits<BiIter>::value_type const* rhs); |
| 366 | |
| 367 | template <class BiIter> |
| 368 | bool |
| 369 | operator==(typename iterator_traits<BiIter>::value_type const& lhs, |
| 370 | const sub_match<BiIter>& rhs); |
| 371 | |
| 372 | template <class BiIter> |
| 373 | bool |
| 374 | operator!=(typename iterator_traits<BiIter>::value_type const& lhs, |
| 375 | const sub_match<BiIter>& rhs); |
| 376 | |
| 377 | template <class BiIter> |
| 378 | bool |
| 379 | operator<(typename iterator_traits<BiIter>::value_type const& lhs, |
| 380 | const sub_match<BiIter>& rhs); |
| 381 | |
| 382 | template <class BiIter> |
| 383 | bool |
| 384 | operator>(typename iterator_traits<BiIter>::value_type const& lhs, |
| 385 | const sub_match<BiIter>& rhs); |
| 386 | |
| 387 | template <class BiIter> |
| 388 | bool |
| 389 | operator>=(typename iterator_traits<BiIter>::value_type const& lhs, |
| 390 | const sub_match<BiIter>& rhs); |
| 391 | |
| 392 | template <class BiIter> |
| 393 | bool |
| 394 | operator<=(typename iterator_traits<BiIter>::value_type const& lhs, |
| 395 | const sub_match<BiIter>& rhs); |
| 396 | |
| 397 | template <class BiIter> |
| 398 | bool |
| 399 | operator==(const sub_match<BiIter>& lhs, |
| 400 | typename iterator_traits<BiIter>::value_type const& rhs); |
| 401 | |
| 402 | template <class BiIter> |
| 403 | bool |
| 404 | operator!=(const sub_match<BiIter>& lhs, |
| 405 | typename iterator_traits<BiIter>::value_type const& rhs); |
| 406 | |
| 407 | template <class BiIter> |
| 408 | bool |
| 409 | operator<(const sub_match<BiIter>& lhs, |
| 410 | typename iterator_traits<BiIter>::value_type const& rhs); |
| 411 | |
| 412 | template <class BiIter> |
| 413 | bool |
| 414 | operator>(const sub_match<BiIter>& lhs, |
| 415 | typename iterator_traits<BiIter>::value_type const& rhs); |
| 416 | |
| 417 | template <class BiIter> |
| 418 | bool |
| 419 | operator>=(const sub_match<BiIter>& lhs, |
| 420 | typename iterator_traits<BiIter>::value_type const& rhs); |
| 421 | |
| 422 | template <class BiIter> |
| 423 | bool |
| 424 | operator<=(const sub_match<BiIter>& lhs, |
| 425 | typename iterator_traits<BiIter>::value_type const& rhs); |
| 426 | |
| 427 | template <class charT, class ST, class BiIter> |
| 428 | basic_ostream<charT, ST>& |
| 429 | operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m); |
| 430 | |
| 431 | template <class BidirectionalIterator, |
| 432 | class Allocator = allocator<sub_match<BidirectionalIterator>>> |
| 433 | class match_results |
| 434 | { |
| 435 | public: |
| 436 | typedef sub_match<BidirectionalIterator> value_type; |
| 437 | typedef const value_type& const_reference; |
| 438 | typedef const_reference reference; |
| 439 | typedef /implementation-defined/ const_iterator; |
| 440 | typedef const_iterator iterator; |
| 441 | typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type; |
| 442 | typedef typename allocator_traits<Allocator>::size_type size_type; |
| 443 | typedef Allocator allocator_type; |
| 444 | typedef typename iterator_traits<BidirectionalIterator>::value_type char_type; |
| 445 | typedef basic_string<char_type> string_type; |
| 446 | |
| 447 | // construct/copy/destroy: |
| 448 | explicit match_results(const Allocator& a = Allocator()); |
| 449 | match_results(const match_results& m); |
| 450 | match_results(match_results&& m); |
| 451 | match_results& operator=(const match_results& m); |
| 452 | match_results& operator=(match_results&& m); |
| 453 | ~match_results(); |
| 454 | |
| 455 | // size: |
| 456 | size_type size() const; |
| 457 | size_type max_size() const; |
| 458 | bool empty() const; |
| 459 | |
| 460 | // element access: |
| 461 | difference_type length(size_type sub = 0) const; |
| 462 | difference_type position(size_type sub = 0) const; |
| 463 | string_type str(size_type sub = 0) const; |
| 464 | const_reference operator[](size_type n) const; |
| 465 | |
| 466 | const_reference prefix() const; |
| 467 | const_reference suffix() const; |
| 468 | |
| 469 | const_iterator begin() const; |
| 470 | const_iterator end() const; |
| 471 | const_iterator cbegin() const; |
| 472 | const_iterator cend() const; |
| 473 | |
| 474 | // format: |
| 475 | template <class OutputIter> |
| 476 | OutputIter |
| 477 | format(OutputIter out, const char_type* fmt_first, |
| 478 | const char_type* fmt_last, |
| 479 | regex_constants::match_flag_type flags = regex_constants::format_default) const; |
| 480 | template <class OutputIter, class ST, class SA> |
| 481 | OutputIter |
| 482 | format(OutputIter out, const basic_string<char_type, ST, SA>& fmt, |
| 483 | regex_constants::match_flag_type flags = regex_constants::format_default) const; |
| 484 | template <class ST, class SA> |
| 485 | basic_string<char_type, ST, SA> |
| 486 | format(const basic_string<char_type, ST, SA>& fmt, |
| 487 | regex_constants::match_flag_type flags = regex_constants::format_default) const; |
| 488 | string_type |
| 489 | format(const char_type* fmt, |
| 490 | regex_constants::match_flag_type flags = regex_constants::format_default) const; |
| 491 | |
| 492 | // allocator: |
| 493 | allocator_type get_allocator() const; |
| 494 | |
| 495 | // swap: |
| 496 | void swap(match_results& that); |
| 497 | }; |
| 498 | |
| 499 | typedef match_results<const char*> cmatch; |
| 500 | typedef match_results<const wchar_t*> wcmatch; |
| 501 | typedef match_results<string::const_iterator> smatch; |
| 502 | typedef match_results<wstring::const_iterator> wsmatch; |
| 503 | |
| 504 | template <class BidirectionalIterator, class Allocator> |
| 505 | bool |
| 506 | operator==(const match_results<BidirectionalIterator, Allocator>& m1, |
| 507 | const match_results<BidirectionalIterator, Allocator>& m2); |
| 508 | |
| 509 | template <class BidirectionalIterator, class Allocator> |
| 510 | bool |
| 511 | operator!=(const match_results<BidirectionalIterator, Allocator>& m1, |
| 512 | const match_results<BidirectionalIterator, Allocator>& m2); |
| 513 | |
| 514 | template <class BidirectionalIterator, class Allocator> |
| 515 | void |
| 516 | swap(match_results<BidirectionalIterator, Allocator>& m1, |
| 517 | match_results<BidirectionalIterator, Allocator>& m2); |
| 518 | |
| 519 | template <class BidirectionalIterator, class Allocator, class charT, class traits> |
| 520 | bool |
| 521 | regex_match(BidirectionalIterator first, BidirectionalIterator last, |
| 522 | match_results<BidirectionalIterator, Allocator>& m, |
| 523 | const basic_regex<charT, traits>& e, |
| 524 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 525 | |
| 526 | template <class BidirectionalIterator, class charT, class traits> |
| 527 | bool |
| 528 | regex_match(BidirectionalIterator first, BidirectionalIterator last, |
| 529 | const basic_regex<charT, traits>& e, |
| 530 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 531 | |
| 532 | template <class charT, class Allocator, class traits> |
| 533 | bool |
| 534 | regex_match(const charT* str, match_results<const charT*, Allocator>& m, |
| 535 | const basic_regex<charT, traits>& e, |
| 536 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 537 | |
| 538 | template <class ST, class SA, class Allocator, class charT, class traits> |
| 539 | bool |
| 540 | regex_match(const basic_string<charT, ST, SA>& s, |
| 541 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, |
| 542 | const basic_regex<charT, traits>& e, |
| 543 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 544 | |
| 545 | template <class charT, class traits> |
| 546 | bool |
| 547 | regex_match(const charT* str, const basic_regex<charT, traits>& e, |
| 548 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 549 | |
| 550 | template <class ST, class SA, class charT, class traits> |
| 551 | bool |
| 552 | regex_match(const basic_string<charT, ST, SA>& s, |
| 553 | const basic_regex<charT, traits>& e, |
| 554 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 555 | |
| 556 | template <class BidirectionalIterator, class Allocator, class charT, class traits> |
| 557 | bool |
| 558 | regex_search(BidirectionalIterator first, BidirectionalIterator last, |
| 559 | match_results<BidirectionalIterator, Allocator>& m, |
| 560 | const basic_regex<charT, traits>& e, |
| 561 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 562 | |
| 563 | template <class BidirectionalIterator, class charT, class traits> |
| 564 | bool |
| 565 | regex_search(BidirectionalIterator first, BidirectionalIterator last, |
| 566 | const basic_regex<charT, traits>& e, |
| 567 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 568 | |
| 569 | template <class charT, class Allocator, class traits> |
| 570 | bool |
| 571 | regex_search(const charT* str, match_results<const charT*, Allocator>& m, |
| 572 | const basic_regex<charT, traits>& e, |
| 573 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 574 | |
| 575 | template <class charT, class traits> |
| 576 | bool |
| 577 | regex_search(const charT* str, const basic_regex<charT, traits>& e, |
| 578 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 579 | |
| 580 | template <class ST, class SA, class charT, class traits> |
| 581 | bool |
| 582 | regex_search(const basic_string<charT, ST, SA>& s, |
| 583 | const basic_regex<charT, traits>& e, |
| 584 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 585 | |
| 586 | template <class ST, class SA, class Allocator, class charT, class traits> |
| 587 | bool |
| 588 | regex_search(const basic_string<charT, ST, SA>& s, |
| 589 | match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m, |
| 590 | const basic_regex<charT, traits>& e, |
| 591 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 592 | |
| 593 | template <class OutputIterator, class BidirectionalIterator, |
| 594 | class traits, class charT, class ST, class SA> |
| 595 | OutputIterator |
| 596 | regex_replace(OutputIterator out, |
| 597 | BidirectionalIterator first, BidirectionalIterator last, |
| 598 | const basic_regex<charT, traits>& e, |
| 599 | const basic_string<charT, ST, SA>& fmt, |
| 600 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 601 | |
| 602 | template <class OutputIterator, class BidirectionalIterator, |
| 603 | class traits, class charT> |
| 604 | OutputIterator |
| 605 | regex_replace(OutputIterator out, |
| 606 | BidirectionalIterator first, BidirectionalIterator last, |
| 607 | const basic_regex<charT, traits>& e, const charT* fmt, |
| 608 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 609 | |
| 610 | template <class traits, class charT, class ST, class SA, class FST, class FSA>> |
| 611 | basic_string<charT, ST, SA> |
| 612 | regex_replace(const basic_string<charT, ST, SA>& s, |
| 613 | const basic_regex<charT, traits>& e, |
| 614 | const basic_string<charT, FST, FSA>& fmt, |
| 615 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 616 | |
| 617 | template <class traits, class charT, class ST, class SA> |
| 618 | basic_string<charT, ST, SA> |
| 619 | regex_replace(const basic_string<charT, ST, SA>& s, |
| 620 | const basic_regex<charT, traits>& e, const charT* fmt, |
| 621 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 622 | |
| 623 | template <class traits, class charT, class ST, class SA> |
| 624 | basic_string<charT> |
| 625 | regex_replace(const charT* s, |
| 626 | const basic_regex<charT, traits>& e, |
| 627 | const basic_string<charT, ST, SA>& fmt, |
| 628 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 629 | |
| 630 | template <class traits, class charT> |
| 631 | basic_string<charT> |
| 632 | regex_replace(const charT* s, |
| 633 | const basic_regex<charT, traits>& e, |
| 634 | const charT* fmt, |
| 635 | regex_constants::match_flag_type flags = regex_constants::match_default); |
| 636 | |
| 637 | template <class BidirectionalIterator, |
| 638 | class charT = typename iterator_traits< BidirectionalIterator>::value_type, |
| 639 | class traits = regex_traits<charT>> |
| 640 | class regex_iterator |
| 641 | { |
| 642 | public: |
| 643 | typedef basic_regex<charT, traits> regex_type; |
| 644 | typedef match_results<BidirectionalIterator> value_type; |
| 645 | typedef ptrdiff_t difference_type; |
| 646 | typedef const value_type* pointer; |
| 647 | typedef const value_type& reference; |
| 648 | typedef forward_iterator_tag iterator_category; |
| 649 | |
| 650 | regex_iterator(); |
| 651 | regex_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 652 | const regex_type& re, |
| 653 | regex_constants::match_flag_type m = regex_constants::match_default); |
| 654 | regex_iterator(const regex_iterator&); |
| 655 | regex_iterator& operator=(const regex_iterator&); |
| 656 | |
| 657 | bool operator==(const regex_iterator&) const; |
| 658 | bool operator!=(const regex_iterator&) const; |
| 659 | |
| 660 | const value_type& operator*() const; |
| 661 | const value_type* operator->() const; |
| 662 | |
| 663 | regex_iterator& operator++(); |
| 664 | regex_iterator operator++(int); |
| 665 | }; |
| 666 | |
| 667 | typedef regex_iterator<const char*> cregex_iterator; |
| 668 | typedef regex_iterator<const wchar_t*> wcregex_iterator; |
| 669 | typedef regex_iterator<string::const_iterator> sregex_iterator; |
| 670 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; |
| 671 | |
| 672 | template <class BidirectionalIterator, |
| 673 | class charT = typename iterator_traits< BidirectionalIterator>::value_type, |
| 674 | class traits = regex_traits<charT>> |
| 675 | class regex_token_iterator |
| 676 | { |
| 677 | public: |
| 678 | typedef basic_regex<charT, traits> regex_type; |
| 679 | typedef sub_match<BidirectionalIterator> value_type; |
| 680 | typedef ptrdiff_t difference_type; |
| 681 | typedef const value_type* pointer; |
| 682 | typedef const value_type& reference; |
| 683 | typedef forward_iterator_tag iterator_category; |
| 684 | |
| 685 | regex_token_iterator(); |
| 686 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 687 | const regex_type& re, int submatch = 0, |
| 688 | regex_constants::match_flag_type m = regex_constants::match_default); |
| 689 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 690 | const regex_type& re, const vector<int>& submatches, |
| 691 | regex_constants::match_flag_type m = regex_constants::match_default); |
| 692 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 693 | const regex_type& re, initializer_list<int> submatches, |
| 694 | regex_constants::match_flag_type m = regex_constants::match_default); |
| 695 | template <size_t N> |
| 696 | regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, |
| 697 | const regex_type& re, const int (&submatches)[N], |
| 698 | regex_constants::match_flag_type m = regex_constants::match_default); |
| 699 | regex_token_iterator(const regex_token_iterator&); |
| 700 | regex_token_iterator& operator=(const regex_token_iterator&); |
| 701 | |
| 702 | bool operator==(const regex_token_iterator&) const; |
| 703 | bool operator!=(const regex_token_iterator&) const; |
| 704 | |
| 705 | const value_type& operator*() const; |
| 706 | const value_type* operator->() const; |
| 707 | |
| 708 | regex_token_iterator& operator++(); |
| 709 | regex_token_iterator operator++(int); |
| 710 | }; |
| 711 | |
| 712 | typedef regex_token_iterator<const char*> cregex_token_iterator; |
| 713 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; |
| 714 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; |
| 715 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 716 | |
| 717 | } // std |
| 718 | */ |
| 719 | |
| 720 | #include <__config> |
| 721 | #include <stdexcept> |
| 722 | #include <__locale> |
| 723 | |
| 724 | #pragma GCC system_header |
| 725 | |
| 726 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 727 | |
| 728 | namespace regex_constants |
| 729 | { |
| 730 | |
| 731 | // syntax_option_type |
| 732 | |
| 733 | enum syntax_option_type |
| 734 | { |
| 735 | icase = 1 << 0, |
| 736 | nosubs = 1 << 1, |
| 737 | optimize = 1 << 2, |
| 738 | collate = 1 << 3, |
| 739 | ECMAScript = 1 << 4, |
| 740 | basic = 1 << 5, |
| 741 | extended = 1 << 6, |
| 742 | awk = 1 << 7, |
| 743 | grep = 1 << 8, |
| 744 | egrep = 1 << 9 |
| 745 | }; |
| 746 | |
| 747 | inline |
| 748 | /*constexpr*/ |
| 749 | syntax_option_type |
| 750 | operator~(syntax_option_type __x) |
| 751 | { |
| 752 | return syntax_option_type(~int(__x)); |
| 753 | } |
| 754 | |
| 755 | inline |
| 756 | /*constexpr*/ |
| 757 | syntax_option_type |
| 758 | operator&(syntax_option_type __x, syntax_option_type __y) |
| 759 | { |
| 760 | return syntax_option_type(int(__x) & int(__y)); |
| 761 | } |
| 762 | |
| 763 | inline |
| 764 | /*constexpr*/ |
| 765 | syntax_option_type |
| 766 | operator|(syntax_option_type __x, syntax_option_type __y) |
| 767 | { |
| 768 | return syntax_option_type(int(__x) | int(__y)); |
| 769 | } |
| 770 | |
| 771 | inline |
| 772 | /*constexpr*/ |
| 773 | syntax_option_type |
| 774 | operator^(syntax_option_type __x, syntax_option_type __y) |
| 775 | { |
| 776 | return syntax_option_type(int(__x) ^ int(__y)); |
| 777 | } |
| 778 | |
| 779 | inline |
| 780 | /*constexpr*/ |
| 781 | syntax_option_type& |
| 782 | operator&=(syntax_option_type& __x, syntax_option_type __y) |
| 783 | { |
| 784 | __x = __x & __y; |
| 785 | return __x; |
| 786 | } |
| 787 | |
| 788 | inline |
| 789 | /*constexpr*/ |
| 790 | syntax_option_type& |
| 791 | operator|=(syntax_option_type& __x, syntax_option_type __y) |
| 792 | { |
| 793 | __x = __x | __y; |
| 794 | return __x; |
| 795 | } |
| 796 | |
| 797 | inline |
| 798 | /*constexpr*/ |
| 799 | syntax_option_type& |
| 800 | operator^=(syntax_option_type& __x, syntax_option_type __y) |
| 801 | { |
| 802 | __x = __x ^ __y; |
| 803 | return __x; |
| 804 | } |
| 805 | |
| 806 | // match_flag_type |
| 807 | |
| 808 | enum match_flag_type |
| 809 | { |
| 810 | match_default = 0, |
| 811 | match_not_bol = 1 << 0, |
| 812 | match_not_eol = 1 << 1, |
| 813 | match_not_bow = 1 << 2, |
| 814 | match_not_eow = 1 << 3, |
| 815 | match_any = 1 << 4, |
| 816 | match_not_null = 1 << 5, |
| 817 | match_continuous = 1 << 6, |
| 818 | match_prev_avail = 1 << 7, |
| 819 | format_default = 0, |
| 820 | format_sed = 1 << 8, |
| 821 | format_no_copy = 1 << 9, |
| 822 | format_first_only = 1 << 10 |
| 823 | }; |
| 824 | |
| 825 | inline |
| 826 | /*constexpr*/ |
| 827 | match_flag_type |
| 828 | operator~(match_flag_type __x) |
| 829 | { |
| 830 | return match_flag_type(~int(__x)); |
| 831 | } |
| 832 | |
| 833 | inline |
| 834 | /*constexpr*/ |
| 835 | match_flag_type |
| 836 | operator&(match_flag_type __x, match_flag_type __y) |
| 837 | { |
| 838 | return match_flag_type(int(__x) & int(__y)); |
| 839 | } |
| 840 | |
| 841 | inline |
| 842 | /*constexpr*/ |
| 843 | match_flag_type |
| 844 | operator|(match_flag_type __x, match_flag_type __y) |
| 845 | { |
| 846 | return match_flag_type(int(__x) | int(__y)); |
| 847 | } |
| 848 | |
| 849 | inline |
| 850 | /*constexpr*/ |
| 851 | match_flag_type |
| 852 | operator^(match_flag_type __x, match_flag_type __y) |
| 853 | { |
| 854 | return match_flag_type(int(__x) ^ int(__y)); |
| 855 | } |
| 856 | |
| 857 | inline |
| 858 | /*constexpr*/ |
| 859 | match_flag_type& |
| 860 | operator&=(match_flag_type& __x, match_flag_type __y) |
| 861 | { |
| 862 | __x = __x & __y; |
| 863 | return __x; |
| 864 | } |
| 865 | |
| 866 | inline |
| 867 | /*constexpr*/ |
| 868 | match_flag_type& |
| 869 | operator|=(match_flag_type& __x, match_flag_type __y) |
| 870 | { |
| 871 | __x = __x | __y; |
| 872 | return __x; |
| 873 | } |
| 874 | |
| 875 | inline |
| 876 | /*constexpr*/ |
| 877 | match_flag_type& |
| 878 | operator^=(match_flag_type& __x, match_flag_type __y) |
| 879 | { |
| 880 | __x = __x ^ __y; |
| 881 | return __x; |
| 882 | } |
| 883 | |
| 884 | enum error_type |
| 885 | { |
| 886 | error_collate = 1, |
| 887 | error_ctype, |
| 888 | error_escape, |
| 889 | error_backref, |
| 890 | error_brack, |
| 891 | error_paren, |
| 892 | error_brace, |
| 893 | error_badbrace, |
| 894 | error_range, |
| 895 | error_space, |
| 896 | error_badrepeat, |
| 897 | error_complexity, |
| 898 | error_stack |
| 899 | }; |
| 900 | |
| 901 | } // regex_constants |
| 902 | |
| 903 | class _LIBCPP_EXCEPTION_ABI regex_error |
| 904 | : public runtime_error |
| 905 | { |
| 906 | regex_constants::error_type __code_; |
| 907 | public: |
| 908 | explicit regex_error(regex_constants::error_type __ecode); |
| 909 | virtual ~regex_error() throw(); |
| 910 | regex_constants::error_type code() const {return __code_;} |
| 911 | }; |
| 912 | |
| 913 | template <class _CharT> |
| 914 | struct regex_traits |
| 915 | { |
| 916 | public: |
| 917 | typedef _CharT char_type; |
| 918 | typedef basic_string<char_type> string_type; |
| 919 | typedef locale locale_type; |
| 920 | typedef unsigned char_class_type; |
| 921 | |
| 922 | private: |
| 923 | locale __loc_; |
| 924 | const ctype<char_type>* __ct_; |
| 925 | const collate<char_type>* __col_; |
| 926 | |
| 927 | public: |
| 928 | regex_traits(); |
| 929 | |
| 930 | static size_t length(const char_type* __p) |
| 931 | {return char_traits<char_type>::length(__p);} |
| 932 | char_type translate(char_type __c) const {return __c;} |
| 933 | char_type translate_nocase(char_type __c) const; |
| 934 | template <class _ForwardIterator> |
| 935 | string_type |
| 936 | transform(_ForwardIterator __f, _ForwardIterator __l) const; |
| 937 | template <class _ForwardIterator> |
| 938 | string_type |
| 939 | transform_primary( _ForwardIterator __f, _ForwardIterator __l) const |
| 940 | {return __transform_primary(__f, __l, char_type());} |
| 941 | template <class _ForwardIterator> |
| 942 | string_type |
| 943 | lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const |
| 944 | {return __lookup_collatename(__f, __l, char_type());} |
| 945 | template <class _ForwardIterator> |
| 946 | char_class_type |
| 947 | lookup_classname(_ForwardIterator __f, _ForwardIterator __l, |
| 948 | bool __icase = false) const; |
| 949 | bool isctype(char_type __c, char_class_type __f) const; |
| 950 | int value(char_type __ch, int __radix) const; |
| 951 | locale_type imbue(locale_type __l); |
| 952 | locale_type getloc()const {return __loc_;} |
| 953 | |
| 954 | private: |
| 955 | void __init(); |
| 956 | |
| 957 | template <class _ForwardIterator> |
| 958 | string_type |
| 959 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 960 | template <class _ForwardIterator> |
| 961 | string_type |
| 962 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 963 | |
| 964 | template <class _ForwardIterator> |
| 965 | string_type |
| 966 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 967 | template <class _ForwardIterator> |
| 968 | string_type |
| 969 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 970 | }; |
| 971 | |
| 972 | template <class _CharT> |
| 973 | regex_traits<_CharT>::regex_traits() |
| 974 | { |
| 975 | __init(); |
| 976 | } |
| 977 | |
| 978 | template <class _CharT> |
| 979 | typename regex_traits<_CharT>::char_type |
| 980 | regex_traits<_CharT>::translate_nocase(char_type __c) const |
| 981 | { |
| 982 | return __ct_->tolower(__c); |
| 983 | } |
| 984 | |
| 985 | template <class _CharT> |
| 986 | template <class _ForwardIterator> |
| 987 | typename regex_traits<_CharT>::string_type |
| 988 | regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const |
| 989 | { |
| 990 | string_type __s(__f, __l); |
| 991 | return __col_->transform(__s.data(), __s.data() + __s.size()); |
| 992 | } |
| 993 | |
| 994 | template <class _CharT> |
| 995 | void |
| 996 | regex_traits<_CharT>::__init() |
| 997 | { |
| 998 | __ct_ = &use_facet<ctype<char_type> >(__loc_); |
| 999 | __col_ = &use_facet<collate<char_type> >(__loc_); |
| 1000 | } |
| 1001 | |
| 1002 | template <class _CharT> |
| 1003 | typename regex_traits<_CharT>::locale_type |
| 1004 | regex_traits<_CharT>::imbue(locale_type __l) |
| 1005 | { |
| 1006 | locale __r = __loc_; |
| 1007 | __loc_ = __l; |
| 1008 | __init(); |
| 1009 | return __r; |
| 1010 | } |
| 1011 | |
| 1012 | // transform_primary is very FreeBSD-specific |
| 1013 | |
| 1014 | template <class _CharT> |
| 1015 | template <class _ForwardIterator> |
| 1016 | typename regex_traits<_CharT>::string_type |
| 1017 | regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, |
| 1018 | _ForwardIterator __l, char) const |
| 1019 | { |
| 1020 | const string_type __s(__f, __l); |
| 1021 | string_type __d = __col_->transform(__s.data(), __s.data() + __s.size()); |
| 1022 | switch (__d.size()) |
| 1023 | { |
| 1024 | case 1: |
| 1025 | break; |
| 1026 | case 12: |
| 1027 | __d[11] = __d[3]; |
| 1028 | break; |
| 1029 | default: |
| 1030 | __d.clear(); |
| 1031 | break; |
| 1032 | } |
| 1033 | return __d; |
| 1034 | } |
| 1035 | |
| 1036 | template <class _CharT> |
| 1037 | template <class _ForwardIterator> |
| 1038 | typename regex_traits<_CharT>::string_type |
| 1039 | regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, |
| 1040 | _ForwardIterator __l, wchar_t) const |
| 1041 | { |
| 1042 | const string_type __s(__f, __l); |
| 1043 | string_type __d = __col_->transform(__s.data(), __s.data() + __s.size()); |
| 1044 | switch (__d.size()) |
| 1045 | { |
| 1046 | case 1: |
| 1047 | break; |
| 1048 | case 3: |
| 1049 | __d[2] = __d[0]; |
| 1050 | break; |
| 1051 | default: |
| 1052 | __d.clear(); |
| 1053 | break; |
| 1054 | } |
| 1055 | return __d; |
| 1056 | } |
| 1057 | |
| 1058 | // lookup_collatename is very FreeBSD-specific |
| 1059 | |
| 1060 | string __get_collation_name(const char* s); |
| 1061 | |
| 1062 | template <class _CharT> |
| 1063 | template <class _ForwardIterator> |
| 1064 | typename regex_traits<_CharT>::string_type |
| 1065 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, |
| 1066 | _ForwardIterator __l, char) const |
| 1067 | { |
| 1068 | string_type __s(__f, __l); |
| 1069 | string_type __r; |
| 1070 | if (!__s.empty()) |
| 1071 | { |
| 1072 | __r = __get_collation_name(__s.c_str()); |
| 1073 | if (__r.empty() && __s.size() <= 2) |
| 1074 | { |
| 1075 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); |
| 1076 | if (__r.size() == 1 || __r.size() == 12) |
| 1077 | __r = __s; |
| 1078 | else |
| 1079 | __r.clear(); |
| 1080 | } |
| 1081 | } |
| 1082 | return __r; |
| 1083 | } |
| 1084 | |
| 1085 | template <class _CharT> |
| 1086 | template <class _ForwardIterator> |
| 1087 | typename regex_traits<_CharT>::string_type |
| 1088 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, |
| 1089 | _ForwardIterator __l, wchar_t) const |
| 1090 | { |
| 1091 | string_type __s(__f, __l); |
| 1092 | string __n; |
| 1093 | __n.reserve(__s.size()); |
| 1094 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); |
| 1095 | __i != __e; ++__i) |
| 1096 | { |
| 1097 | if (static_cast<unsigned>(*__i) >= 127) |
| 1098 | return string_type(); |
| 1099 | __n.push_back(char(*__i)); |
| 1100 | } |
| 1101 | string_type __r; |
| 1102 | if (!__s.empty()) |
| 1103 | { |
| 1104 | __n = __get_collation_name(__n.c_str()); |
| 1105 | if (!__n.empty()) |
| 1106 | __r.assign(__n.begin(), __n.end()); |
| 1107 | else if (__s.size() <= 2) |
| 1108 | { |
| 1109 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); |
| 1110 | if (__r.size() == 1 || __r.size() == 3) |
| 1111 | __r = __s; |
| 1112 | else |
| 1113 | __r.clear(); |
| 1114 | } |
| 1115 | } |
| 1116 | return __r; |
| 1117 | } |
| 1118 | |
| 1119 | _LIBCPP_END_NAMESPACE_STD |
| 1120 | |
| 1121 | #endif // _LIBCPP_REGEX |