Skip to content
StrIterPeekNext

StrIterPeekNext

Description

Peek one position ahead in the iteration direction, i.e. the character the cursor would land on after one StrIterNext step. IterPeekAt already scales the offset by dir, so this passes a plain +1 and stays direction-correct for both forward and reverse iters.

Parameters

Name Direction Description
mi in Pointer to the StrIter to peek into.
out out Destination char *; receives the character one step ahead in the iteration direction.

Success

*out is set to the next character; the cursor is not advanced; returns true.

Failure

That position is outside [0, length); *out is not written, returns false.

Usage example (Cross-references)

Usage examples (Cross-references)
        StrIter si = StrIterFromZstr("abc");
        char    c  = 0;
        if (!StrIterPeekNext(&si, &c) || c != 'b') {
            return false;
        }
        StrIterMustNext(&si); // -> 'b' (last)
        char c = 0x7F;
        if (StrIterPeekNext(&si, &c)) {
            return false;
        }
Last updated on