MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / IsMatch

Method IsMatch

base/attribute.h:243–262  ·  view source on GitHub ↗

Matches the pattern to an attribute. Distinguishes between no-match, partial match and full match cases.

Source from the content-addressed store, hash-verified

241 // Matches the pattern to an attribute.
242 // Distinguishes between no-match, partial match and full match cases.
243 MatchType IsMatch(const Attribute& attribute) const {
244 MatchType result = MatchType::NONE;
245 if (attribute.variable_name() != variable_) {
246 return result;
247 }
248
249 auto max_index = qualifier_path().size();
250 result = MatchType::FULL;
251 if (qualifier_path().size() > attribute.qualifier_path().size()) {
252 max_index = attribute.qualifier_path().size();
253 result = MatchType::PARTIAL;
254 }
255
256 for (size_t i = 0; i < max_index; i++) {
257 if (!(qualifier_path()[i].IsMatch(attribute.qualifier_path()[i]))) {
258 return MatchType::NONE;
259 }
260 }
261 return result;
262 }
263
264 private:
265 std::string variable_;

Callers 1

IsMatchMethod · 0.45

Calls 3

variable_nameMethod · 0.80
sizeMethod · 0.45
qualifier_pathMethod · 0.45

Tested by

no test coverage detected