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

mwm_version.hpp « platform - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f18e0b74d09a15e9af1b4f9fc7a4e1410e5f8dc (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
73
74
#pragma once

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

class FilesContainerR;
class ReaderSrc;
class Writer;
class ModelReaderPtr;

namespace version
{
enum class Format
{
  unknownFormat = -1,
  v1 = 0,  // April 2011
  v2,      // November 2011 (store type index, instead of raw type in mwm)
  v3,      // March 2013 (store type index, instead of raw type in search data)
  v4,      // April 2015 (distinguish и and й in search index)
  v5,      // July 2015 (feature id is the index in vector now).
  v6,      // October 2015 (offsets vector is in mwm now).
  v7,      // November 2015 (supply different search index formats).
  v8,      // February 2016 (long strings in metadata; store seconds since epoch in MwmVersion).
  lastFormat = v8
};

string DebugPrint(Format f);

class MwmVersion
{
public:
  Format GetFormat() const { return m_format; }
  uint64_t GetSecondsSinceEpoch() const { return m_secondsSinceEpoch; }
  /// \return version as YYMMDD.
  uint32_t GetVersion() const;

  void SetFormat(Format format) { m_format = format; }
  void SetSecondsSinceEpoch(uint64_t secondsSinceEpoch) { m_secondsSinceEpoch = secondsSinceEpoch; }

private:
  /// Data layout format in mwm file.
  Format m_format{Format::unknownFormat};
  uint64_t m_secondsSinceEpoch{0};
};

/// Writes latest format and current timestamp to the writer.
void WriteVersion(Writer & w, uint64_t secondsSinceEpoch);

/// Reads mwm version from src.
void ReadVersion(ReaderSrc & src, MwmVersion & version);

/// \return True when version was successfully parsed from container,
///         otherwise returns false. In the latter case version is
///         unchanged.
bool ReadVersion(FilesContainerR const & container, MwmVersion & version);

/// Helper function that is used in FindAllLocalMaps.
uint32_t ReadVersionDate(ModelReaderPtr const & reader);

/// \returns true if version is version of an mwm which was generated after small mwm update.
/// This means it contains routing file as well.
bool IsSingleMwm(int64_t version);

/// \brief This enum sets constants which are used for writing test to set a version of mwm
/// which should be processed as either single or two components (mwm and routing) mwms.
enum ForTesting
{
  FOR_TESTING_TWO_COMPONENT_MWM1 = 10,
  FOR_TESTING_TWO_COMPONENT_MWM2,
  FOR_TESTING_SINGLE_MWM1 = 991215,
  FOR_TESTING_SINGLE_MWM2,
  FOR_TESTING_SINGLE_MWM_LATEST,
};
}  // namespace version