MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / Add

Method Add

extern/re2/re2/set.cc:55–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55int RE2::Set::Add(const StringPiece& pattern, std::string* error) {
56 if (compiled_) {
57 LOG(DFATAL) << "RE2::Set::Add() called after compiling";
58 return -1;
59 }
60
61 Regexp::ParseFlags pf = static_cast<Regexp::ParseFlags>(
62 options_.ParseFlags());
63 RegexpStatus status;
64 re2::Regexp* re = Regexp::Parse(pattern, pf, &status);
65 if (re == NULL) {
66 if (error != NULL)
67 *error = status.Text();
68 if (options_.log_errors())
69 LOG(ERROR) << "Error parsing '" << pattern << "': " << status.Text();
70 return -1;
71 }
72
73 // Concatenate with match index and push on vector.
74 int n = static_cast<int>(elem_.size());
75 re2::Regexp* m = re2::Regexp::HaveMatch(n, pf);
76 if (re->op() == kRegexpConcat) {
77 int nsub = re->nsub();
78 PODArray<re2::Regexp*> sub(nsub + 1);
79 for (int i = 0; i < nsub; i++)
80 sub[i] = re->sub()[i]->Incref();
81 sub[nsub] = m;
82 re->Decref();
83 re = re2::Regexp::Concat(sub.data(), nsub + 1, pf);
84 } else {
85 re2::Regexp* sub[2];
86 sub[0] = re;
87 sub[1] = m;
88 re = re2::Regexp::Concat(sub, 2, pf);
89 }
90 elem_.emplace_back(std::string(pattern), re);
91 return n;
92}
93
94bool RE2::Set::Compile() {
95 if (compiled_) {

Callers 5

mainFunction · 0.45
TESTFunction · 0.45
AddRegexpsAndCompileFunction · 0.45
TESTFunction · 0.45
addMethod · 0.45

Calls 12

ParseFunction · 0.85
ParseFlagsMethod · 0.80
TextMethod · 0.80
log_errorsMethod · 0.80
nsubMethod · 0.80
emplace_backMethod · 0.80
sizeMethod · 0.45
opMethod · 0.45
IncrefMethod · 0.45
subMethod · 0.45
DecrefMethod · 0.45
dataMethod · 0.45

Tested by 4

mainFunction · 0.36
TESTFunction · 0.36
AddRegexpsAndCompileFunction · 0.36
TESTFunction · 0.36