folly::io::Cursor

Read-only cursor over an IOBuf chain.

Synopsis

Declared in <folly/io/Cursor.h>

class Cursor
    : public CursorBase<Cursor, IOBuf const>

Base Classes

NameDescription
CursorBase<Cursor, IOBuf const>Base class implementing the shared cursor logic over an IOBuf chain.

Member Functions

NameDescription
Cursor [constructor]Constructors
advanceToEnd Advances the cursor to the end of the entire IOBuf chain.
borrow Borrow a ThinCursor pointing at the current position.
canAdvance Return true if the cursor could advance the specified number of bytes from its current position.
clone Clone len bytes from this cursor into an IOBuf.
cloneAtMost Clone at most len bytes from this cursor into an IOBuf.
currentBuffer Get the buffer in the IOBuf chain this Cursor currently points into.
data Get the data at the current cursor position.
getCurrentPosition Get the current Cursor position relative to the head of IOBuf chain.
getPositionInCurrentBuffer Get the Cursor position relative to the IOBuf chain's currentBuffer().
isAtEnd Return true if the cursor is at the end of the entire IOBuf chain.
isBounded Check if this cursor has a size limit imposed on it.
length Return the remaining space available in the current IOBuf.
operator+ Get a new cursor, advanced by offset from this cursor.
operator+= Advance the cursor
operator- Subtraction operators
operator-= Retreat the cursor
peek Alternate version of peekBytes() that returns a std::span instead of a ByteRage.
peekBytes Return the available data in the current IOBuf.
pull Copies len bytes from the cursor.
pullAtMost Copies at most len bytes from the cursor.
read Read a value from the cursor.
readBE Read a Big-Endian integral from the cursor.
readFixedString Read a fixed-length string.
readLE Read a Little-Endian integral from the cursor.
readTerminatedString Read a string of bytes until the given terminator character is seen.
readWhile readWhile overloads
reset Reset cursor to point to a new buffer.
retreat Retreat the cursor by at most len bytes.
retreatAtMost Retreat the cursor by at most len bytes.
skip Advance the cursor by len bytes.
skipAtMost Advance the cursor by at most len bytes.
skipNoAdvance Skip bytes in the current IOBuf without advancing to the next one.
skipWhile Skip bytes until the specified predicate returns true.
totalLength Return the space available until the end of the entire IOBuf chain.
tryRead Attempt to read from the cursor.
tryReadBE Attempt to read a Big-Endian integral from the cursor.
tryReadLE Attempt to read a Little-Endian integral from the cursor.
unborrow Return a borrowed ThinCursor, syncing this cursor to its position.
operator== Compare cursors for equality/inequality.
operator!= Compare cursors for inequality.

Protected Member Functions

NameDescription
operator= Assignment operators
advanceBufferIfEmpty Advance to the next buffer if the current one is exhausted.
borrowed Get the borrow-tracking flag, or nullptr when borrow checking is disabled.
dcheckIntegrity Assert in debug builds that the cursor's internal pointers are consistent.
head Get the head buffer of the IOBuf chain.
tryAdvanceBuffer Advance to the next buffer in the chain, if any.
tryRetreatBuffer Retreat to the previous buffer in the chain, if any.

Protected Data Members

NameDescription
absolutePos_ The absolute offset of the current buffer's start within the chain.
buffer_ The head buffer of the IOBuf chain.
crtBegin_ The start of the data in the current buffer.
crtBuf_ The buffer in the chain the cursor currently points into.
crtEnd_ One past the last readable byte in the current buffer.
crtPos_ The current cursor position within the current buffer.
remainingLen_ The number of bytes remaining beyond the current buffer for bounded cursors.