WPILibC++ 2024.1.1-beta-4
wpi::MemoryBuffer Class Referenceabstract

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 </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemoryBuffer.h>

Inheritance diagram for wpi::MemoryBuffer:
wpi::SmallVectorMemoryBuffer wpi::WritableMemoryBuffer wpi::WriteThroughMemoryBuffer

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
 
MemoryBufferoperator= (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< MemoryBufferGetFile (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< MemoryBufferGetFileAsStream (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< MemoryBufferGetOpenFileSlice (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< MemoryBufferGetOpenFile (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< MemoryBufferGetMemBuffer (std::span< const uint8_t > inputData, std::string_view bufferName="")
 Open the specified memory range as a MemoryBuffer. More...
 
static std::unique_ptr< MemoryBufferGetMemBuffer (MemoryBufferRef ref)
 
static std::unique_ptr< MemoryBufferGetMemBufferCopy (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< MemoryBufferGetFileSlice (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)
 

Detailed Description

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.

Member Enumeration Documentation

◆ BufferKind

The kind of memory backing used to support the MemoryBuffer.

Enumerator
MemoryBuffer_Malloc 
MemoryBuffer_MMap 

Constructor & Destructor Documentation

◆ MemoryBuffer() [1/2]

wpi::MemoryBuffer::MemoryBuffer ( )
protecteddefault

◆ MemoryBuffer() [2/2]

wpi::MemoryBuffer::MemoryBuffer ( const MemoryBuffer )
delete

◆ ~MemoryBuffer()

virtual wpi::MemoryBuffer::~MemoryBuffer ( )
virtual

Member Function Documentation

◆ 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

Return an identifier for this buffer, typically the filename it was read from.

Reimplemented in wpi::SmallVectorMemoryBuffer.

◆ GetBufferKind()

virtual BufferKind wpi::MemoryBuffer::GetBufferKind ( ) const
pure virtual

Return information on the memory mechanism used to support the MemoryBuffer.

Implemented in wpi::SmallVectorMemoryBuffer.

◆ GetCharBuffer()

std::span< const char > wpi::MemoryBuffer::GetCharBuffer ( ) const
inline

◆ GetFile()

static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetFile ( std::string_view  filename,
std::error_code &  ec,
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

Map a subrange of the specified file as a MemoryBuffer.

◆ GetMemBuffer() [1/2]

static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetMemBuffer ( MemoryBufferRef  ref)
static

◆ GetMemBuffer() [2/2]

static std::unique_ptr< MemoryBuffer > wpi::MemoryBuffer::GetMemBuffer ( std::span< const uint8_t >  inputData,
std::string_view  bufferName = "" 
)
static

Open the specified memory range as a MemoryBuffer.

◆ 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()

MemoryBufferRef wpi::MemoryBuffer::GetMemBufferRef ( ) const

◆ 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=()

MemoryBuffer & wpi::MemoryBuffer::operator= ( const MemoryBuffer )
delete

◆ size()

size_t wpi::MemoryBuffer::size ( ) const
inline

The documentation for this class was generated from the following file: