* @brief Classifies a subject string by matching against the vector of named multi-patterns * in the order they were added and returns the first matching multi-pattern name. * @param subject string subject being classified. * @param name reference to a string where the name of the class that matched first will be stored. * @return true if something matched, false otherwise. */
| 488 | * @return true if something matched, false otherwise. |
| 489 | */ |
| 490 | bool |
| 491 | Classifier::classify(const String &subject, String &name) const |
| 492 | { |
| 493 | bool matched = false; |
| 494 | for (auto p : _list) { |
| 495 | if (p->empty()) { |
| 496 | continue; |
| 497 | } else if (p->match(subject)) { |
| 498 | name = p->name(); |
| 499 | matched = true; |
| 500 | break; |
| 501 | } |
| 502 | } |
| 503 | return matched; |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * @brief Adds a multi-pattern to the classifier. |
no test coverage detected