2024-04-03 21:03:04 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "./file2.hpp"
|
|
|
|
|
|
|
|
// write to vector or read from span
|
|
|
|
// no seeking for now (could make sense for read)
|
|
|
|
|
|
|
|
struct File2MemW : public File2I {
|
|
|
|
std::vector<uint8_t>& _mem;
|
|
|
|
|
|
|
|
File2MemW(std::vector<uint8_t>& mem);
|
|
|
|
virtual ~File2MemW(void);
|
|
|
|
|
|
|
|
bool isGood(void) override;
|
|
|
|
|
|
|
|
bool write(const ByteSpan data, int64_t pos = -1) override;
|
2024-05-26 21:32:44 +02:00
|
|
|
ByteSpanWithOwnership read(uint64_t size, int64_t pos = -1) override;
|
2024-04-03 21:03:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct File2MemR : public File2I {
|
|
|
|
ByteSpan _mem;
|
|
|
|
int64_t _read_pos{0};
|
|
|
|
|
|
|
|
File2MemR(ByteSpan mem);
|
|
|
|
virtual ~File2MemR(void);
|
|
|
|
|
|
|
|
bool isGood(void) override;
|
|
|
|
|
|
|
|
bool write(const ByteSpan data, int64_t pos = -1) override;
|
2024-05-26 21:32:44 +02:00
|
|
|
ByteSpanWithOwnership read(uint64_t size, int64_t pos = -1) override;
|
2024-04-03 21:03:04 +02:00
|
|
|
};
|
|
|
|
|