source: Vago/Libs/zlib-1.2.8/contrib/ada/zlib-streams.ads@ 1088

Last change on this file since 1088 was 1050, checked in by s10k, 8 years ago
File size: 4.2 KB
RevLine 
[1050]1----------------------------------------------------------------
2-- ZLib for Ada thick binding. --
3-- --
4-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
5-- --
6-- Open source license information is in the zlib.ads file. --
7----------------------------------------------------------------
8
9-- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $
10
11package ZLib.Streams is
12
13 type Stream_Mode is (In_Stream, Out_Stream, Duplex);
14
15 type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
16
17 type Stream_Type is
18 new Ada.Streams.Root_Stream_Type with private;
19
20 procedure Read
21 (Stream : in out Stream_Type;
22 Item : out Ada.Streams.Stream_Element_Array;
23 Last : out Ada.Streams.Stream_Element_Offset);
24
25 procedure Write
26 (Stream : in out Stream_Type;
27 Item : in Ada.Streams.Stream_Element_Array);
28
29 procedure Flush
30 (Stream : in out Stream_Type;
31 Mode : in Flush_Mode := Sync_Flush);
32 -- Flush the written data to the back stream,
33 -- all data placed to the compressor is flushing to the Back stream.
34 -- Should not be used untill necessary, becouse it is decreasing
35 -- compression.
36
37 function Read_Total_In (Stream : in Stream_Type) return Count;
38 pragma Inline (Read_Total_In);
39 -- Return total number of bytes read from back stream so far.
40
41 function Read_Total_Out (Stream : in Stream_Type) return Count;
42 pragma Inline (Read_Total_Out);
43 -- Return total number of bytes read so far.
44
45 function Write_Total_In (Stream : in Stream_Type) return Count;
46 pragma Inline (Write_Total_In);
47 -- Return total number of bytes written so far.
48
49 function Write_Total_Out (Stream : in Stream_Type) return Count;
50 pragma Inline (Write_Total_Out);
51 -- Return total number of bytes written to the back stream.
52
53 procedure Create
54 (Stream : out Stream_Type;
55 Mode : in Stream_Mode;
56 Back : in Stream_Access;
57 Back_Compressed : in Boolean;
58 Level : in Compression_Level := Default_Compression;
59 Strategy : in Strategy_Type := Default_Strategy;
60 Header : in Header_Type := Default;
61 Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
62 := Default_Buffer_Size;
63 Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
64 := Default_Buffer_Size);
65 -- Create the Comression/Decompression stream.
66 -- If mode is In_Stream then Write operation is disabled.
67 -- If mode is Out_Stream then Read operation is disabled.
68
69 -- If Back_Compressed is true then
70 -- Data written to the Stream is compressing to the Back stream
71 -- and data read from the Stream is decompressed data from the Back stream.
72
73 -- If Back_Compressed is false then
74 -- Data written to the Stream is decompressing to the Back stream
75 -- and data read from the Stream is compressed data from the Back stream.
76
77 -- !!! When the Need_Header is False ZLib-Ada is using undocumented
78 -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
79
80 function Is_Open (Stream : Stream_Type) return Boolean;
81
82 procedure Close (Stream : in out Stream_Type);
83
84private
85
86 use Ada.Streams;
87
88 type Buffer_Access is access all Stream_Element_Array;
89
90 type Stream_Type
91 is new Root_Stream_Type with
92 record
93 Mode : Stream_Mode;
94
95 Buffer : Buffer_Access;
96 Rest_First : Stream_Element_Offset;
97 Rest_Last : Stream_Element_Offset;
98 -- Buffer for Read operation.
99 -- We need to have this buffer in the record
100 -- becouse not all read data from back stream
101 -- could be processed during the read operation.
102
103 Buffer_Size : Stream_Element_Offset;
104 -- Buffer size for write operation.
105 -- We do not need to have this buffer
106 -- in the record becouse all data could be
107 -- processed in the write operation.
108
109 Back : Stream_Access;
110 Reader : Filter_Type;
111 Writer : Filter_Type;
112 end record;
113
114end ZLib.Streams;
Note: See TracBrowser for help on using the repository browser.