C# Class Lz4Net.Lz4

ファイルを表示 Open project: khalidsalomao/lz4-net Class Usage Examples

Public Methods

Method Description
Compress ( byte data, Int32 offset, Int32 length, byte &buffer, Lz4Mode mode ) : int

Compresses the byte buffer. This method stores a 8-byte header to store the original and compressed buffer size.

CompressBytes ( byte data, Int32 offset, Int32 length, Lz4Mode mode ) : byte[]

Compresses the byte buffer. This method stores a 8-byte header to store the original and compressed buffer size.

CompressBytes ( byte data, Lz4Mode mode = Lz4Mode.Fast ) : byte[]

Compresses the byte buffer. This method stores a 8-byte header to store the original and compressed buffer size.

CompressString ( string text, Lz4Mode mode = Lz4Mode.Fast ) : string

Compresses the specified text and return a Base64 enconded string.

Decompress ( byte data, int offset, byte &buffer ) : int

Decompresses the byte buffer compressed by a Lz4.CompressBytes or Lz4.Compress method. This method uses the byte array header info to correctly prepare the output buffer.

DecompressBytes ( byte data ) : byte[]

Decompresses the byte buffer compressed by a Lz4.CompressBytes or Lz4.Compress method. This method uses the byte array header info to correctly prepare the output buffer.

DecompressString ( string compressedText ) : string

Decompresses the specified compressed text by the Lz4.CompressString method.

GetCompressedSize ( byte data ) : int

Size of the compressed buffer returned by a Lz4.CompressBytes or Lz4.CompressBytesHC method.

GetUncompressedSize ( byte data ) : int

Size of the original (uncompressed) buffer returned by a Lz4.CompressBytes or Lz4.CompressBytesHC method.

LZ4_compress ( byte source, byte destination, Int32 size ) : int

Native method call (PInvoke) to the LZ4_compress method. The platform target (X86 or X64) is chosen at runtime. Description: Compresses 'isize' bytes from 'source' into 'dest'. Destination buffer must be already allocated, and must be sized to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound(). note : destination buffer must be already allocated. To avoid any problem, size it to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")

LZ4_compressBound ( int isize ) : int

Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible) primarily useful for memory allocation of output buffer.

LZ4_compressHC ( byte source, byte destination, Int32 size ) : int

Native method call (PInvoke) to the LZ4_compressHC method. It provide a High Compression mode that is slower but with a better compression rate. The platform target (X86 or X64) is chosen at runtime. Description: Compresses 'isize' bytes from 'source' into 'dest'. Destination buffer must be already allocated, and must be sized to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound(). note : destination buffer must be already allocated. To avoid any problem, size it to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")

LZ4_uncompress ( byte source, byte destination, Int32 originalSize ) : int

Native method call (PInvoke) to the LZ4_uncompress method. The platform target (X86 or X64) is chosen at runtime. Description: note : destination buffer must be already allocated. its size must be a minimum of 'osize' bytes.

Private Methods

Method Description
LZ4_compressHC_x64 ( byte source, byte destination, Int32 size ) : Int32
LZ4_compressHC_x86 ( byte source, byte destination, Int32 size ) : Int32
LZ4_compress_x64 ( byte source, byte destination, Int32 size ) : Int32
LZ4_compress_x86 ( byte source, byte destination, Int32 size ) : Int32
LZ4_uncompress_x64 ( byte source, byte destination, Int32 size ) : Int32
LZ4_uncompress_x86 ( byte source, byte destination, Int32 size ) : Int32

Method Details

Compress() public static method

Compresses the byte buffer. This method stores a 8-byte header to store the original and compressed buffer size.
public static Compress ( byte data, Int32 offset, Int32 length, byte &buffer, Lz4Mode mode ) : int
data byte The data to be compressed.
offset System.Int32 The offset.
length System.Int32 The length.
buffer byte The compression buffer. If the buffer is null or the size is insuficient, a new array will be created.
mode Lz4Mode The compression mode [Fast, HighCompression].
return int

CompressBytes() public static method

Compresses the byte buffer. This method stores a 8-byte header to store the original and compressed buffer size.
If length if outside data array bounds
public static CompressBytes ( byte data, Int32 offset, Int32 length, Lz4Mode mode ) : byte[]
data byte The data to be compressed.
offset System.Int32 The offset.
length System.Int32 The length.
mode Lz4Mode The compression mode [Fast, HighCompression].
return byte[]

CompressBytes() public static method

Compresses the byte buffer. This method stores a 8-byte header to store the original and compressed buffer size.
public static CompressBytes ( byte data, Lz4Mode mode = Lz4Mode.Fast ) : byte[]
data byte The data to be compressed.
mode Lz4Mode The compression mode [Fast, HighCompression].
return byte[]

CompressString() public static method

Compresses the specified text and return a Base64 enconded string.
public static CompressString ( string text, Lz4Mode mode = Lz4Mode.Fast ) : string
text string The text.
mode Lz4Mode The compression mode [Fast, HighCompression].
return string

Decompress() public static method

Decompresses the byte buffer compressed by a Lz4.CompressBytes or Lz4.Compress method. This method uses the byte array header info to correctly prepare the output buffer.
Input data is incomplete. Data header info size is lesser than total array size
public static Decompress ( byte data, int offset, byte &buffer ) : int
data byte The compressed data returned by a Lz4.CompressBytes or Lz4.Compress method.
offset int The data buffer offset.
buffer byte The decompression buffer. If the buffer is null or the size is insuficient, a new array will be created.
return int

DecompressBytes() public static method

Decompresses the byte buffer compressed by a Lz4.CompressBytes or Lz4.Compress method. This method uses the byte array header info to correctly prepare the output buffer.
public static DecompressBytes ( byte data ) : byte[]
data byte The compressed data returned by a Lz4.CompressBytes or Lz4.Compress method.
return byte[]

DecompressString() public static method

Decompresses the specified compressed text by the Lz4.CompressString method.
Input data is incomplete or was not generated by 'CompressString'.
public static DecompressString ( string compressedText ) : string
compressedText string The compressed text.
return string

GetCompressedSize() public static method

Size of the compressed buffer returned by a Lz4.CompressBytes or Lz4.CompressBytesHC method.
public static GetCompressedSize ( byte data ) : int
data byte The buffer returned by a Lz4.CompressBytes or Lz4.CompressBytesHC method.
return int

GetUncompressedSize() public static method

Size of the original (uncompressed) buffer returned by a Lz4.CompressBytes or Lz4.CompressBytesHC method.
public static GetUncompressedSize ( byte data ) : int
data byte The buffer returned by a Lz4.CompressBytes or Lz4.CompressBytesHC method.
return int

LZ4_compress() public static method

Native method call (PInvoke) to the LZ4_compress method. The platform target (X86 or X64) is chosen at runtime. Description: Compresses 'isize' bytes from 'source' into 'dest'. Destination buffer must be already allocated, and must be sized to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound(). note : destination buffer must be already allocated. To avoid any problem, size it to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
public static LZ4_compress ( byte source, byte destination, Int32 size ) : int
source byte The source (input).
destination byte The destination (output). Its memory must alredy be allocated, use LZ4_compressBound for the size hint.
size System.Int32 The source size. Max supported value is ~1.9GB.
return int

LZ4_compressBound() public static method

Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible) primarily useful for memory allocation of output buffer.
public static LZ4_compressBound ( int isize ) : int
isize int is the input size. Max supported value is ~1.9GB.
return int

LZ4_compressHC() public static method

Native method call (PInvoke) to the LZ4_compressHC method. It provide a High Compression mode that is slower but with a better compression rate. The platform target (X86 or X64) is chosen at runtime. Description: Compresses 'isize' bytes from 'source' into 'dest'. Destination buffer must be already allocated, and must be sized to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound(). note : destination buffer must be already allocated. To avoid any problem, size it to handle worst cases situations (input data not compressible) Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
public static LZ4_compressHC ( byte source, byte destination, Int32 size ) : int
source byte The source (input).
destination byte The destination (output). Its memory must alredy be allocated, use LZ4_compressBound for the size hint.
size System.Int32 The source size. Max supported value is ~1.9GB.
return int

LZ4_uncompress() public static method

Native method call (PInvoke) to the LZ4_uncompress method. The platform target (X86 or X64) is chosen at runtime. Description: note : destination buffer must be already allocated. its size must be a minimum of 'osize' bytes.
public static LZ4_uncompress ( byte source, byte destination, Int32 originalSize ) : int
source byte The source (input).
destination byte The destination (output). Its memory must alredy be allocated, use LZ4_compressBound for the size hint.
originalSize System.Int32 Size of the original buffer. Is the output size, therefore the original size.
return int