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

country_file.cpp « platform - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f013ba92b853a48e84e1f4a0b02d514e64da8505 (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
#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;
    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(TMwmSize mapSize, TMwmSize routingSize)
{
  m_mapSize = mapSize;
  m_routingSize = routingSize;
}

TMwmSize 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)
{
  return version::IsSingleMwm(version) ? GetNameWithExt(countryFile, MapOptions::Map)
                                       : GetNameWithExt(countryFile, opt);
}

string DebugPrint(CountryFile const & file)
{
  ostringstream os;
  os << "CountryFile [" << file.m_name << "]";
  return os.str();
}
}  // namespace platform