Lines Matching defs:RE2
1 // Copyright 2003-2009 The RE2 Authors. All Rights Reserved.
5 // Regular expression interface RE2.
10 #include "re2/re2.h"
18 #include "re2/prog.h"
19 #include "re2/regexp.h"
21 DEFINE_bool(trace_re2, false, "trace RE2 execution");
23 namespace re2 {
29 const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::FullMatchN> RE2::FullMatch;
30 const VariadicFunction2<bool, const StringPiece&, const RE2&, RE2::Arg, RE2::PartialMatchN> RE2::PartialMatch;
31 const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::ConsumeN> RE2::Consume;
32 const VariadicFunction2<bool, StringPiece*, const RE2&, RE2::Arg, RE2::FindAndConsumeN> RE2::FindAndConsume;
36 const int RE2::Options::kDefaultMaxMem; // initialized in re2.h
39 RE2::Options::Options(RE2::CannedOptions opt)
40 : encoding_(opt == RE2::Latin1 ? EncodingLatin1 : EncodingUTF8),
41 posix_syntax_(opt == RE2::POSIX),
42 longest_match_(opt == RE2::POSIX),
43 log_errors_(opt != RE2::Quiet),
71 // Converts from Regexp error code to RE2 error code.
73 // hides the existence of Regexp from RE2 users.
74 static RE2::ErrorCode RegexpErrorToRE2(re2::RegexpStatusCode code) {
76 case re2::kRegexpSuccess:
77 return RE2::NoError;
78 case re2::kRegexpInternalError:
79 return RE2::ErrorInternal;
80 case re2::kRegexpBadEscape:
81 return RE2::ErrorBadEscape;
82 case re2::kRegexpBadCharClass:
83 return RE2::ErrorBadCharClass;
84 case re2::kRegexpBadCharRange:
85 return RE2::ErrorBadCharRange;
86 case re2::kRegexpMissingBracket:
87 return RE2::ErrorMissingBracket;
88 case re2::kRegexpMissingParen:
89 return RE2::ErrorMissingParen;
90 case re2::kRegexpTrailingBackslash:
91 return RE2::ErrorTrailingBackslash;
92 case re2::kRegexpRepeatArgument:
93 return RE2::ErrorRepeatArgument;
94 case re2::kRegexpRepeatSize:
95 return RE2::ErrorRepeatSize;
96 case re2::kRegexpRepeatOp:
97 return RE2::ErrorRepeatOp;
98 case re2::kRegexpBadPerlOp:
99 return RE2::ErrorBadPerlOp;
100 case re2::kRegexpBadUTF8:
101 return RE2::ErrorBadUTF8;
102 case re2::kRegexpBadNamedCapture:
103 return RE2::ErrorBadNamedCapture;
105 return RE2::ErrorInternal;
115 RE2::RE2(const char* pattern) {
119 RE2::RE2(const string& pattern) {
123 RE2::RE2(const StringPiece& pattern) {
127 RE2::RE2(const StringPiece& pattern, const Options& options) {
131 int RE2::Options::ParseFlags() const {
138 case RE2::Options::EncodingUTF8:
140 case RE2::Options::EncodingLatin1:
172 void RE2::Init(const StringPiece& pattern, const Options& options) {
206 re2::Regexp* suffix;
220 error_code_ = RE2::ErrorPatternTooLarge;
233 re2::Prog* RE2::ReverseProg() const {
241 error_code_ = RE2::ErrorPatternTooLarge;
248 RE2::~RE2() {
264 int RE2::ProgramSize() const {
271 const map<string, int>& RE2::NamedCapturingGroups() const {
284 const map<int, string>& RE2::CapturingGroupNames() const {
298 bool RE2::FullMatchN(const StringPiece& text, const RE2& re,
303 bool RE2::PartialMatchN(const StringPiece& text, const RE2& re,
308 bool RE2::ConsumeN(StringPiece* input, const RE2& re,
319 bool RE2::FindAndConsumeN(StringPiece* input, const RE2& re,
332 int RE2::MaxSubmatch(const StringPiece& rewrite) {
349 bool RE2::Replace(string *str,
350 const RE2& re,
369 int RE2::GlobalReplace(string *str,
370 const RE2& re,
409 bool RE2::Extract(const StringPiece &text,
410 const RE2& re,
425 string RE2::QuoteMeta(const StringPiece& unquoted) {
448 // Note that this special handling is not strictly required for RE2,
463 bool RE2::PossibleMatchRange(string* min, string* max, int maxlen) const {
525 bool RE2::Match(const StringPiece& text,
533 LOG(ERROR) << "Invalid RE2: " << *error_;
539 LOG(ERROR) << "RE2: invalid startpos, endpos pair.";
783 bool RE2::DoMatch(const StringPiece& text,
790 LOG(ERROR) << "Invalid RE2: " << *error_;
852 bool RE2::Rewrite(string *out, const StringPiece &rewrite,
888 int RE2::NumberOfCapturingGroups() const {
900 bool RE2::CheckRewriteString(const StringPiece& rewrite, string* error) const {
938 bool RE2::Arg::parse_null(const char* str, int n, void* dest) {
943 bool RE2::Arg::parse_string(const char* str, int n, void* dest) {
949 bool RE2::Arg::parse_stringpiece(const char* str, int n, void* dest) {
955 bool RE2::Arg::parse_char(const char* str, int n, void* dest) {
962 bool RE2::Arg::parse_uchar(const char* str, int n, void* dest) {
1022 bool RE2::Arg::parse_long_radix(const char* str,
1039 bool RE2::Arg::parse_ulong_radix(const char* str,
1062 bool RE2::Arg::parse_short_radix(const char* str,
1074 bool RE2::Arg::parse_ushort_radix(const char* str,
1086 bool RE2::Arg::parse_int_radix(const char* str,
1098 bool RE2::Arg::parse_uint_radix(const char* str,
1110 bool RE2::Arg::parse_longlong_radix(const char* str,
1127 bool RE2::Arg::parse_ulonglong_radix(const char* str,
1175 bool RE2::Arg::parse_double(const char* str, int n, void* dest) {
1179 bool RE2::Arg::parse_float(const char* str, int n, void* dest) {
1185 bool RE2::Arg::parse_##name(const char* str, int n, void* dest) { \
1188 bool RE2::Arg::parse_##name##_hex(const char* str, int n, void* dest) { \
1191 bool RE2::Arg::parse_##name##_octal(const char* str, int n, void* dest) { \
1194 bool RE2::Arg::parse_##name##_cradix(const char* str, int n, void* dest) { \
1209 } // namespace re2