|
LLVM 24.0.0git
|
Provides write only access to a subclass of WritableBinaryStream. More...
#include "llvm/Support/BinaryStreamWriter.h"
Public Member Functions | |
| BinaryStreamWriter ()=default | |
| LLVM_ABI | BinaryStreamWriter (WritableBinaryStreamRef Ref) |
| LLVM_ABI | BinaryStreamWriter (WritableBinaryStream &Stream) |
| LLVM_ABI | BinaryStreamWriter (MutableArrayRef< uint8_t > Data, llvm::endianness Endian) |
| BinaryStreamWriter (const BinaryStreamWriter &Other)=default | |
| BinaryStreamWriter & | operator= (const BinaryStreamWriter &Other)=default |
| virtual | ~BinaryStreamWriter ()=default |
| LLVM_ABI Error | writeBytes (ArrayRef< uint8_t > Buffer) |
Write the bytes specified in Buffer to the underlying stream. | |
| template<typename T> | |
| Error | writeInteger (T Value) |
Write the integer Value to the underlying stream in the specified endianness. | |
| LLVM_ABI Error | writeInt128 (const APSInt &Value) |
Write Value as a 128 bit integer (possibly truncated). | |
| template<typename T> | |
| 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. | |
| LLVM_ABI Error | writeSLEB128 (int64_t Value) |
| Write the unsigned integer Value to the underlying stream using ULEB128 encoding. | |
| LLVM_ABI Error | writeCString (StringRef Str) |
Write the string Str to the underlying stream followed by a null terminator. | |
| LLVM_ABI Error | writeFixedString (StringRef Str) |
Write the string Str to the underlying stream without a null terminator. | |
| LLVM_ABI Error | writeStreamRef (BinaryStreamRef Ref) |
Efficiently reads all data from Ref, and writes it to this stream. | |
| LLVM_ABI Error | writeStreamRef (BinaryStreamRef Ref, uint64_t Size) |
Efficiently reads Size bytes from Ref, and writes it to this stream. | |
| template<typename T> | |
| Error | writeObject (const T &Obj) |
Writes the object Obj to the underlying stream, as if by using memcpy. | |
| template<typename T> | |
| Error | writeArray (ArrayRef< T > Array) |
| Writes an array of objects of type T to the underlying stream, as if by using memcpy. | |
| template<typename T, typename U> | |
| Error | writeArray (VarStreamArray< T, U > Array) |
Writes all data from the array Array to the underlying stream. | |
| template<typename T> | |
| Error | writeArray (FixedStreamArray< T > Array) |
Writes all elements from the array Array to the underlying stream. | |
| LLVM_ABI std::pair< BinaryStreamWriter, BinaryStreamWriter > | split (uint64_t Off) const |
| Splits the Writer into two Writers at a given offset. | |
| void | setOffset (uint64_t Off) |
| uint64_t | getOffset () const |
| uint64_t | getLength () const |
| uint64_t | bytesRemaining () const |
| LLVM_ABI Error | padToAlignment (uint32_t Align) |
Protected Attributes | |
| WritableBinaryStreamRef | Stream |
| uint64_t | Offset = 0 |
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.
Definition at line 33 of file BinaryStreamWriter.h.
|
default |
References llvm::Data, LLVM_ABI, llvm::Ref, and Stream.
Referenced by BinaryStreamWriter(), operator=(), and split().
|
explicit |
Definition at line 18 of file BinaryStreamWriter.cpp.
|
explicit |
Definition at line 21 of file BinaryStreamWriter.cpp.
References Stream.
|
explicit |
Definition at line 24 of file BinaryStreamWriter.cpp.
References llvm::Data, and Stream.
|
default |
References BinaryStreamWriter(), and llvm::Other.
|
virtualdefault |
References LLVM_ABI.
|
inline |
Definition at line 191 of file BinaryStreamWriter.h.
References getLength(), getOffset(), and uint64_t.
Referenced by llvm::pdb::DbiStreamBuilder::commit(), llvm::pdb::InfoStreamBuilder::commit(), commitFpm(), llvm::pdb::DbiModuleDescriptorBuilder::commitSymbolStream(), llvm::msf::WritableMappedBlockStream::createFpmStream(), llvm::CodeViewYAML::toDebugH(), and llvm::CodeViewYAML::toDebugT().
|
inline |
Definition at line 190 of file BinaryStreamWriter.h.
References Stream, and uint64_t.
Referenced by bytesRemaining(), and split().
|
inline |
Definition at line 189 of file BinaryStreamWriter.h.
References Offset, and uint64_t.
Referenced by addPadding(), addPadding(), bytesRemaining(), llvm::codeview::DebugStringTableSubsection::commit(), llvm::codeview::DebugSubsectionRecordBuilder::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commitSymbolStream(), llvm::codeview::SimpleTypeSerializer::serialize(), and llvm::jitlink::CompactUnwindManager< CURecTraits >::writeUnwindInfo().
|
default |
References BinaryStreamWriter(), and llvm::Other.
Definition at line 110 of file BinaryStreamWriter.cpp.
References llvm::alignTo(), Offset, llvm::Error::success(), and writeArray().
Referenced by llvm::codeview::DebugChecksumsSubsection::commit(), llvm::codeview::DebugSubsectionRecordBuilder::commit(), and llvm::pdb::DbiModuleDescriptorBuilder::commit().
|
inline |
Definition at line 188 of file BinaryStreamWriter.h.
References llvm::Off, Offset, and uint64_t.
Referenced by llvm::codeview::DebugStringTableSubsection::commit(), llvm::msf::MSFBuilder::commit(), and llvm::pdb::DbiModuleDescriptorBuilder::commitSymbolStream().
| std::pair< BinaryStreamWriter, BinaryStreamWriter > BinaryStreamWriter::split | ( | uint64_t | Off | ) | const |
Splits the Writer into two Writers at a given offset.
Definition at line 98 of file BinaryStreamWriter.cpp.
References assert(), BinaryStreamWriter(), llvm::First, getLength(), llvm::Off, Offset, and Stream.
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 Obj can be safely copied in this fashion, as no checks are made to ensure that this is safe.
Definition at line 155 of file BinaryStreamWriter.h.
References llvm::invalid_array_size, llvm::make_error(), llvm::Error::success(), T, and writeBytes().
Referenced by llvm::pdb::DbiStreamBuilder::addDbgStream(), llvm::codeview::DebugChecksumsSubsection::commit(), llvm::codeview::DebugCrossModuleImportsSubsection::commit(), llvm::codeview::DebugFrameDataSubsection::commit(), llvm::codeview::DebugInlineeLinesSubsection::commit(), llvm::codeview::DebugLinesSubsection::commit(), llvm::codeview::DebugSymbolRVASubsection::commit(), llvm::msf::MSFBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), llvm::pdb::GSIHashStreamBuilder::commit(), llvm::pdb::DbiStreamBuilder::finalizeMsfLayout(), and padToAlignment().
|
inline |
Writes all elements from the array Array to the underlying stream.
Definition at line 180 of file BinaryStreamWriter.h.
References writeStreamRef().
|
inline |
Writes all data from the array Array to the underlying stream.
Definition at line 172 of file BinaryStreamWriter.h.
References writeStreamRef().
Write the bytes specified in Buffer to the underlying stream.
On success, updates the offset so that subsequent writes will occur at the next unwritten position.
Definition at line 28 of file BinaryStreamWriter.cpp.
References Offset, llvm::ArrayRef< T >::size(), Stream, and llvm::Error::success().
Referenced by llvm::codeview::DebugSymbolsSubsection::commit(), llvm::pdb::PDBFileBuilder::commit(), llvm::pdb::TpiStreamBuilder::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commitSymbolStream(), llvm::msf::WritableMappedBlockStream::createFpmStream(), llvm::CodeViewYAML::toDebugT(), writeArray(), writeFixedString(), writeInteger(), writeObject(), writePublics(), writeSLEB128(), writeStreamRef(), and writeULEB128().
Write the string 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. Str need not be null terminated on input.
Definition at line 62 of file BinaryStreamWriter.cpp.
References llvm::Error::success(), writeFixedString(), and writeObject().
Referenced by llvm::codeview::DebugStringTableSubsection::commit(), and llvm::pdb::DbiModuleDescriptorBuilder::commit().
Similar to writeInteger.
Definition at line 79 of file BinaryStreamWriter.h.
References T, llvm::to_underlying(), and writeInteger().
Referenced by llvm::codeview::DebugInlineeLinesSubsection::commit(), llvm::pdb::DbiStreamBuilder::commit(), and llvm::pdb::InfoStreamBuilder::commit().
Write the string Str to the underlying stream without a null terminator.
On success, updates the offset so that subsequent writes occur at the next unwritten position.
Definition at line 71 of file BinaryStreamWriter.cpp.
References llvm::arrayRefFromStringRef(), and writeBytes().
Referenced by llvm::pdb::NamedStreamMap::commit(), llvm::CodeViewYAML::toDebugH(), and writeCString().
Write Value as a 128 bit integer (possibly truncated).
Value is expected to be in native endian as it is byte swapped if needed.
Definition at line 35 of file BinaryStreamWriter.cpp.
References assert(), llvm::big, Stream, and writeInteger().
Write the integer Value to the underlying stream in the specified endianness.
On success, updates the offset so that subsequent writes occur at the next unwritten position.
Definition at line 61 of file BinaryStreamWriter.h.
References Stream, T, llvm::support::endian::write(), and writeBytes().
Referenced by addPadding(), addPadding(), llvm::codeview::DebugCrossModuleExportsSubsection::commit(), llvm::codeview::DebugFrameDataSubsection::commit(), llvm::codeview::DebugInlineeLinesSubsection::commit(), llvm::msf::MSFBuilder::commit(), llvm::pdb::const_iterator< SrcHeaderBlockEntry >::commit(), llvm::pdb::DbiStreamBuilder::commit(), llvm::pdb::NamedStreamMap::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commitSymbolStream(), llvm::jitlink::aarch64::lowerPointer64AuthEdgesToSigningFunction(), llvm::CodeViewYAML::toDebugH(), toDebugS(), llvm::CodeViewYAML::toDebugT(), writeEnum(), writeInt128(), and llvm::pdb::writeSparseBitVector().
Writes the object Obj to the underlying stream, as if by using memcpy.
It is up to the caller to ensure that type of Obj can be safely copied in this fashion, as no checks are made to ensure that this is safe.
Definition at line 139 of file BinaryStreamWriter.h.
References T, and writeBytes().
Referenced by llvm::codeview::DebugChecksumsSubsection::commit(), llvm::codeview::DebugCrossModuleImportsSubsection::commit(), llvm::codeview::DebugInlineeLinesSubsection::commit(), llvm::codeview::DebugLinesSubsection::commit(), llvm::codeview::DebugSubsectionRecordBuilder::commit(), llvm::msf::MSFBuilder::commit(), llvm::pdb::const_iterator< SrcHeaderBlockEntry >::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), llvm::pdb::GSIHashStreamBuilder::commit(), llvm::pdb::InfoStreamBuilder::commit(), llvm::pdb::TpiStreamBuilder::commit(), commitFpm(), llvm::codeview::SimpleTypeSerializer::serialize(), and writeCString().
| Error BinaryStreamWriter::writeSLEB128 | ( | int64_t | Value | ) |
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
Definition at line 56 of file BinaryStreamWriter.cpp.
References llvm::encodeSLEB128(), llvm::Size, and writeBytes().
| Error BinaryStreamWriter::writeStreamRef | ( | BinaryStreamRef | Ref | ) |
Efficiently reads all data from 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.
Definition at line 76 of file BinaryStreamWriter.cpp.
References llvm::Ref, and writeStreamRef().
Referenced by llvm::codeview::DebugSubsectionRecordBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), llvm::pdb::TpiStreamBuilder::commit(), writeArray(), writeArray(), writeRecords(), and writeStreamRef().
| Error BinaryStreamWriter::writeStreamRef | ( | BinaryStreamRef | Ref, |
| uint64_t | Size ) |
Efficiently reads Size bytes from 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.
Definition at line 80 of file BinaryStreamWriter.cpp.
References llvm::BinaryStreamReader::bytesRemaining(), llvm::Length, llvm::BinaryStreamReader::readLongestContiguousChunk(), llvm::Ref, llvm::Error::success(), and writeBytes().
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
Definition at line 50 of file BinaryStreamWriter.cpp.
References llvm::encodeULEB128(), llvm::Size, and writeBytes().
|
protected |
Definition at line 196 of file BinaryStreamWriter.h.
Referenced by getOffset(), padToAlignment(), setOffset(), split(), and writeBytes().
|
protected |
Definition at line 195 of file BinaryStreamWriter.h.
Referenced by BinaryStreamWriter(), BinaryStreamWriter(), BinaryStreamWriter(), BinaryStreamWriter(), getLength(), split(), writeBytes(), writeInt128(), and writeInteger().