Welcome to mirror list, hosted at ThFree Co, Russian Federation.

displayed_categories.hpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8f3cbd614c07c3d114a112c3c892969d5438fd6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include "indexer/categories_holder.hpp"

#include "std/string.hpp"
#include "std/vector.hpp"

namespace search
{
class DisplayedCategories
{
public:
  DisplayedCategories(CategoriesHolder const & holder);

  // Returns a list of English names of displayed categories for the
  // categories search tab. It's guaranteed that the list remains the
  // same during the application lifetime, keys may be used as parts
  // of resources ids.
  static vector<string> const & GetKeys();

  // Calls |fn| on each pair (synonym name, synonym locale) for the
  // |key|.
  template <typename Fn>
  void ForEachSynonym(string const & key, Fn && fn) const
  {
    auto const & translations = m_holder.GetGroupTranslations();
    auto const it = translations.find("@" + key);
    if (it == translations.end())
      return;

    for (auto const & name : it->second)
      fn(name.m_name, CategoriesHolder::MapIntegerToLocale(name.m_locale));
  }

 private:
  CategoriesHolder const & m_holder;
};
}  // namespace search