CategoriesInfo ----------------------------------------------------------------------------------
| 19 | |
| 20 | // CategoriesInfo ---------------------------------------------------------------------------------- |
| 21 | CategoriesInfo::CategoriesInfo(feature::TypesHolder const & holder, TokenSlice const & tokens, Locales const & locales, |
| 22 | CategoriesHolder const & categories) |
| 23 | { |
| 24 | struct TokenInfo |
| 25 | { |
| 26 | bool m_isCategoryToken = false; |
| 27 | bool m_inFeatureTypes = false; |
| 28 | }; |
| 29 | |
| 30 | QuerySlice slice(tokens); |
| 31 | vector<TokenInfo> infos(slice.Size()); |
| 32 | |
| 33 | ForEachCategoryType(slice, locales, categories, [&](size_t i, uint32_t t) |
| 34 | { |
| 35 | ASSERT_LESS(i, infos.size(), ()); |
| 36 | auto & info = infos[i]; |
| 37 | |
| 38 | info.m_isCategoryToken = true; |
| 39 | if (holder.HasWithSubclass(t)) |
| 40 | info.m_inFeatureTypes = true; |
| 41 | }); |
| 42 | |
| 43 | for (size_t i = 0; i < slice.Size(); ++i) |
| 44 | if (infos[i].m_inFeatureTypes) |
| 45 | m_matchedLength += slice.Get(i).size(); |
| 46 | |
| 47 | // Note that m_inFeatureTypes implies m_isCategoryToken. |
| 48 | |
| 49 | m_pureCategories = all_of(infos.begin(), infos.end(), [](TokenInfo const & info) |
| 50 | { |
| 51 | ASSERT(!info.m_inFeatureTypes || info.m_isCategoryToken, ()); |
| 52 | return info.m_inFeatureTypes; |
| 53 | }); |
| 54 | |
| 55 | m_falseCategories = all_of(infos.begin(), infos.end(), |
| 56 | [](TokenInfo const & info) { return !info.m_inFeatureTypes && info.m_isCategoryToken; }); |
| 57 | } |
| 58 | |
| 59 | // ErrorsMade -------------------------------------------------------------------------------------- |
| 60 | string DebugPrint(ErrorsMade const & errorsMade) |
nothing calls this directly
no test coverage detected