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

postcodes.hpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5c078ceaf3168b568375c81ccf5c6575ff5b32f7 (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
#pragma once

#include "coding/map_uint32_to_val.hpp"
#include "coding/reader.hpp"
#include "coding/text_storage.hpp"
#include "coding/write_to_sink.hpp"
#include "coding/writer.hpp"

#include "base/stl_helpers.hpp"

#include <cstdint>
#include <memory>
#include <string>
#include <unordered_map>

namespace indexer
{
// December 2019 - September 2020 mwm compatibility
class Postcodes
{
public:
  enum class Version : uint8_t
  {
    V0 = 0,
    Latest = V0
  };

  struct Header
  {
    void Read(Reader & reader);

    Version m_version = Version::Latest;
    // All offsets are relative to the start of the section (offset of header is zero).
    uint32_t m_stringsOffset = 0;
    uint32_t m_stringsSize = 0;
    uint32_t m_postcodesMapOffset = 0;
    uint32_t m_postcodesMapSize = 0;
  };

  static std::unique_ptr<Postcodes> Load(Reader & reader);

  // Tries to get |postcode| of the feature with id |featureId|. Returns false if table
  // does not have entry for the feature.
  WARN_UNUSED_RESULT bool Get(uint32_t featureId, std::string & postcode);

private:
  using Map = MapUint32ToValue<uint32_t>;

  std::unique_ptr<Reader> m_stringsSubreader;
  coding::BlockedTextStorageReader m_strings;
  std::unique_ptr<Map> m_map;
  std::unique_ptr<Reader> m_mapSubreader;
  Version m_version = Version::Latest;
};
}  // namespace indexer