Defined in header <cparse/Cursor.hh>
void restore();
Seeks the underlying stream back to the position most recently recorded by store(). If store() recorded that the position was at end-of-file, restore() seeks to std::ios::end and performs one get() to arm the eof state.
Does not clear the stream state. If the stream is currently in eof or fail state — which it will be after the exception that brought the parser here — the seek may not have the effect you expect, because further reads will still see the error bits set. Use safeRestore() after an EOF exception unwinds.
Parameters
None.
Return value
(none)
Exceptions
May throw subject to the underlying stream's exception mask. The constructors set the mask to throw on failbit | eofbit | badbit, so restore() will throw if the seek itself fails or if the stream is already in an error state that the seek does not clear.
Notes
The typical caller is Parser::restoreCursor() during a backtracking extractToken attempt — a path on which the stream state is known to be clean.
The path that goes through an EOF exception should call safeRestore() instead, which temporarily disables the exception mask, clears the stream, restores, and reinstates the mask.
See also
- Cursor::store — record the position to be restored.
- Cursor::safeRestore — restore across an EOF unwind.

