bool Filters::CheckItem(Item& item) { // Filter my status for (size_t i = 0; i < my_status.size(); i++) if (!my_status.at(i) && item.GetMyStatus() == i) return false; // Filter airing status for (size_t i = 0; i < status.size(); i++) if (!status.at(i) && item.GetAiringStatus() == i + 1) return false; // Filter type for (size_t i = 0; i < type.size(); i++) if (!type.at(i) && item.GetType() == i + 1) return false; // Filter text vector<wstring> words; Split(text, L" ", words); RemoveEmptyStrings(words); for (auto it = words.begin(); it != words.end(); ++it) { if (InStr(item.GetTitle(), *it, 0, true) == -1 && InStr(item.GetGenres(), *it, 0, true) == -1 && InStr(item.GetMyTags(), *it, 0, true) == -1) { bool found = false; for (auto synonym = item.GetSynonyms().begin(); !found && synonym != item.GetSynonyms().end(); ++synonym) if (InStr(*synonym, *it, 0, true) > -1) found = true; if (item.IsInList()) for (auto synonym = item.GetUserSynonyms().begin(); !found && synonym != item.GetUserSynonyms().end(); ++synonym) if (InStr(*synonym, *it, 0, true) > -1) found = true; if (!found) return false; } } // Item passed all filters return true; }
bool Filters::CheckItem(const Item& item) const { // Filter my status for (size_t i = 0; i < my_status.size(); i++) if (!my_status.at(i) && item.GetMyStatus() == i) return false; // Filter airing status for (size_t i = 0; i < status.size(); i++) if (!status.at(i) && item.GetAiringStatus() == i + 1) return false; // Filter type for (size_t i = 0; i < type.size(); i++) if (!type.at(i) && item.GetType() == i + 1) return false; // Filter text if (!FilterText(item)) return false; // Item passed all filters return true; }