14 #ifndef LLVM_SUPPORT_MEMORYBUFFER_H
15 #define LLVM_SUPPORT_MEMORYBUFFER_H
28 class MemoryBufferRef;
41 const char *BufferStart;
42 const char *BufferEnd;
48 void init(
const char *BufStart,
const char *BufEnd,
49 bool RequiresNullTerminator);
77 bool RequiresNullTerminator =
true,
bool IsVolatileSize =
false);
100 bool RequiresNullTerminator =
true,
bool IsVolatileSize =
false);
104 static std::unique_ptr<MemoryBuffer>
106 bool RequiresNullTerminator =
true);
108 static std::unique_ptr<MemoryBuffer>
113 static std::unique_ptr<MemoryBuffer>
119 static std::unique_ptr<MemoryBuffer>
125 static std::unique_ptr<MemoryBuffer>
135 bool RequiresNullTerminator =
true);
167 : Buffer(Buffer), Identifier(Identifier) {}
183 #endif // LLVM_SUPPORT_MEMORYBUFFER_H
MemoryBufferRef getMemBufferRef() const
void init(const char *BufStart, const char *BufEnd, bool RequiresNullTerminator)
init - Initialize this MemoryBuffer as a reference to externally allocated memory, memory that we know is already null terminated.
Represents either an error or a value T.
const char * getBufferStart() const
struct LLVMOpaqueMemoryBuffer * LLVMMemoryBufferRef
LLVM uses a polymorphic type hierarchy which C cannot represent, therefore parameters must be passed ...
MemoryBufferRef()=default
MemoryBuffer & operator=(const MemoryBuffer &)=delete
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
StringRef getBuffer() const
const char * getBufferStart() const
static std::unique_ptr< MemoryBuffer > getNewUninitMemBuffer(size_t Size, const Twine &BufferName="")
Allocate a new MemoryBuffer of the specified size that is not initialized.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(int FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatileSize=false)
Given an already-open file descriptor, read the file and return a MemoryBuffer.
static std::unique_ptr< MemoryBuffer > getNewMemBuffer(size_t Size, StringRef BufferName="")
Allocate a new zero-initialized MemoryBuffer of the specified size.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset)
Map a subrange of the specified file as a MemoryBuffer.
virtual BufferKind getBufferKind() const =0
Return information on the memory mechanism used to support the MemoryBuffer.
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getSTDIN()
Read all of stdin into a file buffer, and return it.
const char * getBufferEnd() const
size_t getBufferSize() const
StringRef getBuffer() const
This interface provides simple read-only access to a block of memory, and provides simple methods for...
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it...
size_t getBufferSize() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatileSize=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileAsStream(const Twine &Filename)
Read all of the specified file into a MemoryBuffer as a stream (i.e.
BufferKind
The kind of memory backing used to support the MemoryBuffer.
MemoryBufferRef(MemoryBuffer &Buffer)
const char * getBufferEnd() const
Provides ErrorOr<T> smart pointer.
StringRef getBufferIdentifier() const
MemoryBufferRef(StringRef Buffer, StringRef Identifier)
StringRef - Represent a constant reference to a string, i.e.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFileSlice(int FD, const Twine &Filename, uint64_t MapSize, int64_t Offset)
Given an already-open file descriptor, map some slice of it into a MemoryBuffer.