blob: d50e2d0de62e2227dc972864c950638eba95debc (
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
62
63
64
65
66
67
68
69
70
|
#include "platform/country_file.hpp"
#include "platform/mwm_version.hpp"
#include "defines.hpp"
#include "base/assert.hpp"
#include "std/sstream.hpp"
namespace
{
/// \returns file name (m_name) with extension dependent on the file param.
/// The extension could be .mwm.routing or just .mwm.
/// The method is used for old (two components) mwm support.
string GetNameWithExt(string const & countryFile, MapOptions file)
{
switch (file)
{
case MapOptions::Map:
return countryFile + DATA_FILE_EXTENSION;
case MapOptions::CarRouting:
return countryFile + DATA_FILE_EXTENSION + ROUTING_FILE_EXTENSION;
case MapOptions::Diff:
return countryFile + DIFF_FILE_EXTENSION;
default:
ASSERT(false, ("Can't get name for:", file));
return string();
}
}
} // namespace
namespace platform
{
CountryFile::CountryFile() : m_mapSize(0), m_routingSize(0) {}
CountryFile::CountryFile(string const & name) : m_name(name), m_mapSize(0), m_routingSize(0) {}
string const & CountryFile::GetName() const { return m_name; }
void CountryFile::SetRemoteSizes(MwmSize mapSize, MwmSize routingSize)
{
m_mapSize = mapSize;
m_routingSize = routingSize;
}
MwmSize CountryFile::GetRemoteSize(MapOptions filesMask) const
{
uint32_t size = 0;
if (HasOptions(filesMask, MapOptions::Map))
size += m_mapSize;
if (HasOptions(filesMask, MapOptions::CarRouting))
size += m_routingSize;
return size;
}
string GetFileName(string const & countryFile, MapOptions opt, int64_t version)
{
if (version::IsSingleMwm(version))
opt = opt == MapOptions::Diff ? MapOptions::Diff : MapOptions::Map;
return GetNameWithExt(countryFile, opt);
}
string DebugPrint(CountryFile const & file)
{
ostringstream os;
os << "CountryFile [" << file.m_name << "]";
return os.str();
}
} // namespace platform
|