ReplicaNet and RNLobby  1
Public Member Functions | List of all members
XPCompression Class Reference

#include <XPCompression.h>

Public Member Functions

 XPCompression ()
 
virtual ~XPCompression ()
 
int CalculateMaximumMemory (int size)
 
bool Compress (void *source_data, int source_length, void *destination_data, int *destination_length, int level=10)
 
bool Decompress (void *source_data, int source_length, void *destination_data, int *destination_length, int max_buffer_size)
 

Detailed Description

A general purpose lossless compression and decompression class which implements the LZMPi compression algorithm.

Constructor & Destructor Documentation

The ctor performs some basic initialisation

virtual ~XPCompression ( )
virtual

The dtor makes sure everything is tidy

Member Function Documentation

int CalculateMaximumMemory ( int  size)

Given an input size calculate the maximum absolute worse case for the compressed output

Parameters
sizethe size of the data
Returns
the worse case output length
bool Compress ( void *  source_data,
int  source_length,
void *  destination_data,
int *  destination_length,
int  level = 10 
)

Compress a block of memory

Parameters
source_datathe source data
source_lengththe source data length in bytes
destination_datathe destination data
destination_lengththe pointer to the destination data length in bytes to fill in
levelthe compression level to use. 1 is fast and 10 is best but slower. The default for this parameter is 10. Compression level 6 is a good balance between compression ratio and speed.
Returns
true is no error else false for an error
bool Decompress ( void *  source_data,
int  source_length,
void *  destination_data,
int *  destination_length,
int  max_buffer_size 
)

Decompress a block of memory

Parameters
source_datathe source data
source_lengththe source data length in bytes
destination_datathe destination data
destination_lengththe pointer to the destination data length in bytes to fill in
max_buffer_sizethe maximum size of the destination buffer
Returns
true is no error else false for an error