Read‐write cursor over an IOBuf chain.

Synopsis

Declared in <folly/io/Cursor.h>

template<CursorAccess access>
class RWCursor
    : public CursorBase<RWCursor<access>, IOBuf>
    , public Writable<RWCursor<access>>

Base Classes

Name

Description

CursorBase<RWCursor<access>, IOBuf>

Base class implementing the shared cursor logic over an IOBuf chain.

Writable<RWCursor<access>>

Mixin providing write operations for cursor types.

Types

Name

Description

AtEnd

Tag type selecting the constructor that starts at the end of a queue.

Member Functions

Name

Description

RWCursor [constructor]

Constructors

advanceToEnd

Advances the cursor to the end of the entire IOBuf chain.

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.

gather

Gather at least n bytes contiguously into the current buffer, by coalescing subsequent buffers from the chain as necessary.

gatherAtMost

Gather at most n bytes contiguously into the current buffer, by coalescing subsequent buffers from the chain as necessary.

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().

insert

Insert data at the cursor position.

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.

push

push overloads

pushAtMost

pushAtMost overloads

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.

writableData

Get a raw pointer to the writable section controlled by this cursor.

write

write overloads

writeBE

writeBE overloads

writeLE

writeLE overloads

operator==

Compare cursors for equality/inequality.

operator!=

Compare cursors for inequality.

Using Declarations

Name

pushAtMost

Protected Member Functions

Name

Description

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

Name

Description

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.

Friends

Name

Description

folly::io::CursorBase

Base class implementing the shared cursor logic over an IOBuf chain.

Created with MrDocs