--- code/trunk/pcrecpp.h 2007/07/31 14:39:09 199 +++ code/trunk/pcrecpp.h 2009/03/17 21:30:30 392 @@ -346,16 +346,13 @@ #define PCRE_IS_SET(o) \ (all_options_ & o) == o -// We convert user-passed pointers into special Arg objects -PCRECPP_EXP_DECL Arg no_arg; - /***** Compiling regular expressions: the RE class *****/ // RE_Options allow you to set options to be passed along to pcre, // along with other options we put on top of pcre. // Only 9 modifiers, plus match_limit and match_limit_recursion, // are supported now. -class PCRECPP_EXP_DECL RE_Options { +class PCRECPP_EXP_DEFN RE_Options { public: // constructor RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {} @@ -403,25 +400,25 @@ return PCRE_IS_SET(PCRE_DOTALL); } RE_Options &set_dotall(bool x) { - PCRE_SET_OR_CLEAR(x,PCRE_DOTALL); + PCRE_SET_OR_CLEAR(x, PCRE_DOTALL); } bool extended() const { return PCRE_IS_SET(PCRE_EXTENDED); } RE_Options &set_extended(bool x) { - PCRE_SET_OR_CLEAR(x,PCRE_EXTENDED); + PCRE_SET_OR_CLEAR(x, PCRE_EXTENDED); } bool dollar_endonly() const { return PCRE_IS_SET(PCRE_DOLLAR_ENDONLY); } RE_Options &set_dollar_endonly(bool x) { - PCRE_SET_OR_CLEAR(x,PCRE_DOLLAR_ENDONLY); + PCRE_SET_OR_CLEAR(x, PCRE_DOLLAR_ENDONLY); } bool extra() const { - return PCRE_IS_SET( PCRE_EXTRA); + return PCRE_IS_SET(PCRE_EXTRA); } RE_Options &set_extra(bool x) { PCRE_SET_OR_CLEAR(x, PCRE_EXTRA); @@ -487,14 +484,20 @@ // Interface for regular expression matching. Also corresponds to a // pre-compiled regular expression. An "RE" object is safe for // concurrent use by multiple threads. -class PCRECPP_EXP_DECL RE { +class PCRECPP_EXP_DEFN RE { public: // We provide implicit conversions from strings so that users can // pass in a string or a "const char*" wherever an "RE" is expected. - RE(const char* pat) { Init(pat, NULL); } - RE(const char *pat, const RE_Options& option) { Init(pat, &option); } RE(const string& pat) { Init(pat, NULL); } RE(const string& pat, const RE_Options& option) { Init(pat, &option); } + RE(const char* pat) { Init(pat, NULL); } + RE(const char* pat, const RE_Options& option) { Init(pat, &option); } + RE(const unsigned char* pat) { + Init(reinterpret_cast(pat), NULL); + } + RE(const unsigned char* pat, const RE_Options& option) { + Init(reinterpret_cast(pat), &option); + } // Copy constructor & assignment - note that these are expensive // because they recompile the expression. @@ -617,6 +620,9 @@ // 1.5-2.0? // may become: // 1\.5\-2\.0\? + // Note QuoteMeta behaves the same as perl's QuoteMeta function, + // *except* that it escapes the NUL character (\0) as backslash + 0, + // rather than backslash + NUL. static string QuoteMeta(const StringPiece& unquoted); @@ -640,6 +646,15 @@ // regexp wasn't valid on construction. int NumberOfCapturingGroups() const; + // The default value for an argument, to indicate the end of the argument + // list. This must be used only in optional argument defaults. It should NOT + // be passed explicitly. Some people have tried to use it like this: + // + // FullMatch(x, y, &z, no_arg, &w); + // + // This is a mistake, and will not work. + static Arg no_arg; + private: void Init(const string& pattern, const RE_Options* options);