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

new_feature_categories.hpp « editor - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6151cf0d0aa38640575ccc3a0d560938b311f311 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once

#include "editor/editor_config.hpp"

#include "indexer/categories_holder.hpp"
#include "indexer/categories_index.hpp"

#include "base/macros.hpp"
#include "base/small_set.hpp"

#include <cstdint>
#include <string>
#include <vector>

namespace osm
{
// This class holds an index of categories that can be set for a newly added feature.
class NewFeatureCategories
{
public:
  using TypeName = std::string;
  using TypeNames = std::vector<TypeName>;

  explicit NewFeatureCategories(editor::EditorConfig const & config);

  NewFeatureCategories(NewFeatureCategories && other);

  NewFeatureCategories() = default;

  NewFeatureCategories & operator=(NewFeatureCategories && other) = default;

  // Adds all known synonyms in language |lang| for all categories that
  // can be applied to a newly added feature.
  // If one language is added more than once, all the calls except for the
  // first one are ignored.
  // If |lang| is not supported, "en" is used.
  void AddLanguage(std::string lang);

  // Returns names (in language |queryLang|) and types of categories that have a synonym containing
  // the substring |query| (in any language that was added before).
  // If |lang| is not supported, "en" is used.
  // The returned list is sorted.
  TypeNames Search(std::string const & query) const;

  // Returns all registered names of categories in language |lang| and
  // types corresponding to these names. The language must have been added before.
  // If |lang| is not supported, "en" is used.
  // The returned list is sorted.
  TypeNames const & GetAllCreatableTypeNames() const;

private:
  using Langs =
      base::SmallSet<static_cast<uint64_t>(CategoriesHolder::kMaxSupportedLocaleIndex) + 1>;

  indexer::CategoriesIndex m_index;
  Langs m_addedLangs;
  TypeNames m_types;

  DISALLOW_COPY(NewFeatureCategories);
};
}  // namespace osm