| 110 | } |
| 111 | |
| 112 | NewFeatureCategories::TypeNames NewFeatureCategories::Search(std::string const & query) const |
| 113 | { |
| 114 | if (query.empty()) |
| 115 | return {}; |
| 116 | |
| 117 | std::vector<std::string> tokens; |
| 118 | search::ForEachNormalizedToken(query, [&](strings::UniString const & token) { |
| 119 | tokens.push_back(strings::ToUtf8(token)); |
| 120 | }); |
| 121 | |
| 122 | if (tokens.empty()) |
| 123 | return {}; |
| 124 | |
| 125 | TypeNames result; |
| 126 | |
| 127 | for (auto const & data : m_categoriesData) |
| 128 | { |
| 129 | for (auto const & syn : data.m_synonyms) |
| 130 | { |
| 131 | bool allTokensFound = true; |
| 132 | for (auto const & token : tokens) |
| 133 | { |
| 134 | if (syn.find(token) == std::string::npos) |
| 135 | { |
| 136 | allTokensFound = false; |
| 137 | break; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | if (allTokensFound) |
| 142 | { |
| 143 | result.push_back(data.m_typeName); |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | std::sort(result.begin(), result.end()); |
| 150 | return result; |
| 151 | } |
| 152 | |
| 153 | void NewFeatureCategories::AddToRecentCategories(std::string const & category) |
| 154 | { |