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

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

#include "coding/reader.hpp"

#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>

/// @TODO Add Windows support
class MmapReader : public ModelReader
{
public:
  explicit MmapReader(std::string const & fileName);

  uint64_t Size() const override;
  void Read(uint64_t pos, void * p, size_t size) const override;
  std::unique_ptr<Reader> CreateSubReader(uint64_t pos, uint64_t size) const override;

  /// Direct file/memory access
  uint8_t * Data() const;

protected:
  // Used in special derived readers.
  void SetOffsetAndSize(uint64_t offset, uint64_t size);

private:
  using base_type = ModelReader;
  class MmapData;

  MmapReader(MmapReader const & reader, uint64_t offset, uint64_t size);

  std::shared_ptr<MmapData> m_data;
  uint64_t m_offset;
  uint64_t m_size;
};