StrIterPeekPrev
Description
Peek one position behind in the iteration direction, i.e. the character just consumed by the previous StrIterNext. IterPeekAt scales the offset by dir, so this passes a plain -1 and stays opposite of StrIterPeekNext 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 behind in the iteration direction. |
Success
*out is set to the previous 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)
- In
StrIter.c:72:
StrIterMustNext(&si); // -> 'b'
char c = 0;
if (!StrIterPeekPrev(&si, &c) || c != 'a') {
return false;
}- In
StrIter.c:95:
StrIter si = StrIterFromZstr("ab");
char c = 0x7F;
if (StrIterPeekPrev(&si, &c)) {
return false;
}
Last updated on