forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes_mapping.cpp
50 lines (39 loc) · 933 Bytes
/
types_mapping.cpp
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
#include "indexer/types_mapping.hpp"
#include "indexer/classificator.hpp"
#include "base/string_utils.hpp"
#include "base/stl_add.hpp"
void IndexAndTypeMapping::Clear()
{
m_types.clear();
m_map.clear();
}
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);
m_map.insert(make_pair(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;
}