@@ -86,36 +86,24 @@ class UniversalStringMatcher : public StringMatcher {
86
86
bool match (absl::string_view) const override { return true ; }
87
87
};
88
88
89
- StringMatcherPtr getExtensionStringMatcher (const ::xds::core::v3::TypedExtensionConfig& config,
90
- ThreadLocal::SlotAllocator& tls, Api::Api& api);
89
+ StringMatcherPtr getExtensionStringMatcher (const ::xds::core::v3::TypedExtensionConfig& config);
91
90
92
91
template <class StringMatcherType = envoy::type::matcher::v3::StringMatcher>
93
- class PrivateStringMatcherImpl : public ValueMatcher , public StringMatcher {
92
+ class StringMatcherImpl : public ValueMatcher , public StringMatcher {
94
93
public:
95
- // TODO(ggreenway): convert all but the first parameter into
96
- // `Server::Configuration::CommonFactoryContext`.
97
- explicit PrivateStringMatcherImpl (const StringMatcherType& matcher, Regex::Engine* regex_engine,
98
- ThreadLocal::SlotAllocator* tls, Api::Api* api)
99
- : matcher_(matcher) {
94
+ explicit StringMatcherImpl (const StringMatcherType& matcher) : matcher_(matcher) {
100
95
if (matcher.match_pattern_case () == StringMatcherType::MatchPatternCase::kSafeRegex ) {
101
96
if (matcher.ignore_case ()) {
102
97
ExceptionUtil::throwEnvoyException (" ignore_case has no effect for safe_regex." );
103
98
}
104
- if (regex_engine != nullptr ) {
105
- regex_ = Regex::Utility::parseRegex (matcher_.safe_regex (), *regex_engine);
106
- } else {
107
- // TODO(ggreenway): remove this branch when we always have an engine. This is only
108
- // needed to make tests not complain about dereferencing a null pointer, even though
109
- // the reference isn't actually used.
110
- regex_ = Regex::Utility::parseRegex (matcher_.safe_regex ());
111
- }
99
+ regex_ = Regex::Utility::parseRegex (matcher_.safe_regex ());
112
100
} else if (matcher.match_pattern_case () == StringMatcherType::MatchPatternCase::kContains ) {
113
101
if (matcher_.ignore_case ()) {
114
102
// Cache the lowercase conversion of the Contains matcher for future use
115
103
lowercase_contains_match_ = absl::AsciiStrToLower (matcher_.contains ());
116
104
}
117
105
} else {
118
- initialize (matcher, tls, api );
106
+ initialize (matcher);
119
107
}
120
108
}
121
109
@@ -155,13 +143,11 @@ class PrivateStringMatcherImpl : public ValueMatcher, public StringMatcher {
155
143
// overloading to only handle that case for type `envoy::type::matcher::v3::StringMatcher` to
156
144
// prevent compilation errors on use of `kCustom`.
157
145
158
- void initialize (const xds::type::matcher::v3::StringMatcher&, ThreadLocal::SlotAllocator*,
159
- Api::Api*) {}
146
+ void initialize (const xds::type::matcher::v3::StringMatcher&) {}
160
147
161
- void initialize (const envoy::type::matcher::v3::StringMatcher& matcher,
162
- ThreadLocal::SlotAllocator* tls, Api::Api* api) {
148
+ void initialize (const envoy::type::matcher::v3::StringMatcher& matcher) {
163
149
if (matcher.has_custom ()) {
164
- custom_ = getExtensionStringMatcher (matcher.custom (), *tls, *api );
150
+ custom_ = getExtensionStringMatcher (matcher.custom ());
165
151
}
166
152
}
167
153
@@ -207,34 +193,9 @@ class PrivateStringMatcherImpl : public ValueMatcher, public StringMatcher {
207
193
StringMatcherPtr custom_;
208
194
};
209
195
210
- // Temporarily create two separate types with different constructors, inheriting from the same
211
- // implementation, to make it easier to find and replace all usage of the old one.
212
- // TODO(ggreenway): delete these two extra classes, make `PrivateStringMatcherImpl` back into
213
- // `StringMatcherImpl`.
214
- template <class StringMatcherType = envoy::type::matcher::v3::StringMatcher>
215
- class StringMatcherImplWithContext : public PrivateStringMatcherImpl <StringMatcherType> {
216
- public:
217
- explicit StringMatcherImplWithContext (const StringMatcherType& matcher,
218
- Server::Configuration::CommonFactoryContext& context)
219
- : PrivateStringMatcherImpl<StringMatcherType>(matcher, &context.regexEngine(),
220
- &context.threadLocal(), &context.api()) {}
221
- };
222
-
223
- template <class StringMatcherType = envoy::type::matcher::v3::StringMatcher>
224
- class StringMatcherImpl : public PrivateStringMatcherImpl <StringMatcherType> {
225
- public:
226
- explicit StringMatcherImpl (const StringMatcherType& matcher)
227
- : PrivateStringMatcherImpl<StringMatcherType>(
228
- matcher, Regex::EngineSingleton::getExisting(),
229
- InjectableSingleton<ThreadLocal::SlotAllocator>::getExisting(),
230
- InjectableSingleton<Api::Api>::getExisting()) {}
231
- };
232
-
233
196
class StringMatcherExtensionFactory : public Config ::TypedFactory {
234
197
public:
235
- // TODO(ggreenway): Convert all but first parameter to `CommonFactoryContext`.
236
- virtual StringMatcherPtr createStringMatcher (const ProtobufWkt::Any& config,
237
- ThreadLocal::SlotAllocator& tls, Api::Api& api) PURE;
198
+ virtual StringMatcherPtr createStringMatcher (const ProtobufWkt::Any& config) PURE;
238
199
239
200
std::string category () const override { return " envoy.string_matcher" ; }
240
201
};
0 commit comments