9#ifndef LLVM_SUPPORT_BINARYSTREAMWRITER_H
10#define LLVM_SUPPORT_BINARYSTREAMWRITER_H
59 static_assert(std::is_integral_v<T>,
60 "Cannot call writeInteger with non-integral value!");
68 static_assert(std::is_enum<T>::value,
69 "Cannot call writeEnum with non-Enum type");
71 using U = std::underlying_type_t<T>;
72 return writeInteger<U>(
static_cast<U
>(Num));
129 static_assert(!std::is_pointer<T>::value,
130 "writeObject should not be used with pointers, to write "
131 "the pointed-to value dereference the pointer before calling "
147 if (Array.size() > UINT32_MAX /
sizeof(
T))
148 return make_error<BinaryStreamError>(
153 Array.size() *
sizeof(
T)));
160 template <
typename T,
typename U>
174 std::pair<BinaryStreamWriter, BinaryStreamWriter>
split(
uint64_t Off)
const;
Lightweight arrays that are backed by an arbitrary BinaryStream.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
llvm::endianness getEndian() const
uint64_t getLength() const
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Provides write only access to a subclass of WritableBinaryStream.
Error writeCString(StringRef Str)
Write the string Str to the underlying stream followed by a null terminator.
Error writeArray(FixedStreamArray< T > Array)
Writes all elements from the array Array to the underlying stream.
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
uint64_t getOffset() const
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Error writeSLEB128(int64_t Value)
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
uint64_t bytesRemaining() const
Error writeArray(VarStreamArray< T, U > Array)
Writes all data from the array Array to the underlying stream.
BinaryStreamWriter & operator=(const BinaryStreamWriter &Other)=default
BinaryStreamWriter()=default
std::pair< BinaryStreamWriter, BinaryStreamWriter > split(uint64_t Off) const
Splits the Writer into two Writers at a given offset.
Error writeStreamRef(BinaryStreamRef Ref)
Efficiently reads all data from Ref, and writes it to this stream.
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
uint64_t getLength() const
Error writeFixedString(StringRef Str)
Write the string Str to the underlying stream without a null terminator.
void setOffset(uint64_t Off)
Error writeEnum(T Num)
Similar to writeInteger.
Error writeULEB128(uint64_t Value)
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
WritableBinaryStreamRef Stream
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
BinaryStreamWriter(const BinaryStreamWriter &Other)=default
virtual ~BinaryStreamWriter()=default
Error padToAlignment(uint32_t Align)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
A BinaryStream which can be read from as well as written to.
This is an optimization pass for GlobalISel generic memory operations.
@ Ref
The access may reference the value stored in memory.
This struct is a compact representation of a valid (non-zero power of two) alignment.