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

categories_holder.hpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d25d9b0f5ee18f90ba4491de0945280403d2a949 (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
#pragma once
#include "../base/base.hpp"

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

namespace search
{

struct Category
{
  /// Classificator types
  vector<uint32_t> m_types;

  struct Name
  {
    string m_name;
    int8_t m_lang;
    uint8_t m_prefixLengthToSuggest;
  };

  /// <language, synonym>
  vector<Name> m_synonyms;
};

class CategoriesHolder
{
  typedef vector<Category> ContainerT;
  ContainerT m_categories;

public:
  typedef ContainerT::const_iterator const_iterator;

  /// @return number of loaded categories or 0 if something goes wrong
  size_t LoadFromStream(istream & stream);

  template <class ToDo>
  void ForEachCategory(ToDo toDo) const
  {
    for_each(m_categories.begin(), m_categories.end(), toDo);
  }

  const_iterator begin() const { return m_categories.begin(); }
  const_iterator end() const { return m_categories.end(); }

  void swap(CategoriesHolder & o);
};

inline void swap(CategoriesHolder & a, CategoriesHolder & b)
{
  return a.swap(b);
}

}