Giter VIP home page Giter VIP logo

zflate's Introduction

zflate

This unit allows you to easily compress and decompress buffers and strings like in PHP. Main goal of this unit is to be as small as possible.

  • compiled demo is ~80 kB in size
  • adding unit to uses section increases binary size by ~45 kB, even less if you already use zlib units for other things

Status

Compression Decompression
FunctionFormatStatus
gzdeflate()DEFLATE
gzcompress()ZLIB
gzencode()GZIP
FunctionFormatStatus
gzinflate()DEFLATE
gzuncompress()ZLIB
gzdecode()GZIP
zdecompress()ANY

Usage

compressed := gzencode('some string');
decompressed := gzdecode(compressed);

Use zdecompress() to auto detect stream type and decompress:

compressed := gzencode('some string');
decompressed := zdecompress(compressed);

Functions

//compress whole buffer to DEFLATE at once
function gzdeflate(data: pointer; size: dword; var output: pointer; var outputsize: dword; level: dword=9): boolean;
//compress whole string to DEFLATE at once
function gzdeflate(str: string; level: dword=9): string;
//compress whole bytes to DEFLATE at once
function gzdeflate(bytes: TBytes; level: dword=9): TBytes;
//decompress whole DEFLATE buffer at once
function gzinflate(data: pointer; size: dword; var output: pointer; var outputsize: dword): boolean;
//decompress whole DEFLATE string at once
function gzinflate(str: string): string;
//decompress whole DEFLATE bytes at once
function gzinflate(bytes: TBytes): TBytes;     

//compress whole buffer to ZLIB at once
function gzcompress(data: pointer; size: dword; var output: pointer; var outputsize: dword; level: dword=9): boolean;
//compress whole string to ZLIB at once
function gzcompress(str: string; level: dword=9): string;
//compress whole buffer to ZLIB at once
function gzcompress(bytes: TBytes; level: dword=9): TBytes;
//decompress whole ZLIB buffer at once
function gzuncompress(data: pointer; size: dword; var output: pointer; var outputsize: dword): boolean;
//decompress whole ZLIB string at once
function gzuncompress(str: string): string;
//decompress whole ZLIB buffer at once
function gzuncompress(bytes: TBytes): TBytes;

//compress whole buffer to GZIP at once
function gzencode(data: pointer; size: dword; var output: pointer; var outputsize: dword; level: dword=9; filename: string=''; comment: string=''): boolean;
//compress whole string to GZIP at once
function gzencode(str: string; level: dword=9; filename: string=''; comment: string=''): string;
//compress whole string to GZIP at once
function gzencode(bytes: TBytes; level: dword=9; filename: string=''; comment: string=''): TBytes;
//decompress whole GZIP buffer at once
function gzdecode(data: pointer; size: dword; var output: pointer; var outputsize: dword): boolean;
//decompress whole GZIP string at once
function gzdecode(str: string): string;
//decompress whole GZIP string at once
function gzdecode(bytes: TBytes): TBytes;

//try to detect buffer format and decompress it at once
function zdecompress(data: pointer; size: dword; var output: pointer; var outputsize: dword): boolean;
//try to detect string format and decompress it at once
function zdecompress(str: string): string;
//try to detect bytes format and decompress it at once
function zdecompress(bytes: TBytes): TBytes;

zflatefiles

Additional unit to handle bigger files. Read & write & compress/decompress by chunks.

Status

Compression Decompression
FunctionFormatStatus
gzdeflate_file()DEFLATE
gzcompress_file()ZLIB
gzencode_file()GZIP
FunctionFormatStatus
gzinflate_file()DEFLATE
gzuncompress_file()ZLIB
gzdecode_file()GZIP

Functions

//compress a file to GZIP
function gzencode_file(src, dst: string; level: dword=9; filename: string=''; comment: string=''; progresscb: tzprogresscb=nil; resolution: dword=100): boolean;
//decompress a GZIP file
function gzdecode_file(src, dst: string; progresscb: tzprogresscb=nil; resolution: dword=100): boolean;  

A callback may be provided to these functions. Callback function may abort ongoing operation by returning false.

zflate's People

Contributors

fibodevy avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

grahamegrieve

zflate's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.