Matches the pattern to an attribute. Distinguishes between no-match, partial match and full match cases.
| 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_; |
no test coverage detected