On this page
Ada.Strings.Wide_Maps
Sets of wide characters and mappings between them (RM A.4.7).
Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
Ada.Strings.Maps' operations for Wide_Character, with the same contracts. A set or a mapping is a table held in a Verada.Strings.Texts.Text, shared by copies; = of two sets compares the characters they hold, whatever their tables.
A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.
Import and instantiate
with Ada.Strings.Wide_Maps;import Ada.Strings.Wide_Maps;
A Vibe module imports this unit's names with from Ada.Strings.Wide_Maps import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.
Contract and lifecycle reading
A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.
API 001
Wide_Character_Set (declaration) — A set of wide characters; copies share its table.
Declared interface:
type Wide_Character_Set is private;API 002
Null_Set (declaration) — The set of no characters.
Declared interface:
Null_Set : constant Wide_Character_Set;API 003
Wide_Character_Range (declaration) — The characters from Low to High, for To_Set.
Declared interface:
type Wide_Character_Range is record
Low : Wide_Character;
High : Wide_Character;
end record;API 004
Declared interface:
type Wide_Character_Ranges is array (Positive range <>) of Wide_Character_Range;API 005
To_Set (declaration) — The characters of any of the ranges.
Declared interface:
function To_Set (Ranges : Wide_Character_Ranges) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, To_Set'Result) = (for some I in Ranges'Range => C in Ranges (I).Low .. Ranges (I).High));API 006
To_Ranges (declaration) — The set as the fewest ranges, in ascending order, none empty and no two adjacent.
Declared interface:
function To_Ranges (Set : Wide_Character_Set) return Wide_Character_Ranges
with Global => null,
Post => To_Ranges'Result'First = 1
and then (for all I in To_Ranges'Result'Range => To_Ranges'Result (I).Low <= To_Ranges'Result (I).High)
and then (for all I in To_Ranges'Result'Range =>
(if I < To_Ranges'Result'Last
then Wide_Character'Pos (To_Ranges'Result (I).High) + 1 < Wide_Character'Pos (To_Ranges'Result (I + 1).Low)))
and then (for all C in Wide_Character =>
Is_In (C, Set) = (for some I in To_Ranges'Result'Range => C in To_Ranges'Result (I).Low .. To_Ranges'Result (I).High));API 007
Is_In (declaration) — Whether a character is in a set.
Declared interface:
function Is_In (Element : Wide_Character; Set : Wide_Character_Set) return Boolean
with Global => null;API 008
To_Set (declaration) — The set of a range, of one character, or of a string's characters, as the postcondition states.
Declared interface:
function To_Set (Span : Wide_Character_Range) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, To_Set'Result) = (C in Span.Low .. Span.High));API 009
To_Set (declaration) — The set of a range, of one character, or of a string's characters, as the postcondition states.
Declared interface:
function To_Set (Singleton : Wide_Character) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, To_Set'Result) = (C = Singleton));API 010
Declared interface:
subtype Wide_Character_Sequence is Wide_String;API 011
Declared interface:
function To_Set (Sequence : Wide_Character_Sequence) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, To_Set'Result) = (for some I in Sequence'Range => Sequence (I) = C));API 012
"not" (declaration) — The characters not in the set.
Declared interface:
function "not" (Right : Wide_Character_Set) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, "not"'Result) = not Is_In (C, Right));API 013
"and" (declaration) — The characters in both sets.
Declared interface:
function "and" (Left, Right : Wide_Character_Set) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, "and"'Result) = (Is_In (C, Left) and Is_In (C, Right)));API 014
"or" (declaration) — The characters in either set.
Declared interface:
function "or" (Left, Right : Wide_Character_Set) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, "or"'Result) = (Is_In (C, Left) or Is_In (C, Right)));API 015
"-" (declaration) — The characters in Left and not in Right.
Declared interface:
function "-" (Left, Right : Wide_Character_Set) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, "-"'Result) = (Is_In (C, Left) and not Is_In (C, Right)));API 016
Declared interface:
function "xor" (Left, Right : Wide_Character_Set) return Wide_Character_Set
with Global => null,
Post => (for all C in Wide_Character => Is_In (C, "xor"'Result) = (Is_In (C, Left) /= Is_In (C, Right)));API 017
Is_Subset (declaration) — Whether every character of Elements is in Set.
Declared interface:
function Is_Subset (Elements : Wide_Character_Set; Set : Wide_Character_Set) return Boolean
with Global => null,
Post => Is_Subset'Result = (for all C in Wide_Character => (if Is_In (C, Elements) then Is_In (C, Set)));API 018
Declared interface:
function "<=" (Left : Wide_Character_Set; Right : Wide_Character_Set) return Boolean renames Is_Subset;API 019
"=" (declaration) — Whether two sets hold the same characters (their tables may differ: the empty set's is empty)
Declared interface:
function "=" (Left, Right : Wide_Character_Set) return Boolean
with Global => null,
Post => "="'Result = (for all C in Wide_Character => Is_In (C, Left) = Is_In (C, Right));API 020
To_Sequence (declaration) — The characters of the set, in ascending order.
Declared interface:
function To_Sequence (Set : Wide_Character_Set) return Wide_Character_Sequence
with Global => null,
Post => To_Sequence'Result'First = 1 and then To_Sequence'Result'Length <= 65_536
and then (for all I in To_Sequence'Result'Range =>
(if I < To_Sequence'Result'Last then To_Sequence'Result (I) < To_Sequence'Result (I + 1)))
and then (for all C in Wide_Character => Is_In (C, Set) = (for some I in To_Sequence'Result'Range => To_Sequence'Result (I) = C));API 021
Wide_Character_Mapping (declaration) — A mapping from wide characters to wide characters; copies share its table.
Declared interface:
type Wide_Character_Mapping is private;API 022
Identity (declaration) — The mapping that takes each character to itself.
Declared interface:
Identity : constant Wide_Character_Mapping;API 023
Declared interface:
function Value (Map : Wide_Character_Mapping; Element : Wide_Character) return Wide_Character
with Global => null;API 024
Lemma_Identity (declaration) — (Verada, a lemma for proofs) a mapping equal to the identity takes Element to itself.
Declared interface:
procedure Lemma_Identity (Map : Wide_Character_Mapping; Element : Wide_Character)
with Ghost, Global => null, Always_Terminates,
Pre => Map = Identity,
Post => Value (Map, Element) = Element;API 025
Wide_Character_Mapping_Function (declaration) — A function from wide characters to wide characters.
Declared interface:
type Wide_Character_Mapping_Function is access function (From : Wide_Character) return Wide_Character;API 026
To_Mapping (declaration) — From (I) maps to To (I); every other character to itself (From names each character at most once: where the RM raises Translation_Error, the precondition requires it).
Declared interface:
function To_Mapping (From, To : Wide_String) return Wide_Character_Mapping
with Global => null,
Pre => From'Length = To'Length
and then (for all I in From'Range => (for all J in From'Range => (if I /= J then From (I) /= From (J)))),
Post => (for all I in From'Range => Value (To_Mapping'Result, From (I)) = To (To'First + (I - From'First)))
and then (for all C in Wide_Character => (if (for all I in From'Range => From (I) /= C) then Value (To_Mapping'Result, C) = C));API 027
To_Domain (declaration) — The characters the mapping does not take to themselves, in ascending order.
Declared interface:
function To_Domain (Map : Wide_Character_Mapping) return Wide_Character_Sequence
with Global => null,
Post => To_Domain'Result'First = 1 and then To_Domain'Result'Length <= 65_536
and then (for all I in To_Domain'Result'Range =>
(if I < To_Domain'Result'Last then To_Domain'Result (I) < To_Domain'Result (I + 1)))
and then (for all C in Wide_Character => (Value (Map, C) /= C) = (for some I in To_Domain'Result'Range => To_Domain'Result (I) = C));API 028
To_Range (declaration) — Where the mapping takes the characters of its domain, in the domain's order.
Declared interface:
function To_Range (Map : Wide_Character_Mapping) return Wide_Character_Sequence
with Global => null,
Post => To_Range'Result'First = 1
and then To_Range'Result'Length = To_Domain (Map)'Length
and then (for all I in To_Range'Result'Range => To_Range'Result (I) = Value (Map, To_Domain (Map) (I)));