9#ifndef LLVM_SUPPORT_BINARYSTREAMWRITER_H
10#define LLVM_SUPPORT_BINARYSTREAMWRITER_H
62 static_assert(std::is_integral_v<T>,
63 "Cannot call writeInteger with non-integral value!");
80 static_assert(std::is_enum<T>::value,
81 "Cannot call writeEnum with non-Enum type");
140 static_assert(!std::is_pointer<T>::value,
141 "writeObject should not be used with pointers, to write "
142 "the pointed-to value dereference the pointer before calling "
158 if (Array.size() > UINT32_MAX /
sizeof(
T))
164 Array.size() *
sizeof(
T)));
171 template <
typename T,
typename U>
185 LLVM_ABI std::pair<BinaryStreamWriter, BinaryStreamWriter>
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
Lightweight arrays that are backed by an arbitrary BinaryStream.
This file contains library features backported from future STL versions.
An arbitrary precision integer that knows its signedness.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
LLVM_ABI 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.
LLVM_ABI 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
LLVM_ABI Error writeInt128(const APSInt &Value)
Write Value as a 128 bit integer (possibly truncated).
BinaryStreamWriter()=default
LLVM_ABI std::pair< BinaryStreamWriter, BinaryStreamWriter > split(uint64_t Off) const
Splits the Writer into two Writers at a given offset.
LLVM_ABI Error writeStreamRef(BinaryStreamRef Ref)
Efficiently reads all data from Ref, and writes it to this stream.
LLVM_ABI Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
uint64_t getLength() const
LLVM_ABI 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.
LLVM_ABI 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
LLVM_ABI 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.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Represent a constant reference to a string, i.e.
LLVM Value Representation.
A BinaryStream which can be read from as well as written to.
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
@ Off
Use window algorithm after SMS algorithm fails.
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
@ 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.