LLVM: llvm::BinaryStreamReader Class Reference (original) (raw)
Provides read only access to a subclass of BinaryStream. More...
#include "[llvm/Support/BinaryStreamReader.h](BinaryStreamReader%5F8h%5Fsource.html)"
| Public Member Functions | |
|---|---|
| BinaryStreamReader ()=default | |
| LLVM_ABI | BinaryStreamReader (BinaryStreamRef Ref) |
| LLVM_ABI | BinaryStreamReader (BinaryStream &Stream) |
| LLVM_ABI | BinaryStreamReader (ArrayRef< uint8_t > Data, llvm::endianness Endian) |
| LLVM_ABI | BinaryStreamReader (StringRef Data, llvm::endianness Endian) |
| BinaryStreamReader (const BinaryStreamReader &Other)=default | |
| BinaryStreamReader & | operator= (const BinaryStreamReader &Other)=default |
| virtual | ~BinaryStreamReader ()=default |
| LLVM_ABI Error | readLongestContiguousChunk (ArrayRef< uint8_t > &Buffer) |
| Read as much as possible from the underlying string at the current offset without invoking a copy, and set Buffer to the resulting data slice. | |
| LLVM_ABI Error | readBytes (ArrayRef< uint8_t > &Buffer, uint32_t Size) |
| Read Size bytes from the underlying stream at the current offset and and set Buffer to the resulting data slice. | |
| template<typename T> | |
| Error | readInteger (T &Dest) |
| Read an integer of the specified endianness into Dest and update the stream's offset. | |
| template<typename T> | |
| Error | readEnum (T &Dest) |
| Similar to readInteger. | |
| LLVM_ABI Error | readULEB128 (uint64_t &Dest) |
| Read an unsigned LEB128 encoded value. | |
| LLVM_ABI Error | readSLEB128 (int64_t &Dest) |
| Read a signed LEB128 encoded value. | |
| LLVM_ABI Error | readCString (StringRef &Dest) |
| Read a null terminated string from Dest. | |
| LLVM_ABI Error | readWideString (ArrayRef< UTF16 > &Dest) |
| Similar to readCString, however read a null-terminated UTF16 string instead. | |
| LLVM_ABI Error | readFixedString (StringRef &Dest, uint32_t Length) |
| Read a Length byte string into Dest. | |
| LLVM_ABI Error | readStreamRef (BinaryStreamRef &Ref) |
| Read the entire remainder of the underlying stream into Ref. | |
| LLVM_ABI Error | readStreamRef (BinaryStreamRef &Ref, uint32_t Length) |
| Read Length bytes from the underlying stream into Ref. | |
| LLVM_ABI Error | readSubstream (BinarySubstreamRef &Ref, uint32_t Length) |
| Read Length bytes from the underlying stream into Ref. | |
| template<typename T> | |
| Error | readObject (const T *&Dest) |
| Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the result into Dest. | |
| template<typename T> | |
| Error | readArray (ArrayRef< T > &Array, uint32_t NumElements) |
| Get a reference to a NumElements element array of objects of type T from the underlying stream as if by memcpy, and store the resulting array slice into array. | |
| template<typename T, typename U> | |
| Error | readArray (VarStreamArray< T, U > &Array, uint32_t Size, uint32_t Skew=0) |
| Read a VarStreamArray of size Size bytes and store the result into Array. | |
| template<typename T> | |
| Error | readArray (FixedStreamArray< T > &Array, uint32_t NumItems) |
| Read a FixedStreamArray of NumItems elements and store the result into Array. | |
| bool | empty () const |
| void | setOffset (uint64_t Off) |
| uint64_t | getOffset () const |
| uint64_t | getLength () const |
| uint64_t | bytesRemaining () const |
| LLVM_ABI Error | skip (uint64_t Amount) |
| Advance the stream's offset by Amount bytes. | |
| LLVM_ABI uint8_t | peek () const |
| Examine the next byte of the underlying stream without advancing the stream's offset. | |
| LLVM_ABI Error | padToAlignment (uint32_t Align) |
| LLVM_ABI std::pair< BinaryStreamReader, BinaryStreamReader > | split (uint64_t Offset) const |
Provides read only access to a subclass of BinaryStream.
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 of custom datatypes, although no are overridable.
Definition at line 30 of file BinaryStreamReader.h.
| llvm::BinaryStreamReader::BinaryStreamReader ( ) | default |
|---|
◆ BinaryStreamReader() [2/6]
◆ BinaryStreamReader() [3/6]
| BinaryStreamReader::BinaryStreamReader ( BinaryStream & Stream) | explicit |
|---|
◆ BinaryStreamReader() [4/6]
◆ BinaryStreamReader() [5/6]
◆ BinaryStreamReader() [6/6]
◆ ~BinaryStreamReader()
| virtual llvm::BinaryStreamReader::~BinaryStreamReader ( ) | virtualdefault |
|---|
◆ bytesRemaining()
| uint64_t llvm::BinaryStreamReader::bytesRemaining ( ) const | inline |
|---|
Definition at line 250 of file BinaryStreamReader.h.
References getLength(), and getOffset().
Referenced by llvm::codeview::consume(), llvm::codeview::consume(), llvm::codeview::serialize_arrayref_tail_impl< T >::deserialize(), empty(), llvm::pdb::LinePrinter::formatMsfStreamData(), llvm::CodeViewYAML::fromDebugH(), llvm::CodeViewYAML::fromDebugS(), llvm::CodeViewYAML::fromDebugT(), llvm::pdb::PDBFile::getStringTable(), llvm::codeview::DebugChecksumsSubsectionRef::initialize(), llvm::codeview::DebugCrossModuleExportsSubsectionRef::initialize(), llvm::codeview::DebugCrossModuleImportsSubsectionRef::initialize(), llvm::codeview::DebugFrameDataSubsectionRef::initialize(), llvm::codeview::DebugInlineeLinesSubsectionRef::initialize(), llvm::codeview::DebugLinesSubsectionRef::initialize(), llvm::codeview::DebugSymbolRVASubsectionRef::initialize(), isCodeViewDebugSubsection(), isDebugSSection(), isDebugTSection(), loadSectionContribs(), llvm::pdb::PDBFile::parseFileHeaders(), llvm::pdb::PDBFile::parseStreamData(), readStreamRef(), readStreamRef(), llvm::pdb::DbiStream::reload(), llvm::pdb::InjectedSourceStream::reload(), llvm::pdb::ModuleDebugStreamRef::reload(), llvm::pdb::PDBStringTable::reload(), llvm::pdb::PublicsStream::reload(), llvm::pdb::TpiStream::reload(), llvm::codeview::LazyRandomTypeCollection::reset(), skip(), and llvm::BinaryStreamWriter::writeStreamRef().
◆ empty()
| bool llvm::BinaryStreamReader::empty ( ) const | inline |
|---|
◆ getLength()
| uint64_t llvm::BinaryStreamReader::getLength ( ) const | inline |
|---|
◆ getOffset()
| uint64_t llvm::BinaryStreamReader::getOffset ( ) const | inline |
|---|
◆ operator=()
◆ padToAlignment()
◆ peek()
| uint8_t BinaryStreamReader::peek | ( | ) | const |
|---|
◆ readArray() [1/3]
Get a reference to a NumElements element array of objects of type T from the underlying stream as if by memcpy, and store the resulting array slice into array.
It is up to the caller to ensure that objects of type T can be safely treated in this manner. Updates the stream's offset to point after the newly read object. Whether a copy occurs depends upon the implementation of the underlying stream.
Returns
a success error code if the data was successfully read, otherwise returns an appropriate error code.
Definition at line 180 of file BinaryStreamReader.h.
References assert(), llvm::ArrayRef< T >::data(), llvm::invalid_array_size, llvm::isAddrAligned(), llvm::make_error(), llvm::Align::Of(), readBytes(), llvm::Error::success(), and T.
Referenced by llvm::codeview::serialize_array_impl< T, U >::deserialize(), llvm::codeview::serialize_arrayref_tail_impl< T >::deserialize(), llvm::CodeViewYAML::fromDebugS(), llvm::CodeViewYAML::fromDebugT(), llvm::codeview::DebugChecksumsSubsectionRef::initialize(), llvm::codeview::DebugCrossModuleExportsSubsectionRef::initialize(), llvm::codeview::DebugCrossModuleImportsSubsectionRef::initialize(), llvm::codeview::DebugFrameDataSubsectionRef::initialize(), llvm::codeview::DebugInlineeLinesSubsectionRef::initialize(), llvm::codeview::DebugLinesSubsectionRef::initialize(), llvm::codeview::DebugSymbolRVASubsectionRef::initialize(), llvm::codeview::DebugSymbolsSubsectionRef::initialize(), isDebugSSection(), isDebugTSection(), loadSectionContribs(), llvm::codeview::LineColumnExtractor::operator()(), llvm::pdb::PDBFile::parseFileHeaders(), llvm::pdb::PDBFile::parseStreamData(), readGSIHashBuckets(), readGSIHashRecords(), readWideString(), llvm::pdb::DbiStream::reload(), llvm::pdb::PublicsStream::reload(), llvm::pdb::SymbolStream::reload(), llvm::pdb::TpiStream::reload(), llvm::codeview::LazyRandomTypeCollection::reset(), and resolveTypeIndexReferences().
◆ readArray() [2/3]
◆ readArray() [3/3]
template<typename T, typename U>
Read a VarStreamArray of size Size bytes and store the result into Array.
Updates the stream's offset to point after the newly read array. Never causes a copy (although iterating the elements of the VarStreamArray may, depending upon the implementation of the underlying stream).
Returns
a success error code if the data was successfully read, otherwise returns an appropriate error code.
Definition at line 210 of file BinaryStreamReader.h.
References readStreamRef(), Size, and llvm::Error::success().
◆ readBytes()
Read Size bytes from the underlying stream at the current offset and and set Buffer to the resulting data slice.
Whether a copy occurs depends on the implementation of the underlying stream. Updates the stream's offset to point after the newly read data.
Returns
a success error code if the data was successfully read, otherwise returns an appropriate error code.
Definition at line 36 of file BinaryStreamReader.cpp.
References Size, and llvm::Error::success().
Referenced by llvm::pdb::LinePrinter::formatMsfStreamData(), llvm::CodeViewYAML::fromDebugH(), llvm::VarStreamArrayExtractor< T >::operator()(), llvm::pdb::PDBFile::parseFileHeaders(), readArray(), llvm::codeview::readCVRecordFromStream(), readFixedString(), readInteger(), readObject(), readSLEB128(), and readULEB128().
◆ readCString()
Read a null terminated string from Dest.
Whether a copy occurs depends on the implementation of the underlying stream. Updates the stream's offset to point after the newly read data.
Returns
a success error code if the data was successfully read, otherwise returns an appropriate error code.
Definition at line 73 of file BinaryStreamReader.cpp.
References assert(), llvm::ArrayRef< T >::begin(), llvm::StringRef::find_first_of(), getOffset(), llvm::Length, LLVM_LIKELY, llvm::StringRef::npos, readFixedString(), readLongestContiguousChunk(), setOffset(), llvm::ArrayRef< T >::size(), and llvm::Error::success().
Referenced by llvm::codeview::consume(), llvm::codeview::serialize_null_term_string_array_impl::deserialize(), llvm::pdb::DbiModuleList::getFileName(), llvm::codeview::DebugStringTableSubsectionRef::getString(), and llvm::pdb::DbiModuleDescriptor::initialize().
◆ readEnum()
template<typename T>
| Error llvm::BinaryStreamReader::readEnum ( T & Dest) | inline |
|---|
◆ readFixedString()
◆ readInteger()
template<typename T>
| Error llvm::BinaryStreamReader::readInteger ( T & Dest) | inline |
|---|
Read an integer of the specified endianness into Dest and update the stream's offset.
The data is always copied from the stream's underlying buffer into Dest. Updates the stream's offset to point after the newly read data.
Returns
a success error code if the data was successfully read, otherwise returns an appropriate error code.
Definition at line 69 of file BinaryStreamReader.h.
References llvm::ArrayRef< T >::data(), llvm::support::endian::read(), readBytes(), llvm::Error::success(), and T.
Referenced by llvm::codeview::consume(), llvm::codeview::consume(), llvm::codeview::consume(), llvm::CodeViewYAML::fromDebugH(), llvm::CodeViewYAML::fromDebugS(), llvm::CodeViewYAML::fromDebugT(), isCodeViewDebugSubsection(), llvm::pdb::const_iterator< SrcHeaderBlockEntry >::load(), llvm::pdb::NamedStreamMap::load(), llvm::pdb::PDBFile::parseStreamData(), llvm::object::OffloadBundleFatBin::readEntries(), readEnum(), llvm::pdb::readSparseBitVector(), and llvm::object::readStringOrId().
◆ readLongestContiguousChunk()
◆ readObject()
template<typename T>
| Error llvm::BinaryStreamReader::readObject ( const T *& Dest) | inline |
|---|
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the result into Dest.
It is up to the caller to ensure that objects of type T can be safely treated in this manner. Updates the stream's offset to point after the newly read object. Whether a copy occurs depends upon the implementation of the underlying stream.
Returns
a success error code if the data was successfully read, otherwise returns an appropriate error code.
Definition at line 162 of file BinaryStreamReader.h.
References llvm::ArrayRef< T >::data(), readBytes(), llvm::Error::success(), and T.
Referenced by llvm::codeview::consume(), llvm::codeview::DebugFrameDataSubsectionRef::initialize(), llvm::codeview::DebugLinesSubsectionRef::initialize(), llvm::codeview::DebugSubsectionRecord::initialize(), llvm::pdb::DbiModuleDescriptor::initialize(), llvm::pdb::const_iterator< SrcHeaderBlockEntry >::load(), llvm::codeview::LineColumnExtractor::operator()(), llvm::VarStreamArrayExtractor< T >::operator()(), llvm::pdb::PDBFile::parseFileHeaders(), llvm::codeview::readCVRecordFromStream(), readGSIHashHeader(), readWideString(), llvm::pdb::DbiStream::reload(), llvm::pdb::InfoStream::reload(), llvm::pdb::InjectedSourceStream::reload(), llvm::pdb::PublicsStream::reload(), and llvm::pdb::TpiStream::reload().
◆ readSLEB128()
| Error BinaryStreamReader::readSLEB128 | ( | int64_t & | Dest | ) |
|---|
◆ readStreamRef() [1/2]
◆ readStreamRef() [2/2]
◆ readSubstream()
◆ readULEB128()
◆ readWideString()
◆ setOffset()
| void llvm::BinaryStreamReader::setOffset ( uint64_t Off) | inline |
|---|
◆ skip()
◆ split()
The documentation for this class was generated from the following files:
- include/llvm/Support/BinaryStreamReader.h
- lib/Support/BinaryStreamReader.cpp