with Interfaces ; with ada.streams ; with ada.streams.stream_io ; ---------------------------------------------------------------------- -- Abstract : Bits_Io -- This package converts a normal I/O stream into a bit level I/O ---------------------------------------------------------------------- package Bits_Io is type File_Type is limited private; type File_Mode is (In_File, Out_File, Append_File); type Vector_type is array (natural range <>) of boolean ; pragma pack( Vector_Type ) ; -- Abstract : Open -- A file is opened using normal File Management facilities first and then -- a Bit Stream File is created using the following procedure. It is the same -- procedure whether performing input or output. It is assumed that the file -- is used only for one of these purposes at any time. procedure Open (File : in out File_Type; Mode : in File_Mode ; Stream : access Ada.Streams.Root_Stream_Type'Class ) ; -- Abstract : Read/Write -- The following two procedures allow an Unsigned_8 variable to read or -- write. Similar procedures for Unsigned_16 and Unsigned_32 are also provided procedure Read (File : in out File_Type ; Item : out Interfaces.Unsigned_8 ; Last : out Ada.Streams.Stream_Element_Offset) ; -- Returns the number of bits actually read procedure Write (File : in out File_Type ; Item : in Interfaces.Unsigned_8 ; Last : in integer ); -- How many bits should really be written? procedure Read (File : in out File_Type ; Item : out Interfaces.Unsigned_16 ; Last : out Ada.Streams.Stream_Element_Offset) ; procedure Write (File : in out File_Type ; Item : in Interfaces.Unsigned_16 ; Last : in integer ); procedure Read (File : in out File_Type ; Item : out Interfaces.Unsigned_32 ; Last : out Ada.Streams.Stream_Element_Offset) ; procedure Write (File : in out File_Type ; Item : in Interfaces.Unsigned_32 ; Last : in integer ); -- Abstract : Read/Write -- These are the real I/O procedures where all the work is done. The above -- routines simply call these internally. procedure Read (File : in out File_Type ; Item : out Vector_Type ; Last : out Ada.Streams.Stream_Element_Offset) ; procedure Write (File : in out File_Type ; Item : in Vector_Type ); -- Abstract : Flush -- Used for writing operations, sends any residual bits to the output stream -- packed in a byte. procedure Flush (File : in out File_Type ) ; private type Root_Stream_Access_Type is access all Ada.Streams.Root_Stream_Type'Class ; type File_Type is record Opened : Boolean := False ; Ac : Root_Stream_Access_Type ; Mode : File_Mode ; Residue : Interfaces.Unsigned_8 ; Bits_Used : Integer ; end record ; end Bits_Io ; -- $Author: Administrator $ -- $Revision: 1.1.1.1 $ -- $Log: bits_io.ads,v $ -- Revision 1.1.1.1 2000/08/04 06:07:07 Administrator -- Initial Checkin -- -- Revision 1.1 1998/09/12 04:43:32 srinivr -- Bit level Stream Input/Output routines. Initial Check in with -- some known problems. -- -- Revision 1.1 1998/01/27 03:39:33 srinivr -- Added annotations --