API Reference

Generic Package Parameter(s)

   type DATA_TYPE is private;  
   -->  Provides the data type to be stored in the data file  
  
   type KEY_TYPE is private;  
   -->  Provides the data type to be stored in the keyed (index) file  
  
   with function "<" ( Left, Right : in KEY_TYPE ) return BOOLEAN is <>;  
   -->  Provides comparison "less than" for key values  
  
   with function ">" ( Left, Right : in KEY_TYPE ) return BOOLEAN is <>;  
   -->  Provides comparison "greater than" for key values  
  

type Keyed_File_Type

  
   type Keyed_File_Type is private;  
  

exceptions

   Data_File_Error           : exception;  
   Data_File_Does_Not_Exist  : exception;  
   Data_File_End_Error       : exception;  
   Data_File_Read_Error      : exception;  
   Data_File_Is_Not_Open     : exception;  
   Index_File_Error          : exception;  
   Index_File_Does_Not_Exist : exception;  
   Index_File_End_Error      : exception;  
   Index_File_Read_Error     : exception;  
   Index_File_Is_Not_Open    : exception;  
   Data_Already_Exists       : exception;  
   Data_Does_Not_Exist       : exception;  

procedure Create_File

   procedure Create_File(   
      This : in out Keyed_File_Type;  
      File_Name : in String );  

Creates a Data_File and an Index_file.

Data_File_Error exception will be raised when a Status_Error, Mode_Error, Use_Error, or Device_Error occurs when creating the data file.

Data_File_Does_Not_Exist exception will be raised when a Name_Error occurs when creating the data file.

Index_File_Error exception will be raised when a Status_Error, Mode_Error, Use_Error, or Device_Error occurs when creating the index file.

Index_File_Does_Not_Exist exception will be raised when a Name_Error occurs when creating the index file.

procedure Open_File

   procedure Open_File(   
      This : in out Keyed_File_Type;  
      File_Name : in String );  
  

Opens a Data_File and an Index_File.

Data_File_Error exception will be raised when a Status_Error, Mode_Error, Use_Error, or Device_Error occurs when opening the data file.

Data_File_Does_Not_Exist exception will be raised when a Name_Error occurs when opening the data file.

Data_File_End_Error exception will be raised when End_Error occurs when opening the data file.

Data_File_Read_Error exception will be raised when Data_Error occurs when opening the data file.

Index_File_Error exception will be raised when a Status_Error, Mode_Error, Use_Error, or Device_Error occurs when opening the index file.

Index_File_Does_Not_Exist exception will be raised when a Name_Error occurs when opening the index file.

Index_File_End_Error exception will be raised when End_Error occurs when opening the index file.

Index_File_Read_Error exception will be raised when Data_Error occurs when opening the index file.

procedure Add_Data

   procedure Add_Data (   
      This      : in out Keyed_File_Type;  
      Key_Value : in KEY_TYPE;  
      Data      : in DATA_TYPE );  

Adds Data_Records with unique input Key_Values or duplicate Key_Values in which previous record is non-active. All Data_Records are added to the end of Data_File, while their corresponding keys are kept in ascending order in the Index_File.

Data_Already_Exists exception will be raised when record of index file already exists.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading/writing from/to the index file, or when a Use_Error (capacity of file is exceeded) ocurrs when writing to the index file. Data_File_Error exception will be raised when a Mode_Error or Use_Error (capacity of file is exceeded) ocurrs when writing to the data file.

procedure Delete_Data

   procedure Delete_Data (   
      This      : in out Keyed_File_Type;  
      Key_Value : in KEY_TYPE );  

Deletes the Data_Record associated with the input Key_Value.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading/writing from/to the index file, or when a Use_Error (capacity of file is exceeded) ocurrs when writing to the index file. Data_File_Is_Not_Open exception will be raised when attempting read/ write operations when the data file is closed.

Data_File_End_Error exception will be raised when reading beyond the end of the data file.

Data_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the data file.

Data_File_Error exception will be raised when a Mode_Error ocurrs when reading/writing from/to the data file, or when a Use_Error (capacity of file is exceeded) ocurrs when writing to the data file.

