|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T V
Length: 10840 (0x2a58)
Types: TextFile
Names: »V«
└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
└─⟦5cb1d1d7f⟧ »DATA«
└─⟦3b1ee7bd8⟧
└─⟦this⟧
--------------------------------- COPYRIGHT ------------------------------------
-- (C) 1986 Swiss Federal Institute of Technology (EPFL). --
-- Represented by A. Strohmeier DMA-EPFL 1015 Lausanne Switzerland. --
-- All Rights Reserved. --
--------------------------------------------------------------------------------
--+ TITLE: GENERIC PACKAGE FOR VARIABLE LENGTH STRINGS.
--+ SUPPORT: S.R.Y. LOUBOUTIN, CGL-DMA-EPFL 1015 LAUSANNE.
--+ APPROVAL: 02-FEB-87 A. STROHMEIER.
--+ CREATION: 14-AUG-86 C. GENILLARD.
with Text_Io;
use Text_Io;
generic
Max_Length : in Positive;
package Varying_String_G is
------------------------
--+ OVERVIEW:
--+ This package implements a type V_STRING, which can be used to declare
--+ variable length strings, and related operators.
--+ The length of a V_STRING object may vary during execution between 0 and
--+ MAX_V_STRING_LENGTH (given by the generic parameter MAX_LENGTH), however
--+ that object will always take up the static memory space corresponding to a
--+ V_STRING of MAX_LENGTH characters.
--+
--+ CAUTION:
--+ A standard instantiation of this generic package is provided under the
--+ name of VARYING_STRING, you must use this instantiation when you need
--+ variable length strings. However if you need to do your own instantiation,
--+ please read the declaration of the package VARYING_STRING, especially the
--+ paragraph CAUTION.
--+
--+ PRIMITIVES:
--+ CONSTRUCTORS:
--+ TO_V_STRING (3)
--+ "&" (5)
--+ "*" (6)
--+ SUBSTRING
--+ DELETE
--+ TRUNCATE
--+ INSERT (3)
--+ REPLACE (3)
--+ UPPER_CASE
--+ LOWER_CASE
--+ GET (2)
--+ GET_LINE (2)
--+ QUERIES:
--+ TO_CHARACTER
--+ TO_STRING
--+ TO_INTEGER
--+ LENGTH
--+ "<"
--+ ">"
--+ "<="
--+ ">="
--+ ("=" is predefined as the type V_STRING is private)
--+ POSITION
--+ PUT (2)
--+ PUT_LINE (2)
type V_String is private;
Max_V_String_Length : constant Positive := Max_Length;
Empty_V_String : constant V_String;
V_String_Length_Error : exception;
--+ OVERVIEW:
--+ Raised when a V_STRING of more than MAX_V_STRING_LENGTH characters is
--+ attempted to be built.
V_String_Position_Error : exception;
--+ OVERVIEW:
--+ Raised when a position (parameter POSITION) attempts an access outside
--+ of a V_STRING .
function To_V_String (Source : Character) return V_String;
function To_V_String (Source : String) return V_String;
function To_V_String (Source : Integer) return V_String;
--+ OVERVIEW:
--+ Converts a CHARACTER, a STRING or an INTEGER into a V_STRING.
--+
--+ ERROR:
--+ Raises V_STRING_LENGTH_ERROR if the V_STRING returned would have more
--+ than MAX_V_STRING_LENGTH characters.
function To_Character
(Source : V_String; Position : Positive := 1) return Character;
--+ OVERVIEW:
--+ Returns the character at position POSITION in SOURCE.
--+
--+ ERROR:
--+ Raises V_STRING_POSITION_ERROR if POSITION > LENGTH(SOURCE).
function To_String (Source : V_String) return String;
function To_Integer (Source : V_String) return Integer;
--+ OVERVIEW:
--+ Converts a V_STRING into an INTEGER with the same rules as the
--+ function INTEGER'VALUE.
--+
--+ ERROR:
--+ Raises CONSTRAINT_ERROR if the conversion is not possible.
function Length (Source : V_String) return Natural;
--+ OVERVIEW:
--+ Returns the actual length of SOURCE.
function "&" (Left : V_String; Right : V_String) return V_String;
function "&" (Left : V_String; Right : String) return V_String;
function "&" (Left : String; Right : V_String) return V_String;
function "&" (Left : V_String; Right : Character) return V_String;
function "&" (Left : Character; Right : V_String) return V_String;
--+ ERROR:
--+ Raises V_STRING_LENGTH_ERROR if the V_STRING returned would have more
--+ than MAX_V_STRING_LENGTH characters.
function "*" (Pattern : Character; Count : Natural) return V_String;
function "*" (Count : Natural; Pattern : Character) return V_String;
function "*" (Pattern : String; Count : Natural) return V_String;
function "*" (Count : Natural; Pattern : String) return V_String;
function "*" (Pattern : V_String; Count : Natural) return V_String;
function "*" (Count : Natural; Pattern : V_String) return V_String;
--+ OVERVIEW:
--+ Returns a V_STRING equal to PATTERN repeated COUNT times.
--+
--+ ERROR:
--+ Raises V_STRING_LENGTH_ERROR if the V_STRING returned would have more
--+ than MAX_V_STRING_LENGTH characters.
function "<" (Left, Right : V_String) return Boolean;
function "<=" (Left, Right : V_String) return Boolean;
function ">" (Left, Right : V_String) return Boolean;
function ">=" (Left, Right : V_String) return Boolean;
--+ OVERVIEW:
--+ Lexicographic order comparisons.
function Substring (Source : V_String;
Position : Positive := 1;
Size : Natural := Max_Length) return V_String;
--+ OVERVIEW:
--+ Extracts a substring of SIZE characters long, starting at POSITION in
--+ SOURCE; if SIZE is greater than the length of the substring starting at
--+ POSITION and ending at the end of SOURCE, then this substring will be
--+ returned.
--+
--+ ERROR:
--+ Raises V_STRING_POSITION_ERROR if POSITION > LENGTH(SOURCE).
procedure Delete (Destination : in out V_String;
Position : in Positive := 1;
Size : in Natural := Max_Length);
--+ OVERVIEW:
--+ Deletes SIZE characters from DESTINATION starting at POSITION; if SIZE
--+ is greater than the number of characters from POSITION to the end of
--+ DESTINATION, then these characters will be deleted.
--+
--+ ERROR:
--+ Raises V_STRING_POSITION_ERROR if POSITION > LENGTH(DESTINATION).
procedure Truncate (Destination : in out V_String; Size : in Natural);
--+ OVERVIEW:
--+ Truncates DESTINATION at a length of SIZE characters; if SIZE is
--+ greater than the length of DESTINATION, then no character will be
--+ deleted.
procedure Insert (Destination : in out V_String;
Source : in V_String;
Position : in Positive);
procedure Insert (Destination : in out V_String;
Source : in String;
Position : in Positive);
procedure Insert (Destination : in out V_String;
Source : in Character;
Position : in Positive);
--+ OVERVIEW:
--+ Inserts SOURCE into DESTINATION starting at POSITION.
--+
--+ ERROR:
--+ Raises V_STRING_LENGTH_ERROR if LENGTH(DESTINATION) would become
--+ greater than MAX_V_STRING_LENGTH.
--+ Raises V_STRING_POSITION_ERROR if POSITION > LENGTH(DESTINATION)+1.
procedure Replace (Destination : in out V_String;
Source : in V_String;
Position : in Positive := 1);
procedure Replace (Destination : in out V_String;
Source : in String;
Position : in Positive := 1);
procedure Replace (Destination : in out V_String;
Source : in Character;
Position : in Positive := 1);
--+ OVERVIEW:
--+ Replaces by SOURCE the part of DESTINATION which starts at POSITION.
--+ If needed, DESTINATION is extended.
--+
--+ ERROR:
--+ Raises V_STRING_LENGTH_ERROR if LENGTH(DESTINATION) would become
--+ greater than MAX_V_STRING_LENGTH.
--+ Raises V_STRING_POSITION_ERROR if POSITION > LENGTH(DESTINATION)+1.
function Upper_Case (Source : V_String) return V_String;
--+ OVERVIEW:
--+ Converts lower-case letters of SOURCE into upper-case.
function Lower_Case (Source : V_String) return V_String;
--+ OVERVIEW:
--+ Converts upper-case letters of SOURCE into lower-case.
function Position
(Source : V_String; Pattern : V_String; Start : Positive := 1)
return Natural;
function Position
(Source : V_String; Pattern : String; Start : Positive := 1)
return Natural;
function Position (Source : V_String;
Pattern : Character;
Start : Positive := 1;
Same : Boolean := True) return Natural;
--+ OVERVIEW:
--+ Returns the position of the first occurrence of PATTERN in SOURCE
--+ after position START (returns 0 if not found). For a PATTERN of type
--+ CHARACTER and the parameter SAME set to FALSE, the position of the
--+ first CHARACTER different from PATTERN is returned.
procedure Get (Destination : out V_String; Length : in Natural);
procedure Get (File : in File_Type;
Destination : out V_String;
Length : in Natural);
--+ OVERVIEW:
--+ Overloading of TEXT_IO.GET for V_STRING. Reads LENGTH characters
--+ into DESTINATION.
--+
--+ ERROR:
--+ Raises V_STRING_LENGTH_ERROR if LENGTH > MAX_V_STRING_LENGTH.
--+ In conformance to LRM, an exception defined in package IO_EXCEPTION
--+ may be raised .
procedure Put (Source : in V_String);
procedure Put (File : in File_Type; Source : in V_String);
--+ OVERVIEW:
--+ Overloading of TEXT_IO.PUT for V_STRING.
--+ ERROR:
--+ In conformance to LRM, an exception defined in package IO_EXCEPTION
--+ may be raised .
procedure Get_Line (Destination : out V_String);
procedure Get_Line (File : in File_Type; Destination : out V_String);
--+ OVERVIEW:
--+ Overloading of TEXT_IO.GET_LINE for V_STRING.
--+ ERROR:
--+ In conformance to LRM, an exception defined in package IO_EXCEPTION
--+ may be raised .
procedure Put_Line (Source : in V_String);
procedure Put_Line (File : in File_Type; Source : in V_String);
--+ OVERVIEW:
--+ Overloading of TEXT_IO.PUT_LINE for V_STRING.
--+ ERROR:
--+ In conformance to LRM, an exception defined in package IO_EXCEPTION
--+ may be raised .
private
subtype V_String_Length is Natural range 0 .. Max_V_String_Length;
type Indirect_V_String (Length : V_String_Length := 0) is
record
Str : String (1 .. Length);
end record;
type V_String is
record
S : Indirect_V_String;
end record;
Empty_V_String : constant V_String := (S => (0, ""));
end Varying_String_G;