75class DocumentDecoderCheckpoint {
76 friend class DocumentDecoder;
79 std::uint8_t bomLength,
bool bomMismatch) noexcept
80 : options_(options), encoding_(encoding), nextOffset_(nextOffset), bomLength_(bomLength),
81 bomMismatch_(bomMismatch) {
86 std::uint64_t nextOffset_;
87 std::uint8_t bomLength_;
106 std::optional<DocumentDecoderCheckpoint>
166 std::span<const std::byte> window, std::uint64_t windowOffset,
167 std::uint64_t anchorByteOffset,
bool finalWindow =
false) noexcept;
196 DocumentDecodeResult feedImpl(std::span<const std::byte>, std::uint64_t,
bool, std::span<DecodedScalar>)
noexcept;
199 std::array<std::uint8_t, 4> pending_{};
200 std::uint64_t pendingOffset_{};
201 std::uint64_t nextOffset_{};
202 std::uint8_t pendingSize_{};
203 std::uint8_t bomLength_{};
Definition document_encoding.hpp:75
static constexpr std::size_t LOCAL_WINDOW_BYTES
Maximum original bytes admitted by localCheckpoint().
Definition document_encoding.hpp:142
DocumentEncoding encoding() const noexcept
Definition document_encoding.hpp:181
static DocumentDecoder restore(const DocumentDecoderCheckpoint &checkpoint) noexcept
static DocumentDecoderLocalResult localCheckpoint(const DocumentDecoderCheckpoint &origin, std::span< const std::byte > window, std::uint64_t windowOffset, std::uint64_t anchorByteOffset, bool finalWindow=false) noexcept
std::uint8_t bomLength() const noexcept
Definition document_encoding.hpp:186
DocumentDecoder(DocumentDecoderOptions options={}) noexcept
std::optional< DocumentDecoderCheckpoint > checkpoint() const noexcept
bool bomMismatch() const noexcept
Definition document_encoding.hpp:191
DocumentDecodeResult feed(std::span< const std::byte > input, std::uint64_t offset, bool final, std::span< DecodedScalar > output) noexcept
Public Portals API.
Definition action.hpp:8
DocumentDecodePolicy
Handling of malformed input; ESCAPE is reserved and unsupported.
Definition document_encoding.hpp:26
@ REPLACE
Emit a tagged replacement scalar for each malformed subpart.
Definition document_encoding.hpp:27
@ STRICT_MODE
Fail transactionally on malformed input.
Definition document_encoding.hpp:28
DocumentDecoderLocalStatus
Result of proving a decoded-scalar boundary from a fixed local original-byte window.
Definition document_encoding.hpp:92
@ AT_END
Confirmed EOF has no containing scalar; restartByteOffset is EOF and no checkpoint is supplied.
Definition document_encoding.hpp:94
@ NEED_PREFIX
More original bytes before the supplied local window are required to prove the boundary.
Definition document_encoding.hpp:95
@ INVALID_RANGE
Window exceeds the fixed size, overflows, contradicts BOM extent or excludes the requested anchor.
Definition document_encoding.hpp:98
@ NEED_SUFFIX
More original bytes or confirmed EOF are required to resolve the selected scalar.
Definition document_encoding.hpp:96
@ INVALID_ORIGIN
Origin metadata is unresolved, unsupported or inconsistent with a real decoder boundary.
Definition document_encoding.hpp:99
@ READY
Successful nonempty content; the reserved status strip is blank.
Definition data_presentation.hpp:12
DocumentDecodeStatus
Completion, backpressure, or typed failure of a feed call.
Definition document_encoding.hpp:33
@ OUTPUT_FULL
More output capacity is needed to continue.
Definition document_encoding.hpp:35
@ WORK_LIMIT
The input admission budget was reached.
Definition document_encoding.hpp:36
@ DONE
Confirmed end of stream was processed.
Definition document_encoding.hpp:37
@ INVALID_OFFSET
Input is noncontiguous, overflows, or follows completion.
Definition document_encoding.hpp:40
@ UNSUPPORTED_POLICY
Escape policy or zero work limit is unsupported.
Definition document_encoding.hpp:41
@ MALFORMED
Strict decoding encountered malformed input.
Definition document_encoding.hpp:38
@ NEED_INPUT
More input is needed to continue.
Definition document_encoding.hpp:34
@ ENCODING_UNRESOLVED
Neither explicit choice, BOM nor hint selected an encoding.
Definition document_encoding.hpp:39
@ REPLACE
Explicit mode only: hide the independently owned body outside READY/REFRESHING.
Definition data_presentation.hpp:65
DocumentEncoding
Resolved byte encoding, or an unresolved selection.
Definition document_encoding.hpp:14
@ UTF32LE
UTF-32, little-endian.
Definition document_encoding.hpp:19
@ UNRESOLVED
No encoding has been selected.
Definition document_encoding.hpp:15
@ WINDOWS1251
WHATWG Windows-1251.
Definition document_encoding.hpp:21
@ UTF16BE
UTF-16, big-endian.
Definition document_encoding.hpp:18
@ UTF32BE
UTF-32, big-endian.
Definition document_encoding.hpp:20
@ UTF16LE
UTF-16, little-endian.
Definition document_encoding.hpp:17
@ UTF8
UTF-8.
Definition document_encoding.hpp:16
@ WINDOWS1252
WHATWG Windows-1252.
Definition document_encoding.hpp:22
Decoded Unicode scalar with its exact interval in the original byte stream.
Definition document_encoding.hpp:45
bool replacement
True when emitted for malformed input.
Definition document_encoding.hpp:49
std::uint8_t byteLength
Length of the original byte interval.
Definition document_encoding.hpp:48
char32_t scalar
Unicode scalar value.
Definition document_encoding.hpp:46
std::uint64_t byteOffset
Start of the original byte interval.
Definition document_encoding.hpp:47
Committed feed progress or a transactional failure with its byte location.
Definition document_encoding.hpp:53
std::uint8_t errorLength
Length of the malformed interval when applicable.
Definition document_encoding.hpp:58
DocumentDecodeStatus status
Outcome of the call.
Definition document_encoding.hpp:56
std::size_t outputProduced
Output scalars committed by this call.
Definition document_encoding.hpp:55
std::uint64_t errorOffset
Start of the malformed interval when applicable.
Definition document_encoding.hpp:57
std::size_t inputConsumed
Input bytes committed by this call.
Definition document_encoding.hpp:54
Owning local proof outcome; no input view or source owner is retained.
Definition document_encoding.hpp:103
std::uint64_t restartByteOffset
Separate scalar-start projection for READY, or EOF for AT_END; never edits the anchor.
Definition document_encoding.hpp:109
DocumentDecoderLocalStatus status
Unproven default, then proof/context/error.
Definition document_encoding.hpp:104
std::uint8_t errorLength
Original-byte length of that malformed subpart, not a character count.
Definition document_encoding.hpp:111
std::optional< DocumentDecoderCheckpoint > checkpoint
Present only for READY; caller qualifies the source revision.
Definition document_encoding.hpp:107
std::uint64_t errorOffset
First byte of the selected malformed subpart for MALFORMED.
Definition document_encoding.hpp:110
Encoding selection, malformed-input policy and per-call work bound.
Definition document_encoding.hpp:62
DocumentEncoding hint
Fallback when no explicit choice or BOM exists.
Definition document_encoding.hpp:64
std::size_t workLimit
Maximum input bytes admitted per call; must be nonzero.
Definition document_encoding.hpp:66
DocumentDecodePolicy policy
Malformed-input policy.
Definition document_encoding.hpp:65
DocumentEncoding explicitEncoding
Explicit choice, if any.
Definition document_encoding.hpp:63