WPILibC++ 2024.3.2
wpi::WritableMemoryBuffer Class Reference

This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying contents. More...

#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemoryBuffer.h>

Inheritance diagram for wpi::WritableMemoryBuffer:
wpi::MemoryBuffer

Public Member Functions

uint8_t * begin ()
 
uint8_t * end ()
 
std::span< uint8_t > GetBuffer ()
 
std::span< char > GetCharBuffer () const
 
const uint8_t * begin () const
 
const uint8_t * end () const
 
std::span< const uint8_t > GetBuffer () const
 
size_t size () const
 
- Public Member Functions inherited from wpi::MemoryBuffer
 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< WritableMemoryBufferGetFile (std::string_view filename, std::error_code &ec, int64_t fileSize=-1)
 
static std::unique_ptr< WritableMemoryBufferGetFileSlice (std::string_view filename, std::error_code &ec, uint64_t mapSize, uint64_t offset)
 Map a subrange of the specified file as a WritableMemoryBuffer. More...
 
static std::unique_ptr< WritableMemoryBufferGetNewUninitMemBuffer (size_t size, std::string_view bufferName="")
 Allocate a new MemoryBuffer of the specified size that is not initialized. More...
 
static std::unique_ptr< WritableMemoryBufferGetNewMemBuffer (size_t size, std::string_view bufferName="")
 Allocate a new zero-initialized MemoryBuffer of the specified size. More...
 
- Static Public Member Functions inherited from wpi::MemoryBuffer
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

 WritableMemoryBuffer ()=default
 
- Protected Member Functions inherited from wpi::MemoryBuffer
 MemoryBuffer ()=default
 
void Init (const uint8_t *bufStart, const uint8_t *bufEnd)
 

Additional Inherited Members

- Public Types inherited from wpi::MemoryBuffer
enum  BufferKind { MemoryBuffer_Malloc , MemoryBuffer_MMap }
 The kind of memory backing used to support the MemoryBuffer. More...
 

Detailed Description

This class is an extension of MemoryBuffer, which allows copy-on-write access to the underlying contents.

It only supports creation methods that are guaranteed to produce a writable buffer. For example, mapping a file read-only is not supported.

Constructor & Destructor Documentation

◆ WritableMemoryBuffer()

wpi::WritableMemoryBuffer::WritableMemoryBuffer ( )
protecteddefault

Member Function Documentation

◆ begin() [1/2]

uint8_t * wpi::WritableMemoryBuffer::begin ( )
inline

◆ begin() [2/2]

const uint8_t * wpi::MemoryBuffer::begin ( ) const
inline

◆ end() [1/2]

uint8_t * wpi::WritableMemoryBuffer::end ( )
inline

◆ end() [2/2]

const uint8_t * wpi::MemoryBuffer::end ( ) const
inline

◆ GetBuffer() [1/2]

std::span< uint8_t > wpi::WritableMemoryBuffer::GetBuffer ( )
inline

◆ GetBuffer() [2/2]

std::span< const uint8_t > wpi::MemoryBuffer::GetBuffer ( ) const
inline

◆ GetCharBuffer()

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

◆ GetFile()

static std::unique_ptr< WritableMemoryBuffer > wpi::WritableMemoryBuffer::GetFile ( std::string_view  filename,
std::error_code &  ec,
int64_t  fileSize = -1 
)
static

◆ GetFileSlice()

static std::unique_ptr< WritableMemoryBuffer > wpi::WritableMemoryBuffer::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 WritableMemoryBuffer.

◆ GetNewMemBuffer()

static std::unique_ptr< WritableMemoryBuffer > wpi::WritableMemoryBuffer::GetNewMemBuffer ( size_t  size,
std::string_view  bufferName = "" 
)
static

Allocate a new zero-initialized MemoryBuffer of the specified size.

Note that the caller need not initialize the memory allocated by this method. The memory is owned by the MemoryBuffer object.

◆ GetNewUninitMemBuffer()

static std::unique_ptr< WritableMemoryBuffer > wpi::WritableMemoryBuffer::GetNewUninitMemBuffer ( size_t  size,
std::string_view  bufferName = "" 
)
static

Allocate a new MemoryBuffer of the specified size that is not initialized.

Note that the caller should initialize the memory allocated by this method. The memory is owned by the MemoryBuffer object.

◆ size()

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

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