|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 13312 (0x3400)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, generic, package Maps, seg_0046e3
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦5a81ac88f⟧ »Space Info Vol 1«
└─⟦this⟧
--| @SUMMARY This package provides a "Map" abstraction. A Map consists of a set
--| of "Mappings". A Mapping relates a key field to an arbitrary number
--| of other fields.
--|
--| @INDICES (Text_Processing, Data_Structure)
--|
--| @RAISES All operations raise "Not_Initialized" if passed an uninitialized
--| object.
--|
--| @SPECIAL_NOTES All strings are returned starting at index 1.
--|
with Lines;
with Fields;
generic
--| @DESCRIPTION Specifies which characters are field separators. The
--| beginning and the end of the string is always a field separator. For
--| example, if the Is_Separator function recognizes '|' and '.' as field
--| separators, then the following string contains five fields (three of
--| which are null):
--|
--| |a.|bcd|
--|
--| and the following string contains three fields (one of which is null):
--|
--| a|.bdc
--|
--| The null string contains no fields.
--|
with function Is_Separator (This_Character : in Character) return Boolean;
package Maps is
subtype Field is String;
--|--|--|--|--|--|--|--|--|--|--|--|--|--| MAPPINGS --|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|
--| @SPECIAL_NOTES Ordered list of fields.
--|
type Mapping is private;
--| @SUMMARY Parses the specified string looking for fields, and returns
--| an initialized mapping.
--|
--| @RAISES Parse_Failure (if the string is null or starts with a
--| null field).
--|
--| @SPECIAL_NOTES The first field in the string becomes the key field
--| for the mapping, and it maps to all other fields in the string (if any).
--|
--| The mapping's current field is set to the key field before the
--| mapping is returned.
--|
function Create (From_String : in String) return Mapping;
--| @SUMMARY Returns the image of the specified mapping. Is the inverse of
--| the "Create" function.
--|
function Image (Of_Fields : in Mapping) return String;
--| @SUMMARY Returns True if the specified mapping is "Done".
--|
function Done (This_Mapping : in Mapping) return Boolean;
--| @SUMMARY Resets the current field in the mapping to the key field.
--|
procedure Reset (This_Mapping : in out Mapping);
--| @SUMMARY Returns the current field in the mapping.
--|
--| @RAISES No_Current_Field (if already "Done").
--|
function Current (This_Mapping : in Mapping) return Field;
--| @SUMMARY Replaces the current field in the mapping with the new field.
--|
--| @RAISES No_Current_Field (if already "Done").
--|
--| Out_Of_Range (if an attempt is made to modify the key field
--| of the mapping).
--|
--| Parse_Failure (if the new field contains a separator).
--|
--| @SPECIAL_NOTES Can be called during iteration without altering
--| iterator's position.
--|
procedure Modify (This_Mapping : in out Mapping; New_Field : in Field);
--| @SUMMARY Advances the current field in the mapping to the next field.
--|
--| @RAISES No_Next_Field (if already "Done").
--|
procedure Next (This_Mapping : in out Mapping);
--| @SPECIAL_NOTES Fields are numbered 1..N, and the key field is always 1.
--|
subtype Field_Number is Positive;
--| @SUMMARY Returns the field number corresponding to the current field in
--| the mapping.
--|
--| @RAISES No_Current_Field (if already "Done").
--|
function Position (In_Mapping : in Mapping) return Field_Number;
--| @SUMMARY Sets the current field in the mapping to the specified
--| field number.
--|
--| @RAISES Out_Of_Range (if the specified field number is out of range).
--|
procedure Set (This_Mapping : in out Mapping; To_Field : in Field_Number);
--| @SUMMARY Returns the field corresponding to the specified field number.
--|
--| @RAISES Out_Of_Range (if the specified field number is out of range).
--|
--| @SPECIAL_NOTES Can be called during iteration without altering
--| iterator's position.
--|
function Field_At (This_Position : in Field_Number; In_Mapping : in Mapping)
return Field;
--| @SUMMARY Returns the number of fields in the specified mapping.
--|
function Fields_In (This_Mapping : in Mapping) return Positive;
--| @SUMMARY Adds the specified field to the end of the field iterator,
--| using the specified separator (if the new field is the only field,
--| no separator is used).
--|
--| @RAISES Parse_Failure (if the new field contains a separator,
--| or if the specified separator character is not a valid separator).
--|
--| @SPECIAL_NOTES This operation is NOT safe to call during iteration.
--|
procedure Add (This_Field : in Field;
To_Mapping : in out Mapping;
Using_Separator : in Character);
--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|- MAPS --|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|-
type Map is private;
--| @SUMMARY Parses the specified map file, and returns an initialized map
--| containing N mappings.
--|
--| @RAISES Parse_Failure (if an invalid mapping [i.e. null string, null
--| key field, duplicate key, etc] is encountered while parsing the file).
--|
--| Io_Failure (if difficulty is encountered opening,
--| reading from, or closing the specified file).
--|
--| @SPECIAL_NOTES Each line of the map file must contain a valid string
--| image of a mapping. All key fields must be unique (comparison of key
--| fields is NOT case-sensitive unless "Ignore_Case" is set to False).
--| Empty map files are permitted.
--|
function Create
(From_Map_File : in String; Ignore_Case : in Boolean := True)
return Map;
--| @SUMMARY Saves the specified map to the specified map file by writing
--| the string image of each mapping to the file, separating each
--| field with the field separator.
--|
--| @RAISES Io_Failure (if difficulty is encountered opening,
--| writing to, or closing the specified file).
--|
procedure Save (To_Map_File : in String; This_Map : in out Map);
--| @SUMMARY Returns True iff the specified key is found in the specified
--| map.
--|
--| @RAISES Bad_Mapping (if an invalid mapping is encountered while
--| searching the map).
--|
--| @SPECIAL_NOTES Comparison of key fields is NOT case-sensitive
--| unless the map was created with "Ignore_Case" set to False.
--|
function Is_Mapped (This_Key : in String; In_Map : in Map) return Boolean;
--| @SUMMARY Given a key, returns the mapping for the key.
--|
--| @RAISES No_Mapping (if the key is not found in the map).
--|
--| Bad_Mapping (if an invalid mapping is encountered while
--| searching the map).
--|
--| @SPECIAL_NOTES Comparison of key fields is NOT case-sensitive unless
--| the map was created with "Ignore_Case" set to False.
--|
function Mapping_For (This_Key : in String; In_Map : in Map) return Mapping;
--| @SUMMARY Adds the specified mapping to the specified map.
--|
--| @RAISES Parse_Failure (if the specified mapping is invalid).
--|
--| Bad_Mapping (if an invalid mapping is encountered while
--| searching the map).
--|
--| @SPECIAL_NOTES Overwrites any pre-existing mapping with the same key
--| field. Comparison of key fields is NOT case-sensitive unless the map
--| was created with "Ignore_Case" set to False.
--|
--| Alters iterator state, so is NOT safe to call while iterating,
--| unless the mapping being added has exactly the same key as the
--| current mapping in the map (in which case it replaces the
--| existing mapping without changing current position).
--|
procedure Add (This_Mapping : in Mapping; To_Map : in out Map);
--| @SUMMARY Adds the specified mapping to the specified map.
--|
--| @RAISES Parse_Failure (if the specified mapping is invalid).
--|
--| Bad_Mapping (if an invalid mapping is encountered while
--| searching the map).
--|
--| @SPECIAL_NOTES Overwrites any pre-existing mapping with the same key
--| field. Comparison of key fields is NOT case-sensitive unless the map
--| was created with "Ignore_Case" set to False.
--|
--| Alters iterator state, so is NOT safe to call while iterating,
--| unless the mapping being added has exactly the same key as the
--| current mapping in the map (in which case it replaces the
--| existing mapping without changing current position).
--|
procedure Add (This_Mapping : in String; To_Map : in out Map);
--| @SUMMARY Deletes the current mapping from the specified map.
--|
--| @RAISES No_Current_Mapping (if already "Done").
--|
--| @SPECIAL_NOTES Current mapping is set to the mapping immediately following the
--| deleted mapping. If the deleted mapping was the last one in the
--| map, the map becomes "Done".
--|
procedure Delete (From_Map : in out Map);
--| @SUMMARY Returns True if the specified map is "Done".
--|
function Done (This_Map : in Map) return Boolean;
--| @SUMMARY Resets the current mapping in the map to be the first mapping.
--|
--| @SPECIAL_NOTES If the map is empty, sets "Done" to True.
--|
procedure Reset (This_Map : in out Map);
--| @SUMMARY Returns the current mapping in the map.
--|
--| @RAISES No_Current_Mapping (if already "Done").
--|
--| Bad_Mapping (if the current mapping in the map is invalid).
--|
function Current (This_Map : in Map) return Mapping;
--| @SUMMARY Advances the current mapping in the map to the next mapping.
--|
--| @RAISES No_Next_Mapping (if already "Done").
--|
procedure Next (This_Map : in out Map);
--| @SUMMARY Returns True iff the specified map contains no mappings.
--|
function Is_Empty (This_Map : in Map) return Boolean;
--| @SUMMARY Returns the number of mappings in the specified map.
--|
function Mappings_In (This_Map : in Map) return Natural;
--| @SUMMARY Reclaims space.
--|
procedure Dispose (Of_This_Map : in out Map);
Not_Initialized : exception;
Parse_Failure : exception;
No_Current_Field : exception;
No_Next_Field : exception;
Out_Of_Range : exception;
No_Mapping : exception;
Bad_Mapping : exception;
No_Current_Mapping : exception;
No_Next_Mapping : exception;
Io_Failure : exception;
private
package Mappings is new Fields (Is_Separator);
type Mapping is new Mappings.Iterator;
type Map is
record
Contents : Lines.Iterator;
Ignore_Case : Boolean := True;
end record;
end Maps;
nblk1=c
nid=0
hdr6=18
[0x00] rec0=1e rec1=00 rec2=01 rec3=00a
[0x01] rec0=1c rec1=00 rec2=02 rec3=014
[0x02] rec0=1c rec1=00 rec2=03 rec3=01a
[0x03] rec0=1c rec1=00 rec2=04 rec3=034
[0x04] rec0=17 rec1=00 rec2=05 rec3=02a
[0x05] rec0=16 rec1=00 rec2=06 rec3=026
[0x06] rec0=18 rec1=00 rec2=07 rec3=04e
[0x07] rec0=17 rec1=00 rec2=08 rec3=08c
[0x08] rec0=15 rec1=00 rec2=09 rec3=038
[0x09] rec0=1b rec1=00 rec2=0a rec3=00e
[0x0a] rec0=23 rec1=00 rec2=0b rec3=032
[0x0b] rec0=12 rec1=00 rec2=0c rec3=000
tail 0x215004ce2815c6745201b 0x42a00088462061e03