Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / include / bits / regex_constants.h
blob15e29532c5195cf679c21b24f51d3a56d68b9135
1 // class template regex -*- C++ -*-
3 // Copyright (C) 2010 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /**
26 * @file bits/regex_constants.h
27 * @brief Constant definitions for the std regex library.
29 * This is an internal header file, included by other library headers.
30 * You should not attempt to use it directly.
33 _GLIBCXX_BEGIN_NAMESPACE(std)
35 /**
36 * @namespace std::regex_constants
37 * @brief ISO C++-0x entities sub namespace for regex.
39 namespace regex_constants
41 /**
42 * @name 5.1 Regular Expression Syntax Options
44 //@{
45 enum __syntax_option
47 _S_icase,
48 _S_nosubs,
49 _S_optimize,
50 _S_collate,
51 _S_ECMAScript,
52 _S_basic,
53 _S_extended,
54 _S_awk,
55 _S_grep,
56 _S_egrep,
57 _S_syntax_last
60 /**
61 * @brief This is a bitmask type indicating how to interpret the regex.
63 * The @c syntax_option_type is implementation defined but it is valid to
64 * perform bitwise operations on these values and expect the right thing to
65 * happen.
67 * A valid value of type syntax_option_type shall have exactly one of the
68 * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep
69 * %set.
71 typedef unsigned int syntax_option_type;
73 /**
74 * Specifies that the matching of regular expressions against a character
75 * sequence shall be performed without regard to case.
77 static const syntax_option_type icase = 1 << _S_icase;
79 /**
80 * Specifies that when a regular expression is matched against a character
81 * container sequence, no sub-expression matches are to be stored in the
82 * supplied match_results structure.
84 static const syntax_option_type nosubs = 1 << _S_nosubs;
86 /**
87 * Specifies that the regular expression engine should pay more attention to
88 * the speed with which regular expressions are matched, and less to the
89 * speed with which regular expression objects are constructed. Otherwise
90 * it has no detectable effect on the program output.
92 static const syntax_option_type optimize = 1 << _S_optimize;
94 /**
95 * Specifies that character ranges of the form [a-b] should be locale
96 * sensitive.
98 static const syntax_option_type collate = 1 << _S_collate;
101 * Specifies that the grammar recognized by the regular expression engine is
102 * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript
103 * Language Specification, Standard Ecma-262, third edition, 1999], as
104 * modified in section [28.13]. This grammar is similar to that defined
105 * in the PERL scripting language but extended with elements found in the
106 * POSIX regular expression grammar.
108 static const syntax_option_type ECMAScript = 1 << _S_ECMAScript;
111 * Specifies that the grammar recognized by the regular expression engine is
112 * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001,
113 * Portable Operating System Interface (POSIX), Base Definitions and
114 * Headers, Section 9, Regular Expressions [IEEE, Information Technology --
115 * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
117 static const syntax_option_type basic = 1 << _S_basic;
120 * Specifies that the grammar recognized by the regular expression engine is
121 * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001,
122 * Portable Operating System Interface (POSIX), Base Definitions and Headers,
123 * Section 9, Regular Expressions.
125 static const syntax_option_type extended = 1 << _S_extended;
128 * Specifies that the grammar recognized by the regular expression engine is
129 * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is
130 * identical to syntax_option_type extended, except that C-style escape
131 * sequences are supported. These sequences are:
132 * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos;, &apos;,
133 * and \\ddd (where ddd is one, two, or three octal digits).
135 static const syntax_option_type awk = 1 << _S_awk;
138 * Specifies that the grammar recognized by the regular expression engine is
139 * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is
140 * identical to syntax_option_type basic, except that newlines are treated
141 * as whitespace.
143 static const syntax_option_type grep = 1 << _S_grep;
146 * Specifies that the grammar recognized by the regular expression engine is
147 * that used by POSIX utility grep when given the -E option in
148 * IEEE Std 1003.1-2001. This option is identical to syntax_option_type
149 * extended, except that newlines are treated as whitespace.
151 static const syntax_option_type egrep = 1 << _S_egrep;
153 //@}
156 * @name 5.2 Matching Rules
158 * Matching a regular expression against a sequence of characters [first,
159 * last) proceeds according to the rules of the grammar specified for the
160 * regular expression object, modified according to the effects listed
161 * below for any bitmask elements set.
164 //@{
166 enum __match_flag
168 _S_not_bol,
169 _S_not_eol,
170 _S_not_bow,
171 _S_not_eow,
172 _S_any,
173 _S_not_null,
174 _S_continuous,
175 _S_prev_avail,
176 _S_sed,
177 _S_no_copy,
178 _S_first_only,
179 _S_match_flag_last
183 * @brief This is a bitmask type indicating regex matching rules.
185 * The @c match_flag_type is implementation defined but it is valid to
186 * perform bitwise operations on these values and expect the right thing to
187 * happen.
189 typedef std::bitset<_S_match_flag_last> match_flag_type;
192 * The default matching rules.
194 static const match_flag_type match_default = 0;
197 * The first character in the sequence [first, last) is treated as though it
198 * is not at the beginning of a line, so the character (^) in the regular
199 * expression shall not match [first, first).
201 static const match_flag_type match_not_bol = 1 << _S_not_bol;
204 * The last character in the sequence [first, last) is treated as though it
205 * is not at the end of a line, so the character ($) in the regular
206 * expression shall not match [last, last).
208 static const match_flag_type match_not_eol = 1 << _S_not_eol;
211 * The expression \\b is not matched against the sub-sequence
212 * [first,first).
214 static const match_flag_type match_not_bow = 1 << _S_not_bow;
217 * The expression \\b should not be matched against the sub-sequence
218 * [last,last).
220 static const match_flag_type match_not_eow = 1 << _S_not_eow;
223 * If more than one match is possible then any match is an acceptable
224 * result.
226 static const match_flag_type match_any = 1 << _S_any;
229 * The expression does not match an empty sequence.
231 static const match_flag_type match_not_null = 1 << _S_not_null;
234 * The expression only matches a sub-sequence that begins at first .
236 static const match_flag_type match_continuous = 1 << _S_continuous;
239 * --first is a valid iterator position. When this flag is set then the
240 * flags match_not_bol and match_not_bow are ignored by the regular
241 * expression algorithms 7.11 and iterators 7.12.
243 static const match_flag_type match_prev_avail = 1 << _S_prev_avail;
246 * When a regular expression match is to be replaced by a new string, the
247 * new string is constructed using the rules used by the ECMAScript replace
248 * function in ECMA- 262 [Ecma International, ECMAScript Language
249 * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11
250 * String.prototype.replace. In addition, during search and replace
251 * operations all non-overlapping occurrences of the regular expression
252 * are located and replaced, and sections of the input that did not match
253 * the expression are copied unchanged to the output string.
255 * Format strings (from ECMA-262 [15.5.4.11]):
256 * @li $$ The dollar-sign itself ($)
257 * @li $& The matched substring.
258 * @li $` The portion of @a string that precedes the matched substring.
259 * This would be match_results::prefix().
260 * @li $' The portion of @a string that follows the matched substring.
261 * This would be match_results::suffix().
262 * @li $n The nth capture, where n is in [1,9] and $n is not followed by a
263 * decimal digit. If n <= match_results::size() and the nth capture
264 * is undefined, use the empty string instead. If n >
265 * match_results::size(), the result is implementation-defined.
266 * @li $nn The nnth capture, where nn is a two-digit decimal number on
267 * [01, 99]. If nn <= match_results::size() and the nth capture is
268 * undefined, use the empty string instead. If
269 * nn > match_results::size(), the result is implementation-defined.
271 static const match_flag_type format_default = 0;
274 * When a regular expression match is to be replaced by a new string, the
275 * new string is constructed using the rules used by the POSIX sed utility
276 * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
277 * Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
279 static const match_flag_type format_sed = 1 << _S_sed;
282 * During a search and replace operation, sections of the character
283 * container sequence being searched that do not match the regular
284 * expression shall not be copied to the output string.
286 static const match_flag_type format_no_copy = 1 << _S_no_copy;
289 * When specified during a search and replace operation, only the first
290 * occurrence of the regular expression shall be replaced.
292 static const match_flag_type format_first_only = 1 << _S_first_only;
294 //@}
296 } // namespace regex_constants
298 _GLIBCXX_END_NAMESPACE