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...
#include <wpi/MemoryBuffer.h>
|
static wpi::expected< std::unique_ptr< MemoryBuffer >, std::error_code > | GetFile (std::string_view filename, int64_t fileSize=-1) |
| Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
|
|
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.
|
|
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 > | 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 > | 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.
|
|
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.
|
|
|
| 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.
◆ BufferKind
The kind of memory backing used to support the MemoryBuffer.
Enumerator |
---|
MemoryBuffer_Malloc | |
MemoryBuffer_MMap | |
◆ MemoryBuffer() [1/2]
wpi::MemoryBuffer::MemoryBuffer |
( |
| ) |
|
|
protecteddefault |
◆ MemoryBuffer() [2/2]
◆ ~MemoryBuffer()
virtual wpi::MemoryBuffer::~MemoryBuffer |
( |
| ) |
|
|
virtual |
◆ begin()
const uint8_t * wpi::MemoryBuffer::begin |
( |
| ) |
const |
|
inline |
◆ end()
const uint8_t * wpi::MemoryBuffer::end |
( |
| ) |
const |
|
inline |
◆ GetBuffer()
std::span< const uint8_t > wpi::MemoryBuffer::GetBuffer |
( |
| ) |
const |
|
inline |
◆ GetBufferIdentifier()
virtual std::string_view wpi::MemoryBuffer::GetBufferIdentifier |
( |
| ) |
const |
|
inlinevirtual |
◆ GetBufferKind()
virtual BufferKind wpi::MemoryBuffer::GetBufferKind |
( |
| ) |
const |
|
pure virtual |
◆ GetCharBuffer()
std::span< const char > wpi::MemoryBuffer::GetCharBuffer |
( |
| ) |
const |
|
inline |
◆ GetFile()
static wpi::expected< std::unique_ptr< MemoryBuffer >, std::error_code > wpi::MemoryBuffer::GetFile |
( |
std::string_view | filename, |
|
|
int64_t | fileSize = -1 ) |
|
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.
◆ GetFileAsStream()
static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetFileAsStream |
( |
std::string_view | filename, |
|
|
std::error_code & | ec ) |
|
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).
◆ GetFileSlice()
static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetFileSlice |
( |
std::string_view | filename, |
|
|
std::error_code & | ec, |
|
|
uint64_t | mapSize, |
|
|
uint64_t | offset ) |
|
static |
◆ GetMemBuffer() [1/2]
◆ GetMemBuffer() [2/2]
static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetMemBuffer |
( |
std::span< const uint8_t > | inputData, |
|
|
std::string_view | bufferName = "" ) |
|
static |
◆ GetMemBufferCopy()
static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetMemBufferCopy |
( |
std::span< const uint8_t > | inputData, |
|
|
std::string_view | bufferName = "" ) |
|
static |
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it.
◆ GetMemBufferRef()
◆ GetOpenFile()
static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetOpenFile |
( |
fs::file_t | f, |
|
|
std::string_view | filename, |
|
|
std::error_code & | ec, |
|
|
uint64_t | fileSize ) |
|
static |
Given an already-open file descriptor, read the file and return a MemoryBuffer.
◆ GetOpenFileSlice()
static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetOpenFileSlice |
( |
fs::file_t | f, |
|
|
std::string_view | filename, |
|
|
std::error_code & | ec, |
|
|
uint64_t | mapSize, |
|
|
int64_t | offset ) |
|
static |
Given an already-open file descriptor, map some slice of it into a MemoryBuffer.
The slice is specified by an Offset
and MapSize
.
◆ Init()
void wpi::MemoryBuffer::Init |
( |
const uint8_t * | bufStart, |
|
|
const uint8_t * | bufEnd ) |
|
protected |
◆ operator=()
◆ size()
size_t wpi::MemoryBuffer::size |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: