1. with Ada.Unchecked_Deallocation; 
  2.  
  3. package Zip_Streams.Array_Streams is 
  4.  
  5.     type A_SEA is access all Stream_Element_Array; 
  6.  
  7.     procedure Delete is new Ada.Unchecked_Deallocation( Stream_Element_Array, A_SEA ); 
  8.  
  9.     --------------------------------------------------------------------- 
  10.     -- Array_Stream: stream based on an in-memory Stream_Element_Array -- 
  11.     --------------------------------------------------------------------- 
  12.     type Array_Stream is new Root_Zipstream_Type with private; 
  13.     type A_Array_Stream is access all Array_Stream'Class; 
  14.  
  15.     -- Set a value in the stream, the index will be set 
  16.     -- to null and old data in the stream will be lost. 
  17.     procedure Set( Str : in out Array_Stream; Buf : in out A_SEA ); 
  18.  
  19.     -- Close the Array_Stream and delete its backing buffer 
  20.     procedure Close( Str : in out Array_Stream ); 
  21.  
  22.     procedure Delete( Str : in out A_Array_Stream ); 
  23.  
  24.     Out_Of_Bounds, 
  25.     Null_Stream, 
  26.     Stream_Overflow : exception; 
  27.  
  28. private 
  29.  
  30.     -- Array Stream spec 
  31.     type Array_Stream is new Root_Zipstream_Type with 
  32.         record 
  33.             Buf  : A_SEA := null; 
  34.             Loc  : Stream_Element_Offset := 1; 
  35.             Name : Unbounded_String; 
  36.             ModificationTime : Time := Calendar.Convert(Ada.Calendar.Clock); 
  37.         end record; 
  38.  
  39.     -- Read data from the stream. 
  40.     procedure Read( Stream : in out Array_Stream; 
  41.                     Item   : out Stream_Element_Array; 
  42.                     Last   : out Stream_Element_Offset ); 
  43.  
  44.     -- write data to the stream, starting from the current index. 
  45.     -- Data will be overwritten from index. 
  46.     procedure Write( Stream : in out Array_Stream; 
  47.                      Item   : Stream_Element_Array ); 
  48.  
  49.     -- Set the index on the stream 
  50.     procedure Set_Index( S : access Array_Stream; To : Positive ); 
  51.  
  52.     -- returns the index of the stream 
  53.     function Index( S : access Array_Stream ) return Integer; 
  54.  
  55.     -- returns the Size of the stream 
  56.     function Size( S : access Array_Stream ) return Integer; 
  57.  
  58.     -- sets the name of the stream 
  59.     procedure SetName( S : access Array_Stream; Name : String ); 
  60.  
  61.     -- returns the name of the stream 
  62.     function GetName( S : access Array_Stream ) return String; 
  63.  
  64.     -- this procedure sets the ModificationTime of the stream 
  65.     procedure SetTime( S : access Array_Stream; 
  66.                        ModificationTime : Time ); 
  67.  
  68.     -- this procedure returns the ModificationTime of the stream 
  69.     function GetTime( S : access Array_Stream ) return Time; 
  70.  
  71.     -- returns true if the index is at the end of the stream 
  72.     function End_Of_Stream( S : access Array_Stream ) return Boolean; 
  73.  
  74. end Zip_Streams.Array_Streams;