MCPcopy Create free account
hub / github.com/comaps/comaps / FileReader

Class FileReader

libs/coding/file_reader.hpp:15–49  ·  view source on GitHub ↗

FileReader, cheap to copy, not thread safe. It is assumed that file is not modified during FireReader lifetime, because of caching and assumption that Size() is constant.

Source from the content-addressed store, hash-verified

13// It is assumed that file is not modified during FireReader lifetime,
14// because of caching and assumption that Size() is constant.
15class FileReader : public ModelReader
16{
17public:
18 static uint32_t const kDefaultLogPageSize;
19 static uint32_t const kDefaultLogPageCount;
20
21 explicit FileReader(std::string const & fileName);
22 FileReader(std::string const & fileName, uint32_t logPageSize, uint32_t logPageCount);
23
24 // Reader overrides:
25 uint64_t Size() const override { return m_size; }
26 void Read(uint64_t pos, void * p, size_t size) const override;
27 std::unique_ptr<Reader> CreateSubReader(uint64_t pos, uint64_t size) const override;
28
29 FileReader SubReader(uint64_t pos, uint64_t size) const;
30 uint64_t GetOffset() const { return m_offset; }
31
32protected:
33 // Used in special derived readers.
34 void SetOffsetAndSize(uint64_t offset, uint64_t size);
35
36private:
37 class FileReaderData;
38
39 FileReader(FileReader const & reader, uint64_t offset, uint64_t size, uint32_t logPageSize, uint32_t logPageCount);
40
41 // Throws an exception if a (pos, size) read would result in an out-of-bounds access.
42 void CheckPosAndSize(uint64_t pos, uint64_t size) const;
43
44 uint32_t m_logPageSize;
45 uint32_t m_logPageCount;
46 std::shared_ptr<FileReaderData> m_fileData;
47 uint64_t m_offset;
48 uint64_t m_size;
49};

Callers 13

GetReaderMethod · 0.70
SaveCurrentSizeMethod · 0.70
SubReaderMethod · 0.70
UNIT_TESTFunction · 0.50
UNIT_TESTFunction · 0.50
CreateAndTestZipFunction · 0.50
LoadGpxFromFileFunction · 0.50
ReadFileFunction · 0.50
UNIT_TESTFunction · 0.50
LoadMetadataMethod · 0.50
LoadKmlFileFunction · 0.50

Calls

no outgoing calls

Tested by 8

UNIT_TESTFunction · 0.40
UNIT_TESTFunction · 0.40
CreateAndTestZipFunction · 0.40
LoadGpxFromFileFunction · 0.40
ReadFileFunction · 0.40
UNIT_TESTFunction · 0.40
UNIT_CLASS_TESTFunction · 0.40