LLVM 20.0.0git
Public Member Functions | Friends | List of all members
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 54 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 62 of file DataExtractor.h.

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 67 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 74 of file DataExtractor.h.

References Offset.

Referenced by llvm::ELFAttributeParser::parseSubsection().

◆ takeError()

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

◆ tell()

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

Friends And Related Function Documentation

◆ DataExtractor

friend class DataExtractor
friend

Definition at line 58 of file DataExtractor.h.


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