Go to the documentation of this file.
12 #include "util/util.h"
13 #include "util/logging.h"
17 #include "re2/regexp.h"
18 #include "re2/stringpiece.h"
31 for (
size_t i = 0;
i < elem_.size();
i++)
37 anchor_(other.anchor_),
39 compiled_(other.compiled_),
43 other.elem_.shrink_to_fit();
44 other.compiled_ =
false;
57 LOG(DFATAL) <<
"RE2::Set::Add() called after compiling";
74 int n =
static_cast<int>(elem_.size());
77 int nsub = re->
nsub();
78 PODArray<re2::Regexp*> sub(nsub + 1);
79 for (
int i = 0;
i < nsub;
i++)
96 LOG(DFATAL) <<
"RE2::Set::Compile() called more than once";
100 size_ =
static_cast<int>(elem_.size());
104 std::sort(elem_.begin(), elem_.end(),
105 [](
const Elem& a,
const Elem&
b) ->
bool {
106 return a.first < b.first;
109 PODArray<re2::Regexp*> sub(
size_);
110 for (
int i = 0;
i <
size_;
i++)
113 elem_.shrink_to_fit();
121 return prog_ !=
nullptr;
129 ErrorInfo* error_info)
const {
131 LOG(DFATAL) <<
"RE2::Set::Match() called before compiling";
132 if (error_info != NULL)
133 error_info->kind = kNotCompiled;
136 #ifdef RE2_HAVE_THREAD_LOCAL
139 bool dfa_failed =
false;
140 std::unique_ptr<SparseSet> matches;
146 NULL, &dfa_failed, matches.get());
150 <<
"program size " <<
prog_->
size() <<
", "
153 if (error_info != NULL)
154 error_info->kind = kOutOfMemory;
158 if (error_info != NULL)
159 error_info->kind = kNoError;
163 if (matches->empty()) {
164 LOG(DFATAL) <<
"RE2::Set::Match() matched, but no matches returned?!";
165 if (error_info != NULL)
166 error_info->kind = kInconsistent;
169 v->assign(matches->begin(), matches->end());
171 if (error_info != NULL)
172 error_info->kind = kNoError;
SparseSetT< void > SparseSet
bool Match(const StringPiece &text, std::vector< int > *v) const
Set & operator=(const Set &)=delete
const std::string & error() const
static Regexp * Concat(Regexp **subs, int nsubs, ParseFlags flags)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
const thread_local RE2 * context
Set(const RE2::Options &options, RE2::Anchor anchor)
static Regexp * Parse(const StringPiece &s, ParseFlags flags, RegexpStatus *status)
void set_never_capture(bool b)
static const LogLevel ERROR
bool SearchDFA(const StringPiece &text, const StringPiece &context, Anchor anchor, MatchKind kind, StringPiece *match0, bool *failed, SparseSet *matches)
bool Match(const StringPiece &text, size_t startpos, size_t endpos, Anchor re_anchor, StringPiece *submatch, int nsubmatch) const
DebugStringOptions options_
UniquePtr< SSL_SESSION > ret
const std::string & pattern() const
static Prog * CompileSet(Regexp *re, RE2::Anchor anchor, int64_t max_mem)
static Regexp * HaveMatch(int match_id, ParseFlags flags)
int Add(const StringPiece &pattern, std::string *error)
static Regexp * Alternate(Regexp **subs, int nsubs, ParseFlags flags)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:12