Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:54

0001 ///////////////////////////////////////////////////////////////////////////////
0002 /// \file regex_constants.hpp
0003 /// Contains definitions for the syntax_option_type, match_flag_type and
0004 /// error_type enumerations.
0005 //
0006 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0007 //  Software License, Version 1.0. (See accompanying file
0008 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 
0010 #ifndef BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005
0011 #define BOOST_XPRESSIVE_REGEX_CONSTANTS_HPP_EAN_10_04_2005
0012 
0013 // MS compatible compilers support #pragma once
0014 #if defined(_MSC_VER)
0015 # pragma once
0016 #endif
0017 
0018 #include <boost/mpl/identity.hpp>
0019 
0020 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
0021 # define icase icase_
0022 #endif
0023 
0024 namespace boost { namespace xpressive { namespace regex_constants
0025 {
0026 
0027 /// Flags used to customize the regex syntax
0028 ///
0029 enum syntax_option_type
0030 {
0031     // these flags are required:
0032 
0033     ECMAScript  = 0,        ///< Specifies that the grammar recognized by the regular expression
0034                             ///< engine uses its normal semantics: that is the same as that given
0035                             ///< in the ECMA-262, ECMAScript Language Specification, Chapter 15
0036                             ///< part 10, RegExp (Regular Expression) Objects (FWD.1).
0037                             ///<
0038     icase       = 1 << 1,   ///< Specifies that matching of regular expressions against a character
0039                             ///< container sequence shall be performed without regard to case.
0040                             ///<
0041     nosubs      = 1 << 2,   ///< Specifies that when a regular expression is matched against a
0042                             ///< character container sequence, then no sub-expression matches are to
0043                             ///< be stored in the supplied match_results structure.
0044                             ///<
0045     optimize    = 1 << 3,   ///< Specifies that the regular expression engine should pay more
0046                             ///< attention to the speed with which regular expressions are matched,
0047                             ///< and less to the speed with which regular expression objects are
0048                             ///< constructed. Otherwise it has no detectable effect on the program
0049                             ///< output.
0050                             ///<
0051     collate     = 1 << 4,   ///< Specifies that character ranges of the form "[a-b]" should be
0052                             ///< locale sensitive.
0053                             ///<
0054 
0055     // These flags are optional. If the functionality is supported
0056     // then the flags shall take these names.
0057 
0058     //basic       = 1 << 5,   ///< Specifies that the grammar recognized by the regular expression
0059     //                        ///< engine is the same as that used by POSIX basic regular expressions
0060     //                        ///< in IEEE Std 1003.1-2001, Portable Operating System Interface
0061     //                        ///< (POSIX), Base Definitions and Headers, Section 9, Regular
0062     //                        ///< Expressions (FWD.1).
0063     //                        ///<
0064     //extended    = 1 << 6,   ///< Specifies that the grammar recognized by the regular expression
0065     //                        ///< engine is the same as that used by POSIX extended regular
0066     //                        ///< expressions in IEEE Std 1003.1-2001, Portable Operating System
0067     //                        ///< Interface (POSIX), Base Definitions and Headers, Section 9,
0068     //                        ///< Regular Expressions (FWD.1).
0069     //                        ///<
0070     //awk         = 1 << 7,   ///< Specifies that the grammar recognized by the regular expression
0071     //                        ///< engine is the same as that used by POSIX utility awk in IEEE Std
0072     //                        ///< 1003.1-2001, Portable Operating System Interface (POSIX), Shells
0073     //                        ///< and Utilities, Section 4, awk (FWD.1).
0074     //                        ///<
0075     //grep        = 1 << 8,   ///< Specifies that the grammar recognized by the regular expression
0076     //                        ///< engine is the same as that used by POSIX utility grep in IEEE Std
0077     //                        ///< 1003.1-2001, Portable Operating System Interface (POSIX),
0078     //                        ///< Shells and Utilities, Section 4, Utilities, grep (FWD.1).
0079     //                        ///<
0080     //egrep       = 1 << 9,   ///< Specifies that the grammar recognized by the regular expression
0081     //                        ///< engine is the same as that used by POSIX utility grep when given
0082     //                        ///< the -E option in IEEE Std 1003.1-2001, Portable Operating System
0083     //                        ///< Interface (POSIX), Shells and Utilities, Section 4, Utilities,
0084     //                        ///< grep (FWD.1).
0085     //                        ///<
0086 
0087     // these flags are specific to xpressive, and they help with perl compliance.
0088 
0089     single_line         = 1 << 10,  ///< Specifies that the ^ and \$ metacharacters DO NOT match at
0090                                     ///< internal line breaks. Note that this is the opposite of the
0091                                     ///< perl default. It is the inverse of perl's /m (multi-line)
0092                                     ///< modifier.
0093                                     ///<
0094     not_dot_null        = 1 << 11,  ///< Specifies that the . metacharacter does not match the null
0095                                     ///< character \\0.
0096                                     ///<
0097     not_dot_newline     = 1 << 12,  ///< Specifies that the . metacharacter does not match the
0098                                     ///< newline character \\n.
0099                                     ///<
0100     ignore_white_space  = 1 << 13   ///< Specifies that non-escaped white-space is not significant.
0101                                     ///<
0102 };
0103 
0104 /// Flags used to customize the behavior of the regex algorithms
0105 ///
0106 enum match_flag_type
0107 {
0108     match_default           = 0,        ///< Specifies that matching of regular expressions proceeds
0109                                         ///< without any modification of the normal rules used in
0110                                         ///< ECMA-262, ECMAScript Language Specification, Chapter 15
0111                                         ///< part 10, RegExp (Regular Expression) Objects (FWD.1)
0112                                         ///<
0113     match_not_bol           = 1 << 1,   ///< Specifies that the expression "^" should not be matched
0114                                         ///< against the sub-sequence [first,first).
0115                                         ///<
0116     match_not_eol           = 1 << 2,   ///< Specifies that the expression "\$" should not be
0117                                         ///< matched against the sub-sequence [last,last).
0118                                         ///<
0119     match_not_bow           = 1 << 3,   ///< Specifies that the expression "\\b" should not be
0120                                         ///< matched against the sub-sequence [first,first).
0121                                         ///<
0122     match_not_eow           = 1 << 4,   ///< Specifies that the expression "\\b" should not be
0123                                         ///< matched against the sub-sequence [last,last).
0124                                         ///<
0125     match_any               = 1 << 7,   ///< Specifies that if more than one match is possible then
0126                                         ///< any match is an acceptable result.
0127                                         ///<
0128     match_not_null          = 1 << 8,   ///< Specifies that the expression can not be matched
0129                                         ///< against an empty sequence.
0130                                         ///<
0131     match_continuous        = 1 << 10,  ///< Specifies that the expression must match a sub-sequence
0132                                         ///< that begins at first.
0133                                         ///<
0134     match_partial           = 1 << 11,  ///< Specifies that if no match can be found, then it is
0135                                         ///< acceptable to return a match [from, last) where
0136                                         ///< from != last, if there exists some sequence of characters
0137                                         ///< [from,to) of which [from,last) is a prefix, and which
0138                                         ///< would result in a full match.
0139                                         ///<
0140     match_prev_avail        = 1 << 12,  ///< Specifies that --first is a valid iterator position,
0141                                         ///< when this flag is set then the flags match_not_bol
0142                                         ///< and match_not_bow are ignored by the regular expression
0143                                         ///< algorithms (RE.7) and iterators (RE.8).
0144                                         ///<
0145     format_default          = 0,        ///< Specifies that when a regular expression match is to be
0146                                         ///< replaced by a new string, that the new string is
0147                                         ///< constructed using the rules used by the ECMAScript
0148                                         ///< replace function in ECMA-262, ECMAScript Language
0149                                         ///< Specification, Chapter 15 part 5.4.11
0150                                         ///< String.prototype.replace. (FWD.1). In addition during
0151                                         ///< search and replace operations then all non-overlapping
0152                                         ///< occurrences of the regular expression are located and
0153                                         ///< replaced, and sections of the input that did not match
0154                                         ///< the expression, are copied unchanged to the output
0155                                         ///< string.
0156                                         ///<
0157     format_sed              = 1 << 13,  ///< Specifies that when a regular expression match is to be
0158                                         ///< replaced by a new string, that the new string is
0159                                         ///< constructed using the rules used by the Unix sed
0160                                         ///< utility in IEEE Std 1003.1-2001, Portable Operating
0161                                         ///< SystemInterface (POSIX), Shells and Utilities.
0162                                         ///<
0163     format_perl             = 1 << 14,  ///< Specifies that when a regular expression match is to be
0164                                         ///< replaced by a new string, that the new string is
0165                                         ///< constructed using an implementation defined superset
0166                                         ///< of the rules used by the ECMAScript replace function in
0167                                         ///< ECMA-262, ECMAScript Language Specification, Chapter 15
0168                                         ///< part 5.4.11 String.prototype.replace (FWD.1).
0169                                         ///<
0170     format_no_copy          = 1 << 15,  ///< When specified during a search and replace operation,
0171                                         ///< then sections of the character container sequence being
0172                                         ///< searched that do match the regular expression, are not
0173                                         ///< copied to the output string.
0174                                         ///<
0175     format_first_only       = 1 << 16,  ///< When specified during a search and replace operation,
0176                                         ///< then only the first occurrence of the regular
0177                                         ///< expression is replaced.
0178                                         ///<
0179     format_literal          = 1 << 17,  ///< Treat the format string as a literal.
0180                                         ///<
0181     format_all              = 1 << 18   ///< Specifies that all syntax extensions are enabled,
0182                                         ///< including conditional (?ddexpression1:expression2)
0183                                         ///< replacements.
0184                                         ///<
0185 };
0186 
0187 /// Error codes used by the regex_error type
0188 ///
0189 enum error_type
0190 {
0191     error_collate,              ///< The expression contained an invalid collating element name.
0192                                 ///<
0193     error_ctype,                ///< The expression contained an invalid character class name.
0194                                 ///<
0195     error_escape,               ///< The expression contained an invalid escaped character,
0196                                 ///< or a trailing escape.
0197                                 ///<
0198     error_subreg,               ///< The expression contained an invalid back-reference.
0199                                 ///<
0200     error_brack,                ///< The expression contained mismatched [ and ].
0201                                 ///<
0202     error_paren,                ///< The expression contained mismatched ( and ).
0203                                 ///<
0204     error_brace,                ///< The expression contained mismatched { and }.
0205                                 ///<
0206     error_badbrace,             ///< The expression contained an invalid range in a {} expression.
0207                                 ///<
0208     error_range,                ///< The expression contained an invalid character range, for
0209                                 ///< example [b-a].
0210                                 ///<
0211     error_space,                ///< There was insufficient memory to convert the expression into a
0212                                 ///< finite state machine.
0213                                 ///<
0214     error_badrepeat,            ///< One of *?+{ was not preceded by a valid regular expression.
0215                                 ///<
0216     error_complexity,           ///< The complexity of an attempted match against a regular
0217                                 ///< expression exceeded a pre-set level.
0218                                 ///<
0219     error_stack,                ///< There was insufficient memory to determine whether the regular
0220                                 ///< expression could match the specified character sequence.
0221                                 ///<
0222     error_badref,               ///< An nested regex is uninitialized.
0223                                 ///<
0224     error_badmark,              ///< An invalid use of a named capture.
0225                                 ///<
0226     error_badlookbehind,        ///< An attempt to create a variable-width look-behind assertion
0227                                 ///< was detected.
0228                                 ///<
0229     error_badrule,              ///< An invalid use of a rule was detected.
0230                                 ///<
0231     error_badarg,               ///< An argument to an action was unbound.
0232                                 ///<
0233     error_badattr,              ///< Tried to read from an uninitialized attribute.
0234                                 ///<
0235     error_internal              ///< An internal error has occurred.
0236                                 ///<
0237 };
0238 
0239 /// INTERNAL ONLY
0240 inline syntax_option_type operator &(syntax_option_type b1, syntax_option_type b2)
0241 {
0242     return static_cast<syntax_option_type>(
0243         static_cast<int>(b1) & static_cast<int>(b2));
0244 }
0245 
0246 /// INTERNAL ONLY
0247 inline syntax_option_type operator |(syntax_option_type b1, syntax_option_type b2)
0248 {
0249     return static_cast<syntax_option_type>(static_cast<int>(b1) | static_cast<int>(b2));
0250 }
0251 
0252 /// INTERNAL ONLY
0253 inline syntax_option_type operator ^(syntax_option_type b1, syntax_option_type b2)
0254 {
0255     return static_cast<syntax_option_type>(static_cast<int>(b1) ^ static_cast<int>(b2));
0256 }
0257 
0258 /// INTERNAL ONLY
0259 inline syntax_option_type operator ~(syntax_option_type b)
0260 {
0261     return static_cast<syntax_option_type>(~static_cast<int>(b));
0262 }
0263 
0264 /// INTERNAL ONLY
0265 inline match_flag_type operator &(match_flag_type b1, match_flag_type b2)
0266 {
0267     return static_cast<match_flag_type>(static_cast<int>(b1) & static_cast<int>(b2));
0268 }
0269 
0270 /// INTERNAL ONLY
0271 inline match_flag_type operator |(match_flag_type b1, match_flag_type b2)
0272 {
0273     return static_cast<match_flag_type>(static_cast<int>(b1) | static_cast<int>(b2));
0274 }
0275 
0276 /// INTERNAL ONLY
0277 inline match_flag_type operator ^(match_flag_type b1, match_flag_type b2)
0278 {
0279     return static_cast<match_flag_type>(static_cast<int>(b1) ^ static_cast<int>(b2));
0280 }
0281 
0282 /// INTERNAL ONLY
0283 inline match_flag_type operator ~(match_flag_type b)
0284 {
0285     return static_cast<match_flag_type>(~static_cast<int>(b));
0286 }
0287 
0288 }}} // namespace boost::xpressive::regex_constants
0289 
0290 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
0291 # undef icase
0292 #endif
0293 
0294 #endif