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

types_mapping.cpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79a0b40048f8849465602bb0d2bda5207aec6ed9 (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
#include "types_mapping.hpp"
#include "classificator.hpp"

#include "../base/string_utils.hpp"
#include "../base/stl_add.hpp"


void IndexAndTypeMapping::Load(istream & s)
{
  Classificator const & c = classif();

  string v;
  vector<string> path;

  uint32_t ind = 0;
  while (s.good())
  {
    v.clear();
    s >> v;

    if (!v.empty())
    {
      path.clear();
      strings::Tokenize(v, "|", MakeBackInsertFunctor(path));

      Add(ind++, c.GetTypeByPath(path));
    }
  }
}

void IndexAndTypeMapping::Add(uint32_t ind, uint32_t type)
{
  ASSERT_EQUAL ( ind, m_types.size(), () );
  m_types.push_back(type);

  CHECK ( m_map.insert(make_pair(type, ind)).second, (classif().GetFullObjectName(type), ind) );
}

uint32_t IndexAndTypeMapping::GetIndex(uint32_t t) const
{
  MapT::const_iterator i = m_map.find(t);
  CHECK ( i != m_map.end(), (t, classif().GetFullObjectName(t)) );
  return i->second;
}