DocAda(tm) is a productivity tool of KSCE
|
|
|
| ![]()
About DocAda Light:
Preface / Preliminary
/ Help
/ TOC
/ Copyright
DocAda Online at the Ada Home:
Complete RM95
/ Updates
/ News
The package Strings.Maps defines the types, operations, and other entities needed for character sets and character-to-character mappings.
Static Semantics
The library package Strings.Maps has the following declaration:
package Ada.Strings.Maps is
pragma Preelaborate(Maps);
-- Representation for a set of character values:
type Character_Set is private;
Null_Set : constant Character_Set;
type Character_Range is
record
Low : Character;
High : Character;
end record;
-- Represents Character range Low..High
type Character_Ranges is array (Positive range <>) of Character_Range;
function To_Set (Ranges : in Character_Ranges) return Character_Set;
function To_Set (Span : in Character_Range) return Character_Set;
function To_Ranges (Set : in Character_Set) return Character_Ranges;
function "=" (Left, Right : in Character_Set) return Boolean;
function "not" (Right : in Character_Set) return Character_Set;
function "and" (Left, Right : in Character_Set) return Character_Set;
function "or" (Left, Right : in Character_Set) return Character_Set;
function "xor" (Left, Right : in Character_Set) return Character_Set;
function "-" (Left, Right : in Character_Set) return Character_Set;
function Is_In (Element : in Character;
Set : in Character_Set)
return Boolean;
function Is_Subset (Elements : in Character_Set;
Set : in Character_Set)
return Boolean;
function "<=" (Left : in Character_Set;
Right : in Character_Set)
return Boolean renames Is_Subset;
-- Alternative representation for a set of character values:
subtype Character_Sequence is String;
function To_Set (Sequence : in Character_Sequence) return Character_Set;
function To_Set (Singleton : in Character) return Character_Set;
function To_Sequence (Set : in Character_Set) return Character_Sequence;
-- Representation for a character to character mapping:
type Character_Mapping is private;
function Value (Map : in Character_Mapping;
Element : in Character)
return Character;
Identity : constant Character_Mapping;
function To_Mapping (From, To : in Character_Sequence) return Character_Mapping;
function To_Domain (Map : in Character_Mapping) return Character_Sequence;
function To_Range (Map : in Character_Mapping) return Character_Sequence;
type Character_Mapping_Function is
access function (From : in Character) return Character;
private
... -- not specified by the language
end Ada.Strings.Maps;
An object of type Character_Set represents a set of characters.
Null_Set represents the set containing no characters.
An object Obj of type Character_Range represents the set of characters in the range Obj.Low .. Obj.High.
An object Obj of type Character_Ranges represents the union of the sets corresponding to Obj(I) for I in Obj'Range.
function To_Set (Ranges : in Character_Ranges) return Character_Set;
function To_Set (Span : in Character_Range) return Character_Set;
function To_Ranges (Set : in Character_Set) return Character_Ranges;
function "=" (Left, Right : in Character_Set) return Boolean;
Each of the logical operators "not", "and", "or", and "xor" returns a Character_Set value that represents the set obtained by applying the corresponding operation to the set(s) represented by the parameter(s) of the operator. "-"(Left, Right) is equivalent to "and"(Left, "not"(Right)).
function Is_In (Element : in Character;
Set : in Character_Set);
return Boolean;
function Is_Subset (Elements : in Character_Set;
Set : in Character_Set)
return Boolean;
subtype Character_Sequence is String;
function To_Set (Sequence : in Character_Sequence) return Character_Set;
function To_Set (Singleton : in Character) return Character_Set;
function To_Sequence (Set : in Character_Set) return Character_Sequence;
type Character_Mapping is private;
function Value (Map : in Character_Mapping;
Element : in Character)
return Character;
A character C matches a pattern character P with respect to a given Character_Mapping value Map if Value(Map, C) = P. A string S matches a pattern string P with respect to a given Character_Mapping if their lengths are the same and if each character in S matches its corresponding character in the pattern string P.
String handling subprograms that deal with character mappings have parameters whose type is Character_Mapping.
Identity : constant Character_Mapping;
function To_Mapping (From, To : in Character_Sequence) return Character_Mapping;
function To_Domain (Map : in Character_Mapping) return Character_Sequence;
function To_Range (Map : in Character_Mapping) return Character_Sequence;
An object F of type Character_Mapping_Function maps a Character value C to the Character value F.all(C), which is said to match C with respect to mapping function F.
Examples
To_Mapping("ABCD", "ZZAB") returns a Character_Mapping that maps 'A' and 'B' to 'Z', 'C' to 'A', 'D' to 'B', and each other Character to itself.
About DocAda Light:
Preface / Preliminary
/ Help
/ TOC
/ Copyright
DocAda Online at the Ada Home:
Complete RM95
/ Updates
/ News
|
|
|
| ![]()