class BinaryStreamWriter
Declaration
class BinaryStreamWriter { /* full declaration omitted */ };
Description
Provides write only access to a subclass of `WritableBinaryStream`. Provides bounds checking and helpers for writing certain common data types such as null-terminated strings, integers in various flavors of endianness, etc. Can be subclassed to provide reading and writing of custom datatypes, although no methods are overridable.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:31
Member Variables
- protected llvm::WritableBinaryStreamRef Stream
- protected uint32_t Offset = 0
Method Overview
- public BinaryStreamWriter(llvm::WritableBinaryStreamRef Ref)
- public BinaryStreamWriter(llvm::WritableBinaryStream & Stream)
- public BinaryStreamWriter(MutableArrayRef<uint8_t> Data, llvm::support::endianness Endian)
- public BinaryStreamWriter(const llvm::BinaryStreamWriter & Other)
- public BinaryStreamWriter()
- public uint32_t bytesRemaining() const
- public uint32_t getLength() const
- public uint32_t getOffset() const
- public llvm::Error padToAlignment(uint32_t Align)
- public void setOffset(uint32_t Off)
- public std::pair<BinaryStreamWriter, BinaryStreamWriter> split(uint32_t Off) const
- public template <typename T>llvm::Error writeArray(FixedStreamArray<T> Array)
- public template <typename T, typename U>llvm::Error writeArray(VarStreamArray<T, U> Array)
- public template <typename T>llvm::Error writeArray(ArrayRef<T> Array)
- public llvm::Error writeBytes(ArrayRef<uint8_t> Buffer)
- public llvm::Error writeCString(llvm::StringRef Str)
- public template <typename T>llvm::Error writeEnum(T Num)
- public llvm::Error writeFixedString(llvm::StringRef Str)
- public template <typename T>llvm::Error writeInteger(T Value)
- public template <typename T>llvm::Error writeObject(const T & Obj)
- public llvm::Error writeSLEB128(int64_t Value)
- public llvm::Error writeStreamRef(llvm::BinaryStreamRef Ref, uint32_t Size)
- public llvm::Error writeStreamRef(llvm::BinaryStreamRef Ref)
- public llvm::Error writeULEB128(uint64_t Value)
- public virtual ~BinaryStreamWriter()
Methods
¶BinaryStreamWriter(
llvm::WritableBinaryStreamRef Ref)
BinaryStreamWriter(
llvm::WritableBinaryStreamRef Ref)
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:34
Parameters
¶BinaryStreamWriter(
llvm::WritableBinaryStream& Stream)
BinaryStreamWriter(
llvm::WritableBinaryStream& Stream)
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:35
Parameters
- llvm::WritableBinaryStream& Stream
¶BinaryStreamWriter(
MutableArrayRef<uint8_t> Data,
llvm::support::endianness Endian)
BinaryStreamWriter(
MutableArrayRef<uint8_t> Data,
llvm::support::endianness Endian)
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:36
Parameters
- MutableArrayRef<uint8_t> Data
- llvm::support::endianness Endian
¶BinaryStreamWriter(
const llvm::BinaryStreamWriter& Other)
BinaryStreamWriter(
const llvm::BinaryStreamWriter& Other)
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:39
Parameters
- const llvm::BinaryStreamWriter& Other
¶BinaryStreamWriter()
BinaryStreamWriter()
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:33
¶uint32_t bytesRemaining() const
uint32_t bytesRemaining() const
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:186
¶uint32_t getLength() const
uint32_t getLength() const
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:185
¶uint32_t getOffset() const
uint32_t getOffset() const
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:184
¶llvm::Error padToAlignment(uint32_t Align)
llvm::Error padToAlignment(uint32_t Align)
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:187
Parameters
- uint32_t Align
¶void setOffset(uint32_t Off)
void setOffset(uint32_t Off)
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:183
Parameters
- uint32_t Off
¶std::pair<BinaryStreamWriter, BinaryStreamWriter>
split(uint32_t Off) const
std::pair<BinaryStreamWriter, BinaryStreamWriter>
split(uint32_t Off) const
Description
Splits the Writer into two Writers at a given offset.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:181
Parameters
- uint32_t Off
¶template <typename T>
llvm::Error writeArray(FixedStreamArray<T> Array)
template <typename T>
llvm::Error writeArray(FixedStreamArray<T> Array)
Description
Writes all elements from the array \p Array to the underlying stream.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:176
Templates
- T
Parameters
- FixedStreamArray<T> Array
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶template <typename T, typename U>
llvm::Error writeArray(VarStreamArray<T, U> Array)
template <typename T, typename U>
llvm::Error writeArray(VarStreamArray<T, U> Array)
Description
Writes all data from the array \p Array to the underlying stream.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:168
Templates
- T
- U
Parameters
- VarStreamArray<T, U> Array
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶template <typename T>
llvm::Error writeArray(ArrayRef<T> Array)
template <typename T>
llvm::Error writeArray(ArrayRef<T> Array)
Description
Writes an array of objects of type T to the underlying stream, as if by using memcpy. It is up to the caller to ensure that type of \p Obj can be safely copied in this fashion, as no checks are made to ensure that this is safe.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:151
Templates
- T
Parameters
- ArrayRef<T> Array
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶llvm::Error writeBytes(ArrayRef<uint8_t> Buffer)
llvm::Error writeBytes(ArrayRef<uint8_t> Buffer)
Description
Write the bytes specified in \p Buffer to the underlying stream. On success, updates the offset so that subsequent writes will occur at the next unwritten position.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:56
Parameters
- ArrayRef<uint8_t> Buffer
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶llvm::Error writeCString(llvm::StringRef Str)
llvm::Error writeCString(llvm::StringRef Str)
Description
Write the string \p Str to the underlying stream followed by a null terminator. On success, updates the offset so that subsequent writes occur at the next unwritten position. \p Str need not be null terminated on input.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:103
Parameters
- llvm::StringRef Str
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶template <typename T>
llvm::Error writeEnum(T Num)
template <typename T>
llvm::Error writeEnum(T Num)
Description
Similar to writeInteger
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:74
Templates
- T
Parameters
- T Num
¶llvm::Error writeFixedString(llvm::StringRef Str)
llvm::Error writeFixedString(llvm::StringRef Str)
Description
Write the string \p Str to the underlying stream without a null terminator. On success, updates the offset so that subsequent writes occur at the next unwritten position.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:111
Parameters
- llvm::StringRef Str
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶template <typename T>
llvm::Error writeInteger(T Value)
template <typename T>
llvm::Error writeInteger(T Value)
Description
Write the integer \p Value to the underlying stream in the specified endianness. On success, updates the offset so that subsequent writes occur at the next unwritten position.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:64
Templates
- T
Parameters
- T Value
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶template <typename T>
llvm::Error writeObject(const T& Obj)
template <typename T>
llvm::Error writeObject(const T& Obj)
Description
Writes the object \p Obj to the underlying stream, as if by using memcpy. It is up to the caller to ensure that type of \p Obj can be safely copied in this fashion, as no checks are made to ensure that this is safe.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:135
Templates
- T
Parameters
- const T& Obj
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶llvm::Error writeSLEB128(int64_t Value)
llvm::Error writeSLEB128(int64_t Value)
Description
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:94
Parameters
- int64_t Value
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶llvm::Error writeStreamRef(
llvm::BinaryStreamRef Ref,
uint32_t Size)
llvm::Error writeStreamRef(
llvm::BinaryStreamRef Ref,
uint32_t Size)
Description
Efficiently reads \p Size bytes from \p Ref, and writes it to this stream. This operation will not invoke any copies of the source data, regardless of the source stream's implementation.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:127
Parameters
- llvm::BinaryStreamRef Ref
- uint32_t Size
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶llvm::Error writeStreamRef(
llvm::BinaryStreamRef Ref)
llvm::Error writeStreamRef(
llvm::BinaryStreamRef Ref)
Description
Efficiently reads all data from \p Ref, and writes it to this stream. This operation will not invoke any copies of the source data, regardless of the source stream's implementation.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:119
Parameters
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶llvm::Error writeULEB128(uint64_t Value)
llvm::Error writeULEB128(uint64_t Value)
Description
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:87
Parameters
- uint64_t Value
Returns
a success error code if the data was successfully written, otherwise returns an appropriate error code.
¶virtual ~BinaryStreamWriter()
virtual ~BinaryStreamWriter()
Declared at: llvm/include/llvm/Support/BinaryStreamWriter.h:48