← All compilation units

Flyology_JSON.Numbers.Unsigned_Integers

Description

Converts and renders one modular integer type without allocation.

Parse

procedure Parse (Lexeme : Ada.Streams.Stream_Element_Array; Result : out Parse_Result)

Parse accepts only a complete strict JSON integer spelling. Fractions and exponents are invalid syntax. Every syntactically valid negative spelling, including -0, returns Negative_Value. Range is detected before modular arithmetic can wrap. No failure publishes a Value.

Parameters
Lexeme

Complete exact number-token octets with arbitrary Ada array bounds.

Result

Definite conversion result; its value is eligible only after Converted.

Parse_Result

type Parse_Result is record
   Status : Parse_Status;
   Value  : Value_Type;
end record;

Definite so a constrained out actual cannot fail copy-out. Value is eligible only when Status = Converted; otherwise it remains a valid but unspecified Value_Type value.

Record fields
Status

Conversion outcome that controls whether Value is eligible.

Value

Converted integer when Status is Converted; otherwise unspecified.

Parse_Status

type Parse_Status is (Converted, Invalid_Syntax, Negative_Value, Above_Range);

Result category for conversion of one complete strict JSON integer lexeme.

Enumeration literals
Converted

Conversion succeeded and the result value is eligible.

Invalid_Syntax

The lexeme is not a complete strict JSON integer spelling.

Negative_Value

The lexeme is syntactically valid but has a leading minus sign.

Above_Range

The mathematical integer is greater than Value_Type'Last.

Render

procedure Render
  (Value    : Value_Type;
   Output   : in out Ada.Streams.Stream_Element_Array;
   Produced : out Ada.Streams.Stream_Element_Count;
   Status   : out Numbers.Render_Status)

Render emits exact base ten without a leading zero, exponent, or plus. On insufficient capacity it returns Produced = 0 and leaves Output unchanged. This integer operation never returns Unsupported_Value.

Parameters
Value

Modular integer to render.

Output

Caller storage that receives the complete spelling on success.

Produced

Number of octets written from Output'First, or zero on failure.

Status

Rendering outcome that controls whether the output prefix is published.

Value_Type

type Value_Type is mod <>;

Modular integer type converted and rendered without wrapping or truncation.