WPILibC++ 2024.3.2
|
This interface provides simple read-only access to a block of memory, and provides simple methods for reading files and standard input into a memory buffer. More...
Public Types | |
enum | BufferKind { MemoryBuffer_Malloc , MemoryBuffer_MMap } |
The kind of memory backing used to support the MemoryBuffer. More... | |
Public Member Functions | |
MemoryBuffer (const MemoryBuffer &)=delete | |
MemoryBuffer & | operator= (const MemoryBuffer &)=delete |
virtual | ~MemoryBuffer () |
const uint8_t * | begin () const |
const uint8_t * | end () const |
size_t | size () const |
std::span< const uint8_t > | GetBuffer () const |
std::span< const char > | GetCharBuffer () const |
virtual std::string_view | GetBufferIdentifier () const |
Return an identifier for this buffer, typically the filename it was read from. More... | |
virtual BufferKind | GetBufferKind () const =0 |
Return information on the memory mechanism used to support the MemoryBuffer. More... | |
MemoryBufferRef | GetMemBufferRef () const |
Static Public Member Functions | |
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, otherwise returning null. More... | |
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. More... | |
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. More... | |
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. More... | |
static std::unique_ptr< MemoryBuffer > | GetMemBuffer (std::span< const uint8_t > inputData, std::string_view bufferName="") |
Open the specified memory range as a MemoryBuffer. More... | |
static std::unique_ptr< MemoryBuffer > | GetMemBuffer (MemoryBufferRef ref) |
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. More... | |
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. More... | |
Protected Member Functions | |
MemoryBuffer ()=default | |
void | Init (const uint8_t *bufStart, const uint8_t *bufEnd) |
This interface provides simple read-only access to a block of memory, and provides simple methods for reading files and standard input into a memory buffer.
The kind of memory backing used to support the MemoryBuffer.
Enumerator | |
---|---|
MemoryBuffer_Malloc | |
MemoryBuffer_MMap |
|
protecteddefault |
|
delete |
|
virtual |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Return an identifier for this buffer, typically the filename it was read from.
Reimplemented in wpi::SmallVectorMemoryBuffer.
|
pure virtual |
Return information on the memory mechanism used to support the MemoryBuffer.
Implemented in wpi::SmallVectorMemoryBuffer.
|
inline |
|
static |
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
If FileSize is specified, this means that the client knows that the file exists and that it has the specified size.
|
static |
Read all of the specified file into a MemoryBuffer as a stream (i.e.
until EOF reached). This is useful for special files that look like a regular file but have 0 size (e.g. /proc/cpuinfo on Linux).
|
static |
Map a subrange of the specified file as a MemoryBuffer.
|
static |
|
static |
Open the specified memory range as a MemoryBuffer.
|
static |
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
MemoryBufferRef wpi::MemoryBuffer::GetMemBufferRef | ( | ) | const |
|
static |
Given an already-open file descriptor, read the file and return a MemoryBuffer.
|
static |
Given an already-open file descriptor, map some slice of it into a MemoryBuffer.
The slice is specified by an Offset
and MapSize
.
|
protected |
|
delete |
|
inline |