← All compilation units

Flyology_JSON.Tokens

Description

Bounded transactional collection of already selected token octets.

Abort_Token

procedure Abort_Token (Self : in out Collector)

Abort_Token and Reset are nonraising, idempotent in every state, and return Self to Empty. Retained storage octets become unspecified.

Parameters
Self

Append

procedure Append
  (Self   : in out Collector;
   Value  : Ada.Streams.Stream_Element_Array;
   Status : out Collector_Status)

Append succeeds only in Collecting. It copies all Value octets or none, accepts arbitrary array bounds, and treats an empty Value as a no-op. Value must not overlap Storage. Capacity denial enters Failed and publishes no completed length.

Parameters
Self
Value
Status

Begin_Token

procedure Begin_Token
  (Self : in out Collector; Kind : Token_Kind; Status : out Collector_Status)

Begin_Token succeeds only in Empty. It enters Collecting with no published token. Every other state returns Invalid_Order unchanged.

Parameters
Self
Kind
Status

Collected_Length

function Collected_Length (Self : Collector) return Ada.Streams.Stream_Element_Count
Parameters
Self
Return value

Collector

type Collector (Storage : not null access Token_Storage) is limited private;

Storage is caller-owned, may have arbitrary bounds, and outlives Self. Self performs no allocation and retains no input passed to Append.

Record fields
Storage

Collector_State

type Collector_State is (Empty, Collecting, Complete, Failed);
Enumeration literals
Empty
Collecting
Complete
Failed

Collector_Status

type Collector_Status is
  (Operation_Accepted, Token_Completed, Invalid_Order, Storage_Exhausted);
Enumeration literals
Operation_Accepted
Token_Completed
Invalid_Order
Storage_Exhausted

Complete_Token

procedure Complete_Token (Self : in out Collector; Status : out Collector_Status)

Complete_Token succeeds only in Collecting and atomically publishes the staged prefix length, including zero. Other states return Invalid_Order without changing state or publication.

Parameters
Self
Status

Kind

function Kind (Self : Collector) return Token_Kind
Parameters
Self
Return value

Reset

procedure Reset (Self : in out Collector)
Parameters
Self

State

function State (Self : Collector) return Collector_State
Parameters
Self
Return value

Token_Kind

type Token_Kind is (Decoded_Name, Decoded_String, Exact_Number);
Enumeration literals
Decoded_Name
Decoded_String
Exact_Number

Token_Storage

subtype Token_Storage is Ada.Streams.Stream_Element_Array;

This is the exact stream-element array type, not a derived array type. A completed prefix can therefore be passed directly to another octet API without a conversion, hidden copy, or unchecked overlay.