|
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 - download
Length: 10240 (0x2800) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, generic, package Vstrings, seg_030ab7
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
-- DISCUSSION: -- --\x09This package implements the type "variable-length string" (vstring) --\x09using generics. The alternative approaches are to use a discriminant --\x09record in which the discriminant controls the length of a STRING inside --\x09the record, or a record containing an access type which points to a -- string, which can be deallocated and reallocated when necessary. -- --\x09Advantages of this package: --\x09 * The other approaches force the vstring to be a limited private -- type. Thus, their vstrings cannot appear on the left side of -- the assignment operator; ie., their vstrings cannot be given -- initial values or values by direct assignment. This package -- uses a private type; therefore, these things can be done. -- --\x09 * The other approach stores the vstring in a string whose length --\x09 is determined dynamically. This package uses a fixed length -- string. This difference might be reflected in faster and more -- consistent execution times (this has NOT been verified). -- --\x09Disadvantages of this package: --\x09 * Different instantiations must be used to declare vstrings with --\x09 different maximum lengths (this may be desirable, since --\x09 CONSTRAINT_ERROR will be raised if the maximum is exceeded). -- --\x09 * A second declaration is required to give the type declared by --\x09 the instantiation a name other than "VSTRING." -- --\x09 * The storage required for a vstring is determined by the generic --\x09 parameter LAST and not the actual length of its contents. Thus, -- each object is allocated the maximum amount of storage, regardless -- of its actual size. -- -- MISCELLANEOUS: -- Constraint checking is done explicitly in the code; thus, it cannot -- be suppressed. On the other hand, constraint checking is not lost -- if pragma suppress is supplied to the compilation (-S option) -- (The robustness of the explicit constraint checking has NOT been -- determined). -- -- Compiling with the optimizer (-O option) may significantly reduce -- the size (and possibly execution time) of the resulting executable. -- -- Compiling an instantiation of VSTRINGS is roughly equivelent to -- recompiling VSTRINGS. Since this takes a significant amount of time, -- and the instantiation does not depend on any other library units, -- it is STRONGLY recommended that the instantiation be compiled -- separately, and thus done only ONCE. -- -- USAGE: with VSTRINGS; -- package package_name is new VSTRINGS(maximum_length); -- .......................................................................... -- pragma Page; with Text_Io; use Text_Io; generic Last : Natural; package Vstrings is subtype Strindex is Natural; First : constant Strindex := Strindex'First + 1; type Vstring is private; Nul : constant Vstring; -- Attributes of a VSTRING function Len (From : Vstring) return Strindex; function Max (From : Vstring) return Strindex; function Str (From : Vstring) return String; function Char (From : Vstring; Position : Strindex := First) return Character; -- Comparisons function "<" (Left : Vstring; Right : Vstring) return Boolean; function ">" (Left : Vstring; Right : Vstring) return Boolean; function "<=" (Left : Vstring; Right : Vstring) return Boolean; function ">=" (Left : Vstring; Right : Vstring) return Boolean; -- "=" and "/=" are predefined -- Input/Output procedure Put (File : in File_Type; Item : in Vstring); procedure Put (Item : in Vstring); procedure Put_Line (File : in File_Type; Item : in Vstring); procedure Put_Line (Item : in Vstring); procedure Get (File : in File_Type; Item : out Vstring; Length : in Strindex := Last); procedure Get (Item : out Vstring; Length : in Strindex := Last); procedure Get_Line (File : in File_Type; Item : in out Vstring); procedure Get_Line (Item : in out Vstring); -- Extraction function Slice (From : Vstring; Front, Back : Strindex) return Vstring; function Substr (From : Vstring; Start, Length : Strindex) return Vstring; function Delete (From : Vstring; Front, Back : Strindex) return Vstring; -- Editing function Insert (Target : Vstring; Item : Vstring; Position : Strindex := First) return Vstring; function Insert (Target : Vstring; Item : String; Position : Strindex := First) return Vstring; function Insert (Target : Vstring; Item : Character; Position : Strindex := First) return Vstring; function Append (Target : Vstring; Item : Vstring; Position : Strindex) return Vstring; function Append (Target : Vstring; Item : String; Position : Strindex) return Vstring; function Append (Target : Vstring; Item : Character; Position : Strindex) return Vstring; function Append (Target : Vstring; Item : Vstring) return Vstring; function Append (Target : Vstring; Item : String) return Vstring; function Append (Target : Vstring; Item : Character) return Vstring; function Replace (Target : Vstring; Item : Vstring; Position : Strindex := First) return Vstring; function Replace (Target : Vstring; Item : String; Position : Strindex := First) return Vstring; function Replace (Target : Vstring; Item : Character; Position : Strindex := First) return Vstring; -- Concatenation function "&" (Left : Vstring; Right : Vstring) return Vstring; function "&" (Left : Vstring; Right : String) return Vstring; function "&" (Left : Vstring; Right : Character) return Vstring; function "&" (Left : String; Right : Vstring) return Vstring; function "&" (Left : Character; Right : Vstring) return Vstring; -- Determine the position of a substring function Index (Whole : Vstring; Part : Vstring; Occurrence : Natural := 1) return Strindex; function Index (Whole : Vstring; Part : String; Occurrence : Natural := 1) return Strindex; function Index (Whole : Vstring; Part : Character; Occurrence : Natural := 1) return Strindex; function Rindex (Whole : Vstring; Part : Vstring; Occurrence : Natural := 1) return Strindex; function Rindex (Whole : Vstring; Part : String; Occurrence : Natural := 1) return Strindex; function Rindex (Whole : Vstring; Part : Character; Occurrence : Natural := 1) return Strindex; -- Conversion from other associated types function Vstr (From : String) return Vstring; function Vstr (From : Character) return Vstring; function "+" (From : String) return Vstring; function "+" (From : Character) return Vstring; generic type From is private; type To is private; with function Str (X : From) return String is <>; with function Vstr (Y : String) return To is <>; function Convert (X : From) return To; pragma Page; private type Vstring is record Len : Strindex := Strindex'First; Value : String (First .. Last) := (others => Ascii.Nul); end record; Nul : constant Vstring := (Strindex'First, (others => Ascii.Nul)); end Vstrings; -- -- .......................................................................... -- -- -- DISTRIBUTION AND COPYRIGHT: -- -- This software is released to the Public Domain (note: -- software released to the Public Domain is not subject -- to copyright protection). -- Restrictions on use or distribution: NONE -- -- DISCLAIMER: -- -- This software and its documentation are provided "AS IS" and -- without any expressed or implied warranties whatsoever. -- No warranties as to performance, merchantability, or fitness -- for a particular purpose exist. -- -- Because of the diversity of conditions and hardware under -- which this software may be used, no warranty of fitness for -- a particular purpose is offered. The user is advised to -- test the software thoroughly before relying on it. The user -- must assume the entire risk and liability of using this -- software. -- -- In no event shall any person or organization of people be -- held responsible for any direct, indirect, consequential -- or inconsequential damages or lost profits.
nblk1=9 nid=0 hdr6=12 [0x00] rec0=15 rec1=00 rec2=01 rec3=072 [0x01] rec0=14 rec1=00 rec2=02 rec3=03a [0x02] rec0=1c rec1=00 rec2=03 rec3=000 [0x03] rec0=1c rec1=00 rec2=04 rec3=008 [0x04] rec0=18 rec1=00 rec2=05 rec3=046 [0x05] rec0=17 rec1=00 rec2=06 rec3=03e [0x06] rec0=16 rec1=00 rec2=07 rec3=00e [0x07] rec0=21 rec1=00 rec2=08 rec3=016 [0x08] rec0=16 rec1=00 rec2=09 rec3=000 tail 0x2172a416884a64ebaaa89 0x42a00088462060003