PR fortran/56408
[official-gcc.git] / libstdc++-v3 / include / bits / regex_constants.h
blobb5705ba1caeaab7b6595ce7b9c3e0123fd83afa9
1 // class template regex -*- C++ -*-
3 // Copyright (C) 2010-2014 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 * Do not attempt to use it directly. @headername{regex}
33 namespace std _GLIBCXX_VISIBILITY(default)
35 /**
36 * @defgroup regex Regular Expressions
38 * A facility for performing regular expression pattern matching.
39 * @{
42 /**
43 * @namespace std::regex_constants
44 * @brief ISO C++-0x entities sub namespace for regex.
46 namespace regex_constants
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
50 /**
51 * @name 5.1 Regular Expression Syntax Options
53 //@{
54 enum __syntax_option
56 _S_icase,
57 _S_nosubs,
58 _S_optimize,
59 _S_collate,
60 _S_ECMAScript,
61 _S_basic,
62 _S_extended,
63 _S_awk,
64 _S_grep,
65 _S_egrep,
66 _S_syntax_last
69 /**
70 * @brief This is a bitmask type indicating how to interpret the regex.
72 * The @c syntax_option_type is implementation defined but it is valid to
73 * perform bitwise operations on these values and expect the right thing to
74 * happen.
76 * A valid value of type syntax_option_type shall have exactly one of the
77 * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep
78 * %set.
80 enum syntax_option_type : unsigned int
82 /**
83 * Specifies that the matching of regular expressions against a character
84 * sequence shall be performed without regard to case.
86 icase = 1 << _S_icase,
88 /**
89 * Specifies that when a regular expression is matched against a character
90 * container sequence, no sub-expression matches are to be stored in the
91 * supplied match_results structure.
93 nosubs = 1 << _S_nosubs,
95 /**
96 * Specifies that the regular expression engine should pay more attention to
97 * the speed with which regular expressions are matched, and less to the
98 * speed with which regular expression objects are constructed. Otherwise
99 * it has no detectable effect on the program output.
101 optimize = 1 << _S_optimize,
104 * Specifies that character ranges of the form [a-b] should be locale
105 * sensitive.
107 collate = 1 << _S_collate,
110 * Specifies that the grammar recognized by the regular expression engine is
111 * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript
112 * Language Specification, Standard Ecma-262, third edition, 1999], as
113 * modified in section [28.13]. This grammar is similar to that defined
114 * in the PERL scripting language but extended with elements found in the
115 * POSIX regular expression grammar.
117 ECMAScript = 1 << _S_ECMAScript,
120 * Specifies that the grammar recognized by the regular expression engine is
121 * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001,
122 * Portable Operating System Interface (POSIX), Base Definitions and
123 * Headers, Section 9, Regular Expressions [IEEE, Information Technology --
124 * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
126 basic = 1 << _S_basic,
129 * Specifies that the grammar recognized by the regular expression engine is
130 * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001,
131 * Portable Operating System Interface (POSIX), Base Definitions and
132 * Headers, Section 9, Regular Expressions.
134 extended = 1 << _S_extended,
137 * Specifies that the grammar recognized by the regular expression engine is
138 * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is
139 * identical to syntax_option_type extended, except that C-style escape
140 * sequences are supported. These sequences are:
141 * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos,, &apos,,
142 * and \\ddd (where ddd is one, two, or three octal digits).
144 awk = 1 << _S_awk,
147 * Specifies that the grammar recognized by the regular expression engine is
148 * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is
149 * identical to syntax_option_type basic, except that newlines are treated
150 * as whitespace.
152 grep = 1 << _S_grep,
155 * Specifies that the grammar recognized by the regular expression engine is
156 * that used by POSIX utility grep when given the -E option in
157 * IEEE Std 1003.1-2001. This option is identical to syntax_option_type
158 * extended, except that newlines are treated as whitespace.
160 egrep = 1 << _S_egrep,
163 constexpr inline syntax_option_type
164 operator&(syntax_option_type __a, syntax_option_type __b)
166 return (syntax_option_type)(static_cast<unsigned int>(__a)
167 & static_cast<unsigned int>(__b));
170 constexpr inline syntax_option_type
171 operator|(syntax_option_type __a, syntax_option_type __b)
173 return (syntax_option_type)(static_cast<unsigned int>(__a)
174 | static_cast<unsigned int>(__b));
177 constexpr inline syntax_option_type
178 operator^(syntax_option_type __a, syntax_option_type __b)
180 return (syntax_option_type)(static_cast<unsigned int>(__a)
181 ^ static_cast<unsigned int>(__b));
184 constexpr inline syntax_option_type
185 operator~(syntax_option_type __a)
186 { return (syntax_option_type)(~static_cast<unsigned int>(__a)); }
188 inline syntax_option_type&
189 operator&=(syntax_option_type& __a, syntax_option_type __b)
190 { return __a = __a & __b; }
192 inline syntax_option_type&
193 operator|=(syntax_option_type& __a, syntax_option_type __b)
194 { return __a = __a | __b; }
196 inline syntax_option_type&
197 operator^=(syntax_option_type& __a, syntax_option_type __b)
198 { return __a = __a ^ __b; }
200 //@}
203 * @name 5.2 Matching Rules
205 * Matching a regular expression against a sequence of characters [first,
206 * last) proceeds according to the rules of the grammar specified for the
207 * regular expression object, modified according to the effects listed
208 * below for any bitmask elements set.
211 //@{
213 enum __match_flag
215 _S_not_bol,
216 _S_not_eol,
217 _S_not_bow,
218 _S_not_eow,
219 _S_any,
220 _S_not_null,
221 _S_continuous,
222 _S_prev_avail,
223 _S_sed,
224 _S_no_copy,
225 _S_first_only,
226 _S_match_flag_last
230 * @brief This is a bitmask type indicating regex matching rules.
232 * The @c match_flag_type is implementation defined but it is valid to
233 * perform bitwise operations on these values and expect the right thing to
234 * happen.
236 enum match_flag_type : unsigned int
239 * The default matching rules.
241 match_default = 0,
244 * The first character in the sequence [first, last) is treated as though it
245 * is not at the beginning of a line, so the character (^) in the regular
246 * expression shall not match [first, first).
248 match_not_bol = 1 << _S_not_bol,
251 * The last character in the sequence [first, last) is treated as though it
252 * is not at the end of a line, so the character ($) in the regular
253 * expression shall not match [last, last).
255 match_not_eol = 1 << _S_not_eol,
258 * The expression \\b is not matched against the sub-sequence
259 * [first,first).
261 match_not_bow = 1 << _S_not_bow,
264 * The expression \\b should not be matched against the sub-sequence
265 * [last,last).
267 match_not_eow = 1 << _S_not_eow,
270 * If more than one match is possible then any match is an acceptable
271 * result.
273 match_any = 1 << _S_any,
276 * The expression does not match an empty sequence.
278 match_not_null = 1 << _S_not_null,
281 * The expression only matches a sub-sequence that begins at first .
283 match_continuous = 1 << _S_continuous,
286 * --first is a valid iterator position. When this flag is set then the
287 * flags match_not_bol and match_not_bow are ignored by the regular
288 * expression algorithms 28.11 and iterators 28.12.
290 match_prev_avail = 1 << _S_prev_avail,
293 * When a regular expression match is to be replaced by a new string, the
294 * new string is constructed using the rules used by the ECMAScript replace
295 * function in ECMA- 262 [Ecma International, ECMAScript Language
296 * Specification, Standard Ecma-262, third edition, 1999], part 15.5.4.11
297 * String.prototype.replace. In addition, during search and replace
298 * operations all non-overlapping occurrences of the regular expression
299 * are located and replaced, and sections of the input that did not match
300 * the expression are copied unchanged to the output string.
302 * Format strings (from ECMA-262 [15.5.4.11]):
303 * @li $$ The dollar-sign itself ($)
304 * @li $& The matched substring.
305 * @li $` The portion of @a string that precedes the matched substring.
306 * This would be match_results::prefix().
307 * @li $' The portion of @a string that follows the matched substring.
308 * This would be match_results::suffix().
309 * @li $n The nth capture, where n is in [1,9] and $n is not followed by a
310 * decimal digit. If n <= match_results::size() and the nth capture
311 * is undefined, use the empty string instead. If n >
312 * match_results::size(), the result is implementation-defined.
313 * @li $nn The nnth capture, where nn is a two-digit decimal number on
314 * [01, 99]. If nn <= match_results::size() and the nth capture is
315 * undefined, use the empty string instead. If
316 * nn > match_results::size(), the result is implementation-defined.
318 format_default = 0,
321 * When a regular expression match is to be replaced by a new string, the
322 * new string is constructed using the rules used by the POSIX sed utility
323 * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
324 * Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
326 format_sed = 1 << _S_sed,
329 * During a search and replace operation, sections of the character
330 * container sequence being searched that do not match the regular
331 * expression shall not be copied to the output string.
333 format_no_copy = 1 << _S_no_copy,
336 * When specified during a search and replace operation, only the first
337 * occurrence of the regular expression shall be replaced.
339 format_first_only = 1 << _S_first_only,
342 constexpr inline match_flag_type
343 operator&(match_flag_type __a, match_flag_type __b)
345 return (match_flag_type)(static_cast<unsigned int>(__a)
346 & static_cast<unsigned int>(__b));
349 constexpr inline match_flag_type
350 operator|(match_flag_type __a, match_flag_type __b)
352 return (match_flag_type)(static_cast<unsigned int>(__a)
353 | static_cast<unsigned int>(__b));
356 constexpr inline match_flag_type
357 operator^(match_flag_type __a, match_flag_type __b)
359 return (match_flag_type)(static_cast<unsigned int>(__a)
360 ^ static_cast<unsigned int>(__b));
363 constexpr inline match_flag_type
364 operator~(match_flag_type __a)
365 { return (match_flag_type)(~static_cast<unsigned int>(__a)); }
367 inline match_flag_type&
368 operator&=(match_flag_type& __a, match_flag_type __b)
369 { return __a = __a & __b; }
371 inline match_flag_type&
372 operator|=(match_flag_type& __a, match_flag_type __b)
373 { return __a = __a | __b; }
375 inline match_flag_type&
376 operator^=(match_flag_type& __a, match_flag_type __b)
377 { return __a = __a ^ __b; }
379 //@}
381 _GLIBCXX_END_NAMESPACE_VERSION
382 } // namespace regex_constants
384 /* @} */ // group regex
385 } // namespace std