mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 21:13:35 +00:00
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
This commit is contained in:
43
coding/mmap_reader.hpp
Normal file
43
coding/mmap_reader.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#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;
|
||||
};
|
||||
Reference in New Issue
Block a user