From 6646d624d0901f1bd5a494b67205d00b63ff554b Mon Sep 17 00:00:00 2001 From: Tim Shen Date: Fri, 9 Aug 2013 07:53:28 +0000 Subject: [PATCH] regex_constants.h: Change syntax_option_type to enum type. 2013-08-09 Tim Shen * include/bits/regex_constants.h: Change syntax_option_type to enum type. From-SVN: r201621 --- libstdc++-v3/ChangeLog | 5 + libstdc++-v3/include/bits/regex_constants.h | 198 ++++++++++++-------- 2 files changed, 123 insertions(+), 80 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7a141171ab2..17267c8380d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2013-08-09 Tim Shen + + * include/bits/regex_constants.h: Change syntax_option_type to enum + type. + 2013-08-08 Rainer Orth * include/bits/regex.h: Replace _A, _B, _C, _R by _Ap, _Bp, diff --git a/libstdc++-v3/include/bits/regex_constants.h b/libstdc++-v3/include/bits/regex_constants.h index 8c163cc0b3e..6ac65d79913 100644 --- a/libstdc++-v3/include/bits/regex_constants.h +++ b/libstdc++-v3/include/bits/regex_constants.h @@ -77,87 +77,125 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * elements @c ECMAScript, @c basic, @c extended, @c awk, @c grep, @c egrep * %set. */ - typedef unsigned int syntax_option_type; - - /** - * Specifies that the matching of regular expressions against a character - * sequence shall be performed without regard to case. - */ - constexpr syntax_option_type icase = 1 << _S_icase; - - /** - * Specifies that when a regular expression is matched against a character - * container sequence, no sub-expression matches are to be stored in the - * supplied match_results structure. - */ - constexpr syntax_option_type nosubs = 1 << _S_nosubs; - - /** - * Specifies that the regular expression engine should pay more attention to - * the speed with which regular expressions are matched, and less to the - * speed with which regular expression objects are constructed. Otherwise - * it has no detectable effect on the program output. - */ - constexpr syntax_option_type optimize = 1 << _S_optimize; - - /** - * Specifies that character ranges of the form [a-b] should be locale - * sensitive. - */ - constexpr syntax_option_type collate = 1 << _S_collate; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript - * Language Specification, Standard Ecma-262, third edition, 1999], as - * modified in section [28.13]. This grammar is similar to that defined - * in the PERL scripting language but extended with elements found in the - * POSIX regular expression grammar. - */ - constexpr syntax_option_type ECMAScript = 1 << _S_ECMAScript; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, - * Portable Operating System Interface (POSIX), Base Definitions and - * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- - * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. - */ - constexpr syntax_option_type basic = 1 << _S_basic; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, - * Portable Operating System Interface (POSIX), Base Definitions and Headers, - * Section 9, Regular Expressions. - */ - constexpr syntax_option_type extended = 1 << _S_extended; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is - * identical to syntax_option_type extended, except that C-style escape - * sequences are supported. These sequences are: - * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\', ', - * and \\ddd (where ddd is one, two, or three octal digits). - */ - constexpr syntax_option_type awk = 1 << _S_awk; - - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is - * identical to syntax_option_type basic, except that newlines are treated - * as whitespace. - */ - constexpr syntax_option_type grep = 1 << _S_grep; + enum syntax_option_type + { + /** + * Specifies that the matching of regular expressions against a character + * sequence shall be performed without regard to case. + */ + icase = 1 << _S_icase, + + /** + * Specifies that when a regular expression is matched against a character + * container sequence, no sub-expression matches are to be stored in the + * supplied match_results structure. + */ + nosubs = 1 << _S_nosubs, + + /** + * Specifies that the regular expression engine should pay more attention to + * the speed with which regular expressions are matched, and less to the + * speed with which regular expression objects are constructed. Otherwise + * it has no detectable effect on the program output. + */ + optimize = 1 << _S_optimize, + + /** + * Specifies that character ranges of the form [a-b] should be locale + * sensitive. + */ + collate = 1 << _S_collate, + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by ECMAScript in ECMA-262 [Ecma International, ECMAScript + * Language Specification, Standard Ecma-262, third edition, 1999], as + * modified in section [28.13]. This grammar is similar to that defined + * in the PERL scripting language but extended with elements found in the + * POSIX regular expression grammar. + */ + ECMAScript = 1 << _S_ECMAScript, + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX basic regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and + * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- + * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. + */ + basic = 1 << _S_basic, + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, + * Portable Operating System Interface (POSIX), Base Definitions and Headers, + * Section 9, Regular Expressions. + */ + extended = 1 << _S_extended, + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility awk in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type extended, except that C-style escape + * sequences are supported. These sequences are: + * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos,, &apos,, + * and \\ddd (where ddd is one, two, or three octal digits). + */ + awk = 1 << _S_awk, + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep in IEEE Std 1003.1-2001. This option is + * identical to syntax_option_type basic, except that newlines are treated + * as whitespace. + */ + grep = 1 << _S_grep, + + /** + * Specifies that the grammar recognized by the regular expression engine is + * that used by POSIX utility grep when given the -E option in + * IEEE Std 1003.1-2001. This option is identical to syntax_option_type + * extended, except that newlines are treated as whitespace. + */ + egrep = 1 << _S_egrep, + }; - /** - * Specifies that the grammar recognized by the regular expression engine is - * that used by POSIX utility grep when given the -E option in - * IEEE Std 1003.1-2001. This option is identical to syntax_option_type - * extended, except that newlines are treated as whitespace. - */ - constexpr syntax_option_type egrep = 1 << _S_egrep; + constexpr inline syntax_option_type + operator&(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + & static_cast(__b)); + } + + constexpr inline syntax_option_type + operator|(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + | static_cast(__b)); + } + + constexpr inline syntax_option_type + operator^(syntax_option_type __a, syntax_option_type __b) + { + return (syntax_option_type)(static_cast(__a) + ^ static_cast(__b)); + } + + constexpr inline syntax_option_type + operator~(syntax_option_type __a) + { return (syntax_option_type)(~static_cast(__a)); } + + inline syntax_option_type& + operator&=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a & __b; } + + inline syntax_option_type& + operator|=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a | __b; } + + inline syntax_option_type& + operator^=(syntax_option_type& __a, syntax_option_type __b) + { return __a = __a ^ __b; } //@} -- 2.30.2