|
Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
|
#include <document_encoding.hpp>
Public Member Functions | |
| DocumentDecoder (DocumentDecoderOptions options={}) noexcept | |
| std::optional< DocumentDecoderCheckpoint > | checkpoint () const noexcept |
| DocumentDecodeResult | feed (std::span< const std::byte > input, std::uint64_t offset, bool final, std::span< DecodedScalar > output) noexcept |
| DocumentEncoding | encoding () const noexcept |
| std::uint8_t | bomLength () const noexcept |
| bool | bomMismatch () const noexcept |
Static Public Member Functions | |
| 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 |
Static Public Attributes | |
| static constexpr std::size_t | LOCAL_WINDOW_BYTES = 8 |
| Maximum original bytes admitted by localCheckpoint(). | |
Incrementally decode a single contiguous stream beginning at byte zero.
The caller owns input and output and may discard them on return. The decoder retains at most four input bytes and is not safe for concurrent access. Offsets must equal the starting offset plus inputConsumed from prior successful calls. The starting offset is zero for a new decoder or the checkpoint offset on restore. final denotes confirmed EOF, not temporary absence of bytes. A matching BOM at byte zero is omitted and reported by bomLength(); a conflicting BOM is retained as input and reported by bomMismatch(). The explicit choice takes precedence over a BOM, followed by the hint. No selection is an error.
NEED_INPUT requests another chunk; OUTPUT_FULL requests output space; WORK_LIMIT requests another call with the unconsumed suffix; DONE marks EOF. These statuses commit state and report consumed/produced counts. MALFORMED, ENCODING_UNRESOLVED, INVALID_OFFSET and UNSUPPORTED_POLICY leave state unchanged, return zero counts and invalidate output written during that call. STRICT_MODE reports the first malformed span; REPLACE emits U+FFFD tagged as replacement. ESCAPE and a zero work limit are unsupported. A zero-capacity output may return OUTPUT_FULL after buffering a bounded BOM prefix.
Each scalar retains its original byte interval. Noncharacters are preserved; valid controls are not sanitized and require safe rendering separately. localCheckpoint() proves a bounded cold restart boundary; it does not certify the omitted prefix's validity. Grapheme, line and cell mapping remain separate.
|
explicitnoexcept |
Create a new stream decoder. A zero work limit or ESCAPE is unsupported.
| options | Encoding selection, error policy and input work limit. |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
Capture only after selection, with no pending bytes, before EOF.
|
inlinenoexcept |
|
noexcept |
Decode a bounded contiguous input chunk into caller-owned scalar records.
| input | Borrowed bytes contiguous with the committed input. |
| offset | Absolute offset of the first input byte. |
| final | True only when the end of input is confirmed. |
| output | Caller-owned storage for decoded scalars. |
|
staticnoexcept |
Prove the scalar/subpart containing an anchor without traversing its omitted prefix.
| origin | Real opaque checkpoint after original encoding/BOM resolution, qualified by the caller against the same immutable source revision and decoding policy. |
| window | At most LOCAL_WINDOW_BYTES original bytes, borrowed only for this call. |
| windowOffset | Absolute original-byte offset of the local window, which may be unaligned. |
| anchorByteOffset | Exact user anchor within the inclusive window interval. It stays unchanged; the returned scalar-start projection can precede it, or follow it inside an omitted BOM. |
| finalWindow | True only when window end is proven source EOF, never temporary absence. |
|
staticnoexcept |
Resume a previously captured boundary without probing for another BOM.
| checkpoint | Boundary state bound by the caller to the source revision. |