Loading...
Searching...
No Matches
MemoryInputStream.hpp
#pragma once
#include "InputStream.hpp"
namespace mce::io::stream {
class MemoryInputStream final : public InputStream {
public:
MemoryInputStream(const void* data, size_t size);
virtual size_t read(void* buffer, size_t size) override;
size_t readString(char*& buffer, size_t& size);
virtual size_t seek(size_t position) override;
virtual size_t tell() override;
virtual size_t getSize() override;
private:
const char* data = nullptr;
size_t size;
size_t offset; // the reading position
};
}
mce::io::stream::InputStream
Definition InputStream.hpp:6
mce::io::stream::MemoryInputStream::tell
virtual size_t tell() override
Get the current read position in the buffer.
Definition MemoryInputStream.cpp:41
mce::io::stream::MemoryInputStream::getSize
virtual size_t getSize() override
Get the total size of the memory buffer.
Definition MemoryInputStream.cpp:47
mce::io::stream::MemoryInputStream::read
virtual size_t read(void *buffer, size_t size) override
Read bytes from the memory buffer into the provided buffer.
Definition MemoryInputStream.cpp:12
mce::io::stream::MemoryInputStream::MemoryInputStream
MemoryInputStream(const void *data, size_t size)
Construct a memory input stream over existing data.
Definition MemoryInputStream.cpp:8
mce::io::stream::MemoryInputStream::readString
size_t readString(char *&buffer, size_t &size)
Read a NUL-terminated string from the stream.
Definition MemoryInputStream.cpp:24
mce::io::stream::MemoryInputStream::seek
virtual size_t seek(size_t position) override
Seek to an absolute position in the memory buffer.
Definition MemoryInputStream.cpp:34