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: c1cf2a0bdbfa8680c43b487181bd2fe4f0fef717 (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
#pragma once

#include "reader.hpp"

#include "../std/shared_ptr.hpp"

/// @TODO Add Windows support
class MmapReader : public ModelReader
{
  typedef ModelReader base_type;

  class MmapData;
  shared_ptr<MmapData> m_data;
  uint64_t m_offset;
  uint64_t m_size;

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

public:
  explicit MmapReader(string const & fileName);

  virtual uint64_t Size() const;
  virtual void Read(uint64_t pos, void * p, size_t size) const;
  virtual MmapReader * CreateSubReader(uint64_t pos, uint64_t size) const;

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

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