Defined in header <cparse/Cursor.hh>

void safeRestore() noexcept;

Same as restore() but wrapped in an exception-mask dance that lets it be called from a path where the stream is in eof or fail state:

  1. Save the current exception mask.
  2. Set the mask to std::ios_base::goodbit (no exceptions).
  3. clear() the stream state.
  4. Call restore().
  5. Reinstate the saved exception mask.

Catches every exception. If the stream cannot be recovered, the function returns silently; subsequent reads will observe that isValid() returns false.

Parameters

None.

Return value

(none)

Exceptions

noexcept. Any exception from any step is caught.

Notes

Not currently called by Parser itself, but is the correct method to call from a grammar helper that has just unwound out of an ios_base::failure and wants to resume parsing from an earlier saved point. Reserved for grammars that implement recovery beyond what the default driver provides.

See also