Defined in header <cparse/Cursor.hh>

void store() noexcept;

Records the underlying stream's current position (tellg()) into the cursor's internal position member for a later restore(). Line and column values are not stored separately here — they are part of the cursor object itself and are captured whenever the cursor is copied.

If tellg() throws or reports failure, the cursor sets an internal "position is end-of-file" flag; a subsequent restore() will seek to end-of-file rather than to a specific offset.

Parameters

None.

Return value

(none)

Exceptions

noexcept. Any exception from tellg() is caught internally; the cursor records the "position is EOF" flag instead.

Notes

Called internally by the constructors after opening the stream, and by rewind() after seeking to zero. Parser::storeCursor() calls store() on the active cursor before returning a reference to it.

Grammars rarely call store() directly. The idiomatic backtracking pattern uses cursor copy for save and cursor assign + restore for restore:

Cursor snapshot = getCursor();   // captures current line/column/position
if (!tryConsumeAlternative())
{
    getCursor() = snapshot;      // reassign
    getCursor().restore();       // seek stream back
}

See also