| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [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> | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 723 | #include <initializer_list> | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 724 | #include <utility> | 
|  | 725 | #include <iterator> | 
|  | 726 | #include <string> | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 727 |  | 
|  | 728 | #pragma GCC system_header | 
|  | 729 |  | 
|  | 730 | _LIBCPP_BEGIN_NAMESPACE_STD | 
|  | 731 |  | 
|  | 732 | namespace regex_constants | 
|  | 733 | { | 
|  | 734 |  | 
|  | 735 | // syntax_option_type | 
|  | 736 |  | 
|  | 737 | enum syntax_option_type | 
|  | 738 | { | 
|  | 739 | icase = 1 << 0, | 
|  | 740 | nosubs = 1 << 1, | 
|  | 741 | optimize = 1 << 2, | 
|  | 742 | collate = 1 << 3, | 
|  | 743 | ECMAScript = 1 << 4, | 
|  | 744 | basic = 1 << 5, | 
|  | 745 | extended = 1 << 6, | 
|  | 746 | awk = 1 << 7, | 
|  | 747 | grep = 1 << 8, | 
|  | 748 | egrep = 1 << 9 | 
|  | 749 | }; | 
|  | 750 |  | 
|  | 751 | inline | 
|  | 752 | /*constexpr*/ | 
|  | 753 | syntax_option_type | 
|  | 754 | operator~(syntax_option_type __x) | 
|  | 755 | { | 
|  | 756 | return syntax_option_type(~int(__x)); | 
|  | 757 | } | 
|  | 758 |  | 
|  | 759 | inline | 
|  | 760 | /*constexpr*/ | 
|  | 761 | syntax_option_type | 
|  | 762 | operator&(syntax_option_type __x, syntax_option_type __y) | 
|  | 763 | { | 
|  | 764 | return syntax_option_type(int(__x) & int(__y)); | 
|  | 765 | } | 
|  | 766 |  | 
|  | 767 | inline | 
|  | 768 | /*constexpr*/ | 
|  | 769 | syntax_option_type | 
|  | 770 | operator|(syntax_option_type __x, syntax_option_type __y) | 
|  | 771 | { | 
|  | 772 | return syntax_option_type(int(__x) | int(__y)); | 
|  | 773 | } | 
|  | 774 |  | 
|  | 775 | inline | 
|  | 776 | /*constexpr*/ | 
|  | 777 | syntax_option_type | 
|  | 778 | operator^(syntax_option_type __x, syntax_option_type __y) | 
|  | 779 | { | 
|  | 780 | return syntax_option_type(int(__x) ^ int(__y)); | 
|  | 781 | } | 
|  | 782 |  | 
|  | 783 | inline | 
|  | 784 | /*constexpr*/ | 
|  | 785 | syntax_option_type& | 
|  | 786 | operator&=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 787 | { | 
|  | 788 | __x = __x & __y; | 
|  | 789 | return __x; | 
|  | 790 | } | 
|  | 791 |  | 
|  | 792 | inline | 
|  | 793 | /*constexpr*/ | 
|  | 794 | syntax_option_type& | 
|  | 795 | operator|=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 796 | { | 
|  | 797 | __x = __x | __y; | 
|  | 798 | return __x; | 
|  | 799 | } | 
|  | 800 |  | 
|  | 801 | inline | 
|  | 802 | /*constexpr*/ | 
|  | 803 | syntax_option_type& | 
|  | 804 | operator^=(syntax_option_type& __x, syntax_option_type __y) | 
|  | 805 | { | 
|  | 806 | __x = __x ^ __y; | 
|  | 807 | return __x; | 
|  | 808 | } | 
|  | 809 |  | 
|  | 810 | // match_flag_type | 
|  | 811 |  | 
|  | 812 | enum match_flag_type | 
|  | 813 | { | 
|  | 814 | match_default = 0, | 
|  | 815 | match_not_bol = 1 << 0, | 
|  | 816 | match_not_eol = 1 << 1, | 
|  | 817 | match_not_bow = 1 << 2, | 
|  | 818 | match_not_eow = 1 << 3, | 
|  | 819 | match_any = 1 << 4, | 
|  | 820 | match_not_null = 1 << 5, | 
|  | 821 | match_continuous = 1 << 6, | 
|  | 822 | match_prev_avail = 1 << 7, | 
|  | 823 | format_default = 0, | 
|  | 824 | format_sed = 1 << 8, | 
|  | 825 | format_no_copy = 1 << 9, | 
|  | 826 | format_first_only = 1 << 10 | 
|  | 827 | }; | 
|  | 828 |  | 
|  | 829 | inline | 
|  | 830 | /*constexpr*/ | 
|  | 831 | match_flag_type | 
|  | 832 | operator~(match_flag_type __x) | 
|  | 833 | { | 
|  | 834 | return match_flag_type(~int(__x)); | 
|  | 835 | } | 
|  | 836 |  | 
|  | 837 | inline | 
|  | 838 | /*constexpr*/ | 
|  | 839 | match_flag_type | 
|  | 840 | operator&(match_flag_type __x, match_flag_type __y) | 
|  | 841 | { | 
|  | 842 | return match_flag_type(int(__x) & int(__y)); | 
|  | 843 | } | 
|  | 844 |  | 
|  | 845 | inline | 
|  | 846 | /*constexpr*/ | 
|  | 847 | match_flag_type | 
|  | 848 | operator|(match_flag_type __x, match_flag_type __y) | 
|  | 849 | { | 
|  | 850 | return match_flag_type(int(__x) | int(__y)); | 
|  | 851 | } | 
|  | 852 |  | 
|  | 853 | inline | 
|  | 854 | /*constexpr*/ | 
|  | 855 | match_flag_type | 
|  | 856 | operator^(match_flag_type __x, match_flag_type __y) | 
|  | 857 | { | 
|  | 858 | return match_flag_type(int(__x) ^ int(__y)); | 
|  | 859 | } | 
|  | 860 |  | 
|  | 861 | inline | 
|  | 862 | /*constexpr*/ | 
|  | 863 | match_flag_type& | 
|  | 864 | operator&=(match_flag_type& __x, match_flag_type __y) | 
|  | 865 | { | 
|  | 866 | __x = __x & __y; | 
|  | 867 | return __x; | 
|  | 868 | } | 
|  | 869 |  | 
|  | 870 | inline | 
|  | 871 | /*constexpr*/ | 
|  | 872 | match_flag_type& | 
|  | 873 | operator|=(match_flag_type& __x, match_flag_type __y) | 
|  | 874 | { | 
|  | 875 | __x = __x | __y; | 
|  | 876 | return __x; | 
|  | 877 | } | 
|  | 878 |  | 
|  | 879 | inline | 
|  | 880 | /*constexpr*/ | 
|  | 881 | match_flag_type& | 
|  | 882 | operator^=(match_flag_type& __x, match_flag_type __y) | 
|  | 883 | { | 
|  | 884 | __x = __x ^ __y; | 
|  | 885 | return __x; | 
|  | 886 | } | 
|  | 887 |  | 
|  | 888 | enum error_type | 
|  | 889 | { | 
|  | 890 | error_collate = 1, | 
|  | 891 | error_ctype, | 
|  | 892 | error_escape, | 
|  | 893 | error_backref, | 
|  | 894 | error_brack, | 
|  | 895 | error_paren, | 
|  | 896 | error_brace, | 
|  | 897 | error_badbrace, | 
|  | 898 | error_range, | 
|  | 899 | error_space, | 
|  | 900 | error_badrepeat, | 
|  | 901 | error_complexity, | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 902 | error_stack, | 
|  | 903 | error_temp | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 904 | }; | 
|  | 905 |  | 
|  | 906 | } // regex_constants | 
|  | 907 |  | 
|  | 908 | class _LIBCPP_EXCEPTION_ABI regex_error | 
|  | 909 | : public runtime_error | 
|  | 910 | { | 
|  | 911 | regex_constants::error_type __code_; | 
|  | 912 | public: | 
|  | 913 | explicit regex_error(regex_constants::error_type __ecode); | 
|  | 914 | virtual ~regex_error() throw(); | 
|  | 915 | regex_constants::error_type code() const {return __code_;} | 
|  | 916 | }; | 
|  | 917 |  | 
|  | 918 | template <class _CharT> | 
|  | 919 | struct regex_traits | 
|  | 920 | { | 
|  | 921 | public: | 
|  | 922 | typedef _CharT char_type; | 
|  | 923 | typedef basic_string<char_type> string_type; | 
|  | 924 | typedef locale locale_type; | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 925 | typedef ctype_base::mask char_class_type; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 926 |  | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 927 | static const char_class_type __regex_word = 0x80; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 928 | private: | 
|  | 929 | locale __loc_; | 
|  | 930 | const ctype<char_type>* __ct_; | 
|  | 931 | const collate<char_type>* __col_; | 
|  | 932 |  | 
|  | 933 | public: | 
|  | 934 | regex_traits(); | 
|  | 935 |  | 
|  | 936 | static size_t length(const char_type* __p) | 
|  | 937 | {return char_traits<char_type>::length(__p);} | 
|  | 938 | char_type translate(char_type __c) const {return __c;} | 
|  | 939 | char_type translate_nocase(char_type __c) const; | 
|  | 940 | template <class _ForwardIterator> | 
|  | 941 | string_type | 
|  | 942 | transform(_ForwardIterator __f, _ForwardIterator __l) const; | 
|  | 943 | template <class _ForwardIterator> | 
|  | 944 | string_type | 
|  | 945 | transform_primary( _ForwardIterator __f, _ForwardIterator __l) const | 
|  | 946 | {return __transform_primary(__f, __l, char_type());} | 
|  | 947 | template <class _ForwardIterator> | 
|  | 948 | string_type | 
|  | 949 | lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const | 
|  | 950 | {return __lookup_collatename(__f, __l, char_type());} | 
|  | 951 | template <class _ForwardIterator> | 
|  | 952 | char_class_type | 
|  | 953 | lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 954 | bool __icase = false) const | 
|  | 955 | {return __lookup_classname(__f, __l, __icase, char_type());} | 
|  | 956 | bool isctype(char_type __c, char_class_type __m) const; | 
|  | 957 | int value(char_type __ch, int __radix) const | 
|  | 958 | {return __value(__ch, __radix);} | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 959 | locale_type imbue(locale_type __l); | 
|  | 960 | locale_type getloc()const {return __loc_;} | 
|  | 961 |  | 
|  | 962 | private: | 
|  | 963 | void __init(); | 
|  | 964 |  | 
|  | 965 | template <class _ForwardIterator> | 
|  | 966 | string_type | 
|  | 967 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; | 
|  | 968 | template <class _ForwardIterator> | 
|  | 969 | string_type | 
|  | 970 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 
|  | 971 |  | 
|  | 972 | template <class _ForwardIterator> | 
|  | 973 | string_type | 
|  | 974 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; | 
|  | 975 | template <class _ForwardIterator> | 
|  | 976 | string_type | 
|  | 977 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 978 |  | 
|  | 979 | template <class _ForwardIterator> | 
|  | 980 | char_class_type | 
|  | 981 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
|  | 982 | bool __icase, char) const; | 
|  | 983 | template <class _ForwardIterator> | 
|  | 984 | char_class_type | 
|  | 985 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, | 
|  | 986 | bool __icase, wchar_t) const; | 
|  | 987 |  | 
|  | 988 | static int __value(unsigned char __ch, int __radix); | 
|  | 989 | int __value(char __ch, int __radix) const | 
|  | 990 | {return __value(static_cast<unsigned char>(__ch), __radix);} | 
|  | 991 | int __value(wchar_t __ch, int __radix) const; | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 992 | }; | 
|  | 993 |  | 
|  | 994 | template <class _CharT> | 
|  | 995 | regex_traits<_CharT>::regex_traits() | 
|  | 996 | { | 
|  | 997 | __init(); | 
|  | 998 | } | 
|  | 999 |  | 
|  | 1000 | template <class _CharT> | 
|  | 1001 | typename regex_traits<_CharT>::char_type | 
|  | 1002 | regex_traits<_CharT>::translate_nocase(char_type __c) const | 
|  | 1003 | { | 
|  | 1004 | return __ct_->tolower(__c); | 
|  | 1005 | } | 
|  | 1006 |  | 
|  | 1007 | template <class _CharT> | 
|  | 1008 | template <class _ForwardIterator> | 
|  | 1009 | typename regex_traits<_CharT>::string_type | 
|  | 1010 | regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const | 
|  | 1011 | { | 
|  | 1012 | string_type __s(__f, __l); | 
|  | 1013 | return __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1014 | } | 
|  | 1015 |  | 
|  | 1016 | template <class _CharT> | 
|  | 1017 | void | 
|  | 1018 | regex_traits<_CharT>::__init() | 
|  | 1019 | { | 
|  | 1020 | __ct_ = &use_facet<ctype<char_type> >(__loc_); | 
|  | 1021 | __col_ = &use_facet<collate<char_type> >(__loc_); | 
|  | 1022 | } | 
|  | 1023 |  | 
|  | 1024 | template <class _CharT> | 
|  | 1025 | typename regex_traits<_CharT>::locale_type | 
|  | 1026 | regex_traits<_CharT>::imbue(locale_type __l) | 
|  | 1027 | { | 
|  | 1028 | locale __r = __loc_; | 
|  | 1029 | __loc_ = __l; | 
|  | 1030 | __init(); | 
|  | 1031 | return __r; | 
|  | 1032 | } | 
|  | 1033 |  | 
|  | 1034 | // transform_primary is very FreeBSD-specific | 
|  | 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, char) 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 12: | 
|  | 1049 | __d[11] = __d[3]; | 
|  | 1050 | break; | 
|  | 1051 | default: | 
|  | 1052 | __d.clear(); | 
|  | 1053 | break; | 
|  | 1054 | } | 
|  | 1055 | return __d; | 
|  | 1056 | } | 
|  | 1057 |  | 
|  | 1058 | template <class _CharT> | 
|  | 1059 | template <class _ForwardIterator> | 
|  | 1060 | typename regex_traits<_CharT>::string_type | 
|  | 1061 | regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, | 
|  | 1062 | _ForwardIterator __l, wchar_t) const | 
|  | 1063 | { | 
|  | 1064 | const string_type __s(__f, __l); | 
|  | 1065 | string_type __d = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1066 | switch (__d.size()) | 
|  | 1067 | { | 
|  | 1068 | case 1: | 
|  | 1069 | break; | 
|  | 1070 | case 3: | 
|  | 1071 | __d[2] = __d[0]; | 
|  | 1072 | break; | 
|  | 1073 | default: | 
|  | 1074 | __d.clear(); | 
|  | 1075 | break; | 
|  | 1076 | } | 
|  | 1077 | return __d; | 
|  | 1078 | } | 
|  | 1079 |  | 
|  | 1080 | // lookup_collatename is very FreeBSD-specific | 
|  | 1081 |  | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1082 | string __get_collation_name(const char* __s); | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 1083 |  | 
|  | 1084 | template <class _CharT> | 
|  | 1085 | template <class _ForwardIterator> | 
|  | 1086 | typename regex_traits<_CharT>::string_type | 
|  | 1087 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, | 
|  | 1088 | _ForwardIterator __l, char) const | 
|  | 1089 | { | 
|  | 1090 | string_type __s(__f, __l); | 
|  | 1091 | string_type __r; | 
|  | 1092 | if (!__s.empty()) | 
|  | 1093 | { | 
|  | 1094 | __r = __get_collation_name(__s.c_str()); | 
|  | 1095 | if (__r.empty() && __s.size() <= 2) | 
|  | 1096 | { | 
|  | 1097 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1098 | if (__r.size() == 1 || __r.size() == 12) | 
|  | 1099 | __r = __s; | 
|  | 1100 | else | 
|  | 1101 | __r.clear(); | 
|  | 1102 | } | 
|  | 1103 | } | 
|  | 1104 | return __r; | 
|  | 1105 | } | 
|  | 1106 |  | 
|  | 1107 | template <class _CharT> | 
|  | 1108 | template <class _ForwardIterator> | 
|  | 1109 | typename regex_traits<_CharT>::string_type | 
|  | 1110 | regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, | 
|  | 1111 | _ForwardIterator __l, wchar_t) const | 
|  | 1112 | { | 
|  | 1113 | string_type __s(__f, __l); | 
|  | 1114 | string __n; | 
|  | 1115 | __n.reserve(__s.size()); | 
|  | 1116 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); | 
|  | 1117 | __i != __e; ++__i) | 
|  | 1118 | { | 
|  | 1119 | if (static_cast<unsigned>(*__i) >= 127) | 
|  | 1120 | return string_type(); | 
|  | 1121 | __n.push_back(char(*__i)); | 
|  | 1122 | } | 
|  | 1123 | string_type __r; | 
|  | 1124 | if (!__s.empty()) | 
|  | 1125 | { | 
|  | 1126 | __n = __get_collation_name(__n.c_str()); | 
|  | 1127 | if (!__n.empty()) | 
|  | 1128 | __r.assign(__n.begin(), __n.end()); | 
|  | 1129 | else if (__s.size() <= 2) | 
|  | 1130 | { | 
|  | 1131 | __r = __col_->transform(__s.data(), __s.data() + __s.size()); | 
|  | 1132 | if (__r.size() == 1 || __r.size() == 3) | 
|  | 1133 | __r = __s; | 
|  | 1134 | else | 
|  | 1135 | __r.clear(); | 
|  | 1136 | } | 
|  | 1137 | } | 
|  | 1138 | return __r; | 
|  | 1139 | } | 
|  | 1140 |  | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1141 | // lookup_classname | 
|  | 1142 |  | 
|  | 1143 | ctype_base::mask __get_classname(const char* __s, bool __icase); | 
|  | 1144 |  | 
|  | 1145 | template <class _CharT> | 
|  | 1146 | template <class _ForwardIterator> | 
|  | 1147 | typename regex_traits<_CharT>::char_class_type | 
|  | 1148 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, | 
|  | 1149 | _ForwardIterator __l, | 
|  | 1150 | bool __icase, char) const | 
|  | 1151 | { | 
|  | 1152 | string_type __s(__f, __l); | 
|  | 1153 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 
|  | 1154 | return __get_classname(__s.c_str(), __icase); | 
|  | 1155 | } | 
|  | 1156 |  | 
|  | 1157 | template <class _CharT> | 
|  | 1158 | template <class _ForwardIterator> | 
|  | 1159 | typename regex_traits<_CharT>::char_class_type | 
|  | 1160 | regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, | 
|  | 1161 | _ForwardIterator __l, | 
|  | 1162 | bool __icase, wchar_t) const | 
|  | 1163 | { | 
|  | 1164 | string_type __s(__f, __l); | 
|  | 1165 | __ct_->tolower(&__s[0], &__s[0] + __s.size()); | 
|  | 1166 | string __n; | 
|  | 1167 | __n.reserve(__s.size()); | 
|  | 1168 | for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); | 
|  | 1169 | __i != __e; ++__i) | 
|  | 1170 | { | 
|  | 1171 | if (static_cast<unsigned>(*__i) >= 127) | 
|  | 1172 | return char_class_type(); | 
|  | 1173 | __n.push_back(char(*__i)); | 
|  | 1174 | } | 
|  | 1175 | return __get_classname(__n.c_str(), __icase); | 
|  | 1176 | } | 
|  | 1177 |  | 
|  | 1178 | template <class _CharT> | 
|  | 1179 | bool | 
|  | 1180 | regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const | 
|  | 1181 | { | 
|  | 1182 | if (__ct_->is(__m, __c)) | 
|  | 1183 | return true; | 
|  | 1184 | return (__c == '_' && (__m & __regex_word)); | 
|  | 1185 | } | 
|  | 1186 |  | 
|  | 1187 | template <class _CharT> | 
|  | 1188 | int | 
|  | 1189 | regex_traits<_CharT>::__value(unsigned char __ch, int __radix) | 
|  | 1190 | { | 
|  | 1191 | if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' | 
|  | 1192 | return __ch - '0'; | 
|  | 1193 | if (__radix != 8) | 
|  | 1194 | { | 
|  | 1195 | if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9' | 
|  | 1196 | return __ch - '0'; | 
|  | 1197 | if (__radix == 16) | 
|  | 1198 | { | 
|  | 1199 | __ch |= 0x20; // tolower | 
|  | 1200 | if ('a' <= __ch && __ch <= 'f') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1201 | return __ch - ('a' - 10); | 
| Howard Hinnant | f409d2f | 2010-06-21 21:01:43 | [diff] [blame] | 1202 | } | 
|  | 1203 | } | 
|  | 1204 | return -1; | 
|  | 1205 | } | 
|  | 1206 |  | 
|  | 1207 | template <class _CharT> | 
|  | 1208 | inline | 
|  | 1209 | int | 
|  | 1210 | regex_traits<_CharT>::__value(wchar_t __ch, int __radix) const | 
|  | 1211 | { | 
|  | 1212 | return __value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); | 
|  | 1213 | } | 
|  | 1214 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1215 | template <class _CharT> class __transition; | 
|  | 1216 |  | 
|  | 1217 | template <class _CharT> | 
|  | 1218 | class __state | 
|  | 1219 | { | 
|  | 1220 | typedef __transition<_CharT> __transition; | 
|  | 1221 | __transition* __t1_; | 
|  | 1222 | __transition* __t2_; | 
|  | 1223 | int __state_; | 
|  | 1224 | enum | 
|  | 1225 | { | 
|  | 1226 | __1_not_tried = 0, | 
|  | 1227 | __1_succeded = 1, | 
|  | 1228 | __1_failed = 2, | 
|  | 1229 | __2_not_tried = 0, | 
|  | 1230 | __2_succeded = 4, | 
|  | 1231 | __2_failed = 8 | 
|  | 1232 | }; | 
|  | 1233 |  | 
|  | 1234 | __state(const __state&); | 
|  | 1235 | __state& operator=(const __state&); | 
|  | 1236 | public: | 
|  | 1237 | __state() | 
|  | 1238 | : __t1_(), __t2_(), __state_() {} | 
|  | 1239 | ~__state(); | 
|  | 1240 |  | 
|  | 1241 | const __state* operator()(_CharT __c); | 
|  | 1242 |  | 
|  | 1243 | void __add_one(__transition* __t) {__t1_ = __t;} | 
|  | 1244 | }; | 
|  | 1245 |  | 
|  | 1246 | template <class _CharT> | 
|  | 1247 | __state<_CharT>::~__state() | 
|  | 1248 | { | 
|  | 1249 | delete __t1_; | 
|  | 1250 | delete __t2_; | 
|  | 1251 | } | 
|  | 1252 |  | 
|  | 1253 | template <class _CharT> | 
|  | 1254 | const __state<_CharT>* | 
|  | 1255 | __state<_CharT>::operator()(_CharT __c) | 
|  | 1256 | { | 
|  | 1257 | const __state* __r = nullptr; | 
|  | 1258 | if ((__state_ & 3) == 0) | 
|  | 1259 | { | 
|  | 1260 | if (__t1_) | 
|  | 1261 | { | 
|  | 1262 | __r = (*__t1_)(__c); | 
|  | 1263 | if (__r) | 
|  | 1264 | __state_ |= __1_succeded; | 
|  | 1265 | else | 
|  | 1266 | __state_ |= __1_failed; | 
|  | 1267 | } | 
|  | 1268 | else | 
|  | 1269 | __state_ |= __1_failed; | 
|  | 1270 | } | 
|  | 1271 | else if ((__state_ & 0xC) == 0) | 
|  | 1272 | { | 
|  | 1273 | if (__t2_) | 
|  | 1274 | { | 
|  | 1275 | __r = (*__t2_)(__c); | 
|  | 1276 | if (__r) | 
|  | 1277 | __state_ |= __2_succeded; | 
|  | 1278 | else | 
|  | 1279 | __state_ |= __2_failed; | 
|  | 1280 | } | 
|  | 1281 | else | 
|  | 1282 | __state_ |= __2_failed; | 
|  | 1283 | } | 
|  | 1284 | return __r; | 
|  | 1285 | } | 
|  | 1286 |  | 
|  | 1287 | template <class _CharT> | 
|  | 1288 | class __transition | 
|  | 1289 | { | 
|  | 1290 | __transition(const __transition&); | 
|  | 1291 | __transition& operator=(const __transition&); | 
|  | 1292 |  | 
|  | 1293 | typedef __state<_CharT> __state; | 
|  | 1294 | typedef unique_ptr<__state, void(*)(__state*)> __sptr; | 
|  | 1295 |  | 
|  | 1296 | static void __delete_state(__state* __p) {delete __p;} | 
|  | 1297 | static void __ignore_state(__state*) {} | 
|  | 1298 |  | 
|  | 1299 | protected: | 
|  | 1300 | __sptr __sptr_; | 
|  | 1301 | public: | 
|  | 1302 | __transition(bool __owns, __state* __st) | 
|  | 1303 | : __sptr_(__st, __owns ? &__delete_state : &__ignore_state) {} | 
|  | 1304 | virtual ~__transition() {} | 
|  | 1305 |  | 
|  | 1306 | virtual const __state* operator()(_CharT) const {return __sptr_.get();} | 
|  | 1307 | }; | 
|  | 1308 |  | 
|  | 1309 | template <class _CharT> | 
|  | 1310 | class __match_char | 
|  | 1311 | : public __transition<_CharT> | 
|  | 1312 | { | 
|  | 1313 | typedef __transition<_CharT> base; | 
|  | 1314 | _CharT __c_; | 
|  | 1315 | public: | 
|  | 1316 | __match_char(_CharT __c, bool __owns, __state<_CharT>* __st) | 
|  | 1317 | : base(__owns, __st), __c_(__c) {} | 
|  | 1318 |  | 
|  | 1319 | virtual const __state<_CharT>* operator()(_CharT __c) const | 
|  | 1320 | {return __c == __c_ ? base::__sptr_.get() : nullptr;} | 
|  | 1321 | }; | 
|  | 1322 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1323 | template <class _CharT, class _Traits = regex_traits<_CharT> > | 
|  | 1324 | class basic_regex | 
|  | 1325 | { | 
|  | 1326 | public: | 
|  | 1327 | // types: | 
|  | 1328 | typedef _CharT value_type; | 
|  | 1329 | typedef regex_constants::syntax_option_type flag_type; | 
|  | 1330 | typedef typename _Traits::locale_type locale_type; | 
|  | 1331 |  | 
|  | 1332 | private: | 
|  | 1333 | _Traits __traits_; | 
|  | 1334 | flag_type __flags_; | 
|  | 1335 | unsigned __marked_count_; | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1336 | int __open_count_; | 
|  | 1337 | shared_ptr<__state<_CharT> > __start_; | 
|  | 1338 | __state<_CharT>* __end_; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1339 |  | 
|  | 1340 | public: | 
|  | 1341 | // constants: | 
|  | 1342 | static const/*expr*/ regex_constants::syntax_option_type icase = regex_constants::icase; | 
|  | 1343 | static const/*expr*/ regex_constants::syntax_option_type nosubs = regex_constants::nosubs; | 
|  | 1344 | static const/*expr*/ regex_constants::syntax_option_type optimize = regex_constants::optimize; | 
|  | 1345 | static const/*expr*/ regex_constants::syntax_option_type collate = regex_constants::collate; | 
|  | 1346 | static const/*expr*/ regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; | 
|  | 1347 | static const/*expr*/ regex_constants::syntax_option_type basic = regex_constants::basic; | 
|  | 1348 | static const/*expr*/ regex_constants::syntax_option_type extended = regex_constants::extended; | 
|  | 1349 | static const/*expr*/ regex_constants::syntax_option_type awk = regex_constants::awk; | 
|  | 1350 | static const/*expr*/ regex_constants::syntax_option_type grep = regex_constants::grep; | 
|  | 1351 | static const/*expr*/ regex_constants::syntax_option_type egrep = regex_constants::egrep; | 
|  | 1352 |  | 
|  | 1353 | // construct/copy/destroy: | 
|  | 1354 | basic_regex(); | 
|  | 1355 | explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1356 | : __flags_(__f), __marked_count_(0), __open_count_(0), __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1357 | {__parse(__p, __p + __traits_.length(__p));} | 
|  | 1358 | basic_regex(const value_type* __p, size_t __len, flag_type __f) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1359 | : __flags_(__f), __marked_count_(0), __open_count_(0), __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1360 | {__parse(__p, __p + __len);} | 
|  | 1361 | basic_regex(const basic_regex&); | 
|  | 1362 | #ifdef _LIBCPP_MOVE | 
|  | 1363 | basic_regex(basic_regex&&); | 
|  | 1364 | #endif | 
|  | 1365 | template <class _ST, class _SA> | 
|  | 1366 | explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p, | 
|  | 1367 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1368 | : __flags_(__f), __marked_count_(0), __open_count_(0), __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1369 | {__parse(__p.begin(), __p.end());} | 
|  | 1370 | template <class _ForwardIterator> | 
|  | 1371 | basic_regex(_ForwardIterator __first, _ForwardIterator __last, | 
|  | 1372 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1373 | : __flags_(__f), __marked_count_(0), __open_count_(0), __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1374 | {__parse(__first, __last);} | 
|  | 1375 | basic_regex(initializer_list<value_type> __il, | 
|  | 1376 | flag_type __f = regex_constants::ECMAScript) | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1377 | : __flags_(__f), __marked_count_(0), __open_count_(0), __end_(0) | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1378 | {__parse(__il.begin(), __il.end());} | 
|  | 1379 |  | 
|  | 1380 | ~basic_regex(); | 
|  | 1381 |  | 
|  | 1382 | basic_regex& operator=(const basic_regex&); | 
|  | 1383 | #ifdef _LIBCPP_MOVE | 
|  | 1384 | basic_regex& operator=(basic_regex&&); | 
|  | 1385 | #endif | 
|  | 1386 | basic_regex& operator=(const value_type* __p); | 
|  | 1387 | basic_regex& operator=(initializer_list<value_type> __il); | 
|  | 1388 | template <class _ST, class _SA> | 
|  | 1389 | basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p); | 
|  | 1390 |  | 
|  | 1391 | // assign: | 
|  | 1392 | basic_regex& assign(const basic_regex& __that); | 
|  | 1393 | #ifdef _LIBCPP_MOVE | 
|  | 1394 | basic_regex& assign(basic_regex&& __that); | 
|  | 1395 | #endif | 
|  | 1396 | basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript); | 
|  | 1397 | basic_regex& assign(const value_type* __p, size_t __len, flag_type __f); | 
|  | 1398 | template <class _ST, class _SA> | 
|  | 1399 | basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s, | 
|  | 1400 | flag_type __f = regex_constants::ECMAScript); | 
|  | 1401 | template <class _InputIterator> | 
|  | 1402 | basic_regex& assign(_InputIterator __first, _InputIterator __last, | 
|  | 1403 | flag_type __f = regex_constants::ECMAScript); | 
|  | 1404 | basic_regex& assign(initializer_list<value_type> __il, | 
|  | 1405 | flag_type = regex_constants::ECMAScript); | 
|  | 1406 |  | 
|  | 1407 | // const operations: | 
|  | 1408 | unsigned mark_count() const {return __marked_count_;} | 
|  | 1409 | flag_type flags() const {return __flags_;} | 
|  | 1410 |  | 
|  | 1411 | // locale: | 
|  | 1412 | locale_type imbue(locale_type __loc) {return __traits_.imbue(__loc);} | 
|  | 1413 | locale_type getloc() const {return __traits_.getloc();} | 
|  | 1414 |  | 
|  | 1415 | // swap: | 
|  | 1416 | void swap(basic_regex&); | 
|  | 1417 |  | 
|  | 1418 | private: | 
|  | 1419 | template <class _ForwardIterator> | 
|  | 1420 | void __parse(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1421 | template <class _ForwardIterator> | 
|  | 1422 | _ForwardIterator | 
|  | 1423 | __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1424 | template <class _ForwardIterator> | 
|  | 1425 | _ForwardIterator | 
|  | 1426 | __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1427 | template <class _ForwardIterator> | 
|  | 1428 | _ForwardIterator | 
|  | 1429 | __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1430 | template <class _ForwardIterator> | 
|  | 1431 | _ForwardIterator | 
|  | 1432 | __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1433 | template <class _ForwardIterator> | 
|  | 1434 | _ForwardIterator | 
|  | 1435 | __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1436 | template <class _ForwardIterator> | 
|  | 1437 | _ForwardIterator | 
|  | 1438 | __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1439 | template <class _ForwardIterator> | 
|  | 1440 | _ForwardIterator | 
|  | 1441 | __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1442 | template <class _ForwardIterator> | 
|  | 1443 | _ForwardIterator | 
|  | 1444 | __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1445 | template <class _ForwardIterator> | 
|  | 1446 | _ForwardIterator | 
|  | 1447 | __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1448 | template <class _ForwardIterator> | 
|  | 1449 | _ForwardIterator | 
|  | 1450 | __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1451 | template <class _ForwardIterator> | 
|  | 1452 | _ForwardIterator | 
|  | 1453 | __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1454 | template <class _ForwardIterator> | 
|  | 1455 | _ForwardIterator | 
|  | 1456 | __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1457 | template <class _ForwardIterator> | 
|  | 1458 | _ForwardIterator | 
|  | 1459 | __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 1460 | template <class _ForwardIterator> | 
|  | 1461 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1462 | __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1463 | template <class _ForwardIterator> | 
|  | 1464 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 1465 | __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1466 | template <class _ForwardIterator> | 
|  | 1467 | _ForwardIterator | 
|  | 1468 | __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1469 | template <class _ForwardIterator> | 
|  | 1470 | _ForwardIterator | 
|  | 1471 | __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1472 | template <class _ForwardIterator> | 
|  | 1473 | _ForwardIterator | 
|  | 1474 | __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1475 | template <class _ForwardIterator> | 
|  | 1476 | _ForwardIterator | 
|  | 1477 | __parse_character_class(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1478 | template <class _ForwardIterator> | 
|  | 1479 | _ForwardIterator | 
|  | 1480 | __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1481 | template <class _ForwardIterator> | 
|  | 1482 | _ForwardIterator | 
|  | 1483 | __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1484 | template <class _ForwardIterator> | 
|  | 1485 | _ForwardIterator | 
|  | 1486 | __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1487 | template <class _ForwardIterator> | 
|  | 1488 | _ForwardIterator | 
|  | 1489 | __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1490 | template <class _ForwardIterator> | 
|  | 1491 | _ForwardIterator | 
|  | 1492 | __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1493 | template <class _ForwardIterator> | 
|  | 1494 | _ForwardIterator | 
|  | 1495 | __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1496 | template <class _ForwardIterator> | 
|  | 1497 | _ForwardIterator | 
|  | 1498 | __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
|  | 1499 | template <class _ForwardIterator> | 
|  | 1500 | _ForwardIterator | 
|  | 1501 | __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1502 |  | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 1503 | void __push_l_anchor() {} | 
|  | 1504 | void __push_r_anchor() {} | 
|  | 1505 | void __push_match_any() {} | 
|  | 1506 | void __push_greedy_inf_repeat(int __min) {} | 
|  | 1507 | void __push_exact_repeat(int __count) {} | 
|  | 1508 | void __push_repeat(int __min, int __max) {} | 
|  | 1509 | void __start_nonmatching_list() {} | 
|  | 1510 | void __start_matching_list() {} | 
|  | 1511 | void __end_nonmatching_list() {} | 
|  | 1512 | void __end_matching_list() {} | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1513 | void __push_char(value_type __c); | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 1514 | void __push_char(const typename _Traits::string_type& __c) {} | 
|  | 1515 | void __push_range() {} | 
|  | 1516 | void __push_class_type(typename _Traits::char_class_type) {} | 
|  | 1517 | void __push_back_ref(int __i) {} | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1518 | void __push_alternation() {} | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1519 | }; | 
|  | 1520 |  | 
|  | 1521 | template <class _CharT, class _Traits> | 
|  | 1522 | inline | 
|  | 1523 | basic_regex<_CharT, _Traits>::basic_regex() | 
|  | 1524 | : __traits_(), __flags_(), __marked_count_(0) | 
|  | 1525 | { | 
|  | 1526 | } | 
|  | 1527 |  | 
|  | 1528 | template <class _CharT, class _Traits> | 
|  | 1529 | basic_regex<_CharT, _Traits>::~basic_regex() | 
|  | 1530 | { | 
|  | 1531 | } | 
|  | 1532 |  | 
|  | 1533 | template <class _CharT, class _Traits> | 
|  | 1534 | template <class _ForwardIterator> | 
|  | 1535 | void | 
|  | 1536 | basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, | 
|  | 1537 | _ForwardIterator __last) | 
|  | 1538 | { | 
|  | 1539 | switch (__flags_ & 0x3F0) | 
|  | 1540 | { | 
|  | 1541 | case ECMAScript: | 
|  | 1542 | break; | 
|  | 1543 | case basic: | 
|  | 1544 | __parse_basic_reg_exp(__first, __last); | 
|  | 1545 | break; | 
|  | 1546 | case extended: | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1547 | __parse_extended_reg_exp(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1548 | break; | 
|  | 1549 | case awk: | 
|  | 1550 | break; | 
|  | 1551 | case grep: | 
|  | 1552 | break; | 
|  | 1553 | case egrep: | 
|  | 1554 | break; | 
|  | 1555 | default: | 
|  | 1556 | throw regex_error(regex_constants::error_temp); | 
|  | 1557 | } | 
|  | 1558 | } | 
|  | 1559 |  | 
|  | 1560 | template <class _CharT, class _Traits> | 
|  | 1561 | template <class _ForwardIterator> | 
|  | 1562 | _ForwardIterator | 
|  | 1563 | basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, | 
|  | 1564 | _ForwardIterator __last) | 
|  | 1565 | { | 
|  | 1566 | if (__first != __last) | 
|  | 1567 | { | 
|  | 1568 | if (*__first == '^') | 
|  | 1569 | { | 
|  | 1570 | __push_l_anchor(); | 
|  | 1571 | ++__first; | 
|  | 1572 | } | 
|  | 1573 | if (__first != __last) | 
|  | 1574 | { | 
|  | 1575 | __first = __parse_RE_expression(__first, __last); | 
|  | 1576 | if (__first != __last) | 
|  | 1577 | { | 
|  | 1578 | _ForwardIterator __temp = next(__first); | 
|  | 1579 | if (__temp == __last && *__first == '$') | 
|  | 1580 | { | 
|  | 1581 | __push_r_anchor(); | 
|  | 1582 | ++__first; | 
|  | 1583 | } | 
|  | 1584 | } | 
|  | 1585 | } | 
|  | 1586 | if (__first != __last) | 
|  | 1587 | throw regex_error(regex_constants::error_temp); | 
|  | 1588 | } | 
|  | 1589 | return __first; | 
|  | 1590 | } | 
|  | 1591 |  | 
|  | 1592 | template <class _CharT, class _Traits> | 
|  | 1593 | template <class _ForwardIterator> | 
|  | 1594 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1595 | basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, | 
|  | 1596 | _ForwardIterator __last) | 
|  | 1597 | { | 
|  | 1598 | while (true) | 
|  | 1599 | { | 
|  | 1600 | _ForwardIterator __temp = __parse_ERE_branch(__first, __last); | 
|  | 1601 | if (__temp == __first) | 
|  | 1602 | throw regex_error(regex_constants::error_temp); | 
|  | 1603 | __first = __temp; | 
|  | 1604 | if (__first == __last) | 
|  | 1605 | break; | 
|  | 1606 | if (*__first != '|') | 
|  | 1607 | throw regex_error(regex_constants::error_temp); | 
|  | 1608 | __push_alternation(); | 
|  | 1609 | ++__first; | 
|  | 1610 | } | 
|  | 1611 | return __first; | 
|  | 1612 | } | 
|  | 1613 |  | 
|  | 1614 | template <class _CharT, class _Traits> | 
|  | 1615 | template <class _ForwardIterator> | 
|  | 1616 | _ForwardIterator | 
|  | 1617 | basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, | 
|  | 1618 | _ForwardIterator __last) | 
|  | 1619 | { | 
|  | 1620 | _ForwardIterator __temp = __parse_ERE_expression(__first, __last); | 
|  | 1621 | if (__temp == __first) | 
|  | 1622 | throw regex_error(regex_constants::error_temp); | 
|  | 1623 | do | 
|  | 1624 | { | 
|  | 1625 | __first = __temp; | 
|  | 1626 | __temp = __parse_ERE_expression(__first, __last); | 
|  | 1627 | } while (__temp != __first); | 
|  | 1628 | return __first; | 
|  | 1629 | } | 
|  | 1630 |  | 
|  | 1631 | template <class _CharT, class _Traits> | 
|  | 1632 | template <class _ForwardIterator> | 
|  | 1633 | _ForwardIterator | 
|  | 1634 | basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, | 
|  | 1635 | _ForwardIterator __last) | 
|  | 1636 | { | 
|  | 1637 | _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last); | 
|  | 1638 | if (__temp == __first && __temp != __last) | 
|  | 1639 | { | 
|  | 1640 | switch (*__temp) | 
|  | 1641 | { | 
|  | 1642 | case '^': | 
|  | 1643 | __push_l_anchor(); | 
|  | 1644 | ++__temp; | 
|  | 1645 | break; | 
|  | 1646 | case '$': | 
|  | 1647 | __push_r_anchor(); | 
|  | 1648 | ++__temp; | 
|  | 1649 | break; | 
|  | 1650 | case '(': | 
|  | 1651 | ++__marked_count_; | 
|  | 1652 | ++__open_count_; | 
|  | 1653 | __temp = __parse_extended_reg_exp(++__temp, __last); | 
|  | 1654 | if (__temp == __last || *__temp != ')') | 
|  | 1655 | throw regex_error(regex_constants::error_paren); | 
|  | 1656 | --__open_count_; | 
|  | 1657 | ++__temp; | 
|  | 1658 | break; | 
|  | 1659 | } | 
|  | 1660 | } | 
|  | 1661 | if (__temp != __first) | 
|  | 1662 | __temp = __parse_ERE_dupl_symbol(__temp, __last); | 
|  | 1663 | __first = __temp; | 
|  | 1664 | return __first; | 
|  | 1665 | } | 
|  | 1666 |  | 
|  | 1667 | template <class _CharT, class _Traits> | 
|  | 1668 | template <class _ForwardIterator> | 
|  | 1669 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1670 | basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first, | 
|  | 1671 | _ForwardIterator __last) | 
|  | 1672 | { | 
|  | 1673 | while (true) | 
|  | 1674 | { | 
|  | 1675 | _ForwardIterator __temp = __parse_simple_RE(__first, __last); | 
|  | 1676 | if (__temp == __first) | 
|  | 1677 | break; | 
|  | 1678 | __first = __temp; | 
|  | 1679 | } | 
|  | 1680 | return __first; | 
|  | 1681 | } | 
|  | 1682 |  | 
|  | 1683 | template <class _CharT, class _Traits> | 
|  | 1684 | template <class _ForwardIterator> | 
|  | 1685 | _ForwardIterator | 
|  | 1686 | basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first, | 
|  | 1687 | _ForwardIterator __last) | 
|  | 1688 | { | 
|  | 1689 | if (__first != __last) | 
|  | 1690 | { | 
|  | 1691 | _ForwardIterator __temp = __parse_nondupl_RE(__first, __last); | 
|  | 1692 | if (__temp != __first) | 
|  | 1693 | { | 
|  | 1694 | __first = __temp; | 
|  | 1695 | __first = __parse_RE_dupl_symbol(__first, __last); | 
|  | 1696 | } | 
|  | 1697 | } | 
|  | 1698 | return __first; | 
|  | 1699 | } | 
|  | 1700 |  | 
|  | 1701 | template <class _CharT, class _Traits> | 
|  | 1702 | template <class _ForwardIterator> | 
|  | 1703 | _ForwardIterator | 
|  | 1704 | basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first, | 
|  | 1705 | _ForwardIterator __last) | 
|  | 1706 | { | 
|  | 1707 | _ForwardIterator __temp = __first; | 
|  | 1708 | __first = __parse_one_char_or_coll_elem_RE(__first, __last); | 
|  | 1709 | if (__temp == __first) | 
|  | 1710 | { | 
|  | 1711 | __temp = __parse_Back_open_paren(__first, __last); | 
|  | 1712 | if (__temp != __first) | 
|  | 1713 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1714 | ++__marked_count_; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1715 | __first = __parse_RE_expression(__temp, __last); | 
|  | 1716 | __temp = __parse_Back_close_paren(__first, __last); | 
|  | 1717 | if (__temp == __first) | 
|  | 1718 | throw regex_error(regex_constants::error_paren); | 
|  | 1719 | __first = __temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1720 | } | 
|  | 1721 | else | 
|  | 1722 | __first = __parse_BACKREF(__first, __last); | 
|  | 1723 | } | 
|  | 1724 | return __first; | 
|  | 1725 | } | 
|  | 1726 |  | 
|  | 1727 | template <class _CharT, class _Traits> | 
|  | 1728 | template <class _ForwardIterator> | 
|  | 1729 | _ForwardIterator | 
|  | 1730 | basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE( | 
|  | 1731 | _ForwardIterator __first, | 
|  | 1732 | _ForwardIterator __last) | 
|  | 1733 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1734 | _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1735 | if (__temp == __first) | 
|  | 1736 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1737 | __temp = __parse_QUOTED_CHAR(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1738 | if (__temp == __first) | 
|  | 1739 | { | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1740 | if (__temp != __last && *__temp == '.') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1741 | { | 
|  | 1742 | __push_match_any(); | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1743 | ++__temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1744 | } | 
|  | 1745 | else | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1746 | __temp = __parse_bracket_expression(__first, __last); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1747 | } | 
|  | 1748 | } | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1749 | __first = __temp; | 
|  | 1750 | return __first; | 
|  | 1751 | } | 
|  | 1752 |  | 
|  | 1753 | template <class _CharT, class _Traits> | 
|  | 1754 | template <class _ForwardIterator> | 
|  | 1755 | _ForwardIterator | 
|  | 1756 | basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE( | 
|  | 1757 | _ForwardIterator __first, | 
|  | 1758 | _ForwardIterator __last) | 
|  | 1759 | { | 
|  | 1760 | _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last); | 
|  | 1761 | if (__temp == __first) | 
|  | 1762 | { | 
|  | 1763 | __temp = __parse_QUOTED_CHAR_ERE(__first, __last); | 
|  | 1764 | if (__temp == __first) | 
|  | 1765 | { | 
|  | 1766 | if (__temp != __last && *__temp == '.') | 
|  | 1767 | { | 
|  | 1768 | __push_match_any(); | 
|  | 1769 | ++__temp; | 
|  | 1770 | } | 
|  | 1771 | else | 
|  | 1772 | __temp = __parse_bracket_expression(__first, __last); | 
|  | 1773 | } | 
|  | 1774 | } | 
|  | 1775 | __first = __temp; | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1776 | return __first; | 
|  | 1777 | } | 
|  | 1778 |  | 
|  | 1779 | template <class _CharT, class _Traits> | 
|  | 1780 | template <class _ForwardIterator> | 
|  | 1781 | _ForwardIterator | 
|  | 1782 | basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first, | 
|  | 1783 | _ForwardIterator __last) | 
|  | 1784 | { | 
|  | 1785 | if (__first != __last) | 
|  | 1786 | { | 
|  | 1787 | _ForwardIterator __temp = next(__first); | 
|  | 1788 | if (__temp != __last) | 
|  | 1789 | { | 
|  | 1790 | if (*__first == '\\' && *__temp == '(') | 
|  | 1791 | __first = ++__temp; | 
|  | 1792 | } | 
|  | 1793 | } | 
|  | 1794 | return __first; | 
|  | 1795 | } | 
|  | 1796 |  | 
|  | 1797 | template <class _CharT, class _Traits> | 
|  | 1798 | template <class _ForwardIterator> | 
|  | 1799 | _ForwardIterator | 
|  | 1800 | basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first, | 
|  | 1801 | _ForwardIterator __last) | 
|  | 1802 | { | 
|  | 1803 | if (__first != __last) | 
|  | 1804 | { | 
|  | 1805 | _ForwardIterator __temp = next(__first); | 
|  | 1806 | if (__temp != __last) | 
|  | 1807 | { | 
|  | 1808 | if (*__first == '\\' && *__temp == ')') | 
|  | 1809 | __first = ++__temp; | 
|  | 1810 | } | 
|  | 1811 | } | 
|  | 1812 | return __first; | 
|  | 1813 | } | 
|  | 1814 |  | 
|  | 1815 | template <class _CharT, class _Traits> | 
|  | 1816 | template <class _ForwardIterator> | 
|  | 1817 | _ForwardIterator | 
|  | 1818 | basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first, | 
|  | 1819 | _ForwardIterator __last) | 
|  | 1820 | { | 
|  | 1821 | if (__first != __last) | 
|  | 1822 | { | 
|  | 1823 | _ForwardIterator __temp = next(__first); | 
|  | 1824 | if (__temp != __last) | 
|  | 1825 | { | 
|  | 1826 | if (*__first == '\\' && *__temp == '{') | 
|  | 1827 | __first = ++__temp; | 
|  | 1828 | } | 
|  | 1829 | } | 
|  | 1830 | return __first; | 
|  | 1831 | } | 
|  | 1832 |  | 
|  | 1833 | template <class _CharT, class _Traits> | 
|  | 1834 | template <class _ForwardIterator> | 
|  | 1835 | _ForwardIterator | 
|  | 1836 | basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first, | 
|  | 1837 | _ForwardIterator __last) | 
|  | 1838 | { | 
|  | 1839 | if (__first != __last) | 
|  | 1840 | { | 
|  | 1841 | _ForwardIterator __temp = next(__first); | 
|  | 1842 | if (__temp != __last) | 
|  | 1843 | { | 
|  | 1844 | if (*__first == '\\' && *__temp == '}') | 
|  | 1845 | __first = ++__temp; | 
|  | 1846 | } | 
|  | 1847 | } | 
|  | 1848 | return __first; | 
|  | 1849 | } | 
|  | 1850 |  | 
|  | 1851 | template <class _CharT, class _Traits> | 
|  | 1852 | template <class _ForwardIterator> | 
|  | 1853 | _ForwardIterator | 
|  | 1854 | basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first, | 
|  | 1855 | _ForwardIterator __last) | 
|  | 1856 | { | 
|  | 1857 | if (__first != __last) | 
|  | 1858 | { | 
|  | 1859 | _ForwardIterator __temp = next(__first); | 
|  | 1860 | if (__temp != __last) | 
|  | 1861 | { | 
|  | 1862 | if (*__first == '\\' && '1' <= *__temp && *__temp <= '9') | 
|  | 1863 | { | 
|  | 1864 | __push_back_ref(*__temp - '0'); | 
|  | 1865 | __first = ++__temp; | 
|  | 1866 | } | 
|  | 1867 | } | 
|  | 1868 | } | 
|  | 1869 | return __first; | 
|  | 1870 | } | 
|  | 1871 |  | 
|  | 1872 | template <class _CharT, class _Traits> | 
|  | 1873 | template <class _ForwardIterator> | 
|  | 1874 | _ForwardIterator | 
|  | 1875 | basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first, | 
|  | 1876 | _ForwardIterator __last) | 
|  | 1877 | { | 
|  | 1878 | if (__first != __last) | 
|  | 1879 | { | 
|  | 1880 | _ForwardIterator __temp = next(__first); | 
|  | 1881 | if (__temp == __last && *__first == '$') | 
|  | 1882 | return __first; | 
|  | 1883 | // Not called inside a bracket | 
|  | 1884 | if (*__first == '.' || *__first == '\\' || *__first == '[') | 
|  | 1885 | return __first; | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 1886 | __push_char(*__first); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1887 | ++__first; | 
|  | 1888 | } | 
|  | 1889 | return __first; | 
|  | 1890 | } | 
|  | 1891 |  | 
|  | 1892 | template <class _CharT, class _Traits> | 
|  | 1893 | template <class _ForwardIterator> | 
|  | 1894 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1895 | basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first, | 
|  | 1896 | _ForwardIterator __last) | 
|  | 1897 | { | 
|  | 1898 | if (__first != __last) | 
|  | 1899 | { | 
|  | 1900 | switch (*__first) | 
|  | 1901 | { | 
|  | 1902 | case '^': | 
|  | 1903 | case '.': | 
|  | 1904 | case '[': | 
|  | 1905 | case '$': | 
|  | 1906 | case '(': | 
|  | 1907 | case '|': | 
|  | 1908 | case '*': | 
|  | 1909 | case '+': | 
|  | 1910 | case '?': | 
|  | 1911 | case '{': | 
|  | 1912 | case '\\': | 
|  | 1913 | break; | 
|  | 1914 | case ')': | 
|  | 1915 | if (__open_count_ == 0) | 
|  | 1916 | { | 
|  | 1917 | __push_char(*__first); | 
|  | 1918 | ++__first; | 
|  | 1919 | } | 
|  | 1920 | break; | 
|  | 1921 | default: | 
|  | 1922 | __push_char(*__first); | 
|  | 1923 | ++__first; | 
|  | 1924 | break; | 
|  | 1925 | } | 
|  | 1926 | } | 
|  | 1927 | return __first; | 
|  | 1928 | } | 
|  | 1929 |  | 
|  | 1930 | template <class _CharT, class _Traits> | 
|  | 1931 | template <class _ForwardIterator> | 
|  | 1932 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1933 | basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first, | 
|  | 1934 | _ForwardIterator __last) | 
|  | 1935 | { | 
|  | 1936 | if (__first != __last) | 
|  | 1937 | { | 
|  | 1938 | _ForwardIterator __temp = next(__first); | 
|  | 1939 | if (__temp != __last) | 
|  | 1940 | { | 
|  | 1941 | if (*__first == '\\') | 
|  | 1942 | { | 
|  | 1943 | switch (*__temp) | 
|  | 1944 | { | 
|  | 1945 | case '^': | 
|  | 1946 | case '.': | 
|  | 1947 | case '*': | 
|  | 1948 | case '[': | 
|  | 1949 | case '$': | 
|  | 1950 | case '\\': | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 1951 | __push_char(*__temp); | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 1952 | __first = ++__temp; | 
|  | 1953 | break; | 
|  | 1954 | } | 
|  | 1955 | } | 
|  | 1956 | } | 
|  | 1957 | } | 
|  | 1958 | return __first; | 
|  | 1959 | } | 
|  | 1960 |  | 
|  | 1961 | template <class _CharT, class _Traits> | 
|  | 1962 | template <class _ForwardIterator> | 
|  | 1963 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 1964 | basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first, | 
|  | 1965 | _ForwardIterator __last) | 
|  | 1966 | { | 
|  | 1967 | if (__first != __last) | 
|  | 1968 | { | 
|  | 1969 | _ForwardIterator __temp = next(__first); | 
|  | 1970 | if (__temp != __last) | 
|  | 1971 | { | 
|  | 1972 | if (*__first == '\\') | 
|  | 1973 | { | 
|  | 1974 | switch (*__temp) | 
|  | 1975 | { | 
|  | 1976 | case '^': | 
|  | 1977 | case '.': | 
|  | 1978 | case '*': | 
|  | 1979 | case '[': | 
|  | 1980 | case '$': | 
|  | 1981 | case '\\': | 
|  | 1982 | case '(': | 
|  | 1983 | case ')': | 
|  | 1984 | case '|': | 
|  | 1985 | case '+': | 
|  | 1986 | case '?': | 
|  | 1987 | case '{': | 
|  | 1988 | __push_char(*__temp); | 
|  | 1989 | __first = ++__temp; | 
|  | 1990 | break; | 
|  | 1991 | } | 
|  | 1992 | } | 
|  | 1993 | } | 
|  | 1994 | } | 
|  | 1995 | return __first; | 
|  | 1996 | } | 
|  | 1997 |  | 
|  | 1998 | template <class _CharT, class _Traits> | 
|  | 1999 | template <class _ForwardIterator> | 
|  | 2000 | _ForwardIterator | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2001 | basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first, | 
|  | 2002 | _ForwardIterator __last) | 
|  | 2003 | { | 
|  | 2004 | if (__first != __last) | 
|  | 2005 | { | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2006 | if (*__first == '*') | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2007 | { | 
|  | 2008 | __push_greedy_inf_repeat(0); | 
|  | 2009 | ++__first; | 
|  | 2010 | } | 
|  | 2011 | else | 
|  | 2012 | { | 
|  | 2013 | _ForwardIterator __temp = __parse_Back_open_brace(__first, __last); | 
|  | 2014 | if (__temp != __first) | 
|  | 2015 | { | 
|  | 2016 | int __min = 0; | 
|  | 2017 | __first = __temp; | 
|  | 2018 | __temp = __parse_DUP_COUNT(__first, __last, __min); | 
|  | 2019 | if (__temp == __first) | 
|  | 2020 | throw regex_error(regex_constants::error_badbrace); | 
|  | 2021 | __first = __temp; | 
|  | 2022 | if (__first == __last) | 
|  | 2023 | throw regex_error(regex_constants::error_brace); | 
|  | 2024 | if (*__first != ',') | 
|  | 2025 | { | 
|  | 2026 | __temp = __parse_Back_close_brace(__first, __last); | 
|  | 2027 | if (__temp == __first) | 
|  | 2028 | throw regex_error(regex_constants::error_brace); | 
|  | 2029 | __push_exact_repeat(__min); | 
|  | 2030 | __first = __temp; | 
|  | 2031 | } | 
|  | 2032 | else | 
|  | 2033 | { | 
|  | 2034 | ++__first; // consume ',' | 
|  | 2035 | int __max = -1; | 
|  | 2036 | __first = __parse_DUP_COUNT(__first, __last, __max); | 
|  | 2037 | __temp = __parse_Back_close_brace(__first, __last); | 
|  | 2038 | if (__temp == __first) | 
|  | 2039 | throw regex_error(regex_constants::error_brace); | 
|  | 2040 | if (__max == -1) | 
|  | 2041 | __push_greedy_inf_repeat(__min); | 
|  | 2042 | else | 
|  | 2043 | { | 
|  | 2044 | if (__max < __min) | 
|  | 2045 | throw regex_error(regex_constants::error_badbrace); | 
|  | 2046 | __push_repeat(__min, __max); | 
|  | 2047 | } | 
|  | 2048 | __first = __temp; | 
|  | 2049 | } | 
|  | 2050 | } | 
|  | 2051 | } | 
|  | 2052 | } | 
|  | 2053 | return __first; | 
|  | 2054 | } | 
|  | 2055 |  | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2056 | template <class _CharT, class _Traits> | 
|  | 2057 | template <class _ForwardIterator> | 
|  | 2058 | _ForwardIterator | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 2059 | basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, | 
|  | 2060 | _ForwardIterator __last) | 
|  | 2061 | { | 
|  | 2062 | if (__first != __last) | 
|  | 2063 | { | 
|  | 2064 | switch (*__first) | 
|  | 2065 | { | 
|  | 2066 | case '*': | 
|  | 2067 | __push_greedy_inf_repeat(0); | 
|  | 2068 | ++__first; | 
|  | 2069 | break; | 
|  | 2070 | case '+': | 
|  | 2071 | __push_greedy_inf_repeat(1); | 
|  | 2072 | ++__first; | 
|  | 2073 | break; | 
|  | 2074 | case '?': | 
|  | 2075 | __push_repeat(0, 1); | 
|  | 2076 | ++__first; | 
|  | 2077 | break; | 
|  | 2078 | case '{': | 
|  | 2079 | { | 
|  | 2080 | int __min; | 
|  | 2081 | _ForwardIterator __temp = __parse_DUP_COUNT(__first, __last, __min); | 
|  | 2082 | if (__temp == __first) | 
|  | 2083 | throw regex_error(regex_constants::error_badbrace); | 
|  | 2084 | __first = __temp; | 
|  | 2085 | if (__first == __last) | 
|  | 2086 | throw regex_error(regex_constants::error_brace); | 
|  | 2087 | switch (*__first) | 
|  | 2088 | { | 
|  | 2089 | case '}': | 
|  | 2090 | __push_exact_repeat(__min); | 
|  | 2091 | ++__first; | 
|  | 2092 | break; | 
|  | 2093 | case ',': | 
|  | 2094 | if (++__first == __last) | 
|  | 2095 | throw regex_error(regex_constants::error_badbrace); | 
|  | 2096 | if (*__first == '}') | 
|  | 2097 | { | 
|  | 2098 | __push_greedy_inf_repeat(__min); | 
|  | 2099 | ++__first; | 
|  | 2100 | } | 
|  | 2101 | else | 
|  | 2102 | { | 
|  | 2103 | int __max; | 
|  | 2104 | __temp = __parse_DUP_COUNT(__first, __last, __max); | 
|  | 2105 | if (__temp == __first) | 
|  | 2106 | throw regex_error(regex_constants::error_brace); | 
|  | 2107 | __first = __temp; | 
|  | 2108 | if (__first == __last || *__first != '}') | 
|  | 2109 | throw regex_error(regex_constants::error_brace); | 
|  | 2110 | ++__first; | 
|  | 2111 | if (__max < __min) | 
|  | 2112 | throw regex_error(regex_constants::error_badbrace); | 
|  | 2113 | __push_repeat(__min, __max); | 
|  | 2114 | } | 
|  | 2115 | default: | 
|  | 2116 | throw regex_error(regex_constants::error_badbrace); | 
|  | 2117 | } | 
|  | 2118 | } | 
|  | 2119 | break; | 
|  | 2120 | } | 
|  | 2121 | } | 
|  | 2122 | return __first; | 
|  | 2123 | } | 
|  | 2124 |  | 
|  | 2125 | template <class _CharT, class _Traits> | 
|  | 2126 | template <class _ForwardIterator> | 
|  | 2127 | _ForwardIterator | 
| Howard Hinnant | 0de86b6 | 2010-06-25 20:56:08 | [diff] [blame] | 2128 | basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first, | 
|  | 2129 | _ForwardIterator __last) | 
|  | 2130 | { | 
|  | 2131 | if (__first != __last && *__first == '[') | 
|  | 2132 | { | 
|  | 2133 | if (++__first == __last) | 
|  | 2134 | throw regex_error(regex_constants::error_brack); | 
|  | 2135 | bool __non_matching = false; | 
|  | 2136 | if (*__first == '^') | 
|  | 2137 | { | 
|  | 2138 | ++__first; | 
|  | 2139 | __non_matching = true; | 
|  | 2140 | __start_nonmatching_list(); | 
|  | 2141 | } | 
|  | 2142 | else | 
|  | 2143 | __start_matching_list(); | 
|  | 2144 | if (__first == __last) | 
|  | 2145 | throw regex_error(regex_constants::error_brack); | 
|  | 2146 | if (*__first == ']') | 
|  | 2147 | { | 
|  | 2148 | __push_char(']'); | 
|  | 2149 | ++__first; | 
|  | 2150 | } | 
|  | 2151 | __first = __parse_follow_list(__first, __last); | 
|  | 2152 | if (__first == __last) | 
|  | 2153 | throw regex_error(regex_constants::error_brack); | 
|  | 2154 | if (*__first == '-') | 
|  | 2155 | { | 
|  | 2156 | __push_char('-'); | 
|  | 2157 | ++__first; | 
|  | 2158 | } | 
|  | 2159 | if (__first == __last || *__first != ']') | 
|  | 2160 | throw regex_error(regex_constants::error_brack); | 
|  | 2161 | if (__non_matching) | 
|  | 2162 | __end_nonmatching_list(); | 
|  | 2163 | else | 
|  | 2164 | __end_matching_list(); | 
|  | 2165 | ++__first; | 
|  | 2166 | } | 
|  | 2167 | return __first; | 
|  | 2168 | } | 
|  | 2169 |  | 
|  | 2170 | template <class _CharT, class _Traits> | 
|  | 2171 | template <class _ForwardIterator> | 
|  | 2172 | _ForwardIterator | 
|  | 2173 | basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first, | 
|  | 2174 | _ForwardIterator __last) | 
|  | 2175 | { | 
|  | 2176 | if (__first != __last) | 
|  | 2177 | { | 
|  | 2178 | while (true) | 
|  | 2179 | { | 
|  | 2180 | _ForwardIterator __temp = __parse_expression_term(__first, __last); | 
|  | 2181 | if (__temp == __first) | 
|  | 2182 | break; | 
|  | 2183 | __first = __temp; | 
|  | 2184 | } | 
|  | 2185 | } | 
|  | 2186 | return __first; | 
|  | 2187 | } | 
|  | 2188 |  | 
|  | 2189 | template <class _CharT, class _Traits> | 
|  | 2190 | template <class _ForwardIterator> | 
|  | 2191 | _ForwardIterator | 
|  | 2192 | basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, | 
|  | 2193 | _ForwardIterator __last) | 
|  | 2194 | { | 
|  | 2195 | if (__first != __last && *__first != ']') | 
|  | 2196 | { | 
|  | 2197 | bool __parsed_one = false; | 
|  | 2198 | _ForwardIterator __temp = next(__first); | 
|  | 2199 | if (__temp != __last && *__first == '[') | 
|  | 2200 | { | 
|  | 2201 | if (*__temp == '=') | 
|  | 2202 | return __parse_equivalence_class(++__temp, __last); | 
|  | 2203 | else if (*__temp == ':') | 
|  | 2204 | return __parse_character_class(++__temp, __last); | 
|  | 2205 | else if (*__temp == '.') | 
|  | 2206 | { | 
|  | 2207 | __first = __parse_collating_symbol(++__temp, __last); | 
|  | 2208 | __parsed_one = true; | 
|  | 2209 | } | 
|  | 2210 | } | 
|  | 2211 | if (!__parsed_one) | 
|  | 2212 | { | 
|  | 2213 | __push_char(*__first); | 
|  | 2214 | ++__first; | 
|  | 2215 | } | 
|  | 2216 | if (__first != __last && *__first != ']') | 
|  | 2217 | { | 
|  | 2218 | __temp = next(__first); | 
|  | 2219 | if (__temp != __last && *__first == '-' && *__temp != ']') | 
|  | 2220 | { | 
|  | 2221 | // parse a range | 
|  | 2222 | __first = __temp; | 
|  | 2223 | ++__temp; | 
|  | 2224 | if (__temp != __last && *__first == '[' && *__temp == '.') | 
|  | 2225 | __first = __parse_collating_symbol(++__temp, __last); | 
|  | 2226 | else | 
|  | 2227 | { | 
|  | 2228 | __push_char(*__first); | 
|  | 2229 | ++__first; | 
|  | 2230 | } | 
|  | 2231 | __push_range(); | 
|  | 2232 | } | 
|  | 2233 | } | 
|  | 2234 | } | 
|  | 2235 | return __first; | 
|  | 2236 | } | 
|  | 2237 |  | 
|  | 2238 | template <class _CharT, class _Traits> | 
|  | 2239 | template <class _ForwardIterator> | 
|  | 2240 | _ForwardIterator | 
|  | 2241 | basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first, | 
|  | 2242 | _ForwardIterator __last) | 
|  | 2243 | { | 
|  | 2244 | // Found [= | 
|  | 2245 | // This means =] must exist | 
|  | 2246 | value_type _Equal_close[2] = {'=', ']'}; | 
|  | 2247 | _ForwardIterator __temp = _STD::search(__first, __last, _Equal_close, | 
|  | 2248 | _Equal_close+2); | 
|  | 2249 | if (__temp == __last) | 
|  | 2250 | throw regex_error(regex_constants::error_brack); | 
|  | 2251 | // [__first, __temp) contains all text in [= ... =] | 
|  | 2252 | typedef typename _Traits::string_type string_type; | 
|  | 2253 | string_type __collate_name = | 
|  | 2254 | __traits_.lookup_collatename(__first, __temp); | 
|  | 2255 | if (__collate_name.empty()) | 
|  | 2256 | throw regex_error(regex_constants::error_brack); | 
|  | 2257 | string_type __equiv_name = | 
|  | 2258 | __traits_.transform_primary(__collate_name.begin(), | 
|  | 2259 | __collate_name.end()); | 
|  | 2260 | if (!__equiv_name.empty()) | 
|  | 2261 | __push_char(__equiv_name); | 
|  | 2262 | else | 
|  | 2263 | __push_char(__collate_name); | 
|  | 2264 | __first = next(__temp, 2); | 
|  | 2265 | return __first; | 
|  | 2266 | } | 
|  | 2267 |  | 
|  | 2268 | template <class _CharT, class _Traits> | 
|  | 2269 | template <class _ForwardIterator> | 
|  | 2270 | _ForwardIterator | 
|  | 2271 | basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first, | 
|  | 2272 | _ForwardIterator __last) | 
|  | 2273 | { | 
|  | 2274 | // Found [: | 
|  | 2275 | // This means :] must exist | 
|  | 2276 | value_type _Colon_close[2] = {':', ']'}; | 
|  | 2277 | _ForwardIterator __temp = _STD::search(__first, __last, _Colon_close, | 
|  | 2278 | _Colon_close+2); | 
|  | 2279 | if (__temp == __last) | 
|  | 2280 | throw regex_error(regex_constants::error_brack); | 
|  | 2281 | // [__first, __temp) contains all text in [: ... :] | 
|  | 2282 | typedef typename _Traits::char_class_type char_class_type; | 
|  | 2283 | char_class_type __class_type = | 
|  | 2284 | __traits_.lookup_classname(__first, __temp, __flags_ & icase); | 
|  | 2285 | if (__class_type == 0) | 
|  | 2286 | throw regex_error(regex_constants::error_brack); | 
|  | 2287 | __push_class_type(__class_type); | 
|  | 2288 | __first = next(__temp, 2); | 
|  | 2289 | return __first; | 
|  | 2290 | } | 
|  | 2291 |  | 
|  | 2292 | template <class _CharT, class _Traits> | 
|  | 2293 | template <class _ForwardIterator> | 
|  | 2294 | _ForwardIterator | 
|  | 2295 | basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first, | 
|  | 2296 | _ForwardIterator __last) | 
|  | 2297 | { | 
|  | 2298 | // Found [. | 
|  | 2299 | // This means .] must exist | 
|  | 2300 | value_type _Dot_close[2] = {'.', ']'}; | 
|  | 2301 | _ForwardIterator __temp = _STD::search(__first, __last, _Dot_close, | 
|  | 2302 | _Dot_close+2); | 
|  | 2303 | if (__temp == __last) | 
|  | 2304 | throw regex_error(regex_constants::error_brack); | 
|  | 2305 | // [__first, __temp) contains all text in [. ... .] | 
|  | 2306 | typedef typename _Traits::string_type string_type; | 
|  | 2307 | string_type __collate_name = | 
|  | 2308 | __traits_.lookup_collatename(__first, __temp); | 
|  | 2309 | if (__collate_name.empty()) | 
|  | 2310 | throw regex_error(regex_constants::error_brack); | 
|  | 2311 | __push_char(__collate_name); | 
|  | 2312 | __first = next(__temp, 2); | 
|  | 2313 | return __first; | 
|  | 2314 | } | 
|  | 2315 |  | 
|  | 2316 | template <class _CharT, class _Traits> | 
|  | 2317 | template <class _ForwardIterator> | 
|  | 2318 | _ForwardIterator | 
|  | 2319 | basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, | 
|  | 2320 | _ForwardIterator __last, | 
|  | 2321 | int& __c) | 
|  | 2322 | { | 
|  | 2323 | if (__first != __last && '0' <= *__first && *__first <= '9') | 
|  | 2324 | { | 
|  | 2325 | __c = *__first - '0'; | 
|  | 2326 | for (++__first; __first != __last && '0' <= *__first && *__first <= '9'; | 
|  | 2327 | ++__first) | 
|  | 2328 | { | 
|  | 2329 | __c *= 10; | 
|  | 2330 | __c += *__first - '0'; | 
|  | 2331 | } | 
|  | 2332 | } | 
|  | 2333 | return __first; | 
|  | 2334 | } | 
|  | 2335 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 2336 | template <class _CharT, class _Traits> | 
|  | 2337 | void | 
|  | 2338 | basic_regex<_CharT, _Traits>::__push_char(value_type __c) | 
|  | 2339 | { | 
|  | 2340 | unique_ptr<__state<_CharT> > __new_end(new __state<_CharT>); | 
|  | 2341 | unique_ptr<__transition<_CharT> > __new_transition( | 
|  | 2342 | new __match_char<_CharT>(__c, true, __new_end.get())); | 
|  | 2343 | __state<_CharT>* __e = __new_end.release(); | 
|  | 2344 | if (__end_ == nullptr) | 
|  | 2345 | { | 
|  | 2346 | __start_.reset(new __state<_CharT>); | 
|  | 2347 | __end_ = __start_.get(); | 
|  | 2348 | } | 
|  | 2349 | __end_->__add_one(__new_transition.release()); | 
|  | 2350 | __end_ = __e; | 
|  | 2351 | } | 
|  | 2352 |  | 
| Howard Hinnant | 8c2c18d | 2010-06-24 21:28:00 | [diff] [blame] | 2353 | typedef basic_regex<char> regex; | 
|  | 2354 | typedef basic_regex<wchar_t> wregex; | 
|  | 2355 |  | 
| Howard Hinnant | cd85b9e | 2010-06-29 18:37:43 | [diff] [blame^] | 2356 | // sub_match | 
|  | 2357 |  | 
|  | 2358 | template <class _BidirectionalIterator> | 
|  | 2359 | class sub_match | 
|  | 2360 | : public pair<_BidirectionalIterator, _BidirectionalIterator> | 
|  | 2361 | { | 
|  | 2362 | public: | 
|  | 2363 | typedef _BidirectionalIterator iterator; | 
|  | 2364 | typedef typename iterator_traits<iterator>::value_type value_type; | 
|  | 2365 | typedef typename iterator_traits<iterator>::difference_type difference_type; | 
|  | 2366 | typedef basic_string<value_type> string_type; | 
|  | 2367 |  | 
|  | 2368 | bool matched; | 
|  | 2369 |  | 
|  | 2370 | difference_type length() const | 
|  | 2371 | {return matched ? _STD::distance(this->first, this->second) : 0;} | 
|  | 2372 | string_type str() const | 
|  | 2373 | {return matched ? string_type(this->first, this->second) : string_type();} | 
|  | 2374 | operator string_type() const | 
|  | 2375 | {return str();} | 
|  | 2376 |  | 
|  | 2377 | int compare(const sub_match& __s) const | 
|  | 2378 | {return str().compare(__s.str());} | 
|  | 2379 | int compare(const string_type& __s) const | 
|  | 2380 | {return str().compare(__s);} | 
|  | 2381 | int compare(const value_type* __s) const | 
|  | 2382 | {return str().compare(__s);} | 
|  | 2383 | }; | 
|  | 2384 |  | 
|  | 2385 | typedef sub_match<const char*> csub_match; | 
|  | 2386 | typedef sub_match<const wchar_t*> wcsub_match; | 
|  | 2387 | typedef sub_match<string::const_iterator> ssub_match; | 
|  | 2388 | typedef sub_match<wstring::const_iterator> wssub_match; | 
|  | 2389 |  | 
|  | 2390 | template <class _BiIter> | 
|  | 2391 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2392 | bool | 
|  | 2393 | operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 2394 | { | 
|  | 2395 | return __x.compare(__y) == 0; | 
|  | 2396 | } | 
|  | 2397 |  | 
|  | 2398 | template <class _BiIter> | 
|  | 2399 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2400 | bool | 
|  | 2401 | operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 2402 | { | 
|  | 2403 | return !(__x == __y); | 
|  | 2404 | } | 
|  | 2405 |  | 
|  | 2406 | template <class _BiIter> | 
|  | 2407 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2408 | bool | 
|  | 2409 | operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 2410 | { | 
|  | 2411 | return __x.compare(__y) < 0; | 
|  | 2412 | } | 
|  | 2413 |  | 
|  | 2414 | template <class _BiIter> | 
|  | 2415 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2416 | bool | 
|  | 2417 | operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 2418 | { | 
|  | 2419 | return !(__y < __x); | 
|  | 2420 | } | 
|  | 2421 |  | 
|  | 2422 | template <class _BiIter> | 
|  | 2423 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2424 | bool | 
|  | 2425 | operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 2426 | { | 
|  | 2427 | return !(__x < __y); | 
|  | 2428 | } | 
|  | 2429 |  | 
|  | 2430 | template <class _BiIter> | 
|  | 2431 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2432 | bool | 
|  | 2433 | operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) | 
|  | 2434 | { | 
|  | 2435 | return __y < __x; | 
|  | 2436 | } | 
|  | 2437 |  | 
|  | 2438 | template <class _BiIter, class _ST, class _SA> | 
|  | 2439 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2440 | bool | 
|  | 2441 | operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 2442 | const sub_match<_BiIter>& __y) | 
|  | 2443 | { | 
|  | 2444 | return __y.compare(__x.c_str()) == 0; | 
|  | 2445 | } | 
|  | 2446 |  | 
|  | 2447 | template <class _BiIter, class _ST, class _SA> | 
|  | 2448 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2449 | bool | 
|  | 2450 | operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 2451 | const sub_match<_BiIter>& __y) | 
|  | 2452 | { | 
|  | 2453 | return !(__x == __y); | 
|  | 2454 | } | 
|  | 2455 |  | 
|  | 2456 | template <class _BiIter, class _ST, class _SA> | 
|  | 2457 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2458 | bool | 
|  | 2459 | operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 2460 | const sub_match<_BiIter>& __y) | 
|  | 2461 | { | 
|  | 2462 | return __y.compare(__x.c_str()) > 0; | 
|  | 2463 | } | 
|  | 2464 |  | 
|  | 2465 | template <class _BiIter, class _ST, class _SA> | 
|  | 2466 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2467 | bool | 
|  | 2468 | operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 2469 | const sub_match<_BiIter>& __y) | 
|  | 2470 | { | 
|  | 2471 | return __y < __x; | 
|  | 2472 | } | 
|  | 2473 |  | 
|  | 2474 | template <class _BiIter, class _ST, class _SA> | 
|  | 2475 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2476 | bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 2477 | const sub_match<_BiIter>& __y) | 
|  | 2478 | { | 
|  | 2479 | return !(__x < __y); | 
|  | 2480 | } | 
|  | 2481 |  | 
|  | 2482 | template <class _BiIter, class _ST, class _SA> | 
|  | 2483 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2484 | bool | 
|  | 2485 | operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x, | 
|  | 2486 | const sub_match<_BiIter>& __y) | 
|  | 2487 | { | 
|  | 2488 | return !(__y < __x); | 
|  | 2489 | } | 
|  | 2490 |  | 
|  | 2491 | template <class _BiIter, class _ST, class _SA> | 
|  | 2492 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2493 | bool | 
|  | 2494 | operator==(const sub_match<_BiIter>& __x, | 
|  | 2495 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 2496 | { | 
|  | 2497 | return __x.compare(__y.c_str()) == 0; | 
|  | 2498 | } | 
|  | 2499 |  | 
|  | 2500 | template <class _BiIter, class _ST, class _SA> | 
|  | 2501 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2502 | bool | 
|  | 2503 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 2504 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 2505 | { | 
|  | 2506 | return !(__x == __y); | 
|  | 2507 | } | 
|  | 2508 |  | 
|  | 2509 | template <class _BiIter, class _ST, class _SA> | 
|  | 2510 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2511 | bool | 
|  | 2512 | operator<(const sub_match<_BiIter>& __x, | 
|  | 2513 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 2514 | { | 
|  | 2515 | return __x.compare(__y.c_str()) < 0; | 
|  | 2516 | } | 
|  | 2517 |  | 
|  | 2518 | template <class _BiIter, class _ST, class _SA> | 
|  | 2519 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2520 | bool operator>(const sub_match<_BiIter>& __x, | 
|  | 2521 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 2522 | { | 
|  | 2523 | return __y < __x; | 
|  | 2524 | } | 
|  | 2525 |  | 
|  | 2526 | template <class _BiIter, class _ST, class _SA> | 
|  | 2527 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2528 | bool | 
|  | 2529 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 2530 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 2531 | { | 
|  | 2532 | return !(__x < __y); | 
|  | 2533 | } | 
|  | 2534 |  | 
|  | 2535 | template <class _BiIter, class _ST, class _SA> | 
|  | 2536 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2537 | bool | 
|  | 2538 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 2539 | const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y) | 
|  | 2540 | { | 
|  | 2541 | return !(__y < __x); | 
|  | 2542 | } | 
|  | 2543 |  | 
|  | 2544 | template <class _BiIter> | 
|  | 2545 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2546 | bool | 
|  | 2547 | operator==(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 2548 | const sub_match<_BiIter>& __y) | 
|  | 2549 | { | 
|  | 2550 | return __y.compare(__x) == 0; | 
|  | 2551 | } | 
|  | 2552 |  | 
|  | 2553 | template <class _BiIter> | 
|  | 2554 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2555 | bool | 
|  | 2556 | operator!=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 2557 | const sub_match<_BiIter>& __y) | 
|  | 2558 | { | 
|  | 2559 | return !(__x == __y); | 
|  | 2560 | } | 
|  | 2561 |  | 
|  | 2562 | template <class _BiIter> | 
|  | 2563 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2564 | bool | 
|  | 2565 | operator<(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 2566 | const sub_match<_BiIter>& __y) | 
|  | 2567 | { | 
|  | 2568 | return __y.compare(__x) > 0; | 
|  | 2569 | } | 
|  | 2570 |  | 
|  | 2571 | template <class _BiIter> | 
|  | 2572 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2573 | bool | 
|  | 2574 | operator>(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 2575 | const sub_match<_BiIter>& __y) | 
|  | 2576 | { | 
|  | 2577 | return __y < __x; | 
|  | 2578 | } | 
|  | 2579 |  | 
|  | 2580 | template <class _BiIter> | 
|  | 2581 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2582 | bool | 
|  | 2583 | operator>=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 2584 | const sub_match<_BiIter>& __y) | 
|  | 2585 | { | 
|  | 2586 | return !(__x < __y); | 
|  | 2587 | } | 
|  | 2588 |  | 
|  | 2589 | template <class _BiIter> | 
|  | 2590 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2591 | bool | 
|  | 2592 | operator<=(typename iterator_traits<_BiIter>::value_type const* __x, | 
|  | 2593 | const sub_match<_BiIter>& __y) | 
|  | 2594 | { | 
|  | 2595 | return !(__y < __x); | 
|  | 2596 | } | 
|  | 2597 |  | 
|  | 2598 | template <class _BiIter> | 
|  | 2599 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2600 | bool | 
|  | 2601 | operator==(const sub_match<_BiIter>& __x, | 
|  | 2602 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 2603 | { | 
|  | 2604 | return __x.compare(__y) == 0; | 
|  | 2605 | } | 
|  | 2606 |  | 
|  | 2607 | template <class _BiIter> | 
|  | 2608 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2609 | bool | 
|  | 2610 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 2611 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 2612 | { | 
|  | 2613 | return !(__x == __y); | 
|  | 2614 | } | 
|  | 2615 |  | 
|  | 2616 | template <class _BiIter> | 
|  | 2617 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2618 | bool | 
|  | 2619 | operator<(const sub_match<_BiIter>& __x, | 
|  | 2620 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 2621 | { | 
|  | 2622 | return __x.compare(__y) < 0; | 
|  | 2623 | } | 
|  | 2624 |  | 
|  | 2625 | template <class _BiIter> | 
|  | 2626 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2627 | bool | 
|  | 2628 | operator>(const sub_match<_BiIter>& __x, | 
|  | 2629 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 2630 | { | 
|  | 2631 | return __y < __x; | 
|  | 2632 | } | 
|  | 2633 |  | 
|  | 2634 | template <class _BiIter> | 
|  | 2635 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2636 | bool | 
|  | 2637 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 2638 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 2639 | { | 
|  | 2640 | return !(__x < __y); | 
|  | 2641 | } | 
|  | 2642 |  | 
|  | 2643 | template <class _BiIter> | 
|  | 2644 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2645 | bool | 
|  | 2646 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 2647 | typename iterator_traits<_BiIter>::value_type const* __y) | 
|  | 2648 | { | 
|  | 2649 | return !(__y < __x); | 
|  | 2650 | } | 
|  | 2651 |  | 
|  | 2652 | template <class _BiIter> | 
|  | 2653 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2654 | bool | 
|  | 2655 | operator==(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 2656 | const sub_match<_BiIter>& __y) | 
|  | 2657 | { | 
|  | 2658 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 2659 | return __y.compare(string_type(1, __x)) == 0; | 
|  | 2660 | } | 
|  | 2661 |  | 
|  | 2662 | template <class _BiIter> | 
|  | 2663 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2664 | bool | 
|  | 2665 | operator!=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 2666 | const sub_match<_BiIter>& __y) | 
|  | 2667 | { | 
|  | 2668 | return !(__x == __y); | 
|  | 2669 | } | 
|  | 2670 |  | 
|  | 2671 | template <class _BiIter> | 
|  | 2672 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2673 | bool | 
|  | 2674 | operator<(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 2675 | const sub_match<_BiIter>& __y) | 
|  | 2676 | { | 
|  | 2677 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 2678 | return __y.compare(string_type(1, __x)) > 0; | 
|  | 2679 | } | 
|  | 2680 |  | 
|  | 2681 | template <class _BiIter> | 
|  | 2682 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2683 | bool | 
|  | 2684 | operator>(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 2685 | const sub_match<_BiIter>& __y) | 
|  | 2686 | { | 
|  | 2687 | return __y < __x; | 
|  | 2688 | } | 
|  | 2689 |  | 
|  | 2690 | template <class _BiIter> | 
|  | 2691 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2692 | bool | 
|  | 2693 | operator>=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 2694 | const sub_match<_BiIter>& __y) | 
|  | 2695 | { | 
|  | 2696 | return !(__x < __y); | 
|  | 2697 | } | 
|  | 2698 |  | 
|  | 2699 | template <class _BiIter> | 
|  | 2700 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2701 | bool | 
|  | 2702 | operator<=(typename iterator_traits<_BiIter>::value_type const& __x, | 
|  | 2703 | const sub_match<_BiIter>& __y) | 
|  | 2704 | { | 
|  | 2705 | return !(__y < __x); | 
|  | 2706 | } | 
|  | 2707 |  | 
|  | 2708 | template <class _BiIter> | 
|  | 2709 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2710 | bool | 
|  | 2711 | operator==(const sub_match<_BiIter>& __x, | 
|  | 2712 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 2713 | { | 
|  | 2714 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 2715 | return __x.compare(string_type(1, __y)) == 0; | 
|  | 2716 | } | 
|  | 2717 |  | 
|  | 2718 | template <class _BiIter> | 
|  | 2719 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2720 | bool | 
|  | 2721 | operator!=(const sub_match<_BiIter>& __x, | 
|  | 2722 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 2723 | { | 
|  | 2724 | return !(__x == __y); | 
|  | 2725 | } | 
|  | 2726 |  | 
|  | 2727 | template <class _BiIter> | 
|  | 2728 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2729 | bool | 
|  | 2730 | operator<(const sub_match<_BiIter>& __x, | 
|  | 2731 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 2732 | { | 
|  | 2733 | typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type; | 
|  | 2734 | return __x.compare(string_type(1, __y)) < 0; | 
|  | 2735 | } | 
|  | 2736 |  | 
|  | 2737 | template <class _BiIter> | 
|  | 2738 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2739 | bool | 
|  | 2740 | operator>(const sub_match<_BiIter>& __x, | 
|  | 2741 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 2742 | { | 
|  | 2743 | return __y < __x; | 
|  | 2744 | } | 
|  | 2745 |  | 
|  | 2746 | template <class _BiIter> | 
|  | 2747 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2748 | bool | 
|  | 2749 | operator>=(const sub_match<_BiIter>& __x, | 
|  | 2750 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 2751 | { | 
|  | 2752 | return !(__x < __y); | 
|  | 2753 | } | 
|  | 2754 |  | 
|  | 2755 | template <class _BiIter> | 
|  | 2756 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2757 | bool | 
|  | 2758 | operator<=(const sub_match<_BiIter>& __x, | 
|  | 2759 | typename iterator_traits<_BiIter>::value_type const& __y) | 
|  | 2760 | { | 
|  | 2761 | return !(__y < __x); | 
|  | 2762 | } | 
|  | 2763 |  | 
|  | 2764 | template <class _CharT, class _ST, class _BiIter> | 
|  | 2765 | inline _LIBCPP_INLINE_VISIBILITY | 
|  | 2766 | basic_ostream<_CharT, _ST>& | 
|  | 2767 | operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) | 
|  | 2768 | { | 
|  | 2769 | return __os << __m.str(); | 
|  | 2770 | } | 
|  | 2771 |  | 
| Howard Hinnant | 3257c98 | 2010-06-17 00:34:59 | [diff] [blame] | 2772 | _LIBCPP_END_NAMESPACE_STD | 
|  | 2773 |  | 
|  | 2774 | #endif // _LIBCPP_REGEX |