Files
comaps/coding/mmap_reader.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

44 lines
919 B
C++

#pragma once
#include "coding/reader.hpp"
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
/// @TODO Add Windows support
class MmapReader : public ModelReader
{
public:
enum class Advice
{
Normal,
Random,
Sequential
};
explicit MmapReader(std::string const & fileName, Advice advice = Advice::Normal);
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;
};