1topic "Zlib encapsulation"; 2[2 $$0,0#00000000000000000000000000000000:Default] 3[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] 4[l288;2 $$2,2#27521748481378242620020725143825:desc] 5[0 $$3,0#96390100711032703541132217272105:end] 6[H6;0 $$4,0#05600065144404261032431302351956:begin] 7[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item] 8[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement] 9[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] 10[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] 11[b42;2 $$9,9#13035079074754324216151401829390:normal] 12[{_} 13[ {{10000@(113.42.0) [s0;%% [*@7;4 Zlib]]}}&] 14[s3; &] 15[s1;:Zlib`:`:class: [@(0.0.255)3 class][3 _][*3 Zlib]&] 16[s2;%% This class encapsulates zlib library to provide compression/decompression 17utility.&] 18[s2;%% Encapsulation is specifically designed to allow streaming 19mode of operations. Input data are fed using Put method and can 20be either obtained at output as partial String, or through output 21callback. If using String, it is also always possible to clear 22this output partial String to conserve memory.&] 23[s3; &] 24[ {{10000F(128)G(128)@1 [s0;%% [* Public Method List]]}}&] 25[s3; &] 26[s5;:Zlib`:`:WhenOut: [_^Callback2^ Callback2]<[@(0.0.255) const]_[@(0.0.255) void]_`*, 27[_^dword^ int]>_[* WhenOut]&] 28[s2;%% Output callback. Represents `"consumer function`": When there 29are output data available, they are passed out using this callback. 30Default value stores data into output String inside Zlib.&] 31[s3; &] 32[s4; &] 33[s5;:Zlib`:`:Compress`(`): [@(0.0.255) void]_[* Compress]()&] 34[s2;%% Sets Zlib into compression mode (`"deflate`" in zlib terminology).&] 35[s3; &] 36[s4; &] 37[s5;:Zlib`:`:Decompress`(`): [@(0.0.255) void]_[* Decompress]()&] 38[s2;%% Sets Zlib into decompression mode (`"inflate`" in zlib terminology).&] 39[s3; &] 40[s4; &] 41[s5;:Zlib`:`:Put`(const void`*`,int`): [@(0.0.255) void]_[* Put]([@(0.0.255) const]_[@(0.0.255) v 42oid]_`*[*@3 ptr], [@(0.0.255) int]_[*@3 size])&] 43[s5;:Zlib`:`:Put`(const String`&`): [@(0.0.255) void]_[* Put]([@(0.0.255) const]_[_^String^ S 44tring][@(0.0.255) `&]_[*@3 s])&] 45[s2;%% Puts a block of data to be processed (compressed or decompressed 46based on mode) by Zlib.&] 47[s3;%% &] 48[s4; &] 49[s5;:Zlib`:`:End`(`): [@(0.0.255) void]_[* End]()&] 50[s2;%% Signals the end of input stream.&] 51[s3; &] 52[s4; &] 53[s5;:Zlib`:`:Clear`(`): [@(0.0.255) void]_[* Clear]()&] 54[s2;%% Resets Zlib to initial state (throws out data).&] 55[s3; &] 56[s4; &] 57[s5;:Zlib`:`:Get`(`)const: [@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[* Get]()_[@(0.0.255) c 58onst]&] 59[s5;:Zlib`:`:operator const String`&`(`)const: [@(0.0.255) operator][* _const_String`&]() 60_[@(0.0.255) const]&] 61[s5;:Zlib`:`:operator`~`(`)const: [@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[* ope 62rator`~]()_[@(0.0.255) const]&] 63[s2;%% Returns current output String (it only gets created if WhenOut 64is not redirected somewhere else).&] 65[s3; &] 66[s4; &] 67[s5;:Zlib`:`:ClearOut`(`): [@(0.0.255) void]_[* ClearOut]()&] 68[s2;%% Clears output String. Can be called anytime.&] 69[s3; &] 70[s4; &] 71[s5;:Zlib`:`:GetCRC`(`)const: [_^dword^ dword]_[* GetCRC]()_[@(0.0.255) const]&] 72[s2;%% Returns CRC of uncompressed stream, if CRC mode is active.&] 73[s3; &] 74[s4; &] 75[s5;:Zlib`:`:IsError`(`)const: [@(0.0.255) bool]_[* IsError]()_[@(0.0.255) const]&] 76[s2;%% Returns true if there was error processing input.&] 77[s3; &] 78[s4; &] 79[s5;:Zlib`:`:GetGZipName`(`)const: [_^String^ String]_[* GetGZipName]()_[@(0.0.255) const]&] 80[s2;%% If GZip mode is active and Gzip header is processed, returns 81the name of file.&] 82[s3; &] 83[s4; &] 84[s5;:Zlib`:`:GetGZipComment`(`)const: [_^String^ String]_[* GetGZipComment]()_[@(0.0.255) c 85onst]&] 86[s2;%% If GZip mode is active and Gzip header is processed, returns 87the gzip comment.&] 88[s3; &] 89[s4; &] 90[s5;:Zlib`:`:GZip`(bool`): [_^Zlib^ Zlib][@(0.0.255) `&]_[* GZip]([@(0.0.255) bool]_[*@3 gzip`_ 91]_`=_[@(0.0.255) true])&] 92[s2;%% Activates GZip mode. In this mode Zlib is able to directly 93process .gzip file format.&] 94[s3;%% &] 95[s4; &] 96[s5;:Zlib`:`:Header`(bool`): [_^Zlib^ Zlib][@(0.0.255) `&]_[* Header]([@(0.0.255) bool]_[*@3 hd 97r`_]_`=_[@(0.0.255) true])&] 98[s2;%% Activates zlib header (see zlib documentation for details).&] 99[s3;%% &] 100[s4; &] 101[s5;:Zlib`:`:NoHeader`(`): [_^Zlib^ Zlib][@(0.0.255) `&]_[* NoHeader]()&] 102[s2;%% Same as Header(false).&] 103[s3; &] 104[s4; &] 105[s5;:Zlib`:`:CRC`(bool`): [_^Zlib^ Zlib][@(0.0.255) `&]_[* CRC]([@(0.0.255) bool]_[*@3 b]_`=_[@(0.0.255) t 106rue])&] 107[s2;%% Activates CRC mode. In this mode, Zlib gathers CRC of uncompressed 108data that can be at the end obtained by GetCRC method.&] 109[s3;%% &] 110[s4; &] 111[s5;:Zlib`:`:NoCRC`(`): [_^Zlib^ Zlib][@(0.0.255) `&]_[* NoCRC]()&] 112[s2;%% Same as CRC(false).&] 113[s3; &] 114[s4; &] 115[s5;:Zlib`:`:ChunkSize`(int`): [_^Zlib^ Zlib][@(0.0.255) `&]_[* ChunkSize]([@(0.0.255) int]_[*@3 n 116])&] 117[s2;%% Sets the maximum amount of input or output data to be processed 118in single zlib call.&] 119[s3;%% &] 120[s4; &] 121[s5;:Zlib`:`:Level`(int`): [_^Zlib^ Zlib][@(0.0.255) `&]_[* Level]([@(0.0.255) int]_[*@3 compre 122ssion`_lvl])&] 123[s2;%% Sets the compresison level. Must be 1..9. Default level is 1246.&] 125[s3;%% &] 126[s4; &] 127[s5;:Zlib`:`:Zlib`(`): [* Zlib]()&] 128[s2;%% Constructor.&] 129[s3; &] 130[s4; &] 131[s5;:Zlib`:`:`~Zlib`(`): [@(0.0.255) `~][* Zlib]()&] 132[s2;%% Destructor.&] 133[s3;%% &] 134[s0; &] 135[ {{10000@(113.42.0) [s0;%% [*@7;4 Compression / decompression functions]]}}&] 136[s3; &] 137[s5;:ZCompress`(Stream`&`,Stream`&`,int64`,Gate2`<int64`,int64`>`,bool`): [_^int64^ int 13864]_[* ZCompress]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `& 139]_[*@3 in], [_^int64^ int64]_[*@3 size], [_^Gate2^ Gate2]<[_^int64^ int64], 140[_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false], [@(0.0.255) bool]_[*@3 hdr]_`=_[@(0.0.255) t 141rue])&] 142[s5;:ZCompress`(Stream`&`,Stream`&`,Gate2`<int64`,int64`>`): [_^int64^ int64]_[* ZCompres 143s]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `&]_[*@3 in], 144[_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 145[s5;:ZCompress`(const void`*`,int64`,Gate2`<int64`,int64`>`): [_^String^ String]_[* ZComp 146ress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [_^int64^ int64]_[*@3 len], 147[_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 148[s5;:ZCompress`(const String`&`,Gate2`<int64`,int64`>`): [_^String^ String]_[* ZCompress]( 149[@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 s], [_^Gate2^ Gate2]<[_^int64^ int6 1504], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 151[s2;%% Compresses raw data using zlib from input stream [%-*@3 in], 152memory [%-*@3 data][%- , ][%-*@3 len] or input string [%-*@3 s] to output 153stream [%-*@3 out] (in this case returns a number of bytes written 154or negative integer to signal error) or into String return value 155(returns IsVoid String on error). [%-*@3 progress] can be used 156to track progress of operation, returning true cancels operation. 157Parameter [%-*@3 hdr] can be used to switch`-off zlib header (see 158zlib documentation for details).&] 159[s3;%% &] 160[s4; &] 161[s5;:ZDecompress`(Stream`&`,Stream`&`,int64`,Gate2`<int64`,int64`>`,bool`): [_^int64^ i 162nt64]_[* ZDecompress]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `& 163]_[*@3 in], [_^int64^ int64]_[*@3 size], [_^Gate2^ Gate2]<[_^int64^ int64], 164[_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false], [@(0.0.255) bool]_[*@3 hdr]_`=_[@(0.0.255) t 165rue])&] 166[s5;:ZDecompress`(Stream`&`,Stream`&`,int64`,Gate2`<int64`,int64`>`): [_^int64^ int64]_ 167[* ZDecompress]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `& 168]_[*@3 in], [_^int64^ int64]_[*@3 size], [_^Gate2^ Gate2]<[_^int64^ int64], 169[_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 170[s5;:ZDecompress`(Stream`&`,Stream`&`,Gate2`<int64`,int64`>`): [_^int64^ int64]_[* ZDecom 171press]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `&]_[*@3 in 172], [_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false 173])&] 174[s5;:ZDecompress`(const void`*`,int64`,Gate2`<int64`,int64`>`): [_^String^ String]_[* ZDe 175compress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [_^int64^ int64]_[*@3 len], 176[_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 177[s5;:ZDecompress`(const String`&`,Gate2`<int64`,int64`>`): [_^String^ String]_[* ZDecompr 178ess]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 s], [_^Gate2^ Gate2]<[_^int64^ i 179nt64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 180[s2;%% Decompresses raw data using zlib from input stream [%-*@3 in], 181memory [%-*@3 data][%- , ][%-*@3 len] or input string [%-*@3 s] to output 182stream [%-*@3 out] (in this case returns a number of bytes written 183or negative integer to signal error) or into String return value 184(returns IsVoid String on error). [%-*@3 progress] can be used 185to track progress of operation, returning true cancels operation. 186Parameter [%-*@3 hdr] can be used to switch`-off zlib header (see 187zlib documentation for details).&] 188[s3;%% &] 189[s4;%% &] 190[s5;:GZCompress`(Stream`&`,Stream`&`,int64`,Gate2`<int64`,int64`>`): [_^int64^ int64]_[* G 191ZCompress]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `&]_[*@3 i 192n], [_^int64^ int64]_[*@3 size], [_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 pr 193ogress]_`=_[@(0.0.255) false])&] 194[s5;:GZCompress`(Stream`&`,Stream`&`,Gate2`<int64`,int64`>`): [_^int64^ int64]_[* GZCompr 195ess]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `&]_[*@3 in], 196 [_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false]) 197&] 198[s5;:GZCompress`(const void`*`,int`,Gate2`<int64`,int64`>`): [_^String^ String]_[* GZComp 199ress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [@(0.0.255) int]_[*@3 len], 200[_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 201[s5;:GZCompress`(const String`&`,Gate2`<int64`,int64`>`): [_^String^ String]_[* GZCompres 202s]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 s], [_^Gate2^ Gate2]<[_^int64^ i 203nt64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 204[s2;%% Compresses raw data into gzip file format from input stream 205[%-*@3 in], memory [%-*@3 data][%- , ][%-*@3 len] or input string [%-*@3 s] 206to output stream [%-*@3 out] (in this case returns a number of 207bytes written or negative integer to signal error) or into String 208return value (returns IsVoid String on error). [%-*@3 progress] 209can be used to track progress of operation, returning true cancels 210operation.&] 211[s3;%% &] 212[s4;%% &] 213[s5;:GZDecompress`(Stream`&`,Stream`&`,int64`,Gate2`<int64`,int64`>`): [_^int64^ int64]_ 214[* GZDecompress]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `& 215]_[*@3 in], [_^int64^ int64]_[*@3 size], [_^Gate2^ Gate2]<[_^int64^ int64], 216[_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 217[s5;:GZDecompress`(Stream`&`,Stream`&`,Gate2`<int64`,int64`>`): [_^int64^ int64]_[* GZDec 218ompress]([_^Stream^ Stream][@(0.0.255) `&]_[*@3 out], [_^Stream^ Stream][@(0.0.255) `&]_[*@3 i 219n], [_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) fals 220e])&] 221[s5;:GZDecompress`(const void`*`,int`,Gate2`<int64`,int64`>`): [_^String^ String]_[* GZDe 222compress]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [@(0.0.255) int]_[*@3 len], 223[_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 224[s5;:GZDecompress`(const String`&`,Gate2`<int64`,int64`>`): [_^String^ String]_[* GZDecom 225press]([@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 s], 226[_^Gate2^ Gate2]<[_^int64^ int64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 227[s2;%% Decompresses raw data into gzip file format from input stream 228[%-*@3 in], memory [%-*@3 data][%- , ][%-*@3 len] or input string [%-*@3 s] 229to output stream [%-*@3 out] (in this case returns a number of 230bytes written or negative integer to signal error) or into String 231return value (returns IsVoid String on error). [%-*@3 progress] 232can be used to track progress of operation, returning true cancels 233operation.&] 234[s3;%% &] 235[s4;%% &] 236[s5;:GZCompressFile`(const char`*`,const char`*`,Gate2`<int64`,int64`>`): [@(0.0.255) b 237ool]_[* GZCompressFile]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 dstfile], 238[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 srcfile], [_^Gate2^ Gate2]<[_^int64^ int64], 239[_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 240[s5;:GZCompressFile`(const char`*`,Gate2`<int64`,int64`>`): [@(0.0.255) bool]_[* GZCompre 241ssFile]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 srcfile], [_^Gate2^ Gate2]<[_^int64^ in 242t64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 243[s2;%% Compresses file into gzip format. If [%-*@3 dstfile] is not 244present, the name is created by appending .gz extension to [%-*@3 srcfile]. 245Returns true on success.&] 246[s3;%% &] 247[s4;%% &] 248[s5;:GZDecompressFile`(const char`*`,const char`*`,Gate2`<int64`,int64`>`): [@(0.0.255) b 249ool]_[* GZDecompressFile]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 dstfile], 250[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 srcfile], [_^Gate2^ Gate2]<[_^int64^ int64], 251[_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 252[s5;:GZDecompressFile`(const char`*`,Gate2`<int64`,int64`>`): [@(0.0.255) bool]_[* GZDeco 253mpressFile]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 srcfile], [_^Gate2^ Gate2]<[_^int64^ i 254nt64], [_^int64^ int64]>_[*@3 progress]_`=_[@(0.0.255) false])&] 255[s2;%% Decompresses file from gzip format. If [%-*@3 dstfile] is not 256present, the name is created by removing .gz extension to [%-*@3 srcfile]. 257If [%-*@3 srcfile] does not have .gz extension, function returns 258false to signal error and does nothing. Returns true on success.&] 259[s0;%% ]]