Lines Matching defs:RE2
1 // Copyright 2003-2009 The RE2 Authors. All Rights Reserved.
5 // Regular expression interface RE2.
10 #include "re2/re2.h"
24 #include "re2/prog.h"
25 #include "re2/regexp.h"
27 DEFINE_bool(trace_re2, false, "trace RE2 execution");
29 namespace re2 {
35 const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch = {};
36 const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch = {};
37 const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume = {};
38 const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume = {};
42 RE2::Options::Options()
57 RE2::Options::Options(RE2::CannedOptions opt)
58 : encoding_(opt == RE2::Latin1 ? EncodingLatin1 : EncodingUTF8),
59 posix_syntax_(opt == RE2::POSIX_SYNTAX),
60 longest_match_(opt == RE2::POSIX_SYNTAX),
61 log_errors_(opt != RE2::Quiet),
89 // Converts from Regexp error code to RE2 error code.
91 // hides the existence of Regexp from RE2 users.
92 static RE2::ErrorCode RegexpErrorToRE2(re2::RegexpStatusCode code) {
94 case re2::kRegexpSuccess:
95 return RE2::NoError;
96 case re2::kRegexpInternalError:
97 return RE2::ErrorInternal;
98 case re2::kRegexpBadEscape:
99 return RE2::ErrorBadEscape;
100 case re2::kRegexpBadCharClass:
101 return RE2::ErrorBadCharClass;
102 case re2::kRegexpBadCharRange:
103 return RE2::ErrorBadCharRange;
104 case re2::kRegexpMissingBracket:
105 return RE2::ErrorMissingBracket;
106 case re2::kRegexpMissingParen:
107 return RE2::ErrorMissingParen;
108 case re2::kRegexpTrailingBackslash:
109 return RE2::ErrorTrailingBackslash;
110 case re2::kRegexpRepeatArgument:
111 return RE2::ErrorRepeatArgument;
112 case re2::kRegexpRepeatSize:
113 return RE2::ErrorRepeatSize;
114 case re2::kRegexpRepeatOp:
115 return RE2::ErrorRepeatOp;
116 case re2::kRegexpBadPerlOp:
117 return RE2::ErrorBadPerlOp;
118 case re2::kRegexpBadUTF8:
119 return RE2::ErrorBadUTF8;
120 case re2::kRegexpBadNamedCapture:
121 return RE2::ErrorBadNamedCapture;
123 return RE2::ErrorInternal;
133 RE2::RE2(const char* pattern) {
137 RE2::RE2(const string& pattern) {
141 RE2::RE2(const StringPiece& pattern) {
145 RE2::RE2(const StringPiece& pattern, const Options& options) {
149 int RE2::Options::ParseFlags() const {
156 case RE2::Options::EncodingUTF8:
158 case RE2::Options::EncodingLatin1:
190 void RE2::Init(const StringPiece& pattern, const Options& options) {
224 re2::Regexp* suffix;
238 error_code_ = RE2::ErrorPatternTooLarge;
251 re2::Prog* RE2::ReverseProg() const {
259 error_code_ = RE2::ErrorPatternTooLarge;
266 RE2::~RE2() {
282 int RE2::ProgramSize() const {
289 const map<string, int>& RE2::NamedCapturingGroups() const {
302 const map<int, string>& RE2::CapturingGroupNames() const {
316 bool RE2::FullMatchN(const StringPiece& text, const RE2& re,
321 bool RE2::PartialMatchN(const StringPiece& text, const RE2& re,
326 bool RE2::ConsumeN(StringPiece* input, const RE2& re,
337 bool RE2::FindAndConsumeN(StringPiece* input, const RE2& re,
350 int RE2::MaxSubmatch(const StringPiece& rewrite) {
367 bool RE2::Replace(string *str,
368 const RE2& re,
387 int RE2::GlobalReplace(string *str,
388 const RE2& re,
427 bool RE2::Extract(const StringPiece &text,
428 const RE2& re,
443 string RE2::QuoteMeta(const StringPiece& unquoted) {
466 // Note that this special handling is not strictly required for RE2,
481 bool RE2::PossibleMatchRange(string* min, string* max, int maxlen) const {
543 bool RE2::Match(const StringPiece& text,
551 LOG(ERROR) << "Invalid RE2: " << *error_;
557 LOG(ERROR) << "RE2: invalid startpos, endpos pair.";
801 bool RE2::DoMatch(const StringPiece& text,
808 LOG(ERROR) << "Invalid RE2: " << *error_;
870 bool RE2::Rewrite(string *out, const StringPiece &rewrite,
906 int RE2::NumberOfCapturingGroups() const {
918 bool RE2::CheckRewriteString(const StringPiece& rewrite, string* error) const {
956 bool RE2::Arg::parse_null(const char* str, int n, void* dest) {
961 bool RE2::Arg::parse_string(const char* str, int n, void* dest) {
967 bool RE2::Arg::parse_stringpiece(const char* str, int n, void* dest) {
973 bool RE2::Arg::parse_char(const char* str, int n, void* dest) {
980 bool RE2::Arg::parse_uchar(const char* str, int n, void* dest) {
1040 bool RE2::Arg::parse_long_radix(const char* str,
1057 bool RE2::Arg::parse_ulong_radix(const char* str,
1080 bool RE2::Arg::parse_short_radix(const char* str,
1092 bool RE2::Arg::parse_ushort_radix(const char* str,
1104 RE2::Arg::parse_int_radix(const char* str,
1116 bool RE2::Arg::parse_uint_radix(const char* str,
1128 bool RE2::Arg::parse_longlong_radix(const char* str,
1145 bool RE2::Arg::parse_ulonglong_radix(const char* str,
1193 bool RE2::Arg::parse_double(const char* str, int n, void* dest) {
1197 bool RE2::Arg::parse_float(const char* str, int n, void* dest) {
1203 bool RE2::Arg::parse_##name(const char* str, int n, void* dest) { \
1206 bool RE2::Arg::parse_##name##_hex(const char* str, int n, void* dest) { \
1209 bool RE2::Arg::parse_##name##_octal(const char* str, int n, void* dest) { \
1212 bool RE2::Arg::parse_##name##_cradix(const char* str, int n, void* dest) { \
1227 } // namespace re2