procedure Rewrite_Data

   procedure Rewrite_Data (   
      This      : in out Keyed_File_Type;  
      Key_Value : in KEY_TYPE;  
      Data      : in DATA_TYPE );  

Rewrites the Data_Record associated with the input Key_Value if Active, else raises exception.

Data_Does_Not_Exist exception will be raised when record of index file is not active.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading from the index file.

Data_File_Is_Not_Open exception will be raised when attempting write operations when the data file is closed.

Data_File_Error exception will be raised when a Mode_Error ocurrs when writing to the data file, or when a Use_Error (capacity of file is exceeded) ocurrs when writing to the data file.

procedure Read_Data

   procedure Read_Data (   
      This      : in out Keyed_File_Type;  
      Key_Value : in KEY_TYPE;  
      Data      : out DATA_TYPE );  

Reads the Data_Record associated with the input Key_Value if Active, else raises exception.

Data_Does_Not_Exist exception will be raised when record of index file is not active.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading from the index file.

Data_File_Is_Not_Open exception will be raised when attempting read operation when the data file is closed.

Data_File_End_Error exception will be raised when reading beyond the end of the data file.

Data_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the data file.

Data_File_Error exception will be raised when a Mode_Error ocurrs when reading from the data file.

procedure Read_Data_Le

   procedure Read_Data_Le (   
      This : in out Keyed_File_Type;  
      Key_Value : in KEY_TYPE;  
      Data      : out DATA_TYPE );  

Reads the Data_Record having a Key component less than or equal to input Key_Value if Active, else raises exception.

Data_Does_Not_Exist exception will be raised when record of index file is not active.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading from the index file.

Data_File_Is_Not_Open exception will be raised when attempting read operation when the data file is closed.

Data_File_End_Error exception will be raised when reading beyond the end of the data file.

Data_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the data file.

Data_File_Error exception will be raised when a Mode_Error ocurrs when reading from the data file.

procedure Read_Data_Ge

   procedure Read_Data_Ge (   
      This      : in out Keyed_File_Type;  
      Key_Value : in KEY_TYPE;  
      Data      : out DATA_TYPE );  

Reads the Data_Record having a Key component greater than or equal to input Key_Value if Active, else raises exception.

Data_Does_Not_Exist exception will be raised when record of index file is not active.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading from the index file.

Data_File_Is_Not_Open exception will be raised when attempting read operation when the data file is closed.

Data_File_End_Error exception will be raised when reading beyond the end of the data file.

Data_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the data file.

Data_File_Error exception will be raised when a Mode_Error ocurrs when reading from the data file.

procedure Read_Next_Data

   procedure Read_Next_Data (   
      This : in out Keyed_File_Type;  
      Data : out DATA_TYPE );  

Reads the next Active Data_Record indicated by the current Index_Record.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading from the index file.

Data_File_Is_Not_Open exception will be raised when attempting read operation when the data file is closed.

Data_File_End_Error exception will be raised when reading beyond the end of the data file.

Data_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the data file.

Data_File_Error exception will be raised when a Mode_Error ocurrs when reading from the data file.

procedure Close_File

   procedure Close_File(   
      This : in out Keyed_File_Type);  

Closes the active Data_File and the corresponding active Index_File.

Data_File_Is_Not_Open exception will be raised if the Data file is not open.

Index_File_Is_Not_Open exception will be raised if the Index file is not open.

function File_Exists

   function File_Exists(   
      This      : in Keyed_File_Type;  
      File_Name : in String ) return BOOLEAN;  

Determines if a Data_File and an Index_File exists for the package's File_Name.

function Data_Exists

   function Data_Exists (   
            This      : in Keyed_File_Type;  
            Key_Value : in KEY_TYPE ) return BOOLEAN;  

Determines if a Data_Record exists with the input Key_Value.

Index_File_Is_Not_Open exception will be raised when attempting read operation when the index file is closed.

Index_File_End_Error exception will be raised when reading beyond the end of the index file.

Index_File_Read_Error exception will be raised when a Data_Error ocurrs when reading from the index file.

Index_File_Error exception will be raised when a Mode_Error ocurrs when reading from the index file.