solanaceae_util/solanaceae/file/file2_mem.hpp

33 lines
719 B
C++
Raw Normal View History

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;
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;
ByteSpanWithOwnership read(uint64_t size, int64_t pos = -1) override;
2024-04-03 21:03:04 +02:00
};