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

country.hpp « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd22df70bd897a54f14990fffac6271d71ebef85 (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
71
72
#pragma once

#include "storage/country_decl.hpp"
#include "storage/simple_tree.hpp"
#include "storage/storage_defines.hpp"

#include "platform/local_country_file.hpp"

#include "platform/country_defines.hpp"

#include "defines.hpp"

#include "geometry/rect2d.hpp"

#include "base/buffer_vector.hpp"

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

namespace update
{
class SizeUpdater;
}

namespace storage
{
/// Serves as a proxy between GUI and downloaded files
class Country
{
  friend class update::SizeUpdater;
  /// Name in the country node tree
  string m_name;
  /// Flag to display
  string m_flag;
  /// stores squares with world pieces which are part of the country
  buffer_vector<platform::CountryFile, 1> m_files;

public:
  Country() {}
  Country(string const & name, string const & flag = "") : m_name(name), m_flag(flag) {}

  bool operator<(Country const & other) const { return Name() < other.Name(); }

  void AddFile(platform::CountryFile const & file);

  size_t GetFilesCount() const { return m_files.size(); }

  /// This function valid for current logic - one file for one country (region).
  /// If the logic will be changed, replace GetFile with ForEachFile.
  platform::CountryFile const & GetFile() const
  {
    ASSERT_EQUAL(m_files.size(), 1, (m_name));
    return m_files.front();
  }

  string const & Name() const { return m_name; }
  string const & Flag() const { return m_flag; }

  uint64_t Size(MapOptions opt) const;
};

typedef SimpleTree<Country> CountriesContainerT;

/// @return version of country file or -1 if error was encountered
int64_t LoadCountries(string const & jsonBuffer, CountriesContainerT & countries);

void LoadCountryFile2CountryInfo(string const & jsonBuffer, map<string, CountryInfo> & id2info);

void LoadCountryCode2File(string const & jsonBuffer, multimap<string, string> & code2file);

bool SaveCountries(int64_t version, CountriesContainerT const & countries, string & jsonBuffer);
}  // namespace storage