LLVM 22.0.0git
llvm::DataExtractor::Cursor Class Reference

A class representing a position in a DataExtractor, as well as any error encountered during extraction. More...

#include "llvm/Support/DataExtractor.h"

Public Member Functions

 Cursor (uint64_t Offset)
 Construct a cursor for extraction from the given offset.
 operator bool ()
 Checks whether the cursor is valid (i.e.
uint64_t tell () const
 Return the current position of this Cursor.
void seek (uint64_t NewOffSet)
 Set the cursor to the new offset. This does not impact the error state.
Error takeError ()
 Return error contained inside this Cursor, if any.

Friends

class DataExtractor

Detailed Description

A class representing a position in a DataExtractor, as well as any error encountered during extraction.

It enables one to extract a sequence of values without error-checking and then checking for errors in bulk at the end. The class holds an Error object, so failing to check the result of the parse will result in a runtime error. The error flag is sticky and will cause all subsequent extraction functions to fail without even attempting to parse and without updating the Cursor offset. After clearing the error flag, one can again use the Cursor object for parsing.

Definition at line 55 of file DataExtractor.h.

Constructor & Destructor Documentation

◆ Cursor()

llvm::DataExtractor::Cursor::Cursor ( uint64_t Offset)
inlineexplicit

Construct a cursor for extraction from the given offset.

Definition at line 63 of file DataExtractor.h.

References llvm::success().

Member Function Documentation

◆ operator bool()

llvm::DataExtractor::Cursor::operator bool ( )
inlineexplicit

Checks whether the cursor is valid (i.e.

no errors were encountered). In case of errors, this does not clear the error flag – one must call takeError() instead.

Definition at line 68 of file DataExtractor.h.

◆ seek()

void llvm::DataExtractor::Cursor::seek ( uint64_t NewOffSet)
inline

Set the cursor to the new offset. This does not impact the error state.

Definition at line 75 of file DataExtractor.h.

◆ takeError()

Error llvm::DataExtractor::Cursor::takeError ( )
inline

Return error contained inside this Cursor, if any.

Clears the internal Cursor state.

Definition at line 79 of file DataExtractor.h.

Referenced by llvm::object::ELFFile< ELFT >::android_relas(), decodeBBAddrMapImpl(), llvm::object::decodeCrel(), and llvm::DWARFDebugLine::LineTable::parse().

◆ tell()

uint64_t llvm::DataExtractor::Cursor::tell ( ) const
inline

Return the current position of this Cursor.

In the error state this is the position of the Cursor before the first error was encountered.

Definition at line 72 of file DataExtractor.h.

Referenced by decodeBBAddrMapImpl(), llvm::GCOVFile::readGCDA(), llvm::GCOVFile::readGCNO(), and readULEB128As().

◆ DataExtractor

friend class DataExtractor
friend

Definition at line 59 of file DataExtractor.h.

References DataExtractor.

Referenced by DataExtractor.


The documentation for this class was generated from the following file: