1 1.1 mrg // class template regex -*- C++ -*- 2 1.1 mrg 3 1.1.1.13 mrg // Copyright (C) 2007-2024 Free Software Foundation, Inc. 4 1.1 mrg // 5 1.1 mrg // This file is part of the GNU ISO C++ Library. This library is free 6 1.1 mrg // software; you can redistribute it and/or modify it under the 7 1.1 mrg // terms of the GNU General Public License as published by the 8 1.1 mrg // Free Software Foundation; either version 3, or (at your option) 9 1.1 mrg // any later version. 10 1.1 mrg 11 1.1 mrg // This library is distributed in the hope that it will be useful, 12 1.1 mrg // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 1.1 mrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 1.1 mrg // GNU General Public License for more details. 15 1.1 mrg 16 1.1 mrg // Under Section 7 of GPL version 3, you are granted additional 17 1.1 mrg // permissions described in the GCC Runtime Library Exception, version 18 1.1 mrg // 3.1, as published by the Free Software Foundation. 19 1.1 mrg 20 1.1 mrg // You should have received a copy of the GNU General Public License and 21 1.1 mrg // a copy of the GCC Runtime Library Exception along with this program; 22 1.1 mrg // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23 1.1 mrg // <http://www.gnu.org/licenses/>. 24 1.1 mrg 25 1.1 mrg /** 26 1.1 mrg * @file tr1/regex 27 1.1 mrg * @author Stephen M. Webb <stephen.webb (a] bregmasoft.ca> 28 1.1 mrg * This is a TR1 C++ Library header. 29 1.1 mrg */ 30 1.1 mrg 31 1.1 mrg #ifndef _GLIBCXX_TR1_REGEX 32 1.1 mrg #define _GLIBCXX_TR1_REGEX 1 33 1.1 mrg 34 1.1 mrg #pragma GCC system_header 35 1.1 mrg 36 1.1.1.13 mrg #include <bits/requires_hosted.h> // TR1 37 1.1.1.13 mrg 38 1.1 mrg #include <algorithm> 39 1.1 mrg #include <bitset> 40 1.1 mrg #include <iterator> 41 1.1 mrg #include <locale> 42 1.1 mrg #include <stdexcept> 43 1.1 mrg #include <string> 44 1.1 mrg #include <vector> 45 1.1 mrg #include <utility> 46 1.1 mrg #include <sstream> 47 1.1 mrg 48 1.1.1.2 mrg namespace std _GLIBCXX_VISIBILITY(default) 49 1.1.1.2 mrg { 50 1.1.1.8 mrg _GLIBCXX_BEGIN_NAMESPACE_VERSION 51 1.1.1.8 mrg 52 1.1.1.2 mrg namespace tr1 53 1.1.1.2 mrg { 54 1.1.1.2 mrg /** 55 1.1.1.2 mrg * @defgroup tr1_regex Regular Expressions 56 1.1.1.2 mrg * A facility for performing regular expression pattern matching. 57 1.1.1.2 mrg */ 58 1.1.1.11 mrg ///@{ 59 1.1.1.2 mrg 60 1.1.1.2 mrg /** @namespace std::regex_constants 61 1.1.1.2 mrg * @brief ISO C++ 0x entities sub namespace for regex. 62 1.1.1.2 mrg */ 63 1.1.1.2 mrg namespace regex_constants 64 1.1.1.2 mrg { 65 1.1.1.2 mrg /** 66 1.1.1.2 mrg * @name 5.1 Regular Expression Syntax Options 67 1.1.1.2 mrg */ 68 1.1.1.11 mrg ///@{ 69 1.1.1.2 mrg enum __syntax_option 70 1.1.1.2 mrg { 71 1.1.1.2 mrg _S_icase, 72 1.1.1.2 mrg _S_nosubs, 73 1.1.1.2 mrg _S_optimize, 74 1.1.1.2 mrg _S_collate, 75 1.1.1.2 mrg _S_ECMAScript, 76 1.1.1.2 mrg _S_basic, 77 1.1.1.2 mrg _S_extended, 78 1.1.1.2 mrg _S_awk, 79 1.1.1.2 mrg _S_grep, 80 1.1.1.2 mrg _S_egrep, 81 1.1.1.2 mrg _S_syntax_last 82 1.1.1.2 mrg }; 83 1.1.1.2 mrg 84 1.1.1.2 mrg /** 85 1.1.1.2 mrg * @brief This is a bitmask type indicating how to interpret the regex. 86 1.1.1.2 mrg * 87 1.1.1.2 mrg * The @c syntax_option_type is implementation defined but it is valid to 88 1.1.1.2 mrg * perform bitwise operations on these values and expect the right thing to 89 1.1.1.2 mrg * happen. 90 1.1.1.2 mrg * 91 1.1.1.2 mrg * A valid value of type syntax_option_type shall have exactly one of the 92 1.1.1.2 mrg * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep 93 1.1.1.2 mrg * %set. 94 1.1.1.2 mrg */ 95 1.1.1.2 mrg typedef unsigned int syntax_option_type; 96 1.1.1.2 mrg 97 1.1.1.2 mrg /** 98 1.1.1.2 mrg * Specifies that the matching of regular expressions against a character 99 1.1.1.2 mrg * sequence shall be performed without regard to case. 100 1.1.1.2 mrg */ 101 1.1.1.2 mrg static const syntax_option_type icase = 1 << _S_icase; 102 1.1.1.2 mrg 103 1.1.1.2 mrg /** 104 1.1.1.2 mrg * Specifies that when a regular expression is matched against a character 105 1.1.1.2 mrg * container sequence, no sub-expression matches are to be stored in the 106 1.1.1.2 mrg * supplied match_results structure. 107 1.1.1.2 mrg */ 108 1.1.1.2 mrg static const syntax_option_type nosubs = 1 << _S_nosubs; 109 1.1.1.2 mrg 110 1.1.1.2 mrg /** 111 1.1.1.2 mrg * Specifies that the regular expression engine should pay more attention to 112 1.1.1.2 mrg * the speed with which regular expressions are matched, and less to the 113 1.1.1.2 mrg * speed with which regular expression objects are constructed. Otherwise 114 1.1.1.2 mrg * it has no detectable effect on the program output. 115 1.1.1.2 mrg */ 116 1.1.1.2 mrg static const syntax_option_type optimize = 1 << _S_optimize; 117 1.1.1.2 mrg 118 1.1.1.2 mrg /** 119 1.1.1.2 mrg * Specifies that character ranges of the form [a-b] should be locale 120 1.1.1.2 mrg * sensitive. 121 1.1.1.2 mrg */ 122 1.1.1.2 mrg static const syntax_option_type collate = 1 << _S_collate; 123 1.1.1.2 mrg 124 1.1.1.2 mrg /** 125 1.1.1.2 mrg * Specifies that the grammar recognized by the regular expression engine is 126 1.1.1.2 mrg * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript 127 1.1.1.2 mrg * Language Specification, Standard Ecma-262, third edition, 1999], as 128 1.1.1.2 mrg * modified in tr1 section [7.13]. This grammar is similar to that defined 129 1.1.1.2 mrg * in the PERL scripting language but extended with elements found in the 130 1.1.1.2 mrg * POSIX regular expression grammar. 131 1.1.1.2 mrg */ 132 1.1.1.2 mrg static const syntax_option_type ECMAScript = 1 << _S_ECMAScript; 133 1.1.1.2 mrg 134 1.1.1.2 mrg /** 135 1.1.1.2 mrg * Specifies that the grammar recognized by the regular expression engine is 136 1.1.1.2 mrg * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, 137 1.1.1.2 mrg * Portable Operating System Interface (POSIX), Base Definitions and 138 1.1.1.2 mrg * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- 139 1.1.1.2 mrg * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. 140 1.1.1.2 mrg */ 141 1.1.1.2 mrg static const syntax_option_type basic = 1 << _S_basic; 142 1.1.1.2 mrg 143 1.1.1.2 mrg /** 144 1.1.1.2 mrg * Specifies that the grammar recognized by the regular expression engine is 145 1.1.1.2 mrg * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, 146 1.1.1.2 mrg * Portable Operating System Interface (POSIX), Base Definitions and Headers, 147 1.1.1.2 mrg * Section 9, Regular Expressions. 148 1.1.1.2 mrg */ 149 1.1.1.2 mrg static const syntax_option_type extended = 1 << _S_extended; 150 1.1.1.2 mrg 151 1.1.1.2 mrg /** 152 1.1.1.2 mrg * Specifies that the grammar recognized by the regular expression engine is 153 1.1.1.2 mrg * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is 154 1.1.1.2 mrg * identical to syntax_option_type extended, except that C-style escape 155 1.1.1.2 mrg * sequences are supported. These sequences are: 156 1.1.1.2 mrg * \\\\, \\a, \\b, \\f, 157 1.1.1.2 mrg * \\n, \\r, \\t , \\v, 158 1.1.1.2 mrg * \\', ', and \\ddd 159 1.1.1.2 mrg * (where ddd is one, two, or three octal digits). 160 1.1.1.2 mrg */ 161 1.1.1.2 mrg static const syntax_option_type awk = 1 << _S_awk; 162 1.1.1.2 mrg 163 1.1.1.2 mrg /** 164 1.1.1.2 mrg * Specifies that the grammar recognized by the regular expression engine is 165 1.1.1.2 mrg * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is 166 1.1.1.2 mrg * identical to syntax_option_type basic, except that newlines are treated 167 1.1.1.2 mrg * as whitespace. 168 1.1.1.2 mrg */ 169 1.1.1.2 mrg static const syntax_option_type grep = 1 << _S_grep; 170 1.1.1.2 mrg 171 1.1.1.2 mrg /** 172 1.1.1.2 mrg * Specifies that the grammar recognized by the regular expression engine is 173 1.1.1.2 mrg * that used by POSIX utility grep when given the -E option in 174 1.1.1.2 mrg * IEEE Std 1003.1-2001. This option is identical to syntax_option_type 175 1.1.1.2 mrg * extended, except that newlines are treated as whitespace. 176 1.1.1.2 mrg */ 177 1.1.1.2 mrg static const syntax_option_type egrep = 1 << _S_egrep; 178 1.1.1.2 mrg 179 1.1.1.11 mrg ///@} 180 1.1.1.2 mrg 181 1.1.1.2 mrg /** 182 1.1.1.2 mrg * @name 5.2 Matching Rules 183 1.1.1.2 mrg * 184 1.1.1.2 mrg * Matching a regular expression against a sequence of characters [first, 185 1.1.1.2 mrg * last) proceeds according to the rules of the grammar specified for the 186 1.1.1.2 mrg * regular expression object, modified according to the effects listed 187 1.1.1.2 mrg * below for any bitmask elements set. 188 1.1.1.2 mrg * 189 1.1.1.2 mrg */ 190 1.1.1.11 mrg ///@{ 191 1.1.1.2 mrg 192 1.1.1.2 mrg enum __match_flag 193 1.1.1.2 mrg { 194 1.1.1.2 mrg _S_not_bol, 195 1.1.1.2 mrg _S_not_eol, 196 1.1.1.2 mrg _S_not_bow, 197 1.1.1.2 mrg _S_not_eow, 198 1.1.1.2 mrg _S_any, 199 1.1.1.2 mrg _S_not_null, 200 1.1.1.2 mrg _S_continuous, 201 1.1.1.2 mrg _S_prev_avail, 202 1.1.1.2 mrg _S_sed, 203 1.1.1.2 mrg _S_no_copy, 204 1.1.1.2 mrg _S_first_only, 205 1.1.1.2 mrg _S_match_flag_last 206 1.1.1.2 mrg }; 207 1.1.1.2 mrg 208 1.1.1.2 mrg /** 209 1.1.1.2 mrg * @brief This is a bitmask type indicating regex matching rules. 210 1.1.1.2 mrg * 211 1.1.1.2 mrg * The @c match_flag_type is implementation defined but it is valid to 212 1.1.1.2 mrg * perform bitwise operations on these values and expect the right thing to 213 1.1.1.2 mrg * happen. 214 1.1.1.2 mrg */ 215 1.1.1.2 mrg typedef std::bitset<_S_match_flag_last> match_flag_type; 216 1.1.1.2 mrg 217 1.1.1.2 mrg /** 218 1.1.1.2 mrg * The default matching rules. 219 1.1.1.2 mrg */ 220 1.1.1.2 mrg static const match_flag_type match_default = 0; 221 1.1.1.2 mrg 222 1.1.1.2 mrg /** 223 1.1.1.2 mrg * The first character in the sequence [first, last) is treated as though it 224 1.1.1.2 mrg * is not at the beginning of a line, so the character (^) in the regular 225 1.1.1.2 mrg * expression shall not match [first, first). 226 1.1.1.2 mrg */ 227 1.1.1.2 mrg static const match_flag_type match_not_bol = 1 << _S_not_bol; 228 1.1.1.2 mrg 229 1.1.1.2 mrg /** 230 1.1.1.2 mrg * The last character in the sequence [first, last) is treated as though it 231 1.1.1.2 mrg * is not at the end of a line, so the character ($) in the regular 232 1.1.1.2 mrg * expression shall not match [last, last). 233 1.1.1.2 mrg */ 234 1.1.1.2 mrg static const match_flag_type match_not_eol = 1 << _S_not_eol; 235 1.1.1.2 mrg 236 1.1.1.2 mrg /** 237 1.1.1.2 mrg * The expression \\b is not matched against the sub-sequence 238 1.1.1.2 mrg * [first,first). 239 1.1.1.2 mrg */ 240 1.1.1.2 mrg static const match_flag_type match_not_bow = 1 << _S_not_bow; 241 1.1.1.2 mrg 242 1.1.1.2 mrg /** 243 1.1.1.2 mrg * The expression \\b should not be matched against the sub-sequence 244 1.1.1.2 mrg * [last,last). 245 1.1.1.2 mrg */ 246 1.1.1.2 mrg static const match_flag_type match_not_eow = 1 << _S_not_eow; 247 1.1.1.2 mrg 248 1.1.1.2 mrg /** 249 1.1.1.2 mrg * If more than one match is possible then any match is an acceptable 250 1.1.1.2 mrg * result. 251 1.1.1.2 mrg */ 252 1.1.1.2 mrg static const match_flag_type match_any = 1 << _S_any; 253 1.1.1.2 mrg 254 1.1.1.2 mrg /** 255 1.1.1.2 mrg * The expression does not match an empty sequence. 256 1.1.1.2 mrg */ 257 1.1.1.2 mrg static const match_flag_type match_not_null = 1 << _S_not_null; 258 1.1.1.2 mrg 259 1.1.1.2 mrg /** 260 1.1.1.2 mrg * The expression only matches a sub-sequence that begins at first . 261 1.1.1.2 mrg */ 262 1.1.1.2 mrg static const match_flag_type match_continuous = 1 << _S_continuous; 263 1.1.1.2 mrg 264 1.1.1.2 mrg /** 265 1.1.1.2 mrg * --first is a valid iterator position. When this flag is set then the 266 1.1.1.2 mrg * flags match_not_bol and match_not_bow are ignored by the regular 267 1.1.1.2 mrg * expression algorithms 7.11 and iterators 7.12. 268 1.1.1.2 mrg */ 269 1.1.1.2 mrg static const match_flag_type match_prev_avail = 1 << _S_prev_avail; 270 1.1.1.2 mrg 271 1.1.1.2 mrg /** 272 1.1.1.2 mrg * When a regular expression match is to be replaced by a new string, the 273 1.1.1.2 mrg * new string is constructed using the rules used by the ECMAScript replace 274 1.1.1.2 mrg * function in ECMA- 262 [Ecma International, ECMAScript Language 275 1.1.1.2 mrg * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11 276 1.1.1.2 mrg * String.prototype.replace. In addition, during search and replace 277 1.1.1.2 mrg * operations all non-overlapping occurrences of the regular expression 278 1.1.1.2 mrg * are located and replaced, and sections of the input that did not match 279 1.1.1.2 mrg * the expression are copied unchanged to the output string. 280 1.1.1.2 mrg * 281 1.1.1.2 mrg * Format strings (from ECMA-262 [15.5.4.11]): 282 1.1.1.2 mrg * @li $$ The dollar-sign itself ($) 283 1.1.1.2 mrg * @li $& The matched substring. 284 1.1.1.2 mrg * @li $` The portion of @a string that precedes the matched substring. 285 1.1.1.2 mrg * This would be match_results::prefix(). 286 1.1.1.2 mrg * @li $' The portion of @a string that follows the matched substring. 287 1.1.1.2 mrg * This would be match_results::suffix(). 288 1.1.1.2 mrg * @li $n The nth capture, where n is in [1,9] and $n is not followed by a 289 1.1.1.2 mrg * decimal digit. If n <= match_results::size() and the nth capture 290 1.1.1.2 mrg * is undefined, use the empty string instead. If n > 291 1.1.1.2 mrg * match_results::size(), the result is implementation-defined. 292 1.1.1.2 mrg * @li $nn The nnth capture, where nn is a two-digit decimal number on 293 1.1.1.2 mrg * [01, 99]. If nn <= match_results::size() and the nth capture is 294 1.1.1.2 mrg * undefined, use the empty string instead. If 295 1.1.1.2 mrg * nn > match_results::size(), the result is implementation-defined. 296 1.1.1.2 mrg */ 297 1.1.1.2 mrg static const match_flag_type format_default = 0; 298 1.1.1.2 mrg 299 1.1.1.2 mrg /** 300 1.1.1.2 mrg * When a regular expression match is to be replaced by a new string, the 301 1.1.1.2 mrg * new string is constructed using the rules used by the POSIX sed utility 302 1.1.1.2 mrg * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable 303 1.1.1.2 mrg * Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. 304 1.1.1.2 mrg */ 305 1.1.1.2 mrg static const match_flag_type format_sed = 1 << _S_sed; 306 1.1.1.2 mrg 307 1.1.1.2 mrg /** 308 1.1.1.2 mrg * During a search and replace operation, sections of the character 309 1.1.1.2 mrg * container sequence being searched that do not match the regular 310 1.1.1.2 mrg * expression shall not be copied to the output string. 311 1.1.1.2 mrg */ 312 1.1.1.2 mrg static const match_flag_type format_no_copy = 1 << _S_no_copy; 313 1.1.1.2 mrg 314 1.1.1.2 mrg /** 315 1.1.1.2 mrg * When specified during a search and replace operation, only the first 316 1.1.1.2 mrg * occurrence of the regular expression shall be replaced. 317 1.1.1.2 mrg */ 318 1.1.1.2 mrg static const match_flag_type format_first_only = 1 << _S_first_only; 319 1.1.1.2 mrg 320 1.1.1.11 mrg ///@} 321 1.1.1.2 mrg 322 1.1.1.2 mrg /** 323 1.1.1.2 mrg * @name 5.3 Error Types 324 1.1.1.2 mrg */ 325 1.1.1.11 mrg ///@{ 326 1.1.1.2 mrg 327 1.1.1.2 mrg enum error_type 328 1.1.1.2 mrg { 329 1.1.1.2 mrg _S_error_collate, 330 1.1.1.2 mrg _S_error_ctype, 331 1.1.1.2 mrg _S_error_escape, 332 1.1.1.2 mrg _S_error_backref, 333 1.1.1.2 mrg _S_error_brack, 334 1.1.1.2 mrg _S_error_paren, 335 1.1.1.2 mrg _S_error_brace, 336 1.1.1.2 mrg _S_error_badbrace, 337 1.1.1.2 mrg _S_error_range, 338 1.1.1.2 mrg _S_error_space, 339 1.1.1.2 mrg _S_error_badrepeat, 340 1.1.1.2 mrg _S_error_complexity, 341 1.1.1.2 mrg _S_error_stack, 342 1.1.1.2 mrg _S_error_last 343 1.1.1.2 mrg }; 344 1.1.1.2 mrg 345 1.1.1.2 mrg /** The expression contained an invalid collating element name. */ 346 1.1.1.2 mrg static const error_type error_collate(_S_error_collate); 347 1.1.1.2 mrg 348 1.1.1.2 mrg /** The expression contained an invalid character class name. */ 349 1.1.1.2 mrg static const error_type error_ctype(_S_error_ctype); 350 1.1.1.2 mrg 351 1.1.1.2 mrg /** 352 1.1.1.2 mrg * The expression contained an invalid escaped character, or a trailing 353 1.1.1.2 mrg * escape. 354 1.1.1.2 mrg */ 355 1.1.1.2 mrg static const error_type error_escape(_S_error_escape); 356 1.1.1.2 mrg 357 1.1.1.2 mrg /** The expression contained an invalid back reference. */ 358 1.1.1.2 mrg static const error_type error_backref(_S_error_backref); 359 1.1.1.2 mrg 360 1.1.1.2 mrg /** The expression contained mismatched [ and ]. */ 361 1.1.1.2 mrg static const error_type error_brack(_S_error_brack); 362 1.1.1.2 mrg 363 1.1.1.2 mrg /** The expression contained mismatched ( and ). */ 364 1.1.1.2 mrg static const error_type error_paren(_S_error_paren); 365 1.1.1.2 mrg 366 1.1.1.2 mrg /** The expression contained mismatched { and } */ 367 1.1.1.2 mrg static const error_type error_brace(_S_error_brace); 368 1.1.1.2 mrg 369 1.1.1.2 mrg /** The expression contained an invalid range in a {} expression. */ 370 1.1.1.2 mrg static const error_type error_badbrace(_S_error_badbrace); 371 1.1.1.2 mrg 372 1.1.1.2 mrg /** 373 1.1.1.2 mrg * The expression contained an invalid character range, 374 1.1.1.2 mrg * such as [b-a] in most encodings. 375 1.1.1.2 mrg */ 376 1.1.1.2 mrg static const error_type error_range(_S_error_range); 377 1.1.1.2 mrg 378 1.1.1.2 mrg /** 379 1.1.1.2 mrg * There was insufficient memory to convert the expression into a 380 1.1.1.2 mrg * finite state machine. 381 1.1.1.2 mrg */ 382 1.1.1.2 mrg static const error_type error_space(_S_error_space); 383 1.1.1.2 mrg 384 1.1.1.2 mrg /** 385 1.1.1.2 mrg * One of <em>*?+{</em> was not preceded by a valid regular expression. 386 1.1.1.2 mrg */ 387 1.1.1.2 mrg static const error_type error_badrepeat(_S_error_badrepeat); 388 1.1.1.2 mrg 389 1.1.1.2 mrg /** 390 1.1.1.2 mrg * The complexity of an attempted match against a regular expression 391 1.1.1.2 mrg * exceeded a pre-set level. 392 1.1.1.2 mrg */ 393 1.1.1.2 mrg static const error_type error_complexity(_S_error_complexity); 394 1.1.1.2 mrg 395 1.1.1.2 mrg /** 396 1.1.1.2 mrg * There was insufficient memory to determine whether the 397 1.1.1.2 mrg * regular expression could match the specified character sequence. 398 1.1.1.2 mrg */ 399 1.1.1.2 mrg static const error_type error_stack(_S_error_stack); 400 1.1.1.2 mrg 401 1.1.1.11 mrg ///@} 402 1.1.1.2 mrg } 403 1.1.1.2 mrg 404 1.1.1.2 mrg // [7.8] Class regex_error 405 1.1.1.2 mrg /** 406 1.1.1.2 mrg * @brief A regular expression exception class. 407 1.1.1.2 mrg * @ingroup exceptions 408 1.1.1.2 mrg * 409 1.1.1.2 mrg * The regular expression library throws objects of this class on error. 410 1.1.1.2 mrg */ 411 1.1.1.2 mrg class regex_error 412 1.1.1.2 mrg : public std::runtime_error 413 1.1.1.2 mrg { 414 1.1.1.2 mrg public: 415 1.1.1.2 mrg /** 416 1.1.1.2 mrg * @brief Constructs a regex_error object. 417 1.1.1.2 mrg * 418 1.1.1.2 mrg * @param ecode the regex error code. 419 1.1.1.2 mrg */ 420 1.1.1.2 mrg explicit 421 1.1.1.2 mrg regex_error(regex_constants::error_type __ecode) 422 1.1.1.2 mrg : std::runtime_error("regex_error"), _M_code(__ecode) 423 1.1.1.2 mrg { } 424 1.1.1.2 mrg 425 1.1.1.2 mrg /** 426 1.1.1.2 mrg * @brief Gets the regex error code. 427 1.1.1.2 mrg * 428 1.1.1.2 mrg * @returns the regex error code. 429 1.1.1.2 mrg */ 430 1.1.1.2 mrg regex_constants::error_type 431 1.1.1.2 mrg code() const 432 1.1.1.2 mrg { return _M_code; } 433 1.1.1.2 mrg 434 1.1.1.2 mrg protected: 435 1.1.1.2 mrg regex_constants::error_type _M_code; 436 1.1.1.2 mrg }; 437 1.1.1.2 mrg 438 1.1.1.2 mrg // [7.7] Class regex_traits 439 1.1.1.2 mrg /** 440 1.1.1.2 mrg * @brief Describes aspects of a regular expression. 441 1.1.1.2 mrg * 442 1.1.1.2 mrg * A regular expression traits class that satisfies the requirements of tr1 443 1.1.1.2 mrg * section [7.2]. 444 1.1.1.2 mrg * 445 1.1.1.2 mrg * The class %regex is parameterized around a set of related types and 446 1.1.1.2 mrg * functions used to complete the definition of its semantics. This class 447 1.1.1.2 mrg * satisfies the requirements of such a traits class. 448 1.1.1.2 mrg */ 449 1.1.1.2 mrg template<typename _Ch_type> 450 1.1.1.2 mrg struct regex_traits 451 1.1.1.2 mrg { 452 1.1.1.2 mrg public: 453 1.1.1.2 mrg typedef _Ch_type char_type; 454 1.1.1.2 mrg typedef std::basic_string<char_type> string_type; 455 1.1.1.2 mrg typedef std::locale locale_type; 456 1.1.1.2 mrg typedef std::ctype_base::mask char_class_type; 457 1.1.1.2 mrg 458 1.1.1.2 mrg public: 459 1.1.1.2 mrg /** 460 1.1.1.2 mrg * @brief Constructs a default traits object. 461 1.1.1.2 mrg */ 462 1.1.1.2 mrg regex_traits() 463 1.1.1.2 mrg { } 464 1.1.1.2 mrg 465 1.1.1.2 mrg /** 466 1.1.1.2 mrg * @brief Gives the length of a C-style string starting at @p __p. 467 1.1.1.2 mrg * 468 1.1.1.2 mrg * @param __p a pointer to the start of a character sequence. 469 1.1.1.2 mrg * 470 1.1.1.2 mrg * @returns the number of characters between @p *__p and the first 471 1.1.1.2 mrg * default-initialized value of type @p char_type. In other words, uses 472 1.1.1.2 mrg * the C-string algorithm for determining the length of a sequence of 473 1.1.1.2 mrg * characters. 474 1.1.1.2 mrg */ 475 1.1.1.2 mrg static std::size_t 476 1.1.1.2 mrg length(const char_type* __p) 477 1.1.1.2 mrg { return string_type::traits_type::length(__p); } 478 1.1.1.2 mrg 479 1.1.1.2 mrg /** 480 1.1.1.2 mrg * @brief Performs the identity translation. 481 1.1.1.2 mrg * 482 1.1.1.2 mrg * @param c A character to the locale-specific character set. 483 1.1.1.2 mrg * 484 1.1.1.2 mrg * @returns c. 485 1.1.1.2 mrg */ 486 1.1.1.2 mrg char_type 487 1.1.1.2 mrg translate(char_type __c) const 488 1.1.1.2 mrg { return __c; } 489 1.1.1.2 mrg 490 1.1.1.2 mrg /** 491 1.1.1.2 mrg * @brief Translates a character into a case-insensitive equivalent. 492 1.1.1.2 mrg * 493 1.1.1.2 mrg * @param c A character to the locale-specific character set. 494 1.1.1.2 mrg * 495 1.1.1.2 mrg * @returns the locale-specific lower-case equivalent of c. 496 1.1.1.2 mrg * @throws std::bad_cast if the imbued locale does not support the ctype 497 1.1.1.2 mrg * facet. 498 1.1.1.2 mrg */ 499 1.1.1.2 mrg char_type 500 1.1.1.2 mrg translate_nocase(char_type __c) const 501 1.1.1.2 mrg { 502 1.1.1.2 mrg using std::ctype; 503 1.1.1.2 mrg using std::use_facet; 504 1.1.1.2 mrg return use_facet<ctype<char_type> >(_M_locale).tolower(__c); 505 1.1.1.2 mrg } 506 1.1.1.2 mrg 507 1.1.1.2 mrg /** 508 1.1.1.2 mrg * @brief Gets a sort key for a character sequence. 509 1.1.1.2 mrg * 510 1.1.1.2 mrg * @param first beginning of the character sequence. 511 1.1.1.2 mrg * @param last one-past-the-end of the character sequence. 512 1.1.1.2 mrg * 513 1.1.1.2 mrg * Returns a sort key for the character sequence designated by the 514 1.1.1.2 mrg * iterator range [F1, F2) such that if the character sequence [G1, G2) 515 1.1.1.2 mrg * sorts before the character sequence [H1, H2) then 516 1.1.1.2 mrg * v.transform(G1, G2) < v.transform(H1, H2). 517 1.1.1.2 mrg * 518 1.1.1.2 mrg * What this really does is provide a more efficient way to compare a 519 1.1.1.2 mrg * string to multiple other strings in locales with fancy collation 520 1.1.1.2 mrg * rules and equivalence classes. 521 1.1.1.2 mrg * 522 1.1.1.2 mrg * @returns a locale-specific sort key equivalent to the input range. 523 1.1.1.2 mrg * 524 1.1.1.2 mrg * @throws std::bad_cast if the current locale does not have a collate 525 1.1.1.2 mrg * facet. 526 1.1.1.2 mrg */ 527 1.1.1.2 mrg template<typename _Fwd_iter> 528 1.1.1.2 mrg string_type 529 1.1.1.2 mrg transform(_Fwd_iter __first, _Fwd_iter __last) const 530 1.1.1.2 mrg { 531 1.1.1.2 mrg using std::collate; 532 1.1.1.2 mrg using std::use_facet; 533 1.1.1.2 mrg const collate<_Ch_type>& __c(use_facet< 534 1.1.1.2 mrg collate<_Ch_type> >(_M_locale)); 535 1.1.1.2 mrg string_type __s(__first, __last); 536 1.1.1.2 mrg return __c.transform(__s.data(), __s.data() + __s.size()); 537 1.1.1.2 mrg } 538 1.1.1.2 mrg 539 1.1.1.2 mrg /** 540 1.1.1.2 mrg * @brief Dunno. 541 1.1.1.2 mrg * 542 1.1.1.2 mrg * @param first beginning of the character sequence. 543 1.1.1.2 mrg * @param last one-past-the-end of the character sequence. 544 1.1.1.2 mrg * 545 1.1.1.2 mrg * Effects: if typeid(use_facet<collate<_Ch_type> >) == 546 1.1.1.2 mrg * typeid(collate_byname<_Ch_type>) and the form of the sort key 547 1.1.1.2 mrg * returned by collate_byname<_Ch_type>::transform(first, last) is known 548 1.1.1.2 mrg * and can be converted into a primary sort key then returns that key, 549 1.1.1.2 mrg * otherwise returns an empty string. WTF?? 550 1.1.1.2 mrg * 551 1.1.1.2 mrg * @todo Implement this function. 552 1.1.1.2 mrg */ 553 1.1.1.2 mrg template<typename _Fwd_iter> 554 1.1.1.2 mrg string_type 555 1.1.1.2 mrg transform_primary(_Fwd_iter __first, _Fwd_iter __last) const; 556 1.1.1.2 mrg 557 1.1.1.2 mrg /** 558 1.1.1.2 mrg * @brief Gets a collation element by name. 559 1.1.1.2 mrg * 560 1.1.1.2 mrg * @param first beginning of the collation element name. 561 1.1.1.2 mrg * @param last one-past-the-end of the collation element name. 562 1.1.1.2 mrg * 563 1.1.1.2 mrg * @returns a sequence of one or more characters that represents the 564 1.1.1.2 mrg * collating element consisting of the character sequence designated by 565 1.1.1.2 mrg * the iterator range [first, last). Returns an empty string if the 566 1.1.1.2 mrg * character sequence is not a valid collating element. 567 1.1.1.2 mrg * 568 1.1.1.2 mrg * @todo Implement this function. 569 1.1.1.2 mrg */ 570 1.1.1.2 mrg template<typename _Fwd_iter> 571 1.1.1.2 mrg string_type 572 1.1.1.2 mrg lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const; 573 1.1.1.2 mrg 574 1.1.1.2 mrg /** 575 1.1.1.2 mrg * @brief Maps one or more characters to a named character 576 1.1.1.2 mrg * classification. 577 1.1.1.2 mrg * 578 1.1.1.2 mrg * @param first beginning of the character sequence. 579 1.1.1.2 mrg * @param last one-past-the-end of the character sequence. 580 1.1.1.2 mrg * 581 1.1.1.2 mrg * @returns an unspecified value that represents the character 582 1.1.1.2 mrg * classification named by the character sequence designated by the 583 1.1.1.2 mrg * iterator range [first, last). The value returned shall be independent 584 1.1.1.2 mrg * of the case of the characters in the character sequence. If the name 585 1.1.1.2 mrg * is not recognized then returns a value that compares equal to 0. 586 1.1.1.2 mrg * 587 1.1.1.2 mrg * At least the following names (or their wide-character equivalent) are 588 1.1.1.2 mrg * supported. 589 1.1.1.2 mrg * - d 590 1.1.1.2 mrg * - w 591 1.1.1.2 mrg * - s 592 1.1.1.2 mrg * - alnum 593 1.1.1.2 mrg * - alpha 594 1.1.1.2 mrg * - blank 595 1.1.1.2 mrg * - cntrl 596 1.1.1.2 mrg * - digit 597 1.1.1.2 mrg * - graph 598 1.1.1.2 mrg * - lower 599 1.1.1.2 mrg * - print 600 1.1.1.2 mrg * - punct 601 1.1.1.2 mrg * - space 602 1.1.1.2 mrg * - upper 603 1.1.1.2 mrg * - xdigit 604 1.1.1.2 mrg * 605 1.1.1.2 mrg * @todo Implement this function. 606 1.1.1.2 mrg */ 607 1.1.1.2 mrg template<typename _Fwd_iter> 608 1.1.1.2 mrg char_class_type 609 1.1.1.2 mrg lookup_classname(_Fwd_iter __first, _Fwd_iter __last) const; 610 1.1.1.2 mrg 611 1.1.1.2 mrg /** 612 1.1.1.2 mrg * @brief Determines if @p c is a member of an identified class. 613 1.1.1.2 mrg * 614 1.1.1.2 mrg * @param c a character. 615 1.1.1.2 mrg * @param f a class type (as returned from lookup_classname). 616 1.1.1.2 mrg * 617 1.1.1.2 mrg * @returns true if the character @p c is a member of the classification 618 1.1.1.2 mrg * represented by @p f, false otherwise. 619 1.1.1.2 mrg * 620 1.1.1.2 mrg * @throws std::bad_cast if the current locale does not have a ctype 621 1.1.1.2 mrg * facet. 622 1.1.1.2 mrg */ 623 1.1.1.2 mrg bool 624 1.1.1.2 mrg isctype(_Ch_type __c, char_class_type __f) const; 625 1.1.1.2 mrg 626 1.1.1.2 mrg /** 627 1.1.1.2 mrg * @brief Converts a digit to an int. 628 1.1.1.2 mrg * 629 1.1.1.2 mrg * @param ch a character representing a digit. 630 1.1.1.2 mrg * @param radix the radix if the numeric conversion (limited to 8, 10, 631 1.1.1.2 mrg * or 16). 632 1.1.1.2 mrg * 633 1.1.1.2 mrg * @returns the value represented by the digit ch in base radix if the 634 1.1.1.2 mrg * character ch is a valid digit in base radix; otherwise returns -1. 635 1.1.1.2 mrg */ 636 1.1.1.2 mrg int 637 1.1.1.2 mrg value(_Ch_type __ch, int __radix) const; 638 1.1.1.2 mrg 639 1.1.1.2 mrg /** 640 1.1.1.2 mrg * @brief Imbues the regex_traits object with a copy of a new locale. 641 1.1.1.2 mrg * 642 1.1.1.2 mrg * @param loc A locale. 643 1.1.1.2 mrg * 644 1.1.1.2 mrg * @returns a copy of the previous locale in use by the regex_traits 645 1.1.1.2 mrg * object. 646 1.1.1.2 mrg * 647 1.1.1.2 mrg * @note Calling imbue with a different locale than the one currently in 648 1.1.1.2 mrg * use invalidates all cached data held by *this. 649 1.1.1.2 mrg */ 650 1.1.1.2 mrg locale_type 651 1.1.1.2 mrg imbue(locale_type __loc) 652 1.1.1.2 mrg { 653 1.1.1.2 mrg std::swap(_M_locale, __loc); 654 1.1.1.2 mrg return __loc; 655 1.1.1.2 mrg } 656 1.1.1.2 mrg 657 1.1.1.2 mrg /** 658 1.1.1.2 mrg * @brief Gets a copy of the current locale in use by the regex_traits 659 1.1.1.2 mrg * object. 660 1.1.1.2 mrg */ 661 1.1.1.2 mrg locale_type 662 1.1.1.2 mrg getloc() const 663 1.1.1.2 mrg { return _M_locale; } 664 1.1.1.2 mrg 665 1.1.1.2 mrg protected: 666 1.1.1.2 mrg locale_type _M_locale; 667 1.1.1.2 mrg }; 668 1.1.1.2 mrg 669 1.1.1.2 mrg template<typename _Ch_type> 670 1.1.1.2 mrg bool regex_traits<_Ch_type>:: 671 1.1.1.2 mrg isctype(_Ch_type __c, char_class_type __f) const 672 1.1.1.2 mrg { 673 1.1.1.2 mrg using std::ctype; 674 1.1.1.2 mrg using std::use_facet; 675 1.1.1.2 mrg const ctype<_Ch_type>& __ctype(use_facet< 676 1.1.1.2 mrg ctype<_Ch_type> >(_M_locale)); 677 1.1.1.2 mrg 678 1.1.1.2 mrg if (__ctype.is(__c, __f)) 679 1.1.1.2 mrg return true; 680 1.1.1.3 mrg #if 0 681 1.1.1.2 mrg // special case of underscore in [[:w:]] 682 1.1.1.2 mrg if (__c == __ctype.widen('_')) 683 1.1.1.2 mrg { 684 1.1.1.2 mrg const char* const __wb[] = "w"; 685 1.1.1.2 mrg char_class_type __wt = this->lookup_classname(__wb, 686 1.1.1.2 mrg __wb + sizeof(__wb)); 687 1.1.1.2 mrg if (__f | __wt) 688 1.1.1.2 mrg return true; 689 1.1.1.2 mrg } 690 1.1.1.2 mrg 691 1.1.1.2 mrg // special case of [[:space:]] in [[:blank:]] 692 1.1.1.2 mrg if (__c == __ctype.isspace(__c)) 693 1.1.1.2 mrg { 694 1.1.1.2 mrg const char* const __bb[] = "blank"; 695 1.1.1.2 mrg char_class_type __bt = this->lookup_classname(__bb, 696 1.1.1.2 mrg __bb + sizeof(__bb)); 697 1.1.1.2 mrg if (__f | __bt) 698 1.1.1.2 mrg return true; 699 1.1.1.2 mrg } 700 1.1.1.3 mrg #endif 701 1.1.1.2 mrg return false; 702 1.1.1.2 mrg } 703 1.1.1.2 mrg 704 1.1.1.2 mrg template<typename _Ch_type> 705 1.1.1.2 mrg int regex_traits<_Ch_type>:: 706 1.1.1.2 mrg value(_Ch_type __ch, int __radix) const 707 1.1.1.2 mrg { 708 1.1.1.2 mrg std::basic_istringstream<_Ch_type> __is(string_type(1, __ch)); 709 1.1.1.2 mrg int __v; 710 1.1.1.2 mrg if (__radix == 8) 711 1.1.1.2 mrg __is >> std::oct; 712 1.1.1.2 mrg else if (__radix == 16) 713 1.1.1.2 mrg __is >> std::hex; 714 1.1.1.2 mrg __is >> __v; 715 1.1.1.2 mrg return __is.fail() ? -1 : __v; 716 1.1.1.2 mrg } 717 1.1.1.2 mrg 718 1.1.1.2 mrg // [7.8] Class basic_regex 719 1.1.1.2 mrg /** 720 1.1.1.2 mrg * Objects of specializations of this class represent regular expressions 721 1.1.1.2 mrg * constructed from sequences of character type @p _Ch_type. 722 1.1.1.2 mrg * 723 1.1.1.2 mrg * Storage for the regular expression is allocated and deallocated as 724 1.1.1.2 mrg * necessary by the member functions of this class. 725 1.1.1.2 mrg */ 726 1.1.1.2 mrg template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> > 727 1.1.1.2 mrg class basic_regex 728 1.1.1.2 mrg { 729 1.1.1.2 mrg public: 730 1.1.1.2 mrg // types: 731 1.1.1.2 mrg typedef _Ch_type value_type; 732 1.1.1.2 mrg typedef regex_constants::syntax_option_type flag_type; 733 1.1.1.2 mrg typedef typename _Rx_traits::locale_type locale_type; 734 1.1.1.2 mrg typedef typename _Rx_traits::string_type string_type; 735 1.1.1.2 mrg 736 1.1.1.2 mrg /** 737 1.1.1.2 mrg * @name Constants 738 1.1.1.2 mrg * tr1 [7.8.1] std [28.8.1] 739 1.1.1.2 mrg */ 740 1.1.1.11 mrg ///@{ 741 1.1.1.2 mrg static const regex_constants::syntax_option_type icase 742 1.1.1.2 mrg = regex_constants::icase; 743 1.1.1.2 mrg static const regex_constants::syntax_option_type nosubs 744 1.1.1.2 mrg = regex_constants::nosubs; 745 1.1.1.2 mrg static const regex_constants::syntax_option_type optimize 746 1.1.1.2 mrg = regex_constants::optimize; 747 1.1.1.2 mrg static const regex_constants::syntax_option_type collate 748 1.1.1.2 mrg = regex_constants::collate; 749 1.1.1.2 mrg static const regex_constants::syntax_option_type ECMAScript 750 1.1.1.2 mrg = regex_constants::ECMAScript; 751 1.1.1.2 mrg static const regex_constants::syntax_option_type basic 752 1.1.1.2 mrg = regex_constants::basic; 753 1.1.1.2 mrg static const regex_constants::syntax_option_type extended 754 1.1.1.2 mrg = regex_constants::extended; 755 1.1.1.2 mrg static const regex_constants::syntax_option_type awk 756 1.1.1.2 mrg = regex_constants::awk; 757 1.1.1.2 mrg static const regex_constants::syntax_option_type grep 758 1.1.1.2 mrg = regex_constants::grep; 759 1.1.1.2 mrg static const regex_constants::syntax_option_type egrep 760 1.1.1.2 mrg = regex_constants::egrep; 761 1.1.1.11 mrg ///@} 762 1.1.1.2 mrg 763 1.1.1.2 mrg // [7.8.2] construct/copy/destroy 764 1.1.1.2 mrg /** 765 1.1.1.2 mrg * Constructs a basic regular expression that does not match any 766 1.1.1.2 mrg * character sequence. 767 1.1.1.2 mrg */ 768 1.1.1.2 mrg basic_regex() 769 1.1.1.2 mrg : _M_flags(regex_constants::ECMAScript), _M_pattern(), _M_mark_count(0) 770 1.1.1.2 mrg { _M_compile(); } 771 1.1.1.2 mrg 772 1.1.1.2 mrg /** 773 1.1.1.2 mrg * @brief Constructs a basic regular expression from the sequence 774 1.1.1.2 mrg * [p, p + char_traits<_Ch_type>::length(p)) interpreted according to the 775 1.1.1.2 mrg * flags in @p f. 776 1.1.1.2 mrg * 777 1.1.1.2 mrg * @param p A pointer to the start of a C-style null-terminated string 778 1.1.1.2 mrg * containing a regular expression. 779 1.1.1.2 mrg * @param f Flags indicating the syntax rules and options. 780 1.1.1.2 mrg * 781 1.1.1.2 mrg * @throws regex_error if @p p is not a valid regular expression. 782 1.1.1.2 mrg */ 783 1.1.1.2 mrg explicit 784 1.1.1.2 mrg basic_regex(const _Ch_type* __p, 785 1.1.1.2 mrg flag_type __f = regex_constants::ECMAScript) 786 1.1.1.2 mrg : _M_flags(__f), _M_pattern(__p), _M_mark_count(0) 787 1.1.1.2 mrg { _M_compile(); } 788 1.1.1.2 mrg 789 1.1.1.2 mrg /** 790 1.1.1.2 mrg * @brief Constructs a basic regular expression from the sequence 791 1.1.1.2 mrg * [p, p + len) interpreted according to the flags in @p f. 792 1.1.1.2 mrg * 793 1.1.1.2 mrg * @param p A pointer to the start of a string containing a regular 794 1.1.1.2 mrg * expression. 795 1.1.1.2 mrg * @param len The length of the string containing the regular expression. 796 1.1.1.2 mrg * @param f Flags indicating the syntax rules and options. 797 1.1.1.2 mrg * 798 1.1.1.2 mrg * @throws regex_error if @p p is not a valid regular expression. 799 1.1.1.2 mrg */ 800 1.1.1.2 mrg basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f) 801 1.1.1.2 mrg : _M_flags(__f) , _M_pattern(__p, __len), _M_mark_count(0) 802 1.1.1.2 mrg { _M_compile(); } 803 1.1.1.2 mrg 804 1.1.1.2 mrg /** 805 1.1.1.2 mrg * @brief Copy-constructs a basic regular expression. 806 1.1.1.2 mrg * 807 1.1.1.2 mrg * @param rhs A @p regex object. 808 1.1.1.2 mrg */ 809 1.1.1.2 mrg basic_regex(const basic_regex& __rhs) 810 1.1.1.2 mrg : _M_flags(__rhs._M_flags), _M_pattern(__rhs._M_pattern), 811 1.1.1.2 mrg _M_mark_count(__rhs._M_mark_count) 812 1.1.1.2 mrg { _M_compile(); } 813 1.1.1.2 mrg 814 1.1.1.2 mrg /** 815 1.1.1.2 mrg * @brief Constructs a basic regular expression from the string 816 1.1.1.2 mrg * @p s interpreted according to the flags in @p f. 817 1.1.1.2 mrg * 818 1.1.1.2 mrg * @param s A string containing a regular expression. 819 1.1.1.2 mrg * @param f Flags indicating the syntax rules and options. 820 1.1.1.2 mrg * 821 1.1.1.2 mrg * @throws regex_error if @p s is not a valid regular expression. 822 1.1.1.2 mrg */ 823 1.1.1.2 mrg template<typename _Ch_traits, typename _Ch_alloc> 824 1.1.1.2 mrg explicit 825 1.1.1.2 mrg basic_regex(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, 826 1.1.1.2 mrg flag_type __f = regex_constants::ECMAScript) 827 1.1.1.2 mrg : _M_flags(__f), _M_pattern(__s.begin(), __s.end()), _M_mark_count(0) 828 1.1.1.2 mrg { _M_compile(); } 829 1.1.1.2 mrg 830 1.1.1.2 mrg /** 831 1.1.1.2 mrg * @brief Constructs a basic regular expression from the range 832 1.1.1.2 mrg * [first, last) interpreted according to the flags in @p f. 833 1.1.1.2 mrg * 834 1.1.1.2 mrg * @param first The start of a range containing a valid regular 835 1.1.1.2 mrg * expression. 836 1.1.1.2 mrg * @param last The end of a range containing a valid regular 837 1.1.1.2 mrg * expression. 838 1.1.1.2 mrg * @param f The format flags of the regular expression. 839 1.1.1.2 mrg * 840 1.1.1.2 mrg * @throws regex_error if @p [first, last) is not a valid regular 841 1.1.1.2 mrg * expression. 842 1.1.1.2 mrg */ 843 1.1.1.2 mrg template<typename _InputIterator> 844 1.1.1.2 mrg basic_regex(_InputIterator __first, _InputIterator __last, 845 1.1.1.2 mrg flag_type __f = regex_constants::ECMAScript) 846 1.1.1.2 mrg : _M_flags(__f), _M_pattern(__first, __last), _M_mark_count(0) 847 1.1.1.2 mrg { _M_compile(); } 848 1.1.1.2 mrg 849 1.1.1.2 mrg #ifdef _GLIBCXX_INCLUDE_AS_CXX11 850 1.1.1.2 mrg /** 851 1.1.1.2 mrg * @brief Constructs a basic regular expression from an initializer list. 852 1.1.1.2 mrg * 853 1.1.1.2 mrg * @param l The initializer list. 854 1.1.1.2 mrg * @param f The format flags of the regular expression. 855 1.1.1.2 mrg * 856 1.1.1.2 mrg * @throws regex_error if @p l is not a valid regular expression. 857 1.1.1.2 mrg */ 858 1.1.1.2 mrg basic_regex(initializer_list<_Ch_type> __l, 859 1.1.1.2 mrg flag_type __f = regex_constants::ECMAScript) 860 1.1.1.2 mrg : _M_flags(__f), _M_pattern(__l.begin(), __l.end()), _M_mark_count(0) 861 1.1.1.2 mrg { _M_compile(); } 862 1.1.1.2 mrg #endif 863 1.1.1.2 mrg 864 1.1.1.2 mrg /** 865 1.1.1.2 mrg * @brief Destroys a basic regular expression. 866 1.1.1.2 mrg */ 867 1.1.1.2 mrg ~basic_regex() 868 1.1.1.2 mrg { } 869 1.1.1.2 mrg 870 1.1.1.2 mrg /** 871 1.1.1.2 mrg * @brief Assigns one regular expression to another. 872 1.1.1.2 mrg */ 873 1.1.1.2 mrg basic_regex& 874 1.1.1.2 mrg operator=(const basic_regex& __rhs) 875 1.1.1.2 mrg { return this->assign(__rhs); } 876 1.1.1.2 mrg 877 1.1.1.2 mrg /** 878 1.1.1.2 mrg * @brief Replaces a regular expression with a new one constructed from 879 1.1.1.2 mrg * a C-style null-terminated string. 880 1.1.1.2 mrg * 881 1.1.1.2 mrg * @param A pointer to the start of a null-terminated C-style string 882 1.1.1.2 mrg * containing a regular expression. 883 1.1.1.2 mrg */ 884 1.1.1.2 mrg basic_regex& 885 1.1.1.2 mrg operator=(const _Ch_type* __p) 886 1.1.1.2 mrg { return this->assign(__p, flags()); } 887 1.1.1.2 mrg 888 1.1.1.2 mrg /** 889 1.1.1.2 mrg * @brief Replaces a regular expression with a new one constructed from 890 1.1.1.2 mrg * a string. 891 1.1.1.2 mrg * 892 1.1.1.2 mrg * @param A pointer to a string containing a regular expression. 893 1.1.1.2 mrg */ 894 1.1.1.2 mrg template<typename _Ch_typeraits, typename _Allocator> 895 1.1.1.2 mrg basic_regex& 896 1.1.1.2 mrg operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s) 897 1.1.1.2 mrg { return this->assign(__s, flags()); } 898 1.1.1.2 mrg 899 1.1.1.2 mrg // [7.8.3] assign 900 1.1.1.2 mrg /** 901 1.1.1.2 mrg * @brief the real assignment operator. 902 1.1.1.2 mrg * 903 1.1.1.2 mrg * @param that Another regular expression object. 904 1.1.1.2 mrg */ 905 1.1.1.2 mrg basic_regex& 906 1.1.1.2 mrg assign(const basic_regex& __that) 907 1.1.1.2 mrg { 908 1.1.1.2 mrg basic_regex __tmp(__that); 909 1.1.1.2 mrg this->swap(__tmp); 910 1.1.1.2 mrg return *this; 911 1.1.1.2 mrg } 912 1.1.1.2 mrg 913 1.1.1.2 mrg /** 914 1.1.1.2 mrg * @brief Assigns a new regular expression to a regex object from a 915 1.1.1.2 mrg * C-style null-terminated string containing a regular expression 916 1.1.1.2 mrg * pattern. 917 1.1.1.2 mrg * 918 1.1.1.2 mrg * @param p A pointer to a C-style null-terminated string containing 919 1.1.1.2 mrg * a regular expression pattern. 920 1.1.1.2 mrg * @param flags Syntax option flags. 921 1.1.1.2 mrg * 922 1.1.1.2 mrg * @throws regex_error if p does not contain a valid regular expression 923 1.1.1.2 mrg * pattern interpreted according to @p flags. If regex_error is thrown, 924 1.1.1.2 mrg * *this remains unchanged. 925 1.1.1.2 mrg */ 926 1.1.1.2 mrg basic_regex& 927 1.1.1.2 mrg assign(const _Ch_type* __p, 928 1.1.1.2 mrg flag_type __flags = regex_constants::ECMAScript) 929 1.1.1.2 mrg { return this->assign(string_type(__p), __flags); } 930 1.1.1.2 mrg 931 1.1.1.2 mrg /** 932 1.1.1.2 mrg * @brief Assigns a new regular expression to a regex object from a 933 1.1.1.2 mrg * C-style string containing a regular expression pattern. 934 1.1.1.2 mrg * 935 1.1.1.2 mrg * @param p A pointer to a C-style string containing a 936 1.1.1.2 mrg * regular expression pattern. 937 1.1.1.2 mrg * @param len The length of the regular expression pattern string. 938 1.1.1.2 mrg * @param flags Syntax option flags. 939 1.1.1.2 mrg * 940 1.1.1.2 mrg * @throws regex_error if p does not contain a valid regular expression 941 1.1.1.2 mrg * pattern interpreted according to @p flags. If regex_error is thrown, 942 1.1.1.2 mrg * *this remains unchanged. 943 1.1.1.2 mrg */ 944 1.1.1.2 mrg basic_regex& 945 1.1.1.2 mrg assign(const _Ch_type* __p, std::size_t __len, flag_type __flags) 946 1.1.1.2 mrg { return this->assign(string_type(__p, __len), __flags); } 947 1.1.1.2 mrg 948 1.1.1.2 mrg /** 949 1.1.1.2 mrg * @brief Assigns a new regular expression to a regex object from a 950 1.1.1.2 mrg * string containing a regular expression pattern. 951 1.1.1.2 mrg * 952 1.1.1.2 mrg * @param s A string containing a regular expression pattern. 953 1.1.1.2 mrg * @param flags Syntax option flags. 954 1.1.1.2 mrg * 955 1.1.1.2 mrg * @throws regex_error if p does not contain a valid regular expression 956 1.1.1.2 mrg * pattern interpreted according to @p flags. If regex_error is thrown, 957 1.1.1.2 mrg * *this remains unchanged. 958 1.1.1.2 mrg */ 959 1.1.1.2 mrg template<typename _Ch_typeraits, typename _Allocator> 960 1.1.1.2 mrg basic_regex& 961 1.1.1.2 mrg assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s, 962 1.1.1.2 mrg flag_type __f = regex_constants::ECMAScript) 963 1.1.1.2 mrg { 964 1.1.1.2 mrg basic_regex __tmp(__s, __f); 965 1.1.1.2 mrg this->swap(__tmp); 966 1.1.1.2 mrg return *this; 967 1.1.1.2 mrg } 968 1.1.1.2 mrg 969 1.1.1.2 mrg /** 970 1.1.1.2 mrg * @brief Assigns a new regular expression to a regex object. 971 1.1.1.2 mrg * 972 1.1.1.2 mrg * @param first The start of a range containing a valid regular 973 1.1.1.2 mrg * expression. 974 1.1.1.2 mrg * @param last The end of a range containing a valid regular 975 1.1.1.2 mrg * expression. 976 1.1.1.2 mrg * @param flags Syntax option flags. 977 1.1.1.2 mrg * 978 1.1.1.2 mrg * @throws regex_error if p does not contain a valid regular expression 979 1.1.1.2 mrg * pattern interpreted according to @p flags. If regex_error is thrown, 980 1.1.1.2 mrg * the object remains unchanged. 981 1.1.1.2 mrg */ 982 1.1.1.2 mrg template<typename _InputIterator> 983 1.1.1.2 mrg basic_regex& 984 1.1.1.2 mrg assign(_InputIterator __first, _InputIterator __last, 985 1.1.1.2 mrg flag_type __flags = regex_constants::ECMAScript) 986 1.1.1.2 mrg { return this->assign(string_type(__first, __last), __flags); } 987 1.1.1.2 mrg 988 1.1.1.2 mrg #ifdef _GLIBCXX_INCLUDE_AS_CXX11 989 1.1.1.2 mrg /** 990 1.1.1.2 mrg * @brief Assigns a new regular expression to a regex object. 991 1.1.1.2 mrg * 992 1.1.1.2 mrg * @param l An initializer list representing a regular expression. 993 1.1.1.2 mrg * @param flags Syntax option flags. 994 1.1.1.2 mrg * 995 1.1.1.2 mrg * @throws regex_error if @p l does not contain a valid regular 996 1.1.1.2 mrg * expression pattern interpreted according to @p flags. If regex_error 997 1.1.1.2 mrg * is thrown, the object remains unchanged. 998 1.1.1.2 mrg */ 999 1.1.1.2 mrg basic_regex& 1000 1.1.1.2 mrg assign(initializer_list<_Ch_type> __l, 1001 1.1.1.2 mrg flag_type __f = regex_constants::ECMAScript) 1002 1.1.1.2 mrg { return this->assign(__l.begin(), __l.end(), __f); } 1003 1.1.1.2 mrg #endif 1004 1.1.1.2 mrg 1005 1.1.1.2 mrg // [7.8.4] const operations 1006 1.1.1.2 mrg /** 1007 1.1.1.2 mrg * @brief Gets the number of marked subexpressions within the regular 1008 1.1.1.2 mrg * expression. 1009 1.1.1.2 mrg */ 1010 1.1.1.2 mrg unsigned int 1011 1.1.1.2 mrg mark_count() const 1012 1.1.1.2 mrg { return _M_mark_count; } 1013 1.1.1.2 mrg 1014 1.1.1.2 mrg /** 1015 1.1.1.2 mrg * @brief Gets the flags used to construct the regular expression 1016 1.1.1.2 mrg * or in the last call to assign(). 1017 1.1.1.2 mrg */ 1018 1.1.1.2 mrg flag_type 1019 1.1.1.2 mrg flags() const 1020 1.1.1.2 mrg { return _M_flags; } 1021 1.1.1.2 mrg 1022 1.1.1.2 mrg // [7.8.5] locale 1023 1.1.1.2 mrg /** 1024 1.1.1.2 mrg * @brief Imbues the regular expression object with the given locale. 1025 1.1.1.2 mrg * 1026 1.1.1.2 mrg * @param loc A locale. 1027 1.1.1.2 mrg */ 1028 1.1.1.2 mrg locale_type 1029 1.1.1.2 mrg imbue(locale_type __loc) 1030 1.1.1.2 mrg { return _M_traits.imbue(__loc); } 1031 1.1.1.2 mrg 1032 1.1.1.2 mrg /** 1033 1.1.1.2 mrg * @brief Gets the locale currently imbued in the regular expression 1034 1.1.1.2 mrg * object. 1035 1.1.1.2 mrg */ 1036 1.1.1.2 mrg locale_type 1037 1.1.1.2 mrg getloc() const 1038 1.1.1.2 mrg { return _M_traits.getloc(); } 1039 1.1.1.2 mrg 1040 1.1.1.2 mrg // [7.8.6] swap 1041 1.1.1.2 mrg /** 1042 1.1.1.2 mrg * @brief Swaps the contents of two regular expression objects. 1043 1.1.1.2 mrg * 1044 1.1.1.2 mrg * @param rhs Another regular expression object. 1045 1.1.1.2 mrg */ 1046 1.1.1.2 mrg void 1047 1.1.1.2 mrg swap(basic_regex& __rhs) 1048 1.1.1.2 mrg { 1049 1.1.1.2 mrg std::swap(_M_flags, __rhs._M_flags); 1050 1.1.1.2 mrg std::swap(_M_pattern, __rhs._M_pattern); 1051 1.1.1.2 mrg std::swap(_M_mark_count, __rhs._M_mark_count); 1052 1.1.1.2 mrg std::swap(_M_traits, __rhs._M_traits); 1053 1.1.1.2 mrg } 1054 1.1.1.2 mrg 1055 1.1.1.2 mrg private: 1056 1.1.1.2 mrg /** 1057 1.1.1.2 mrg * @brief Compiles a regular expression pattern into a NFA. 1058 1.1.1.2 mrg * @todo Implement this function. 1059 1.1.1.2 mrg */ 1060 1.1.1.2 mrg void _M_compile(); 1061 1.1.1.2 mrg 1062 1.1.1.2 mrg protected: 1063 1.1.1.2 mrg flag_type _M_flags; 1064 1.1.1.2 mrg string_type _M_pattern; 1065 1.1.1.2 mrg unsigned int _M_mark_count; 1066 1.1.1.2 mrg _Rx_traits _M_traits; 1067 1.1.1.2 mrg }; 1068 1.1.1.2 mrg 1069 1.1.1.2 mrg /** @brief Standard regular expressions. */ 1070 1.1.1.2 mrg typedef basic_regex<char> regex; 1071 1.1.1.2 mrg #ifdef _GLIBCXX_USE_WCHAR_T 1072 1.1.1.2 mrg /** @brief Standard wide-character regular expressions. */ 1073 1.1.1.2 mrg typedef basic_regex<wchar_t> wregex; 1074 1.1.1.2 mrg #endif 1075 1.1.1.2 mrg 1076 1.1.1.2 mrg 1077 1.1.1.2 mrg // [7.8.6] basic_regex swap 1078 1.1.1.2 mrg /** 1079 1.1.1.2 mrg * @brief Swaps the contents of two regular expression objects. 1080 1.1.1.2 mrg * @param lhs First regular expression. 1081 1.1.1.2 mrg * @param rhs Second regular expression. 1082 1.1.1.2 mrg */ 1083 1.1.1.2 mrg template<typename _Ch_type, typename _Rx_traits> 1084 1.1.1.2 mrg inline void 1085 1.1.1.2 mrg swap(basic_regex<_Ch_type, _Rx_traits>& __lhs, 1086 1.1.1.2 mrg basic_regex<_Ch_type, _Rx_traits>& __rhs) 1087 1.1.1.2 mrg { __lhs.swap(__rhs); } 1088 1.1.1.2 mrg 1089 1.1.1.2 mrg 1090 1.1.1.2 mrg // [7.9] Class template sub_match 1091 1.1.1.2 mrg /** 1092 1.1.1.2 mrg * A sequence of characters matched by a particular marked sub-expression. 1093 1.1.1.2 mrg * 1094 1.1.1.2 mrg * An object of this class is essentially a pair of iterators marking a 1095 1.1.1.2 mrg * matched subexpression within a regular expression pattern match. Such 1096 1.1.1.2 mrg * objects can be converted to and compared with std::basic_string objects 1097 1.1.1.2 mrg * of a similar base character type as the pattern matched by the regular 1098 1.1.1.2 mrg * expression. 1099 1.1.1.2 mrg * 1100 1.1.1.2 mrg * The iterators that make up the pair are the usual half-open interval 1101 1.1.1.2 mrg * referencing the actual original pattern matched. 1102 1.1.1.2 mrg */ 1103 1.1.1.2 mrg template<typename _BiIter> 1104 1.1.1.2 mrg class sub_match : public std::pair<_BiIter, _BiIter> 1105 1.1.1.2 mrg { 1106 1.1.1.2 mrg public: 1107 1.1.1.2 mrg typedef typename iterator_traits<_BiIter>::value_type value_type; 1108 1.1.1.2 mrg typedef typename iterator_traits<_BiIter>::difference_type 1109 1.1.1.2 mrg difference_type; 1110 1.1.1.2 mrg typedef _BiIter iterator; 1111 1.1.1.2 mrg 1112 1.1.1.2 mrg public: 1113 1.1.1.2 mrg bool matched; 1114 1.1.1.2 mrg 1115 1.1.1.2 mrg /** 1116 1.1.1.2 mrg * Gets the length of the matching sequence. 1117 1.1.1.2 mrg */ 1118 1.1.1.2 mrg difference_type 1119 1.1.1.2 mrg length() const 1120 1.1.1.2 mrg { return this->matched ? std::distance(this->first, this->second) : 0; } 1121 1.1.1.2 mrg 1122 1.1.1.2 mrg /** 1123 1.1.1.2 mrg * @brief Gets the matching sequence as a string. 1124 1.1.1.2 mrg * 1125 1.1.1.2 mrg * @returns the matching sequence as a string. 1126 1.1.1.2 mrg * 1127 1.1.1.2 mrg * This is the implicit conversion operator. It is identical to the 1128 1.1.1.2 mrg * str() member function except that it will want to pop up in 1129 1.1.1.2 mrg * unexpected places and cause a great deal of confusion and cursing 1130 1.1.1.2 mrg * from the unwary. 1131 1.1.1.2 mrg */ 1132 1.1.1.2 mrg operator basic_string<value_type>() const 1133 1.1.1.2 mrg { 1134 1.1.1.2 mrg return this->matched 1135 1.1.1.2 mrg ? std::basic_string<value_type>(this->first, this->second) 1136 1.1.1.2 mrg : std::basic_string<value_type>(); 1137 1.1.1.2 mrg } 1138 1.1.1.2 mrg 1139 1.1.1.2 mrg /** 1140 1.1.1.2 mrg * @brief Gets the matching sequence as a string. 1141 1.1.1.2 mrg * 1142 1.1.1.2 mrg * @returns the matching sequence as a string. 1143 1.1.1.2 mrg */ 1144 1.1.1.2 mrg basic_string<value_type> 1145 1.1.1.2 mrg str() const 1146 1.1.1.2 mrg { 1147 1.1.1.2 mrg return this->matched 1148 1.1.1.2 mrg ? std::basic_string<value_type>(this->first, this->second) 1149 1.1.1.2 mrg : std::basic_string<value_type>(); 1150 1.1.1.2 mrg } 1151 1.1.1.2 mrg 1152 1.1.1.2 mrg /** 1153 1.1.1.2 mrg * @brief Compares this and another matched sequence. 1154 1.1.1.2 mrg * 1155 1.1.1.2 mrg * @param s Another matched sequence to compare to this one. 1156 1.1.1.2 mrg * 1157 1.1.1.2 mrg * @retval <0 this matched sequence will collate before @p s. 1158 1.1.1.2 mrg * @retval =0 this matched sequence is equivalent to @p s. 1159 1.1.1.2 mrg * @retval <0 this matched sequence will collate after @p s. 1160 1.1.1.2 mrg */ 1161 1.1.1.2 mrg int 1162 1.1.1.2 mrg compare(const sub_match& __s) const 1163 1.1.1.2 mrg { return this->str().compare(__s.str()); } 1164 1.1.1.2 mrg 1165 1.1.1.2 mrg /** 1166 1.1.1.2 mrg * @brief Compares this sub_match to a string. 1167 1.1.1.2 mrg * 1168 1.1.1.2 mrg * @param s A string to compare to this sub_match. 1169 1.1.1.2 mrg * 1170 1.1.1.2 mrg * @retval <0 this matched sequence will collate before @p s. 1171 1.1.1.2 mrg * @retval =0 this matched sequence is equivalent to @p s. 1172 1.1.1.2 mrg * @retval <0 this matched sequence will collate after @p s. 1173 1.1.1.2 mrg */ 1174 1.1.1.2 mrg int 1175 1.1.1.2 mrg compare(const basic_string<value_type>& __s) const 1176 1.1.1.2 mrg { return this->str().compare(__s); } 1177 1.1.1.2 mrg 1178 1.1.1.2 mrg /** 1179 1.1.1.2 mrg * @brief Compares this sub_match to a C-style string. 1180 1.1.1.2 mrg * 1181 1.1.1.2 mrg * @param s A C-style string to compare to this sub_match. 1182 1.1.1.2 mrg * 1183 1.1.1.2 mrg * @retval <0 this matched sequence will collate before @p s. 1184 1.1.1.2 mrg * @retval =0 this matched sequence is equivalent to @p s. 1185 1.1.1.2 mrg * @retval <0 this matched sequence will collate after @p s. 1186 1.1.1.2 mrg */ 1187 1.1.1.2 mrg int 1188 1.1.1.2 mrg compare(const value_type* __s) const 1189 1.1.1.2 mrg { return this->str().compare(__s); } 1190 1.1.1.2 mrg }; 1191 1.1.1.2 mrg 1192 1.1.1.2 mrg 1193 1.1.1.2 mrg /** @brief Standard regex submatch over a C-style null-terminated string. */ 1194 1.1.1.2 mrg typedef sub_match<const char*> csub_match; 1195 1.1.1.2 mrg /** @brief Standard regex submatch over a standard string. */ 1196 1.1.1.2 mrg typedef sub_match<string::const_iterator> ssub_match; 1197 1.1.1.2 mrg #ifdef _GLIBCXX_USE_WCHAR_T 1198 1.1.1.2 mrg /** @brief Regex submatch over a C-style null-terminated wide string. */ 1199 1.1.1.2 mrg typedef sub_match<const wchar_t*> wcsub_match; 1200 1.1.1.2 mrg /** @brief Regex submatch over a standard wide string. */ 1201 1.1.1.2 mrg typedef sub_match<wstring::const_iterator> wssub_match; 1202 1.1.1.2 mrg #endif 1203 1.1.1.2 mrg 1204 1.1.1.2 mrg // [7.9.2] sub_match non-member operators 1205 1.1.1.2 mrg 1206 1.1.1.2 mrg /** 1207 1.1.1.2 mrg * @brief Tests the equivalence of two regular expression submatches. 1208 1.1.1.2 mrg * @param lhs First regular expression submatch. 1209 1.1.1.2 mrg * @param rhs Second regular expression submatch. 1210 1.1.1.2 mrg * @returns true if @a lhs is equivalent to @a rhs, false otherwise. 1211 1.1.1.2 mrg */ 1212 1.1.1.2 mrg template<typename _BiIter> 1213 1.1.1.2 mrg inline bool 1214 1.1.1.2 mrg operator==(const sub_match<_BiIter>& __lhs, 1215 1.1.1.2 mrg const sub_match<_BiIter>& __rhs) 1216 1.1.1.2 mrg { return __lhs.compare(__rhs) == 0; } 1217 1.1.1.2 mrg 1218 1.1.1.2 mrg /** 1219 1.1.1.2 mrg * @brief Tests the inequivalence of two regular expression submatches. 1220 1.1.1.2 mrg * @param lhs First regular expression submatch. 1221 1.1.1.2 mrg * @param rhs Second regular expression submatch. 1222 1.1.1.2 mrg * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. 1223 1.1.1.2 mrg */ 1224 1.1.1.2 mrg template<typename _BiIter> 1225 1.1.1.2 mrg inline bool 1226 1.1.1.2 mrg operator!=(const sub_match<_BiIter>& __lhs, 1227 1.1.1.2 mrg const sub_match<_BiIter>& __rhs) 1228 1.1.1.2 mrg { return __lhs.compare(__rhs) != 0; } 1229 1.1.1.2 mrg 1230 1.1.1.2 mrg /** 1231 1.1.1.2 mrg * @brief Tests the ordering of two regular expression submatches. 1232 1.1.1.2 mrg * @param lhs First regular expression submatch. 1233 1.1.1.2 mrg * @param rhs Second regular expression submatch. 1234 1.1.1.2 mrg * @returns true if @a lhs precedes @a rhs, false otherwise. 1235 1.1.1.2 mrg */ 1236 1.1.1.2 mrg template<typename _BiIter> 1237 1.1.1.2 mrg inline bool 1238 1.1.1.2 mrg operator<(const sub_match<_BiIter>& __lhs, 1239 1.1.1.2 mrg const sub_match<_BiIter>& __rhs) 1240 1.1.1.2 mrg { return __lhs.compare(__rhs) < 0; } 1241 1.1.1.2 mrg 1242 1.1.1.2 mrg /** 1243 1.1.1.2 mrg * @brief Tests the ordering of two regular expression submatches. 1244 1.1.1.2 mrg * @param lhs First regular expression submatch. 1245 1.1.1.2 mrg * @param rhs Second regular expression submatch. 1246 1.1.1.2 mrg * @returns true if @a lhs does not succeed @a rhs, false otherwise. 1247 1.1.1.2 mrg */ 1248 1.1.1.2 mrg template<typename _BiIter> 1249 1.1.1.2 mrg inline bool 1250 1.1.1.2 mrg operator<=(const sub_match<_BiIter>& __lhs, 1251 1.1.1.2 mrg const sub_match<_BiIter>& __rhs) 1252 1.1.1.2 mrg { return __lhs.compare(__rhs) <= 0; } 1253 1.1.1.2 mrg 1254 1.1.1.2 mrg /** 1255 1.1.1.2 mrg * @brief Tests the ordering of two regular expression submatches. 1256 1.1.1.2 mrg * @param lhs First regular expression submatch. 1257 1.1.1.2 mrg * @param rhs Second regular expression submatch. 1258 1.1.1.2 mrg * @returns true if @a lhs does not precede @a rhs, false otherwise. 1259 1.1.1.2 mrg */ 1260 1.1.1.2 mrg template<typename _BiIter> 1261 1.1.1.2 mrg inline bool 1262 1.1.1.2 mrg operator>=(const sub_match<_BiIter>& __lhs, 1263 1.1.1.2 mrg const sub_match<_BiIter>& __rhs) 1264 1.1.1.2 mrg { return __lhs.compare(__rhs) >= 0; } 1265 1.1.1.2 mrg 1266 1.1.1.2 mrg /** 1267 1.1.1.2 mrg * @brief Tests the ordering of two regular expression submatches. 1268 1.1.1.2 mrg * @param lhs First regular expression submatch. 1269 1.1.1.2 mrg * @param rhs Second regular expression submatch. 1270 1.1.1.2 mrg * @returns true if @a lhs succeeds @a rhs, false otherwise. 1271 1.1.1.2 mrg */ 1272 1.1.1.2 mrg template<typename _BiIter> 1273 1.1.1.2 mrg inline bool 1274 1.1.1.2 mrg operator>(const sub_match<_BiIter>& __lhs, 1275 1.1.1.2 mrg const sub_match<_BiIter>& __rhs) 1276 1.1.1.2 mrg { return __lhs.compare(__rhs) > 0; } 1277 1.1.1.2 mrg 1278 1.1.1.2 mrg /** 1279 1.1.1.2 mrg * @brief Tests the equivalence of a string and a regular expression 1280 1.1.1.2 mrg * submatch. 1281 1.1.1.2 mrg * @param lhs A string. 1282 1.1.1.2 mrg * @param rhs A regular expression submatch. 1283 1.1.1.2 mrg * @returns true if @a lhs is equivalent to @a rhs, false otherwise. 1284 1.1.1.2 mrg */ 1285 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1286 1.1.1.2 mrg inline bool 1287 1.1.1.2 mrg operator==(const basic_string< 1288 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1289 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __lhs, 1290 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1291 1.1.1.2 mrg { return __lhs == __rhs.str(); } 1292 1.1.1.2 mrg 1293 1.1.1.2 mrg /** 1294 1.1.1.2 mrg * @brief Tests the inequivalence of a string and a regular expression 1295 1.1.1.2 mrg * submatch. 1296 1.1.1.2 mrg * @param lhs A string. 1297 1.1.1.2 mrg * @param rhs A regular expression submatch. 1298 1.1.1.2 mrg * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. 1299 1.1.1.2 mrg */ 1300 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1301 1.1.1.2 mrg inline bool 1302 1.1.1.2 mrg operator!=(const basic_string< 1303 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1304 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) 1305 1.1.1.2 mrg { return __lhs != __rhs.str(); } 1306 1.1.1.2 mrg 1307 1.1.1.2 mrg /** 1308 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1309 1.1.1.2 mrg * @param lhs A string. 1310 1.1.1.2 mrg * @param rhs A regular expression submatch. 1311 1.1.1.2 mrg * @returns true if @a lhs precedes @a rhs, false otherwise. 1312 1.1.1.2 mrg */ 1313 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1314 1.1.1.2 mrg inline bool 1315 1.1.1.2 mrg operator<(const basic_string< 1316 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1317 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) 1318 1.1.1.2 mrg { return __lhs < __rhs.str(); } 1319 1.1.1.2 mrg 1320 1.1.1.2 mrg /** 1321 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1322 1.1.1.2 mrg * @param lhs A string. 1323 1.1.1.2 mrg * @param rhs A regular expression submatch. 1324 1.1.1.2 mrg * @returns true if @a lhs succeeds @a rhs, false otherwise. 1325 1.1.1.2 mrg */ 1326 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1327 1.1.1.2 mrg inline bool 1328 1.1.1.2 mrg operator>(const basic_string< 1329 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1330 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) 1331 1.1.1.2 mrg { return __lhs > __rhs.str(); } 1332 1.1.1.2 mrg 1333 1.1.1.2 mrg /** 1334 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1335 1.1.1.2 mrg * @param lhs A string. 1336 1.1.1.2 mrg * @param rhs A regular expression submatch. 1337 1.1.1.2 mrg * @returns true if @a lhs does not precede @a rhs, false otherwise. 1338 1.1.1.2 mrg */ 1339 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1340 1.1.1.2 mrg inline bool 1341 1.1.1.2 mrg operator>=(const basic_string< 1342 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1343 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) 1344 1.1.1.2 mrg { return __lhs >= __rhs.str(); } 1345 1.1.1.2 mrg 1346 1.1.1.2 mrg /** 1347 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1348 1.1.1.2 mrg * @param lhs A string. 1349 1.1.1.2 mrg * @param rhs A regular expression submatch. 1350 1.1.1.2 mrg * @returns true if @a lhs does not succeed @a rhs, false otherwise. 1351 1.1.1.2 mrg */ 1352 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1353 1.1.1.2 mrg inline bool 1354 1.1.1.2 mrg operator<=(const basic_string< 1355 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1356 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs) 1357 1.1.1.2 mrg { return __lhs <= __rhs.str(); } 1358 1.1.1.2 mrg 1359 1.1.1.2 mrg /** 1360 1.1.1.2 mrg * @brief Tests the equivalence of a regular expression submatch and a 1361 1.1.1.2 mrg * string. 1362 1.1.1.2 mrg * @param lhs A regular expression submatch. 1363 1.1.1.2 mrg * @param rhs A string. 1364 1.1.1.2 mrg * @returns true if @a lhs is equivalent to @a rhs, false otherwise. 1365 1.1.1.2 mrg */ 1366 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1367 1.1.1.2 mrg inline bool 1368 1.1.1.2 mrg operator==(const sub_match<_Bi_iter>& __lhs, 1369 1.1.1.2 mrg const basic_string< 1370 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1371 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __rhs) 1372 1.1.1.2 mrg { return __lhs.str() == __rhs; } 1373 1.1.1.2 mrg 1374 1.1.1.2 mrg /** 1375 1.1.1.2 mrg * @brief Tests the inequivalence of a regular expression submatch and a 1376 1.1.1.2 mrg * string. 1377 1.1.1.2 mrg * @param lhs A regular expression submatch. 1378 1.1.1.2 mrg * @param rhs A string. 1379 1.1.1.2 mrg * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. 1380 1.1.1.2 mrg */ 1381 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc> 1382 1.1.1.2 mrg inline bool 1383 1.1.1.2 mrg operator!=(const sub_match<_Bi_iter>& __lhs, 1384 1.1.1.2 mrg const basic_string< 1385 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1386 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __rhs) 1387 1.1.1.2 mrg { return __lhs.str() != __rhs; } 1388 1.1.1.2 mrg 1389 1.1.1.2 mrg /** 1390 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1391 1.1.1.2 mrg * @param lhs A regular expression submatch. 1392 1.1.1.2 mrg * @param rhs A string. 1393 1.1.1.2 mrg * @returns true if @a lhs precedes @a rhs, false otherwise. 1394 1.1.1.2 mrg */ 1395 1.1.1.2 mrg template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> 1396 1.1.1.2 mrg inline bool 1397 1.1.1.2 mrg operator<(const sub_match<_Bi_iter>& __lhs, 1398 1.1.1.2 mrg const basic_string< 1399 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1400 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __rhs) 1401 1.1.1.2 mrg { return __lhs.str() < __rhs; } 1402 1.1.1.2 mrg 1403 1.1.1.2 mrg /** 1404 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1405 1.1.1.2 mrg * @param lhs A regular expression submatch. 1406 1.1.1.2 mrg * @param rhs A string. 1407 1.1.1.2 mrg * @returns true if @a lhs succeeds @a rhs, false otherwise. 1408 1.1.1.2 mrg */ 1409 1.1.1.2 mrg template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> 1410 1.1.1.2 mrg inline bool 1411 1.1.1.2 mrg operator>(const sub_match<_Bi_iter>& __lhs, 1412 1.1.1.2 mrg const basic_string< 1413 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1414 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __rhs) 1415 1.1.1.2 mrg { return __lhs.str() > __rhs; } 1416 1.1.1.2 mrg 1417 1.1.1.2 mrg /** 1418 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1419 1.1.1.2 mrg * @param lhs A regular expression submatch. 1420 1.1.1.2 mrg * @param rhs A string. 1421 1.1.1.2 mrg * @returns true if @a lhs does not precede @a rhs, false otherwise. 1422 1.1.1.2 mrg */ 1423 1.1.1.2 mrg template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> 1424 1.1.1.2 mrg inline bool 1425 1.1.1.2 mrg operator>=(const sub_match<_Bi_iter>& __lhs, 1426 1.1.1.2 mrg const basic_string< 1427 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1428 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __rhs) 1429 1.1.1.2 mrg { return __lhs.str() >= __rhs; } 1430 1.1.1.2 mrg 1431 1.1.1.2 mrg /** 1432 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1433 1.1.1.2 mrg * @param lhs A regular expression submatch. 1434 1.1.1.2 mrg * @param rhs A string. 1435 1.1.1.2 mrg * @returns true if @a lhs does not succeed @a rhs, false otherwise. 1436 1.1.1.2 mrg */ 1437 1.1.1.2 mrg template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc> 1438 1.1.1.2 mrg inline bool 1439 1.1.1.2 mrg operator<=(const sub_match<_Bi_iter>& __lhs, 1440 1.1.1.2 mrg const basic_string< 1441 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type, 1442 1.1.1.2 mrg _Ch_traits, _Ch_alloc>& __rhs) 1443 1.1.1.2 mrg { return __lhs.str() <= __rhs; } 1444 1.1.1.2 mrg 1445 1.1.1.2 mrg /** 1446 1.1.1.2 mrg * @brief Tests the equivalence of a C string and a regular expression 1447 1.1.1.2 mrg * submatch. 1448 1.1.1.2 mrg * @param lhs A C string. 1449 1.1.1.2 mrg * @param rhs A regular expression submatch. 1450 1.1.1.2 mrg * @returns true if @a lhs is equivalent to @a rhs, false otherwise. 1451 1.1.1.2 mrg */ 1452 1.1.1.2 mrg template<typename _Bi_iter> 1453 1.1.1.2 mrg inline bool 1454 1.1.1.2 mrg operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, 1455 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1456 1.1.1.2 mrg { return __lhs == __rhs.str(); } 1457 1.1.1.2 mrg 1458 1.1.1.2 mrg /** 1459 1.1.1.2 mrg * @brief Tests the inequivalence of an iterator value and a regular 1460 1.1.1.2 mrg * expression submatch. 1461 1.1.1.2 mrg * @param lhs A regular expression submatch. 1462 1.1.1.2 mrg * @param rhs A string. 1463 1.1.1.2 mrg * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. 1464 1.1.1.2 mrg */ 1465 1.1.1.2 mrg template<typename _Bi_iter> 1466 1.1.1.2 mrg inline bool 1467 1.1.1.2 mrg operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, 1468 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1469 1.1.1.2 mrg { return __lhs != __rhs.str(); } 1470 1.1.1.2 mrg 1471 1.1.1.2 mrg /** 1472 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1473 1.1.1.2 mrg * @param lhs A string. 1474 1.1.1.2 mrg * @param rhs A regular expression submatch. 1475 1.1.1.2 mrg * @returns true if @a lhs precedes @a rhs, false otherwise. 1476 1.1.1.2 mrg */ 1477 1.1.1.2 mrg template<typename _Bi_iter> 1478 1.1.1.2 mrg inline bool 1479 1.1.1.2 mrg operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, 1480 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1481 1.1.1.2 mrg { return __lhs < __rhs.str(); } 1482 1.1.1.2 mrg 1483 1.1.1.2 mrg /** 1484 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1485 1.1.1.2 mrg * @param lhs A string. 1486 1.1.1.2 mrg * @param rhs A regular expression submatch. 1487 1.1.1.2 mrg * @returns true if @a lhs succeeds @a rhs, false otherwise. 1488 1.1.1.2 mrg */ 1489 1.1.1.2 mrg template<typename _Bi_iter> 1490 1.1.1.2 mrg inline bool 1491 1.1.1.2 mrg operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, 1492 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1493 1.1.1.2 mrg { return __lhs > __rhs.str(); } 1494 1.1.1.2 mrg 1495 1.1.1.2 mrg /** 1496 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1497 1.1.1.2 mrg * @param lhs A string. 1498 1.1.1.2 mrg * @param rhs A regular expression submatch. 1499 1.1.1.2 mrg * @returns true if @a lhs does not precede @a rhs, false otherwise. 1500 1.1.1.2 mrg */ 1501 1.1.1.2 mrg template<typename _Bi_iter> 1502 1.1.1.2 mrg inline bool 1503 1.1.1.2 mrg operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, 1504 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1505 1.1.1.2 mrg { return __lhs >= __rhs.str(); } 1506 1.1.1.2 mrg 1507 1.1.1.2 mrg /** 1508 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1509 1.1.1.2 mrg * @param lhs A string. 1510 1.1.1.2 mrg * @param rhs A regular expression submatch. 1511 1.1.1.2 mrg * @returns true if @a lhs does not succeed @a rhs, false otherwise. 1512 1.1.1.2 mrg */ 1513 1.1.1.2 mrg template<typename _Bi_iter> 1514 1.1.1.2 mrg inline bool 1515 1.1.1.2 mrg operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, 1516 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1517 1.1.1.2 mrg { return __lhs <= __rhs.str(); } 1518 1.1.1.2 mrg 1519 1.1.1.2 mrg /** 1520 1.1.1.2 mrg * @brief Tests the equivalence of a regular expression submatch and a 1521 1.1.1.2 mrg * string. 1522 1.1.1.2 mrg * @param lhs A regular expression submatch. 1523 1.1.1.2 mrg * @param rhs A pointer to a string? 1524 1.1.1.2 mrg * @returns true if @a lhs is equivalent to @a rhs, false otherwise. 1525 1.1.1.2 mrg */ 1526 1.1.1.2 mrg template<typename _Bi_iter> 1527 1.1.1.2 mrg inline bool 1528 1.1.1.2 mrg operator==(const sub_match<_Bi_iter>& __lhs, 1529 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const* __rhs) 1530 1.1.1.2 mrg { return __lhs.str() == __rhs; } 1531 1.1.1.2 mrg 1532 1.1.1.2 mrg /** 1533 1.1.1.2 mrg * @brief Tests the inequivalence of a regular expression submatch and a 1534 1.1.1.2 mrg * string. 1535 1.1.1.2 mrg * @param lhs A regular expression submatch. 1536 1.1.1.2 mrg * @param rhs A pointer to a string. 1537 1.1.1.2 mrg * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. 1538 1.1.1.2 mrg */ 1539 1.1.1.2 mrg template<typename _Bi_iter> 1540 1.1.1.2 mrg inline bool 1541 1.1.1.2 mrg operator!=(const sub_match<_Bi_iter>& __lhs, 1542 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const* __rhs) 1543 1.1.1.2 mrg { return __lhs.str() != __rhs; } 1544 1.1.1.2 mrg 1545 1.1.1.2 mrg /** 1546 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1547 1.1.1.2 mrg * @param lhs A regular expression submatch. 1548 1.1.1.2 mrg * @param rhs A string. 1549 1.1.1.2 mrg * @returns true if @a lhs precedes @a rhs, false otherwise. 1550 1.1.1.2 mrg */ 1551 1.1.1.2 mrg template<typename _Bi_iter> 1552 1.1.1.2 mrg inline bool 1553 1.1.1.2 mrg operator<(const sub_match<_Bi_iter>& __lhs, 1554 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const* __rhs) 1555 1.1.1.2 mrg { return __lhs.str() < __rhs; } 1556 1.1.1.2 mrg 1557 1.1.1.2 mrg /** 1558 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1559 1.1.1.2 mrg * @param lhs A regular expression submatch. 1560 1.1.1.2 mrg * @param rhs A string. 1561 1.1.1.2 mrg * @returns true if @a lhs succeeds @a rhs, false otherwise. 1562 1.1.1.2 mrg */ 1563 1.1.1.2 mrg template<typename _Bi_iter> 1564 1.1.1.2 mrg inline bool 1565 1.1.1.2 mrg operator>(const sub_match<_Bi_iter>& __lhs, 1566 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const* __rhs) 1567 1.1.1.2 mrg { return __lhs.str() > __rhs; } 1568 1.1.1.2 mrg 1569 1.1.1.2 mrg /** 1570 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1571 1.1.1.2 mrg * @param lhs A regular expression submatch. 1572 1.1.1.2 mrg * @param rhs A string. 1573 1.1.1.2 mrg * @returns true if @a lhs does not precede @a rhs, false otherwise. 1574 1.1.1.2 mrg */ 1575 1.1.1.2 mrg template<typename _Bi_iter> 1576 1.1.1.2 mrg inline bool 1577 1.1.1.2 mrg operator>=(const sub_match<_Bi_iter>& __lhs, 1578 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const* __rhs) 1579 1.1.1.2 mrg { return __lhs.str() >= __rhs; } 1580 1.1.1.2 mrg 1581 1.1.1.2 mrg /** 1582 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1583 1.1.1.2 mrg * @param lhs A regular expression submatch. 1584 1.1.1.2 mrg * @param rhs A string. 1585 1.1.1.2 mrg * @returns true if @a lhs does not succeed @a rhs, false otherwise. 1586 1.1.1.2 mrg */ 1587 1.1.1.2 mrg template<typename _Bi_iter> 1588 1.1.1.2 mrg inline bool 1589 1.1.1.2 mrg operator<=(const sub_match<_Bi_iter>& __lhs, 1590 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const* __rhs) 1591 1.1.1.2 mrg { return __lhs.str() <= __rhs; } 1592 1.1.1.2 mrg 1593 1.1.1.2 mrg /** 1594 1.1.1.2 mrg * @brief Tests the equivalence of a string and a regular expression 1595 1.1.1.2 mrg * submatch. 1596 1.1.1.2 mrg * @param lhs A string. 1597 1.1.1.2 mrg * @param rhs A regular expression submatch. 1598 1.1.1.2 mrg * @returns true if @a lhs is equivalent to @a rhs, false otherwise. 1599 1.1.1.2 mrg */ 1600 1.1.1.2 mrg template<typename _Bi_iter> 1601 1.1.1.2 mrg inline bool 1602 1.1.1.2 mrg operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, 1603 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1604 1.1.1.2 mrg { return __lhs == __rhs.str(); } 1605 1.1.1.2 mrg 1606 1.1.1.2 mrg /** 1607 1.1.1.2 mrg * @brief Tests the inequivalence of a string and a regular expression 1608 1.1.1.2 mrg * submatch. 1609 1.1.1.2 mrg * @param lhs A string. 1610 1.1.1.2 mrg * @param rhs A regular expression submatch. 1611 1.1.1.2 mrg * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. 1612 1.1.1.2 mrg */ 1613 1.1.1.2 mrg template<typename _Bi_iter> 1614 1.1.1.2 mrg inline bool 1615 1.1.1.2 mrg operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, 1616 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1617 1.1.1.2 mrg { return __lhs != __rhs.str(); } 1618 1.1.1.2 mrg 1619 1.1.1.2 mrg /** 1620 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1621 1.1.1.2 mrg * @param lhs A string. 1622 1.1.1.2 mrg * @param rhs A regular expression submatch. 1623 1.1.1.2 mrg * @returns true if @a lhs precedes @a rhs, false otherwise. 1624 1.1.1.2 mrg */ 1625 1.1.1.2 mrg template<typename _Bi_iter> 1626 1.1.1.2 mrg inline bool 1627 1.1.1.2 mrg operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, 1628 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1629 1.1.1.2 mrg { return __lhs < __rhs.str(); } 1630 1.1.1.2 mrg 1631 1.1.1.2 mrg /** 1632 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1633 1.1.1.2 mrg * @param lhs A string. 1634 1.1.1.2 mrg * @param rhs A regular expression submatch. 1635 1.1.1.2 mrg * @returns true if @a lhs succeeds @a rhs, false otherwise. 1636 1.1.1.2 mrg */ 1637 1.1.1.2 mrg template<typename _Bi_iter> 1638 1.1.1.2 mrg inline bool 1639 1.1.1.2 mrg operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, 1640 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1641 1.1.1.2 mrg { return __lhs > __rhs.str(); } 1642 1.1.1.2 mrg 1643 1.1.1.2 mrg /** 1644 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1645 1.1.1.2 mrg * @param lhs A string. 1646 1.1.1.2 mrg * @param rhs A regular expression submatch. 1647 1.1.1.2 mrg * @returns true if @a lhs does not precede @a rhs, false otherwise. 1648 1.1.1.2 mrg */ 1649 1.1.1.2 mrg template<typename _Bi_iter> 1650 1.1.1.2 mrg inline bool 1651 1.1.1.2 mrg operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, 1652 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1653 1.1.1.2 mrg { return __lhs >= __rhs.str(); } 1654 1.1.1.2 mrg 1655 1.1.1.2 mrg /** 1656 1.1.1.2 mrg * @brief Tests the ordering of a string and a regular expression submatch. 1657 1.1.1.2 mrg * @param lhs A string. 1658 1.1.1.2 mrg * @param rhs A regular expression submatch. 1659 1.1.1.2 mrg * @returns true if @a lhs does not succeed @a rhs, false otherwise. 1660 1.1.1.2 mrg */ 1661 1.1.1.2 mrg template<typename _Bi_iter> 1662 1.1.1.2 mrg inline bool 1663 1.1.1.2 mrg operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, 1664 1.1.1.2 mrg const sub_match<_Bi_iter>& __rhs) 1665 1.1.1.2 mrg { return __lhs <= __rhs.str(); } 1666 1.1.1.2 mrg 1667 1.1.1.2 mrg /** 1668 1.1.1.2 mrg * @brief Tests the equivalence of a regular expression submatch and a 1669 1.1.1.2 mrg * string. 1670 1.1.1.2 mrg * @param lhs A regular expression submatch. 1671 1.1.1.2 mrg * @param rhs A const string reference. 1672 1.1.1.2 mrg * @returns true if @a lhs is equivalent to @a rhs, false otherwise. 1673 1.1.1.2 mrg */ 1674 1.1.1.2 mrg template<typename _Bi_iter> 1675 1.1.1.2 mrg inline bool 1676 1.1.1.2 mrg operator==(const sub_match<_Bi_iter>& __lhs, 1677 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const& __rhs) 1678 1.1.1.2 mrg { return __lhs.str() == __rhs; } 1679 1.1.1.2 mrg 1680 1.1.1.2 mrg /** 1681 1.1.1.2 mrg * @brief Tests the inequivalence of a regular expression submatch and a 1682 1.1.1.2 mrg * string. 1683 1.1.1.2 mrg * @param lhs A regular expression submatch. 1684 1.1.1.2 mrg * @param rhs A const string reference. 1685 1.1.1.2 mrg * @returns true if @a lhs is not equivalent to @a rhs, false otherwise. 1686 1.1.1.2 mrg */ 1687 1.1.1.2 mrg template<typename _Bi_iter> 1688 1.1.1.2 mrg inline bool 1689 1.1.1.2 mrg operator!=(const sub_match<_Bi_iter>& __lhs, 1690 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const& __rhs) 1691 1.1.1.2 mrg { return __lhs.str() != __rhs; } 1692 1.1.1.2 mrg 1693 1.1.1.2 mrg /** 1694 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1695 1.1.1.2 mrg * @param lhs A regular expression submatch. 1696 1.1.1.2 mrg * @param rhs A const string reference. 1697 1.1.1.2 mrg * @returns true if @a lhs precedes @a rhs, false otherwise. 1698 1.1.1.2 mrg */ 1699 1.1.1.2 mrg template<typename _Bi_iter> 1700 1.1.1.2 mrg inline bool 1701 1.1.1.2 mrg operator<(const sub_match<_Bi_iter>& __lhs, 1702 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const& __rhs) 1703 1.1.1.2 mrg { return __lhs.str() < __rhs; } 1704 1.1.1.2 mrg 1705 1.1.1.2 mrg /** 1706 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1707 1.1.1.2 mrg * @param lhs A regular expression submatch. 1708 1.1.1.2 mrg * @param rhs A const string reference. 1709 1.1.1.2 mrg * @returns true if @a lhs succeeds @a rhs, false otherwise. 1710 1.1.1.2 mrg */ 1711 1.1.1.2 mrg template<typename _Bi_iter> 1712 1.1.1.2 mrg inline bool 1713 1.1.1.2 mrg operator>(const sub_match<_Bi_iter>& __lhs, 1714 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const& __rhs) 1715 1.1.1.2 mrg { return __lhs.str() > __rhs; } 1716 1.1.1.2 mrg 1717 1.1.1.2 mrg /** 1718 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1719 1.1.1.2 mrg * @param lhs A regular expression submatch. 1720 1.1.1.2 mrg * @param rhs A const string reference. 1721 1.1.1.2 mrg * @returns true if @a lhs does not precede @a rhs, false otherwise. 1722 1.1.1.2 mrg */ 1723 1.1.1.2 mrg template<typename _Bi_iter> 1724 1.1.1.2 mrg inline bool 1725 1.1.1.2 mrg operator>=(const sub_match<_Bi_iter>& __lhs, 1726 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const& __rhs) 1727 1.1.1.2 mrg { return __lhs.str() >= __rhs; } 1728 1.1.1.2 mrg 1729 1.1.1.2 mrg /** 1730 1.1.1.2 mrg * @brief Tests the ordering of a regular expression submatch and a string. 1731 1.1.1.2 mrg * @param lhs A regular expression submatch. 1732 1.1.1.2 mrg * @param rhs A const string reference. 1733 1.1.1.2 mrg * @returns true if @a lhs does not succeed @a rhs, false otherwise. 1734 1.1.1.2 mrg */ 1735 1.1.1.2 mrg template<typename _Bi_iter> 1736 1.1.1.2 mrg inline bool 1737 1.1.1.2 mrg operator<=(const sub_match<_Bi_iter>& __lhs, 1738 1.1.1.2 mrg typename iterator_traits<_Bi_iter>::value_type const& __rhs) 1739 1.1.1.2 mrg { return __lhs.str() <= __rhs; } 1740 1.1.1.2 mrg 1741 1.1.1.2 mrg /** 1742 1.1.1.2 mrg * @brief Inserts a matched string into an output stream. 1743 1.1.1.2 mrg * 1744 1.1.1.2 mrg * @param os The output stream. 1745 1.1.1.2 mrg * @param m A submatch string. 1746 1.1.1.2 mrg * 1747 1.1.1.2 mrg * @returns the output stream with the submatch string inserted. 1748 1.1.1.2 mrg */ 1749 1.1.1.2 mrg template<typename _Ch_type, typename _Ch_traits, typename _Bi_iter> 1750 1.1.1.2 mrg inline 1751 1.1.1.2 mrg basic_ostream<_Ch_type, _Ch_traits>& 1752 1.1.1.2 mrg operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, 1753 1.1.1.2 mrg const sub_match<_Bi_iter>& __m) 1754 1.1.1.2 mrg { return __os << __m.str(); } 1755 1.1.1.2 mrg 1756 1.1.1.2 mrg // [7.10] Class template match_results 1757 1.1.1.2 mrg /** 1758 1.1.1.2 mrg * @brief The results of a match or search operation. 1759 1.1.1.2 mrg * 1760 1.1.1.2 mrg * A collection of character sequences representing the result of a regular 1761 1.1.1.2 mrg * expression match. Storage for the collection is allocated and freed as 1762 1.1.1.2 mrg * necessary by the member functions of class template match_results. 1763 1.1.1.2 mrg * 1764 1.1.1.2 mrg * This class satisfies the Sequence requirements, with the exception that 1765 1.1.1.2 mrg * only the operations defined for a const-qualified Sequence are supported. 1766 1.1.1.2 mrg * 1767 1.1.1.2 mrg * The sub_match object stored at index 0 represents sub-expression 0, i.e. 1768 1.1.1.2 mrg * the whole match. In this case the sub_match member matched is always true. 1769 1.1.1.2 mrg * The sub_match object stored at index n denotes what matched the marked 1770 1.1.1.2 mrg * sub-expression n within the matched expression. If the sub-expression n 1771 1.1.1.2 mrg * participated in a regular expression match then the sub_match member 1772 1.1.1.2 mrg * matched evaluates to true, and members first and second denote the range 1773 1.1.1.2 mrg * of characters [first, second) which formed that match. Otherwise matched 1774 1.1.1.2 mrg * is false, and members first and second point to the end of the sequence 1775 1.1.1.2 mrg * that was searched. 1776 1.1.1.2 mrg * 1777 1.1.1.2 mrg * @nosubgrouping 1778 1.1.1.2 mrg */ 1779 1.1.1.2 mrg template<typename _Bi_iter, 1780 1.1.1.2 mrg typename _Allocator = allocator<sub_match<_Bi_iter> > > 1781 1.1.1.2 mrg class match_results 1782 1.1.1.2 mrg : private std::vector<std::tr1::sub_match<_Bi_iter>, _Allocator> 1783 1.1.1.2 mrg { 1784 1.1.1.2 mrg private: 1785 1.1.1.2 mrg typedef std::vector<std::tr1::sub_match<_Bi_iter>, _Allocator> 1786 1.1.1.2 mrg _Base_type; 1787 1.1.1.2 mrg 1788 1.1.1.2 mrg public: 1789 1.1.1.2 mrg /** 1790 1.1.1.2 mrg * @name 10.? Public Types 1791 1.1.1.2 mrg */ 1792 1.1.1.11 mrg ///@{ 1793 1.1.1.2 mrg typedef sub_match<_Bi_iter> value_type; 1794 1.1.1.10 mrg typedef typename _Base_type::const_reference const_reference; 1795 1.1.1.2 mrg typedef const_reference reference; 1796 1.1.1.2 mrg typedef typename _Base_type::const_iterator const_iterator; 1797 1.1.1.2 mrg typedef const_iterator iterator; 1798 1.1.1.2 mrg typedef typename iterator_traits<_Bi_iter>::difference_type 1799 1.1.1.2 mrg difference_type; 1800 1.1.1.2 mrg typedef typename _Allocator::size_type size_type; 1801 1.1.1.2 mrg typedef _Allocator allocator_type; 1802 1.1.1.2 mrg typedef typename iterator_traits<_Bi_iter>::value_type char_type; 1803 1.1.1.2 mrg typedef basic_string<char_type> string_type; 1804 1.1.1.11 mrg ///@} 1805 1.1.1.2 mrg 1806 1.1.1.2 mrg public: 1807 1.1.1.2 mrg /** 1808 1.1.1.2 mrg * @name 10.1 Construction, Copying, and Destruction 1809 1.1.1.2 mrg */ 1810 1.1.1.11 mrg ///@{ 1811 1.1.1.2 mrg 1812 1.1.1.2 mrg /** 1813 1.1.1.2 mrg * @brief Constructs a default %match_results container. 1814 1.1.1.2 mrg * @post size() returns 0 and str() returns an empty string. 1815 1.1.1.2 mrg */ 1816 1.1.1.2 mrg explicit 1817 1.1.1.2 mrg match_results(const _Allocator& __a = _Allocator()) 1818 1.1.1.2 mrg : _Base_type(__a), _M_matched(false) 1819 1.1.1.2 mrg { } 1820 1.1.1.2 mrg 1821 1.1.1.2 mrg /** 1822 1.1.1.2 mrg * @brief Copy constructs a %match_results. 1823 1.1.1.2 mrg */ 1824 1.1.1.2 mrg match_results(const match_results& __rhs) 1825 1.1.1.2 mrg : _Base_type(__rhs), _M_matched(__rhs._M_matched), 1826 1.1.1.2 mrg _M_prefix(__rhs._M_prefix), _M_suffix(__rhs._M_suffix) 1827 1.1.1.2 mrg { } 1828 1.1.1.2 mrg 1829 1.1.1.2 mrg /** 1830 1.1.1.2 mrg * @brief Assigns rhs to *this. 1831 1.1.1.2 mrg */ 1832 1.1.1.2 mrg match_results& 1833 1.1.1.2 mrg operator=(const match_results& __rhs) 1834 1.1.1.2 mrg { 1835 1.1.1.2 mrg match_results __tmp(__rhs); 1836 1.1.1.2 mrg this->swap(__tmp); 1837 1.1.1.2 mrg return *this; 1838 1.1.1.2 mrg } 1839 1.1.1.2 mrg 1840 1.1.1.2 mrg /** 1841 1.1.1.2 mrg * @brief Destroys a %match_results object. 1842 1.1.1.2 mrg */ 1843 1.1.1.2 mrg ~match_results() 1844 1.1.1.2 mrg { } 1845 1.1.1.2 mrg 1846 1.1.1.11 mrg ///@} 1847 1.1.1.2 mrg 1848 1.1.1.2 mrg /** 1849 1.1.1.2 mrg * @name 10.2 Size 1850 1.1.1.2 mrg */ 1851 1.1.1.11 mrg ///@{ 1852 1.1.1.2 mrg 1853 1.1.1.2 mrg /** 1854 1.1.1.2 mrg * @brief Gets the number of matches and submatches. 1855 1.1.1.2 mrg * 1856 1.1.1.2 mrg * The number of matches for a given regular expression will be either 0 1857 1.1.1.2 mrg * if there was no match or mark_count() + 1 if a match was successful. 1858 1.1.1.2 mrg * Some matches may be empty. 1859 1.1.1.2 mrg * 1860 1.1.1.2 mrg * @returns the number of matches found. 1861 1.1.1.2 mrg */ 1862 1.1.1.2 mrg size_type 1863 1.1.1.2 mrg size() const 1864 1.1.1.2 mrg { return _M_matched ? _Base_type::size() + 1 : 0; } 1865 1.1.1.2 mrg 1866 1.1.1.2 mrg //size_type 1867 1.1.1.2 mrg //max_size() const; 1868 1.1.1.2 mrg using _Base_type::max_size; 1869 1.1.1.2 mrg 1870 1.1.1.2 mrg /** 1871 1.1.1.2 mrg * @brief Indicates if the %match_results contains no results. 1872 1.1.1.2 mrg * @retval true The %match_results object is empty. 1873 1.1.1.2 mrg * @retval false The %match_results object is not empty. 1874 1.1.1.2 mrg */ 1875 1.1.1.9 mrg _GLIBCXX_NODISCARD bool 1876 1.1.1.2 mrg empty() const 1877 1.1.1.2 mrg { return size() == 0; } 1878 1.1.1.2 mrg 1879 1.1.1.11 mrg ///@} 1880 1.1.1.2 mrg 1881 1.1.1.2 mrg /** 1882 1.1.1.2 mrg * @name 10.3 Element Access 1883 1.1.1.2 mrg */ 1884 1.1.1.11 mrg ///@{ 1885 1.1.1.2 mrg 1886 1.1.1.2 mrg /** 1887 1.1.1.2 mrg * @brief Gets the length of the indicated submatch. 1888 1.1.1.2 mrg * @param sub indicates the submatch. 1889 1.1.1.2 mrg * 1890 1.1.1.2 mrg * This function returns the length of the indicated submatch, or the 1891 1.1.1.2 mrg * length of the entire match if @p sub is zero (the default). 1892 1.1.1.2 mrg */ 1893 1.1.1.2 mrg difference_type 1894 1.1.1.2 mrg length(size_type __sub = 0) const 1895 1.1.1.2 mrg { return _M_matched ? this->str(__sub).length() : 0; } 1896 1.1.1.2 mrg 1897 1.1.1.2 mrg /** 1898 1.1.1.2 mrg * @brief Gets the offset of the beginning of the indicated submatch. 1899 1.1.1.2 mrg * @param sub indicates the submatch. 1900 1.1.1.2 mrg * 1901 1.1.1.2 mrg * This function returns the offset from the beginning of the target 1902 1.1.1.2 mrg * sequence to the beginning of the submatch, unless the value of @p sub 1903 1.1.1.2 mrg * is zero (the default), in which case this function returns the offset 1904 1.1.1.2 mrg * from the beginning of the target sequence to the beginning of the 1905 1.1.1.2 mrg * match. 1906 1.1.1.2 mrg */ 1907 1.1.1.2 mrg difference_type 1908 1.1.1.2 mrg position(size_type __sub = 0) const 1909 1.1.1.2 mrg { 1910 1.1.1.2 mrg return _M_matched ? std::distance(this->prefix().first, 1911 1.1.1.2 mrg (*this)[__sub].first) : 0; 1912 1.1.1.2 mrg } 1913 1.1.1.2 mrg 1914 1.1.1.2 mrg /** 1915 1.1.1.2 mrg * @brief Gets the match or submatch converted to a string type. 1916 1.1.1.2 mrg * @param sub indicates the submatch. 1917 1.1.1.2 mrg * 1918 1.1.1.2 mrg * This function gets the submatch (or match, if @p sub is zero) extracted 1919 1.1.1.2 mrg * from the target range and converted to the associated string type. 1920 1.1.1.2 mrg */ 1921 1.1.1.2 mrg string_type 1922 1.1.1.2 mrg str(size_type __sub = 0) const 1923 1.1.1.2 mrg { return _M_matched ? (*this)[__sub].str() : string_type(); } 1924 1.1.1.2 mrg 1925 1.1.1.2 mrg /** 1926 1.1.1.2 mrg * @brief Gets a %sub_match reference for the match or submatch. 1927 1.1.1.2 mrg * @param sub indicates the submatch. 1928 1.1.1.2 mrg * 1929 1.1.1.2 mrg * This function gets a reference to the indicated submatch, or the entire 1930 1.1.1.2 mrg * match if @p sub is zero. 1931 1.1.1.2 mrg * 1932 1.1.1.2 mrg * If @p sub >= size() then this function returns a %sub_match with a 1933 1.1.1.2 mrg * special value indicating no submatch. 1934 1.1.1.2 mrg */ 1935 1.1.1.2 mrg const_reference 1936 1.1.1.2 mrg operator[](size_type __sub) const 1937 1.1.1.2 mrg { return _Base_type::operator[](__sub); } 1938 1.1.1.2 mrg 1939 1.1.1.2 mrg /** 1940 1.1.1.2 mrg * @brief Gets a %sub_match representing the match prefix. 1941 1.1.1.2 mrg * 1942 1.1.1.2 mrg * This function gets a reference to a %sub_match object representing the 1943 1.1.1.2 mrg * part of the target range between the start of the target range and the 1944 1.1.1.2 mrg * start of the match. 1945 1.1.1.2 mrg */ 1946 1.1.1.2 mrg const_reference 1947 1.1.1.2 mrg prefix() const 1948 1.1.1.2 mrg { return _M_prefix; } 1949 1.1.1.2 mrg 1950 1.1.1.2 mrg /** 1951 1.1.1.2 mrg * @brief Gets a %sub_match representing the match suffix. 1952 1.1.1.2 mrg * 1953 1.1.1.2 mrg * This function gets a reference to a %sub_match object representing the 1954 1.1.1.2 mrg * part of the target range between the end of the match and the end of 1955 1.1.1.2 mrg * the target range. 1956 1.1.1.2 mrg */ 1957 1.1.1.2 mrg const_reference 1958 1.1.1.2 mrg suffix() const 1959 1.1.1.2 mrg { return _M_suffix; } 1960 1.1.1.2 mrg 1961 1.1.1.2 mrg /** 1962 1.1.1.2 mrg * @brief Gets an iterator to the start of the %sub_match collection. 1963 1.1.1.2 mrg */ 1964 1.1.1.2 mrg const_iterator 1965 1.1.1.2 mrg begin() const 1966 1.1.1.2 mrg { return _Base_type::begin(); } 1967 1.1.1.2 mrg 1968 1.1.1.2 mrg #ifdef _GLIBCXX_INCLUDE_AS_CXX11 1969 1.1.1.2 mrg /** 1970 1.1.1.2 mrg * @brief Gets an iterator to the start of the %sub_match collection. 1971 1.1.1.2 mrg */ 1972 1.1.1.2 mrg const_iterator 1973 1.1.1.2 mrg cbegin() const 1974 1.1.1.2 mrg { return _Base_type::begin(); } 1975 1.1.1.2 mrg #endif 1976 1.1.1.2 mrg 1977 1.1.1.2 mrg /** 1978 1.1.1.2 mrg * @brief Gets an iterator to one-past-the-end of the collection. 1979 1.1.1.2 mrg */ 1980 1.1.1.2 mrg const_iterator 1981 1.1.1.2 mrg end() const 1982 1.1.1.2 mrg { return _Base_type::end(); } 1983 1.1.1.2 mrg 1984 1.1.1.2 mrg #ifdef _GLIBCXX_INCLUDE_AS_CXX11 1985 1.1.1.2 mrg /** 1986 1.1.1.2 mrg * @brief Gets an iterator to one-past-the-end of the collection. 1987 1.1.1.2 mrg */ 1988 1.1.1.2 mrg const_iterator 1989 1.1.1.2 mrg cend() const 1990 1.1.1.2 mrg { return _Base_type::end(); } 1991 1.1.1.2 mrg #endif 1992 1.1.1.2 mrg 1993 1.1.1.11 mrg ///@} 1994 1.1.1.2 mrg 1995 1.1.1.2 mrg /** 1996 1.1.1.2 mrg * @name 10.4 Formatting 1997 1.1.1.2 mrg * 1998 1.1.1.2 mrg * These functions perform formatted substitution of the matched 1999 1.1.1.2 mrg * character sequences into their target. The format specifiers 2000 1.1.1.2 mrg * and escape sequences accepted by these functions are 2001 1.1.1.2 mrg * determined by their @p flags parameter as documented above. 2002 1.1.1.2 mrg */ 2003 1.1.1.11 mrg ///@{ 2004 1.1.1.2 mrg 2005 1.1.1.2 mrg /** 2006 1.1.1.2 mrg * @todo Implement this function. 2007 1.1.1.2 mrg */ 2008 1.1.1.2 mrg template<typename _Out_iter> 2009 1.1.1.2 mrg _Out_iter 2010 1.1.1.2 mrg format(_Out_iter __out, const string_type& __fmt, 2011 1.1.1.2 mrg regex_constants::match_flag_type __flags 2012 1.1.1.2 mrg = regex_constants::format_default) const; 2013 1.1.1.2 mrg 2014 1.1.1.2 mrg /** 2015 1.1.1.2 mrg * @todo Implement this function. 2016 1.1.1.2 mrg */ 2017 1.1.1.2 mrg string_type 2018 1.1.1.2 mrg format(const string_type& __fmt, 2019 1.1.1.2 mrg regex_constants::match_flag_type __flags 2020 1.1.1.2 mrg = regex_constants::format_default) const; 2021 1.1.1.2 mrg 2022 1.1.1.11 mrg ///@} 2023 1.1.1.2 mrg 2024 1.1.1.2 mrg /** 2025 1.1.1.2 mrg * @name 10.5 Allocator 2026 1.1.1.2 mrg */ 2027 1.1.1.12 mrg ///@{ 2028 1.1.1.2 mrg 2029 1.1.1.2 mrg /** 2030 1.1.1.2 mrg * @brief Gets a copy of the allocator. 2031 1.1.1.2 mrg */ 2032 1.1.1.2 mrg //allocator_type 2033 1.1.1.2 mrg //get_allocator() const; 2034 1.1.1.2 mrg using _Base_type::get_allocator; 2035 1.1.1.2 mrg 2036 1.1.1.11 mrg ///@} 2037 1.1.1.2 mrg 2038 1.1.1.2 mrg /** 2039 1.1.1.2 mrg * @name 10.6 Swap 2040 1.1.1.2 mrg */ 2041 1.1.1.12 mrg ///@{ 2042 1.1.1.2 mrg 2043 1.1.1.2 mrg /** 2044 1.1.1.2 mrg * @brief Swaps the contents of two match_results. 2045 1.1.1.2 mrg */ 2046 1.1.1.2 mrg void 2047 1.1.1.2 mrg swap(match_results& __that) 2048 1.1.1.2 mrg { 2049 1.1.1.2 mrg _Base_type::swap(__that); 2050 1.1.1.2 mrg std::swap(_M_matched, __that._M_matched); 2051 1.1.1.2 mrg std::swap(_M_prefix, __that._M_prefix); 2052 1.1.1.2 mrg std::swap(_M_suffix, __that._M_suffix); 2053 1.1.1.2 mrg } 2054 1.1.1.11 mrg ///@} 2055 1.1.1.2 mrg 2056 1.1.1.2 mrg private: 2057 1.1.1.2 mrg bool _M_matched; 2058 1.1.1.2 mrg value_type _M_prefix; 2059 1.1.1.2 mrg value_type _M_suffix; 2060 1.1.1.2 mrg }; 2061 1.1.1.2 mrg 2062 1.1.1.2 mrg typedef match_results<const char*> cmatch; 2063 1.1.1.2 mrg typedef match_results<string::const_iterator> smatch; 2064 1.1.1.2 mrg #ifdef _GLIBCXX_USE_WCHAR_T 2065 1.1.1.2 mrg typedef match_results<const wchar_t*> wcmatch; 2066 1.1.1.2 mrg typedef match_results<wstring::const_iterator> wsmatch; 2067 1.1 mrg #endif 2068 1.1 mrg 2069 1.1.1.2 mrg // match_results comparisons 2070 1.1.1.2 mrg /** 2071 1.1.1.2 mrg * @brief Compares two match_results for equality. 2072 1.1.1.2 mrg * @returns true if the two objects refer to the same match, 2073 1.1.1.2 mrg * false otherwise. 2074 1.1.1.2 mrg * @todo Implement this function. 2075 1.1.1.2 mrg */ 2076 1.1.1.2 mrg template<typename _Bi_iter, typename _Allocator> 2077 1.1.1.2 mrg inline bool 2078 1.1.1.2 mrg operator==(const match_results<_Bi_iter, _Allocator>& __m1, 2079 1.1.1.2 mrg const match_results<_Bi_iter, _Allocator>& __m2); 2080 1.1.1.2 mrg 2081 1.1.1.2 mrg /** 2082 1.1.1.2 mrg * @brief Compares two match_results for inequality. 2083 1.1.1.2 mrg * @returns true if the two objects do not refer to the same match, 2084 1.1.1.2 mrg * false otherwise. 2085 1.1.1.2 mrg */ 2086 1.1.1.2 mrg template<typename _Bi_iter, class _Allocator> 2087 1.1.1.2 mrg inline bool 2088 1.1.1.2 mrg operator!=(const match_results<_Bi_iter, _Allocator>& __m1, 2089 1.1.1.2 mrg const match_results<_Bi_iter, _Allocator>& __m2) 2090 1.1.1.2 mrg { return !(__m1 == __m2); } 2091 1.1.1.2 mrg 2092 1.1.1.2 mrg // [7.10.6] match_results swap 2093 1.1.1.2 mrg /** 2094 1.1.1.2 mrg * @brief Swaps two match results. 2095 1.1.1.2 mrg * @param lhs A match result. 2096 1.1.1.2 mrg * @param rhs A match result. 2097 1.1.1.2 mrg * 2098 1.1.1.2 mrg * The contents of the two match_results objects are swapped. 2099 1.1.1.2 mrg */ 2100 1.1.1.2 mrg template<typename _Bi_iter, typename _Allocator> 2101 1.1.1.2 mrg inline void 2102 1.1.1.2 mrg swap(match_results<_Bi_iter, _Allocator>& __lhs, 2103 1.1.1.2 mrg match_results<_Bi_iter, _Allocator>& __rhs) 2104 1.1.1.2 mrg { __lhs.swap(__rhs); } 2105 1.1.1.2 mrg 2106 1.1.1.2 mrg // [7.11.2] Function template regex_match 2107 1.1.1.2 mrg /** 2108 1.1.1.2 mrg * @name Matching, Searching, and Replacing 2109 1.1.1.2 mrg */ 2110 1.1.1.11 mrg ///@{ 2111 1.1.1.2 mrg 2112 1.1.1.2 mrg /** 2113 1.1.1.2 mrg * @brief Determines if there is a match between the regular expression @p e 2114 1.1.1.2 mrg * and all of the character sequence [first, last). 2115 1.1.1.2 mrg * 2116 1.1.1.2 mrg * @param first Beginning of the character sequence to match. 2117 1.1.1.2 mrg * @param last One-past-the-end of the character sequence to match. 2118 1.1.1.2 mrg * @param m The match results. 2119 1.1.1.2 mrg * @param re The regular expression. 2120 1.1.1.2 mrg * @param flags Controls how the regular expression is matched. 2121 1.1.1.2 mrg * 2122 1.1.1.2 mrg * @retval true A match exists. 2123 1.1.1.2 mrg * @retval false Otherwise. 2124 1.1.1.2 mrg * 2125 1.1.1.2 mrg * @throws an exception of type regex_error. 2126 1.1.1.2 mrg * 2127 1.1.1.2 mrg * @todo Implement this function. 2128 1.1.1.2 mrg */ 2129 1.1.1.2 mrg template<typename _Bi_iter, typename _Allocator, 2130 1.1.1.2 mrg typename _Ch_type, typename _Rx_traits> 2131 1.1.1.2 mrg bool 2132 1.1.1.2 mrg regex_match(_Bi_iter __first, _Bi_iter __last, 2133 1.1.1.2 mrg match_results<_Bi_iter, _Allocator>& __m, 2134 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2135 1.1.1.2 mrg regex_constants::match_flag_type __flags 2136 1.1.1.2 mrg = regex_constants::match_default); 2137 1.1.1.2 mrg 2138 1.1.1.2 mrg /** 2139 1.1.1.2 mrg * @brief Indicates if there is a match between the regular expression @p e 2140 1.1.1.2 mrg * and all of the character sequence [first, last). 2141 1.1.1.2 mrg * 2142 1.1.1.2 mrg * @param first Beginning of the character sequence to match. 2143 1.1.1.2 mrg * @param last One-past-the-end of the character sequence to match. 2144 1.1.1.2 mrg * @param re The regular expression. 2145 1.1.1.2 mrg * @param flags Controls how the regular expression is matched. 2146 1.1.1.2 mrg * 2147 1.1.1.2 mrg * @retval true A match exists. 2148 1.1.1.2 mrg * @retval false Otherwise. 2149 1.1.1.2 mrg * 2150 1.1.1.2 mrg * @throws an exception of type regex_error. 2151 1.1.1.2 mrg */ 2152 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits> 2153 1.1.1.2 mrg bool 2154 1.1.1.2 mrg regex_match(_Bi_iter __first, _Bi_iter __last, 2155 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2156 1.1.1.2 mrg regex_constants::match_flag_type __flags 2157 1.1.1.2 mrg = regex_constants::match_default) 2158 1.1.1.2 mrg { 2159 1.1.1.2 mrg match_results<_Bi_iter> __what; 2160 1.1.1.2 mrg return regex_match(__first, __last, __what, __re, __flags); 2161 1.1.1.2 mrg } 2162 1.1.1.2 mrg 2163 1.1.1.2 mrg /** 2164 1.1.1.2 mrg * @brief Determines if there is a match between the regular expression @p e 2165 1.1.1.2 mrg * and a C-style null-terminated string. 2166 1.1.1.2 mrg * 2167 1.1.1.2 mrg * @param s The C-style null-terminated string to match. 2168 1.1.1.2 mrg * @param m The match results. 2169 1.1.1.2 mrg * @param re The regular expression. 2170 1.1.1.2 mrg * @param f Controls how the regular expression is matched. 2171 1.1.1.2 mrg * 2172 1.1.1.2 mrg * @retval true A match exists. 2173 1.1.1.2 mrg * @retval false Otherwise. 2174 1.1.1.2 mrg * 2175 1.1.1.2 mrg * @throws an exception of type regex_error. 2176 1.1.1.2 mrg */ 2177 1.1.1.2 mrg template<typename _Ch_type, typename _Allocator, typename _Rx_traits> 2178 1.1.1.2 mrg inline bool 2179 1.1.1.2 mrg regex_match(const _Ch_type* __s, 2180 1.1.1.2 mrg match_results<const _Ch_type*, _Allocator>& __m, 2181 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2182 1.1.1.2 mrg regex_constants::match_flag_type __f 2183 1.1.1.2 mrg = regex_constants::match_default) 2184 1.1.1.2 mrg { return regex_match(__s, __s + _Rx_traits::length(__s), __m, __re, __f); } 2185 1.1.1.2 mrg 2186 1.1.1.2 mrg /** 2187 1.1.1.2 mrg * @brief Determines if there is a match between the regular expression @p e 2188 1.1.1.2 mrg * and a string. 2189 1.1.1.2 mrg * 2190 1.1.1.2 mrg * @param s The string to match. 2191 1.1.1.2 mrg * @param m The match results. 2192 1.1.1.2 mrg * @param re The regular expression. 2193 1.1.1.2 mrg * @param flags Controls how the regular expression is matched. 2194 1.1.1.2 mrg * 2195 1.1.1.2 mrg * @retval true A match exists. 2196 1.1.1.2 mrg * @retval false Otherwise. 2197 1.1.1.2 mrg * 2198 1.1.1.2 mrg * @throws an exception of type regex_error. 2199 1.1.1.2 mrg */ 2200 1.1.1.2 mrg template<typename _Ch_traits, typename _Ch_alloc, 2201 1.1.1.2 mrg typename _Allocator, typename _Ch_type, typename _Rx_traits> 2202 1.1.1.2 mrg inline bool 2203 1.1.1.2 mrg regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, 2204 1.1.1.2 mrg match_results<typename basic_string<_Ch_type, 2205 1.1.1.2 mrg _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, 2206 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2207 1.1.1.2 mrg regex_constants::match_flag_type __flags 2208 1.1.1.2 mrg = regex_constants::match_default) 2209 1.1.1.2 mrg { return regex_match(__s.begin(), __s.end(), __m, __re, __flags); } 2210 1.1.1.2 mrg 2211 1.1.1.2 mrg /** 2212 1.1.1.2 mrg * @brief Indicates if there is a match between the regular expression @p e 2213 1.1.1.2 mrg * and a C-style null-terminated string. 2214 1.1.1.2 mrg * 2215 1.1.1.2 mrg * @param s The C-style null-terminated string to match. 2216 1.1.1.2 mrg * @param re The regular expression. 2217 1.1.1.2 mrg * @param f Controls how the regular expression is matched. 2218 1.1.1.2 mrg * 2219 1.1.1.2 mrg * @retval true A match exists. 2220 1.1.1.2 mrg * @retval false Otherwise. 2221 1.1.1.2 mrg * 2222 1.1.1.2 mrg * @throws an exception of type regex_error. 2223 1.1.1.2 mrg */ 2224 1.1.1.2 mrg template<typename _Ch_type, class _Rx_traits> 2225 1.1.1.2 mrg inline bool 2226 1.1.1.2 mrg regex_match(const _Ch_type* __s, 2227 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2228 1.1.1.2 mrg regex_constants::match_flag_type __f 2229 1.1.1.2 mrg = regex_constants::match_default) 2230 1.1.1.2 mrg { return regex_match(__s, __s + _Rx_traits::length(__s), __re, __f); } 2231 1.1.1.2 mrg 2232 1.1.1.2 mrg /** 2233 1.1.1.2 mrg * @brief Indicates if there is a match between the regular expression @p e 2234 1.1.1.2 mrg * and a string. 2235 1.1.1.2 mrg * 2236 1.1.1.2 mrg * @param s [IN] The string to match. 2237 1.1.1.2 mrg * @param re [IN] The regular expression. 2238 1.1.1.2 mrg * @param flags [IN] Controls how the regular expression is matched. 2239 1.1.1.2 mrg * 2240 1.1.1.2 mrg * @retval true A match exists. 2241 1.1.1.2 mrg * @retval false Otherwise. 2242 1.1.1.2 mrg * 2243 1.1.1.2 mrg * @throws an exception of type regex_error. 2244 1.1.1.2 mrg */ 2245 1.1.1.2 mrg template<typename _Ch_traits, typename _Str_allocator, 2246 1.1.1.2 mrg typename _Ch_type, typename _Rx_traits> 2247 1.1.1.2 mrg inline bool 2248 1.1.1.2 mrg regex_match(const basic_string<_Ch_type, _Ch_traits, _Str_allocator>& __s, 2249 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2250 1.1.1.2 mrg regex_constants::match_flag_type __flags 2251 1.1.1.2 mrg = regex_constants::match_default) 2252 1.1.1.2 mrg { return regex_match(__s.begin(), __s.end(), __re, __flags); } 2253 1.1.1.2 mrg 2254 1.1.1.2 mrg // [7.11.3] Function template regex_search 2255 1.1.1.2 mrg /** 2256 1.1.1.2 mrg * Searches for a regular expression within a range. 2257 1.1.1.2 mrg * @param first [IN] The start of the string to search. 2258 1.1.1.2 mrg * @param last [IN] One-past-the-end of the string to search. 2259 1.1.1.2 mrg * @param m [OUT] The match results. 2260 1.1.1.2 mrg * @param re [IN] The regular expression to search for. 2261 1.1.1.2 mrg * @param flags [IN] Search policy flags. 2262 1.1.1.2 mrg * @retval true A match was found within the string. 2263 1.1.1.2 mrg * @retval false No match was found within the string, the content of %m is 2264 1.1.1.2 mrg * undefined. 2265 1.1.1.2 mrg * 2266 1.1.1.2 mrg * @throws an exception of type regex_error. 2267 1.1.1.2 mrg * 2268 1.1.1.2 mrg * @todo Implement this function. 2269 1.1.1.2 mrg */ 2270 1.1.1.2 mrg template<typename _Bi_iter, typename _Allocator, 2271 1.1.1.2 mrg typename _Ch_type, typename _Rx_traits> 2272 1.1.1.2 mrg inline bool 2273 1.1.1.2 mrg regex_search(_Bi_iter __first, _Bi_iter __last, 2274 1.1.1.2 mrg match_results<_Bi_iter, _Allocator>& __m, 2275 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2276 1.1.1.2 mrg regex_constants::match_flag_type __flags 2277 1.1.1.2 mrg = regex_constants::match_default); 2278 1.1.1.2 mrg 2279 1.1.1.2 mrg /** 2280 1.1.1.2 mrg * Searches for a regular expression within a range. 2281 1.1.1.2 mrg * @param first [IN] The start of the string to search. 2282 1.1.1.2 mrg * @param last [IN] One-past-the-end of the string to search. 2283 1.1.1.2 mrg * @param re [IN] The regular expression to search for. 2284 1.1.1.2 mrg * @param flags [IN] Search policy flags. 2285 1.1.1.2 mrg * @retval true A match was found within the string. 2286 1.1.1.2 mrg * @retval false No match was found within the string. 2287 1.1.1.2 mrg * @doctodo 2288 1.1.1.2 mrg * 2289 1.1.1.2 mrg * @throws an exception of type regex_error. 2290 1.1.1.2 mrg */ 2291 1.1.1.2 mrg template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits> 2292 1.1.1.2 mrg inline bool 2293 1.1.1.2 mrg regex_search(_Bi_iter __first, _Bi_iter __last, 2294 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __re, 2295 1.1.1.2 mrg regex_constants::match_flag_type __flags 2296 1.1.1.2 mrg = regex_constants::match_default) 2297 1.1.1.2 mrg { 2298 1.1.1.2 mrg match_results<_Bi_iter> __what; 2299 1.1.1.2 mrg return regex_search(__first, __last, __what, __re, __flags); 2300 1.1.1.2 mrg } 2301 1.1.1.2 mrg 2302 1.1.1.2 mrg /** 2303 1.1.1.2 mrg * @brief Searches for a regular expression within a C-string. 2304 1.1.1.2 mrg * @param s [IN] A C-string to search for the regex. 2305 1.1.1.2 mrg * @param m [OUT] The set of regex matches. 2306 1.1.1.2 mrg * @param e [IN] The regex to search for in @p s. 2307 1.1.1.2 mrg * @param f [IN] The search flags. 2308 1.1.1.2 mrg * @retval true A match was found within the string. 2309 1.1.1.2 mrg * @retval false No match was found within the string, the content of %m is 2310 1.1.1.2 mrg * undefined. 2311 1.1.1.2 mrg * @doctodo 2312 1.1.1.2 mrg * 2313 1.1.1.2 mrg * @throws an exception of type regex_error. 2314 1.1.1.2 mrg */ 2315 1.1.1.2 mrg template<typename _Ch_type, class _Allocator, class _Rx_traits> 2316 1.1.1.2 mrg inline bool 2317 1.1.1.2 mrg regex_search(const _Ch_type* __s, 2318 1.1.1.2 mrg match_results<const _Ch_type*, _Allocator>& __m, 2319 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __e, 2320 1.1.1.2 mrg regex_constants::match_flag_type __f 2321 1.1.1.2 mrg = regex_constants::match_default) 2322 1.1.1.2 mrg { return regex_search(__s, __s + _Rx_traits::length(__s), __m, __e, __f); } 2323 1.1.1.2 mrg 2324 1.1.1.2 mrg /** 2325 1.1.1.2 mrg * @brief Searches for a regular expression within a C-string. 2326 1.1.1.2 mrg * @param s [IN] The C-string to search. 2327 1.1.1.2 mrg * @param e [IN] The regular expression to search for. 2328 1.1.1.2 mrg * @param f [IN] Search policy flags. 2329 1.1.1.2 mrg * @retval true A match was found within the string. 2330 1.1.1.2 mrg * @retval false No match was found within the string. 2331 1.1.1.2 mrg * @doctodo 2332 1.1.1.2 mrg * 2333 1.1.1.2 mrg * @throws an exception of type regex_error. 2334 1.1.1.2 mrg */ 2335 1.1.1.2 mrg template<typename _Ch_type, typename _Rx_traits> 2336 1.1.1.2 mrg inline bool 2337 1.1.1.2 mrg regex_search(const _Ch_type* __s, 2338 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __e, 2339 1.1.1.2 mrg regex_constants::match_flag_type __f 2340 1.1.1.2 mrg = regex_constants::match_default) 2341 1.1.1.2 mrg { return regex_search(__s, __s + _Rx_traits::length(__s), __e, __f); } 2342 1.1.1.2 mrg 2343 1.1.1.2 mrg /** 2344 1.1.1.2 mrg * @brief Searches for a regular expression within a string. 2345 1.1.1.2 mrg * @param s [IN] The string to search. 2346 1.1.1.2 mrg * @param e [IN] The regular expression to search for. 2347 1.1.1.2 mrg * @param flags [IN] Search policy flags. 2348 1.1.1.2 mrg * @retval true A match was found within the string. 2349 1.1.1.2 mrg * @retval false No match was found within the string. 2350 1.1.1.2 mrg * @doctodo 2351 1.1.1.2 mrg * 2352 1.1.1.2 mrg * @throws an exception of type regex_error. 2353 1.1.1.2 mrg */ 2354 1.1.1.2 mrg template<typename _Ch_traits, typename _String_allocator, 2355 1.1.1.2 mrg typename _Ch_type, typename _Rx_traits> 2356 1.1.1.2 mrg inline bool 2357 1.1.1.2 mrg regex_search(const basic_string<_Ch_type, _Ch_traits, 2358 1.1.1.2 mrg _String_allocator>& __s, 2359 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __e, 2360 1.1.1.2 mrg regex_constants::match_flag_type __flags 2361 1.1.1.2 mrg = regex_constants::match_default) 2362 1.1.1.2 mrg { return regex_search(__s.begin(), __s.end(), __e, __flags); } 2363 1.1.1.2 mrg 2364 1.1.1.2 mrg /** 2365 1.1.1.2 mrg * @brief Searches for a regular expression within a string. 2366 1.1.1.2 mrg * @param s [IN] A C++ string to search for the regex. 2367 1.1.1.2 mrg * @param m [OUT] The set of regex matches. 2368 1.1.1.2 mrg * @param e [IN] The regex to search for in @p s. 2369 1.1.1.2 mrg * @param f [IN] The search flags. 2370 1.1.1.2 mrg * @retval true A match was found within the string. 2371 1.1.1.2 mrg * @retval false No match was found within the string, the content of %m is 2372 1.1.1.2 mrg * undefined. 2373 1.1.1.2 mrg * 2374 1.1.1.2 mrg * @throws an exception of type regex_error. 2375 1.1.1.2 mrg */ 2376 1.1.1.2 mrg template<typename _Ch_traits, typename _Ch_alloc, 2377 1.1.1.2 mrg typename _Allocator, typename _Ch_type, 2378 1.1.1.2 mrg typename _Rx_traits> 2379 1.1.1.2 mrg inline bool 2380 1.1.1.2 mrg regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s, 2381 1.1.1.2 mrg match_results<typename basic_string<_Ch_type, 2382 1.1.1.2 mrg _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m, 2383 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __e, 2384 1.1.1.2 mrg regex_constants::match_flag_type __f 2385 1.1.1.2 mrg = regex_constants::match_default) 2386 1.1.1.2 mrg { return regex_search(__s.begin(), __s.end(), __m, __e, __f); } 2387 1.1.1.2 mrg 2388 1.1.1.2 mrg // tr1 [7.11.4] std [28.11.4] Function template regex_replace 2389 1.1.1.2 mrg /** 2390 1.1.1.2 mrg * @doctodo 2391 1.1.1.2 mrg * @param out 2392 1.1.1.2 mrg * @param first 2393 1.1.1.2 mrg * @param last 2394 1.1.1.2 mrg * @param e 2395 1.1.1.2 mrg * @param fmt 2396 1.1.1.2 mrg * @param flags 2397 1.1.1.2 mrg * 2398 1.1.1.2 mrg * @returns out 2399 1.1.1.2 mrg * @throws an exception of type regex_error. 2400 1.1.1.2 mrg * 2401 1.1.1.2 mrg * @todo Implement this function. 2402 1.1.1.2 mrg */ 2403 1.1.1.2 mrg template<typename _Out_iter, typename _Bi_iter, 2404 1.1.1.2 mrg typename _Rx_traits, typename _Ch_type> 2405 1.1.1.2 mrg inline _Out_iter 2406 1.1.1.2 mrg regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, 2407 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __e, 2408 1.1.1.2 mrg const basic_string<_Ch_type>& __fmt, 2409 1.1.1.2 mrg regex_constants::match_flag_type __flags 2410 1.1.1.2 mrg = regex_constants::match_default); 2411 1.1.1.2 mrg 2412 1.1.1.2 mrg /** 2413 1.1.1.2 mrg * @doctodo 2414 1.1.1.2 mrg * @param s 2415 1.1.1.2 mrg * @param e 2416 1.1.1.2 mrg * @param fmt 2417 1.1.1.2 mrg * @param flags 2418 1.1.1.2 mrg * 2419 1.1.1.2 mrg * @returns a copy of string @p s with replacements. 2420 1.1.1.2 mrg * 2421 1.1.1.2 mrg * @throws an exception of type regex_error. 2422 1.1.1.2 mrg */ 2423 1.1.1.2 mrg template<typename _Rx_traits, typename _Ch_type> 2424 1.1.1.2 mrg inline basic_string<_Ch_type> 2425 1.1.1.2 mrg regex_replace(const basic_string<_Ch_type>& __s, 2426 1.1.1.2 mrg const basic_regex<_Ch_type, _Rx_traits>& __e, 2427 1.1.1.2 mrg const basic_string<_Ch_type>& __fmt, 2428 1.1.1.2 mrg regex_constants::match_flag_type __flags 2429 1.1.1.2 mrg = regex_constants::match_default) 2430 1.1.1.2 mrg { 2431 1.1.1.2 mrg std::string __result; 2432 1.1.1.2 mrg regex_replace(std::back_inserter(__result), 2433 1.1.1.2 mrg __s.begin(), __s.end(), __e, __fmt, __flags); 2434 1.1.1.2 mrg return __result; 2435 1.1.1.2 mrg } 2436 1.1.1.2 mrg 2437 1.1.1.11 mrg ///@} 2438 1.1.1.2 mrg 2439 1.1.1.2 mrg // tr1 [7.12.1] std [28.12] Class template regex_iterator 2440 1.1.1.2 mrg /** 2441 1.1.1.2 mrg * An iterator adaptor that will provide repeated calls of regex_search over 2442 1.1.1.2 mrg * a range until no more matches remain. 2443 1.1.1.2 mrg */ 2444 1.1.1.2 mrg template<typename _Bi_iter, 2445 1.1.1.2 mrg typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type, 2446 1.1.1.2 mrg typename _Rx_traits = regex_traits<_Ch_type> > 2447 1.1.1.2 mrg class regex_iterator 2448 1.1.1.2 mrg { 2449 1.1.1.2 mrg public: 2450 1.1.1.2 mrg typedef basic_regex<_Ch_type, _Rx_traits> regex_type; 2451 1.1.1.2 mrg typedef match_results<_Bi_iter> value_type; 2452 1.1.1.2 mrg typedef std::ptrdiff_t difference_type; 2453 1.1.1.2 mrg typedef const value_type* pointer; 2454 1.1.1.2 mrg typedef const value_type& reference; 2455 1.1.1.2 mrg typedef std::forward_iterator_tag iterator_category; 2456 1.1.1.2 mrg 2457 1.1.1.2 mrg public: 2458 1.1.1.2 mrg /** 2459 1.1.1.2 mrg * @brief Provides a singular iterator, useful for indicating 2460 1.1.1.2 mrg * one-past-the-end of a range. 2461 1.1.1.2 mrg * @todo Implement this function. 2462 1.1.1.2 mrg * @doctodo 2463 1.1.1.2 mrg */ 2464 1.1.1.2 mrg regex_iterator(); 2465 1.1.1.2 mrg 2466 1.1.1.2 mrg /** 2467 1.1.1.2 mrg * Constructs a %regex_iterator... 2468 1.1.1.2 mrg * @param a [IN] The start of a text range to search. 2469 1.1.1.2 mrg * @param b [IN] One-past-the-end of the text range to search. 2470 1.1.1.2 mrg * @param re [IN] The regular expression to match. 2471 1.1.1.2 mrg * @param m [IN] Policy flags for match rules. 2472 1.1.1.2 mrg * @todo Implement this function. 2473 1.1.1.2 mrg * @doctodo 2474 1.1.1.2 mrg */ 2475 1.1.1.2 mrg regex_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, 2476 1.1.1.2 mrg regex_constants::match_flag_type __m 2477 1.1.1.2 mrg = regex_constants::match_default); 2478 1.1.1.2 mrg 2479 1.1.1.2 mrg /** 2480 1.1.1.2 mrg * Copy constructs a %regex_iterator. 2481 1.1.1.2 mrg * @todo Implement this function. 2482 1.1.1.2 mrg * @doctodo 2483 1.1.1.2 mrg */ 2484 1.1.1.2 mrg regex_iterator(const regex_iterator& __rhs); 2485 1.1.1.2 mrg 2486 1.1.1.2 mrg /** 2487 1.1.1.2 mrg * @todo Implement this function. 2488 1.1.1.2 mrg * @doctodo 2489 1.1.1.2 mrg */ 2490 1.1.1.2 mrg regex_iterator& 2491 1.1.1.2 mrg operator=(const regex_iterator& __rhs); 2492 1.1.1.2 mrg 2493 1.1.1.2 mrg /** 2494 1.1.1.2 mrg * @todo Implement this function. 2495 1.1.1.2 mrg * @doctodo 2496 1.1.1.2 mrg */ 2497 1.1.1.2 mrg bool 2498 1.1.1.2 mrg operator==(const regex_iterator& __rhs); 2499 1.1.1.2 mrg 2500 1.1.1.2 mrg /** 2501 1.1.1.2 mrg * @todo Implement this function. 2502 1.1.1.2 mrg * @doctodo 2503 1.1.1.2 mrg */ 2504 1.1.1.2 mrg bool 2505 1.1.1.2 mrg operator!=(const regex_iterator& __rhs); 2506 1.1.1.2 mrg 2507 1.1.1.2 mrg /** 2508 1.1.1.2 mrg * @todo Implement this function. 2509 1.1.1.2 mrg * @doctodo 2510 1.1.1.2 mrg */ 2511 1.1.1.2 mrg const value_type& 2512 1.1.1.2 mrg operator*(); 2513 1.1.1.2 mrg 2514 1.1.1.2 mrg /** 2515 1.1.1.2 mrg * @todo Implement this function. 2516 1.1.1.2 mrg * @doctodo 2517 1.1.1.2 mrg */ 2518 1.1.1.2 mrg const value_type* 2519 1.1.1.2 mrg operator->(); 2520 1.1.1.2 mrg 2521 1.1.1.2 mrg /** 2522 1.1.1.2 mrg * @todo Implement this function. 2523 1.1.1.2 mrg * @doctodo 2524 1.1.1.2 mrg */ 2525 1.1.1.2 mrg regex_iterator& 2526 1.1.1.2 mrg operator++(); 2527 1.1.1.2 mrg 2528 1.1.1.2 mrg /** 2529 1.1.1.2 mrg * @todo Implement this function. 2530 1.1.1.2 mrg * @doctodo 2531 1.1.1.2 mrg */ 2532 1.1.1.2 mrg regex_iterator 2533 1.1.1.2 mrg operator++(int); 2534 1.1.1.2 mrg 2535 1.1.1.2 mrg private: 2536 1.1.1.2 mrg // these members are shown for exposition only: 2537 1.1.1.2 mrg _Bi_iter begin; 2538 1.1.1.2 mrg _Bi_iter end; 2539 1.1.1.2 mrg const regex_type* pregex; 2540 1.1.1.2 mrg regex_constants::match_flag_type flags; 2541 1.1.1.2 mrg match_results<_Bi_iter> match; 2542 1.1.1.2 mrg }; 2543 1.1.1.2 mrg 2544 1.1.1.2 mrg typedef regex_iterator<const char*> cregex_iterator; 2545 1.1.1.2 mrg typedef regex_iterator<string::const_iterator> sregex_iterator; 2546 1.1.1.2 mrg #ifdef _GLIBCXX_USE_WCHAR_T 2547 1.1.1.2 mrg typedef regex_iterator<const wchar_t*> wcregex_iterator; 2548 1.1.1.2 mrg typedef regex_iterator<wstring::const_iterator> wsregex_iterator; 2549 1.1.1.2 mrg #endif 2550 1.1.1.2 mrg 2551 1.1.1.2 mrg // [7.12.2] Class template regex_token_iterator 2552 1.1.1.2 mrg /** 2553 1.1.1.2 mrg * Iterates over submatches in a range (or @a splits a text string). 2554 1.1.1.2 mrg * 2555 1.1.1.2 mrg * The purpose of this iterator is to enumerate all, or all specified, 2556 1.1.1.2 mrg * matches of a regular expression within a text range. The dereferenced 2557 1.1.1.2 mrg * value of an iterator of this class is a std::tr1::sub_match object. 2558 1.1.1.2 mrg */ 2559 1.1.1.2 mrg template<typename _Bi_iter, 2560 1.1.1.2 mrg typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type, 2561 1.1.1.2 mrg typename _Rx_traits = regex_traits<_Ch_type> > 2562 1.1.1.2 mrg class regex_token_iterator 2563 1.1.1.2 mrg { 2564 1.1.1.2 mrg public: 2565 1.1.1.2 mrg typedef basic_regex<_Ch_type, _Rx_traits> regex_type; 2566 1.1.1.2 mrg typedef sub_match<_Bi_iter> value_type; 2567 1.1.1.2 mrg typedef std::ptrdiff_t difference_type; 2568 1.1.1.2 mrg typedef const value_type* pointer; 2569 1.1.1.2 mrg typedef const value_type& reference; 2570 1.1.1.2 mrg typedef std::forward_iterator_tag iterator_category; 2571 1.1.1.2 mrg 2572 1.1.1.2 mrg public: 2573 1.1.1.2 mrg /** 2574 1.1.1.2 mrg * @brief Default constructs a %regex_token_iterator. 2575 1.1.1.2 mrg * @todo Implement this function. 2576 1.1.1.2 mrg * 2577 1.1.1.2 mrg * A default-constructed %regex_token_iterator is a singular iterator 2578 1.1.1.2 mrg * that will compare equal to the one-past-the-end value for any 2579 1.1.1.2 mrg * iterator of the same type. 2580 1.1.1.2 mrg */ 2581 1.1.1.2 mrg regex_token_iterator(); 2582 1.1.1.2 mrg 2583 1.1.1.2 mrg /** 2584 1.1.1.2 mrg * Constructs a %regex_token_iterator... 2585 1.1.1.2 mrg * @param a [IN] The start of the text to search. 2586 1.1.1.2 mrg * @param b [IN] One-past-the-end of the text to search. 2587 1.1.1.2 mrg * @param re [IN] The regular expression to search for. 2588 1.1.1.2 mrg * @param submatch [IN] Which submatch to return. There are some 2589 1.1.1.2 mrg * special values for this parameter: 2590 1.1.1.2 mrg * - -1 each enumerated subexpression does NOT 2591 1.1.1.2 mrg * match the regular expression (aka field 2592 1.1.1.2 mrg * splitting) 2593 1.1.1.2 mrg * - 0 the entire string matching the 2594 1.1.1.2 mrg * subexpression is returned for each match 2595 1.1.1.2 mrg * within the text. 2596 1.1.1.2 mrg * - >0 enumerates only the indicated 2597 1.1.1.2 mrg * subexpression from a match within the text. 2598 1.1.1.2 mrg * @param m [IN] Policy flags for match rules. 2599 1.1.1.2 mrg * 2600 1.1.1.2 mrg * @todo Implement this function. 2601 1.1.1.2 mrg * @doctodo 2602 1.1.1.2 mrg */ 2603 1.1.1.2 mrg regex_token_iterator(_Bi_iter __a, _Bi_iter __b, const regex_type& __re, 2604 1.1.1.2 mrg int __submatch = 0, 2605 1.1.1.2 mrg regex_constants::match_flag_type __m 2606 1.1.1.2 mrg = regex_constants::match_default); 2607 1.1.1.2 mrg 2608 1.1.1.2 mrg /** 2609 1.1.1.2 mrg * Constructs a %regex_token_iterator... 2610 1.1.1.2 mrg * @param a [IN] The start of the text to search. 2611 1.1.1.2 mrg * @param b [IN] One-past-the-end of the text to search. 2612 1.1.1.2 mrg * @param re [IN] The regular expression to search for. 2613 1.1.1.2 mrg * @param submatches [IN] A list of subexpressions to return for each 2614 1.1.1.2 mrg * regular expression match within the text. 2615 1.1.1.2 mrg * @param m [IN] Policy flags for match rules. 2616 1.1.1.2 mrg * 2617 1.1.1.2 mrg * @todo Implement this function. 2618 1.1.1.2 mrg * @doctodo 2619 1.1.1.2 mrg */ 2620 1.1.1.2 mrg regex_token_iterator(_Bi_iter __a, _Bi_iter __b, 2621 1.1.1.2 mrg const regex_type& __re, 2622 1.1.1.2 mrg const std::vector<int>& __submatches, 2623 1.1.1.2 mrg regex_constants::match_flag_type __m 2624 1.1.1.2 mrg = regex_constants::match_default); 2625 1.1.1.2 mrg 2626 1.1.1.2 mrg /** 2627 1.1.1.2 mrg * Constructs a %regex_token_iterator... 2628 1.1.1.2 mrg * @param a [IN] The start of the text to search. 2629 1.1.1.2 mrg * @param b [IN] One-past-the-end of the text to search. 2630 1.1.1.2 mrg * @param re [IN] The regular expression to search for. 2631 1.1.1.2 mrg * @param submatches [IN] A list of subexpressions to return for each 2632 1.1.1.2 mrg * regular expression match within the text. 2633 1.1.1.2 mrg * @param m [IN] Policy flags for match rules. 2634 1.1.1.2 mrg 2635 1.1.1.2 mrg * @todo Implement this function. 2636 1.1.1.2 mrg * @doctodo 2637 1.1.1.2 mrg */ 2638 1.1.1.2 mrg template<std::size_t _Nm> 2639 1.1.1.2 mrg regex_token_iterator(_Bi_iter __a, _Bi_iter __b, 2640 1.1.1.2 mrg const regex_type& __re, 2641 1.1.1.2 mrg const int (&__submatches)[_Nm], 2642 1.1.1.2 mrg regex_constants::match_flag_type __m 2643 1.1.1.2 mrg = regex_constants::match_default); 2644 1.1.1.2 mrg 2645 1.1.1.2 mrg /** 2646 1.1.1.2 mrg * @brief Copy constructs a %regex_token_iterator. 2647 1.1.1.2 mrg * @param rhs [IN] A %regex_token_iterator to copy. 2648 1.1.1.2 mrg * @todo Implement this function. 2649 1.1.1.2 mrg */ 2650 1.1.1.2 mrg regex_token_iterator(const regex_token_iterator& __rhs); 2651 1.1.1.2 mrg 2652 1.1.1.2 mrg /** 2653 1.1.1.2 mrg * @brief Assigns a %regex_token_iterator to another. 2654 1.1.1.2 mrg * @param rhs [IN] A %regex_token_iterator to copy. 2655 1.1.1.2 mrg * @todo Implement this function. 2656 1.1.1.2 mrg */ 2657 1.1.1.2 mrg regex_token_iterator& 2658 1.1.1.2 mrg operator=(const regex_token_iterator& __rhs); 2659 1.1.1.2 mrg 2660 1.1.1.2 mrg /** 2661 1.1.1.2 mrg * @brief Compares a %regex_token_iterator to another for equality. 2662 1.1.1.2 mrg * @todo Implement this function. 2663 1.1.1.2 mrg */ 2664 1.1.1.2 mrg bool 2665 1.1.1.2 mrg operator==(const regex_token_iterator& __rhs); 2666 1.1.1.2 mrg 2667 1.1.1.2 mrg /** 2668 1.1.1.2 mrg * @brief Compares a %regex_token_iterator to another for inequality. 2669 1.1.1.2 mrg * @todo Implement this function. 2670 1.1.1.2 mrg */ 2671 1.1.1.2 mrg bool 2672 1.1.1.2 mrg operator!=(const regex_token_iterator& __rhs); 2673 1.1.1.2 mrg 2674 1.1.1.2 mrg /** 2675 1.1.1.2 mrg * @brief Dereferences a %regex_token_iterator. 2676 1.1.1.2 mrg * @todo Implement this function. 2677 1.1.1.2 mrg */ 2678 1.1.1.2 mrg const value_type& 2679 1.1.1.2 mrg operator*(); 2680 1.1.1.2 mrg 2681 1.1.1.2 mrg /** 2682 1.1.1.2 mrg * @brief Selects a %regex_token_iterator member. 2683 1.1.1.2 mrg * @todo Implement this function. 2684 1.1.1.2 mrg */ 2685 1.1.1.2 mrg const value_type* 2686 1.1.1.2 mrg operator->(); 2687 1.1.1.2 mrg 2688 1.1.1.2 mrg /** 2689 1.1.1.2 mrg * @brief Increments a %regex_token_iterator. 2690 1.1.1.2 mrg * @todo Implement this function. 2691 1.1.1.2 mrg */ 2692 1.1.1.2 mrg regex_token_iterator& 2693 1.1.1.2 mrg operator++(); 2694 1.1.1.2 mrg 2695 1.1.1.2 mrg /** 2696 1.1.1.2 mrg * @brief Postincrements a %regex_token_iterator. 2697 1.1.1.2 mrg * @todo Implement this function. 2698 1.1.1.2 mrg */ 2699 1.1.1.2 mrg regex_token_iterator 2700 1.1.1.2 mrg operator++(int); 2701 1.1.1.2 mrg 2702 1.1.1.2 mrg private: // data members for exposition only: 2703 1.1.1.2 mrg typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> position_iterator; 2704 1.1.1.2 mrg 2705 1.1.1.2 mrg position_iterator __position; 2706 1.1.1.2 mrg const value_type* __result; 2707 1.1.1.2 mrg value_type __suffix; 2708 1.1.1.2 mrg std::size_t __n; 2709 1.1.1.2 mrg std::vector<int> __subs; 2710 1.1.1.2 mrg }; 2711 1.1.1.2 mrg 2712 1.1.1.2 mrg /** @brief Token iterator for C-style NULL-terminated strings. */ 2713 1.1.1.2 mrg typedef regex_token_iterator<const char*> cregex_token_iterator; 2714 1.1.1.2 mrg /** @brief Token iterator for standard strings. */ 2715 1.1.1.2 mrg typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; 2716 1.1.1.2 mrg #ifdef _GLIBCXX_USE_WCHAR_T 2717 1.1.1.2 mrg /** @brief Token iterator for C-style NULL-terminated wide strings. */ 2718 1.1.1.2 mrg typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; 2719 1.1.1.2 mrg /** @brief Token iterator for standard wide-character strings. */ 2720 1.1.1.2 mrg typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; 2721 1.1.1.2 mrg #endif 2722 1.1.1.2 mrg 2723 1.1.1.11 mrg ///@} 2724 1.1.1.8 mrg } 2725 1.1.1.2 mrg 2726 1.1.1.2 mrg _GLIBCXX_END_NAMESPACE_VERSION 2727 1.1.1.2 mrg } 2728 1.1.1.2 mrg 2729 1.1 mrg #endif // _GLIBCXX_TR1_REGEX 2730