grpc
third_party
re2
re2
re2/re2/set.h
Go to the documentation of this file.
1
// Copyright 2010 The RE2 Authors. All Rights Reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
5
#ifndef RE2_SET_H_
6
#define RE2_SET_H_
7
8
#include <memory>
9
#include <string>
10
#include <utility>
11
#include <vector>
12
13
#include "re2/re2.h"
14
15
namespace
re2
{
16
class
Prog;
17
class
Regexp;
18
}
// namespace re2
19
20
namespace
re2
{
21
22
// An RE2::Set represents a collection of regexps that can
23
// be searched for simultaneously.
24
class
RE2::Set {
25
public
:
26
enum
ErrorKind
{
27
kNoError
= 0,
28
kNotCompiled
,
// The set is not compiled.
29
kOutOfMemory
,
// The DFA ran out of memory.
30
kInconsistent
,
// The result is inconsistent. This should never happen.
31
};
32
33
struct
ErrorInfo {
34
ErrorKind
kind
;
35
};
36
37
Set
(
const
RE2::Options
&
options
,
RE2::Anchor
anchor);
38
~Set
();
39
40
// Not copyable.
41
Set
(
const
Set
&) =
delete
;
42
Set
&
operator=
(
const
Set
&) =
delete
;
43
// Movable.
44
Set
(
Set
&& other);
45
Set
&
operator=
(
Set
&& other);
46
47
// Adds pattern to the set using the options passed to the constructor.
48
// Returns the index that will identify the regexp in the output of Match(),
49
// or -1 if the regexp cannot be parsed.
50
// Indices are assigned in sequential order starting from 0.
51
// Errors do not increment the index; if error is not NULL, *error will hold
52
// the error message from the parser.
53
int
Add
(
const
StringPiece
&
pattern
,
std::string
*
error
);
54
55
// Compiles the set in preparation for matching.
56
// Returns false if the compiler runs out of memory.
57
// Add() must not be called again after Compile().
58
// Compile() must be called before Match().
59
bool
Compile
();
60
61
// Returns true if text matches at least one of the regexps in the set.
62
// Fills v (if not NULL) with the indices of the matching regexps.
63
// Callers must not expect v to be sorted.
64
bool
Match
(
const
StringPiece
&
text
, std::vector<int>*
v
)
const
;
65
66
// As above, but populates error_info (if not NULL) when none of the regexps
67
// in the set matched. This can inform callers when DFA execution fails, for
68
// example, because they might wish to handle that case differently.
69
bool
Match
(
const
StringPiece
&
text
, std::vector<int>*
v
,
70
ErrorInfo* error_info)
const
;
71
72
private
:
73
typedef
std::pair<std::string, re2::Regexp*>
Elem
;
74
75
RE2::Options
options_
;
76
RE2::Anchor
anchor_
;
77
std::vector<Elem>
elem_
;
78
bool
compiled_
;
79
int
size_
;
80
std::unique_ptr<re2::Prog>
prog_
;
81
};
82
83
}
// namespace re2
84
85
#endif // RE2_SET_H_
re2::RE2::Set::kOutOfMemory
@ kOutOfMemory
Definition:
bloaty/third_party/re2/re2/set.h:28
re2::RE2::Set::kNoError
@ kNoError
Definition:
bloaty/third_party/re2/re2/set.h:26
re2::RE2::Set::Match
bool Match(const StringPiece &text, std::vector< int > *v) const
Definition:
bloaty/third_party/re2/re2/set.cc:105
re2::RE2::Set::size_
int size_
Definition:
bloaty/third_party/re2/re2/set.h:72
re2::RE2::Set::operator=
Set & operator=(const Set &)=delete
testing::internal::string
::std::string string
Definition:
bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
re2::RE2::error
const std::string & error() const
Definition:
bloaty/third_party/re2/re2/re2.h:275
re2::RE2::Set::Elem
std::pair< std::string, re2::Regexp * > Elem
Definition:
re2/re2/set.h:73
re2
Definition:
bloaty/third_party/re2/re2/bitmap256.h:17
re2::RE2::Set::compiled_
bool compiled_
Definition:
bloaty/third_party/re2/re2/set.h:71
re2::RE2::Set::ErrorKind
ErrorKind
Definition:
bloaty/third_party/re2/re2/set.h:25
gen_server_registered_method_bad_client_test_body.text
def text
Definition:
gen_server_registered_method_bad_client_test_body.py:50
re2::RE2::Set::prog_
std::unique_ptr< re2::Prog > prog_
Definition:
re2/re2/set.h:80
re2::RE2::options
const Options & options() const
Definition:
bloaty/third_party/re2/re2/re2.h:699
setup.v
v
Definition:
third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
re2::RE2::Set::Set
Set(const RE2::Options &options, RE2::Anchor anchor)
Definition:
bloaty/third_party/re2/re2/set.cc:21
re2::RE2::Set::kInconsistent
@ kInconsistent
Definition:
bloaty/third_party/re2/re2/set.h:29
re2::RE2::Set::options_
RE2::Options options_
Definition:
bloaty/third_party/re2/re2/set.h:67
re2::RE2::Set::anchor_
RE2::Anchor anchor_
Definition:
bloaty/third_party/re2/re2/set.h:68
re2::RE2::Options
Definition:
bloaty/third_party/re2/re2/re2.h:548
re2::RE2::Set::Compile
bool Compile()
Definition:
bloaty/third_party/re2/re2/set.cc:75
re2::RE2::Set::~Set
~Set()
Definition:
bloaty/third_party/re2/re2/set.cc:30
re2::RE2::pattern
const std::string & pattern() const
Definition:
bloaty/third_party/re2/re2/re2.h:271
re2::RE2::Set::elem_
std::vector< Elem > elem_
Definition:
bloaty/third_party/re2/re2/set.h:69
re2::RE2::Set::Add
int Add(const StringPiece &pattern, std::string *error)
Definition:
bloaty/third_party/re2/re2/set.cc:36
re2::RE2::Anchor
Anchor
Definition:
bloaty/third_party/re2/re2/re2.h:472
re2::RE2::Set::ErrorInfo::kind
ErrorKind kind
Definition:
bloaty/third_party/re2/re2/set.h:33
re2::StringPiece
Definition:
bloaty/third_party/re2/re2/stringpiece.h:39
re2::RE2::Set::kNotCompiled
@ kNotCompiled
Definition:
bloaty/third_party/re2/re2/set.h:27
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:12