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.             ModificationTime : Time := Calendar.Convert(Ada.Calendar.Clock); 
  36.         end record; 
  37.  
  38.     -- Read data from the stream. 
  39.     procedure Read( Stream : in out Array_Stream; 
  40.                     Item   : out Stream_Element_Array; 
  41.                     Last   : out Stream_Element_Offset ); 
  42.  
  43.     -- write data to the stream, starting from the current index. 
  44.     -- Data will be overwritten from index. 
  45.     procedure Write( Stream : in out Array_Stream; 
  46.                      Item   : Stream_Element_Array ); 
  47.  
  48.     -- Set the index on the stream 
  49.     procedure Set_Index( S : access Array_Stream; To : Positive ); 
  50.  
  51.     -- returns the index of the stream 
  52.     function Index( S : access Array_Stream ) return Integer; 
  53.  
  54.     -- returns the Size of the stream 
  55.     function Size( S : access Array_Stream ) return Integer; 
  56.  
  57.     -- this procedure sets the ModificationTime of the stream 
  58.     procedure SetTime( S : access Array_Stream; 
  59.                        ModificationTime : Time ); 
  60.  
  61.     -- this procedure returns the ModificationTime of the stream 
  62.     function GetTime( S : access Array_Stream ) return Time; 
  63.  
  64.     -- returns true if the index is at the end of the stream 
  65.     function End_Of_Stream( S : access Array_Stream ) return Boolean; 
  66.  
  67. end Zip_Streams.Array_Streams;