Description
Converts and renders one signed 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, -0 converts to zero, and range is detected before arithmetic overflow. 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
Valueis eligible.- Value
Converted integer when
StatusisConverted; otherwise unspecified.
Parse_Status
type Parse_Status is (Converted, Invalid_Syntax, Below_Range, 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.
- Below_Range
The mathematical integer is less than
Value_Type'First.- 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
Signed 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 range <>;
Signed integer type converted and rendered without rounding or truncation.