endSequenceKeep method

void endSequenceKeep()

Closes the current sequence, keeping its frame even when it received no content.

Behaves like a write: it first emits any held-back headers — this frame's and every enclosing one's — and then the end marker, so a contentless sequence still reaches the wire as begin + end.

Required wherever the frame carries information beyond its contents:

  • a wrapper-array element (struct/union/nested row): element presence is what carries a dynamic array's length — *highest present id
    • 1* (MESSAGE_SPEC §5.1) — so dropping an all-default element would change the decoded length, not just the bytes;
  • an array field already known to differ from a non-empty declared default: absence would reconstruct that default, so the empty frame is the only encoding of "explicitly empty" (MESSAGE_SPEC §2, §3).

The two failure directions are not symmetric, which is why this is the safe choice when in doubt: using it where endSequence would do costs one non-canonical empty frame that every decoder normalizes away, while the reverse silently changes an array's length.

Implementation

void endSequenceKeep() {
  if (_nPendingSeq != 0) _commitPendingSequences();
  _writeByte(0x07);
  if (_depth > 0) _depth--;
}