Files
comaps/generator/search_index_builder.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

48 lines
1.4 KiB
C++

#pragma once
#include "generator/generate_info.hpp"
#include "indexer/ftypes_matcher.hpp"
#include <string>
#include <vector>
#include <unordered_map>
namespace indexer
{
class SynonymsHolder
{
public:
// Default ctor is reading data/synonyms.txt file.
SynonymsHolder();
explicit SynonymsHolder(std::string const & fPath);
template <class ToDo>
void ForEach(std::string const & key, ToDo && toDo) const
{
auto it = m_map.find(key);
if (it != m_map.end())
{
for (auto const & v : it->second)
toDo(v);
}
}
template <class Types> static bool CanApply(Types const & types)
{
auto const type = ftypes::IsLocalityChecker::Instance().GetType(types);
return (type == ftypes::LocalityType::Country || type == ftypes::LocalityType::State);
}
private:
std::unordered_map<std::string, std::vector<std::string>> m_map;
};
// Builds the latest version of the search index section and writes it to the mwm file.
// An attempt to rewrite the search index of an old mwm may result in a future crash
// when using search because this function does not update mwm's version. This results
// in version mismatch when trying to read the index.
bool BuildSearchIndexFromDataFile(std::string const & country, feature::GenerateInfo const & info,
bool forceRebuild, uint32_t threadsCount);
} // namespace indexer