LLVM
8.0.1
|
Provides write only access to a subclass of WritableBinaryStream
.
More...
#include "llvm/Support/BinaryStreamWriter.h"
Public Member Functions | |
BinaryStreamWriter ()=default | |
BinaryStreamWriter (WritableBinaryStreamRef Ref) | |
BinaryStreamWriter (WritableBinaryStream &Stream) | |
BinaryStreamWriter (MutableArrayRef< uint8_t > Data, llvm::support::endianness Endian) | |
BinaryStreamWriter (const BinaryStreamWriter &Other) | |
BinaryStreamWriter & | operator= (const BinaryStreamWriter &Other) |
virtual | ~BinaryStreamWriter () |
Error | writeBytes (ArrayRef< uint8_t > Buffer) |
Write the bytes specified in Buffer to the underlying stream. More... | |
template<typename T > | |
Error | writeInteger (T Value) |
Write the integer Value to the underlying stream in the specified endianness. More... | |
template<typename T > | |
Error | writeEnum (T Num) |
Similar to writeInteger. More... | |
Error | writeCString (StringRef Str) |
Write the string Str to the underlying stream followed by a null terminator. More... | |
Error | writeFixedString (StringRef Str) |
Write the string Str to the underlying stream without a null terminator. More... | |
Error | writeStreamRef (BinaryStreamRef Ref) |
Efficiently reads all data from Ref , and writes it to this stream. More... | |
Error | writeStreamRef (BinaryStreamRef Ref, uint32_t Size) |
Efficiently reads Size bytes from Ref , and writes it to this stream. More... | |
template<typename T > | |
Error | writeObject (const T &Obj) |
Writes the object Obj to the underlying stream, as if by using memcpy. More... | |
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. More... | |
template<typename T , typename U > | |
Error | writeArray (VarStreamArray< T, U > Array) |
Writes all data from the array Array to the underlying stream. More... | |
template<typename T > | |
Error | writeArray (FixedStreamArray< T > Array) |
Writes all elements from the array Array to the underlying stream. More... | |
std::pair< BinaryStreamWriter, BinaryStreamWriter > | split (uint32_t Off) const |
Splits the Writer into two Writers at a given offset. More... | |
void | setOffset (uint32_t Off) |
uint32_t | getOffset () const |
uint32_t | getLength () const |
uint32_t | bytesRemaining () const |
Error | padToAlignment (uint32_t Align) |
Protected Attributes | |
WritableBinaryStreamRef | Stream |
uint32_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 32 of file BinaryStreamWriter.h.
|
default |
|
explicit |
Definition at line 18 of file BinaryStreamWriter.cpp.
|
explicit |
Definition at line 21 of file BinaryStreamWriter.cpp.
|
explicit |
Definition at line 24 of file BinaryStreamWriter.cpp.
|
inline |
Definition at line 40 of file BinaryStreamWriter.h.
|
inlinevirtual |
Definition at line 49 of file BinaryStreamWriter.h.
References writeBytes().
|
inline |
Definition at line 173 of file BinaryStreamWriter.h.
References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, getLength(), getOffset(), and padToAlignment().
Referenced by llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), commitFpm(), llvm::msf::WritableMappedBlockStream::createFpmStream(), llvm::pdb::PDBFileBuilder::getNamedStreamIndex(), llvm::pdb::DbiStreamBuilder::getSourceFileNameIndex(), llvm::pdb::PDBStringTableBuilder::setStrings(), and llvm::codeview::ContinuationRecordBuilder::writeMemberType().
|
inline |
Definition at line 172 of file BinaryStreamWriter.h.
References llvm::BinaryStream::getLength().
Referenced by llvm::codeview::ContinuationRecordBuilder::begin(), bytesRemaining(), padToAlignment(), split(), and llvm::codeview::ContinuationRecordBuilder::writeMemberType().
|
inline |
Definition at line 171 of file BinaryStreamWriter.h.
References Offset.
Referenced by addPadding(), llvm::codeview::ContinuationRecordBuilder::begin(), bytesRemaining(), llvm::codeview::DebugSubsectionRecordBuilder::commit(), llvm::codeview::DebugStringTableSubsection::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::pdb::DbiStreamBuilder::getSourceFileNameIndex(), llvm::codeview::SimpleTypeSerializer::serialize(), llvm::codeview::SymbolSerializer::visitSymbolEnd(), and llvm::codeview::ContinuationRecordBuilder::writeMemberType().
|
inline |
Definition at line 43 of file BinaryStreamWriter.h.
Definition at line 83 of file BinaryStreamWriter.cpp.
References llvm::alignTo(), getLength(), Offset, llvm::stream_too_short, llvm::Error::success(), and writeInteger().
Referenced by bytesRemaining(), llvm::codeview::DebugSubsectionRecordBuilder::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::codeview::DebugChecksumsSubsection::commit(), llvm::pdb::DbiStreamBuilder::getSourceFileNameIndex(), and llvm::codeview::CodeViewRecordIO::padToAlignment().
|
inline |
Definition at line 170 of file BinaryStreamWriter.h.
References Offset.
Referenced by llvm::codeview::ContinuationRecordBuilder::begin(), llvm::msf::MSFBuilder::commit(), llvm::codeview::SymbolSerializer::visitSymbolBegin(), llvm::codeview::SymbolSerializer::visitSymbolEnd(), and llvm::codeview::ContinuationRecordBuilder::writeMemberType().
std::pair< BinaryStreamWriter, BinaryStreamWriter > BinaryStreamWriter::split | ( | uint32_t | Off | ) | const |
Splits the Writer into two Writers at a given offset.
Definition at line 71 of file BinaryStreamWriter.cpp.
References assert(), llvm::BinaryStreamRefBase< RefType, StreamType >::drop_front(), getLength(), llvm::BinaryStreamRefBase< RefType, StreamType >::keep_front(), Offset, and Stream.
Referenced by llvm::pdb::PDBStringTableBuilder::commit(), and writeArray().
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 138 of file BinaryStreamWriter.h.
References llvm::ArrayRef< T >::data(), llvm::ArrayRef< T >::empty(), llvm::invalid_array_size, llvm::ArrayRef< T >::size(), llvm::Error::success(), T, and writeBytes().
Referenced by llvm::pdb::DbiStreamBuilder::addDbgStream(), llvm::codeview::DebugFrameDataSubsection::commit(), llvm::codeview::DebugSymbolRVASubsection::commit(), llvm::pdb::GSIHashStreamBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), llvm::codeview::DebugCrossModuleImportsSubsection::commit(), llvm::codeview::DebugChecksumsSubsection::commit(), llvm::codeview::DebugInlineeLinesSubsection::commit(), llvm::msf::MSFBuilder::commit(), llvm::codeview::DebugLinesSubsection::commit(), llvm::pdb::DbiStreamBuilder::finalizeMsfLayout(), llvm::pdb::PDBStringTableBuilder::setStrings(), and writeRecords().
|
inline |
Writes all data from the array Array
to the underlying stream.
Definition at line 155 of file BinaryStreamWriter.h.
References llvm::VarStreamArray< ValueType, Extractor >::getUnderlyingStream(), and writeStreamRef().
|
inline |
Writes all elements from the array Array
to the underlying stream.
Definition at line 163 of file BinaryStreamWriter.h.
References llvm::FixedStreamArray< T >::getUnderlyingStream(), split(), and 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, llvm::Error::success(), and llvm::WritableBinaryStreamRef::writeBytes().
Referenced by llvm::codeview::DebugSymbolsSubsection::commit(), llvm::pdb::PDBFileBuilder::commit(), llvm::pdb::TpiStreamBuilder::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::msf::WritableMappedBlockStream::createFpmStream(), llvm::pdb::PDBFileBuilder::getNamedStreamIndex(), llvm::codeview::CodeViewRecordIO::mapByteVectorTail(), llvm::codeview::CodeViewRecordIO::mapGuid(), writeArray(), writeFixedString(), writeInteger(), writeObject(), writeStreamRef(), and ~BinaryStreamWriter().
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 35 of file BinaryStreamWriter.cpp.
References llvm::Error::success(), writeFixedString(), and writeObject().
Referenced by llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::pdb::DbiStreamBuilder::getSourceFileNameIndex(), llvm::codeview::CodeViewRecordIO::mapStringZ(), and writeEnum().
Similar to writeInteger.
Definition at line 75 of file BinaryStreamWriter.h.
References Size, writeCString(), writeFixedString(), and writeStreamRef().
Referenced by llvm::pdb::DbiStreamBuilder::commit(), llvm::codeview::DebugInlineeLinesSubsection::commit(), and llvm::codeview::ContinuationRecordBuilder::writeMemberType().
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 44 of file BinaryStreamWriter.cpp.
References llvm::arrayRefFromStringRef(), and writeBytes().
Referenced by llvm::pdb::NamedStreamMap::commit(), writeCString(), and writeEnum().
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 65 of file BinaryStreamWriter.h.
References llvm::BinaryStream::getEndian(), T, and writeBytes().
Referenced by addPadding(), llvm::pdb::NamedStreamMap::commit(), llvm::codeview::DebugFrameDataSubsection::commit(), llvm::codeview::DebugCrossModuleExportsSubsection::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), llvm::codeview::DebugInlineeLinesSubsection::commit(), llvm::msf::MSFBuilder::commit(), llvm::pdb::HashTable< llvm::pdb::SrcHeaderBlockEntry, llvm::pdb::StringTableHashTraits >::commit(), llvm::pdb::DbiStreamBuilder::getSourceFileNameIndex(), llvm::codeview::CodeViewRecordIO::mapInteger(), llvm::codeview::CodeViewRecordIO::mapStringZVectorZ(), llvm::codeview::CodeViewRecordIO::mapVectorN(), padToAlignment(), llvm::pdb::PDBStringTableBuilder::setStrings(), llvm::codeview::SymbolSerializer::visitSymbolEnd(), 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 122 of file BinaryStreamWriter.h.
References writeBytes().
Referenced by llvm::codeview::ContinuationRecordBuilder::begin(), llvm::pdb::GSIHashStreamBuilder::commit(), llvm::pdb::TpiStreamBuilder::commit(), llvm::codeview::DebugSubsectionRecordBuilder::commit(), llvm::pdb::DbiModuleDescriptorBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), llvm::codeview::DebugCrossModuleImportsSubsection::commit(), llvm::codeview::DebugChecksumsSubsection::commit(), llvm::codeview::DebugInlineeLinesSubsection::commit(), llvm::msf::MSFBuilder::commit(), llvm::codeview::DebugLinesSubsection::commit(), llvm::pdb::HashTable< llvm::pdb::SrcHeaderBlockEntry, llvm::pdb::StringTableHashTraits >::commit(), commitFpm(), llvm::pdb::PDBFileBuilder::getNamedStreamIndex(), llvm::codeview::CodeViewRecordIO::mapObject(), llvm::pdb::PDBStringTableBuilder::setStrings(), writeCString(), writeRecordPrefix(), and writeRecords().
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 49 of file BinaryStreamWriter.cpp.
References llvm::BinaryStreamRefBase< RefType, StreamType >::getLength().
Referenced by llvm::pdb::TpiStreamBuilder::commit(), llvm::codeview::DebugSubsectionRecordBuilder::commit(), llvm::pdb::DbiStreamBuilder::commit(), writeArray(), writeEnum(), and writeRecords().
Error BinaryStreamWriter::writeStreamRef | ( | BinaryStreamRef | Ref, |
uint32_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 53 of file BinaryStreamWriter.cpp.
References llvm::BinaryStreamRefBase< RefType, StreamType >::slice(), llvm::Error::success(), and writeBytes().
|
protected |
Definition at line 178 of file BinaryStreamWriter.h.
Referenced by getOffset(), operator=(), padToAlignment(), setOffset(), split(), and writeBytes().
|
protected |
Definition at line 177 of file BinaryStreamWriter.h.
Referenced by operator=(), split(), and writeBytes().