26#include <system_error>
61 size_t size()
const {
return m_bufferEnd - m_bufferStart; }
68 return "Unknown buffer";
149 static std::unique_ptr<WritableMemoryBuffer>
GetFile(
200 static std::unique_ptr<WriteThroughMemoryBuffer>
GetFile(
220 std::span<const uint8_t> m_buffer;
228 : m_buffer(
buffer), m_id(id) {}
230 std::span<const uint8_t>
GetBuffer()
const {
return m_buffer; }
236 size_t size()
const {
return m_buffer.size(); }
\rst A contiguous memory buffer with an optional growing ability.
Definition: core.h:862
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:45
static std::unique_ptr< MemoryBuffer > GetOpenFileSlice(fs::file_t f, std::string_view filename, std::error_code &ec, uint64_t mapSize, int64_t offset)
Given an already-open file descriptor, map some slice of it into a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > GetFile(std::string_view filename, std::error_code &ec, int64_t fileSize=-1)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
BufferKind
The kind of memory backing used to support the MemoryBuffer.
Definition: MemoryBuffer.h:120
@ MemoryBuffer_Malloc
Definition: MemoryBuffer.h:120
@ MemoryBuffer_MMap
Definition: MemoryBuffer.h:120
virtual std::string_view GetBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
Definition: MemoryBuffer.h:67
static std::unique_ptr< MemoryBuffer > GetOpenFile(fs::file_t f, std::string_view filename, std::error_code &ec, uint64_t fileSize)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > GetMemBuffer(std::span< const uint8_t > inputData, std::string_view bufferName="")
Open the specified memory range as a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > GetMemBufferCopy(std::span< const uint8_t > inputData, std::string_view bufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
const uint8_t * begin() const
Definition: MemoryBuffer.h:59
std::span< const uint8_t > GetBuffer() const
Definition: MemoryBuffer.h:63
virtual BufferKind GetBufferKind() const =0
Return information on the memory mechanism used to support the MemoryBuffer.
static std::unique_ptr< MemoryBuffer > GetFileSlice(std::string_view filename, std::error_code &ec, uint64_t mapSize, uint64_t offset)
Map a subrange of the specified file as a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > GetFileAsStream(std::string_view filename, std::error_code &ec)
Read all of the specified file into a MemoryBuffer as a stream (i.e.
MemoryBuffer(const MemoryBuffer &)=delete
MemoryBuffer & operator=(const MemoryBuffer &)=delete
const uint8_t * end() const
Definition: MemoryBuffer.h:60
void Init(const uint8_t *bufStart, const uint8_t *bufEnd)
MemoryBufferRef GetMemBufferRef() const
static std::unique_ptr< MemoryBuffer > GetMemBuffer(MemoryBufferRef ref)
size_t size() const
Definition: MemoryBuffer.h:61
Definition: MemoryBuffer.h:219
std::string_view GetBufferIdentifier() const
Definition: MemoryBuffer.h:232
MemoryBufferRef(MemoryBuffer &buffer)
Definition: MemoryBuffer.h:225
std::span< const uint8_t > GetBuffer() const
Definition: MemoryBuffer.h:230
MemoryBufferRef(std::span< const uint8_t > buffer, std::string_view id)
Definition: MemoryBuffer.h:227
const uint8_t * begin() const
Definition: MemoryBuffer.h:234
MemoryBufferRef()=default
size_t size() const
Definition: MemoryBuffer.h:236
const uint8_t * end() const
Definition: MemoryBuffer.h:235
This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying conte...
Definition: MemoryBuffer.h:133
WritableMemoryBuffer()=default
static std::unique_ptr< WritableMemoryBuffer > GetFile(std::string_view filename, std::error_code &ec, int64_t fileSize=-1)
static std::unique_ptr< WritableMemoryBuffer > GetFileSlice(std::string_view filename, std::error_code &ec, uint64_t mapSize, uint64_t offset)
Map a subrange of the specified file as a WritableMemoryBuffer.
uint8_t * end()
Definition: MemoryBuffer.h:146
std::span< uint8_t > GetBuffer()
Definition: MemoryBuffer.h:147
uint8_t * begin()
Definition: MemoryBuffer.h:145
static std::unique_ptr< WritableMemoryBuffer > GetNewMemBuffer(size_t size, std::string_view bufferName="")
Allocate a new zero-initialized MemoryBuffer of the specified size.
static std::unique_ptr< WritableMemoryBuffer > GetNewUninitMemBuffer(size_t size, std::string_view bufferName="")
Allocate a new MemoryBuffer of the specified size that is not initialized.
size_t size() const
Definition: MemoryBuffer.h:61
This class is an extension of MemoryBuffer, which allows write access to the underlying contents and ...
Definition: MemoryBuffer.h:184
static std::unique_ptr< WriteThroughMemoryBuffer > GetFileSlice(std::string_view filename, std::error_code &ec, uint64_t mapSize, uint64_t offset)
Map a subrange of the specified file as a ReadWriteMemoryBuffer.
WriteThroughMemoryBuffer()=default
static std::unique_ptr< WriteThroughMemoryBuffer > GetFile(std::string_view filename, std::error_code &ec, int64_t fileSize=-1)
std::span< uint8_t > GetBuffer()
Definition: MemoryBuffer.h:198
uint8_t * begin()
Definition: MemoryBuffer.h:196
uint8_t * end()
Definition: MemoryBuffer.h:197
basic_string_view< char > string_view
Definition: core.h:520
::uint64_t uint64_t
Definition: Meta.h:58
::int64_t int64_t
Definition: Meta.h:59
::uint8_t uint8_t
Definition: Meta.h:52
Definition: MappedFileRegion.h:12
int file_t
Definition: MappedFileRegion.h:17
Definition: AprilTagFieldLayout.h:18