NDEVR
API Documentation
Compressor

A series of static methods designed to compress objects and reduce their memory consumption or file size. More...

Static Public Member Functions

static CompressedStringInfo AddString (BinaryCompressionObject &data, const String &string)
 Adds a string to the BinaryCompressionObject, returning the Compressed string info.
template<class t_type, class t_memory_manager>
static std::enable_if< ObjectInfo< t_type >::Buffer >::type Compress (BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< t_type, t_memory_manager > &data)
 Compresses a buffer of buffer-type elements (nested buffers) by flattening sub-buffer sizes and contents, then compressing each part separately.
template<class t_type, class t_memory_manager>
static std::enable_if<!ObjectInfo< t_type >::Buffer >::type Compress (BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< t_type, t_memory_manager > &data)
 Compresses a buffer of non-buffer (flat) elements into the given compression object.
static void CompressData (BinaryCompressionObject &data)
 Compresses the BinaryCompressionObject.
template<class t_memory_manager>
static void CompressString (BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< String, t_memory_manager > &data)
 Compresses a buffer of strings by adding each to the shared string table and then compressing the resulting index buffer.
static void DecompressData (BinaryCompressionObject &data)
 Decompresses the BinaryCompressionObject.
static char * GetString (BinaryCompressionObject &data, const Bounds< 1, uint04 > &bounds)
 Retrieves a raw string pointer from the compression object using byte offset bounds.
static char * GetString (BinaryCompressionObject &data, uint04 index)
 Retrieves a raw string pointer from the compression object by reference index.
static uint04 GetStringLength (BinaryCompressionObject &data, uint04 index)
 Returns the length of a stored string identified by its reference index.
template<class t_type>
static CompressionMode PickCompressionMode (CompressionMode compression_mode=e_default_compression)
 Selects the most appropriate compression mode for the given type.
static sint04 ZLibCompress (uint01 *compressed, const uint01 *uncompressed, size_t &compressed_size, size_t decompressed_size)
 A simple, raw call into zlibs compress function, except if the compressed size is larger than the uncompressed size, in which case the contents of compressed are copied over.
static sint04 ZLibCompressFile (File src, File output, const PasswordString &password=PasswordString())
 Compresses a file or folder and writes it to an output.
static sint04 ZLibDecompress (const uint01 *compressed, uint01 *uncompressed, size_t compressed_size, size_t &decompressed_size)
 A simple, raw call into zlibs uncompress function.
static sint04 ZLibDecompressFile (File src, File output_dir, const PasswordString &password=PasswordString())
 Decompresses a file or folder and writes it to an output directory.
static Module ZLibModule ()
 Returns module information for the version of zlib used in this implementation.

Detailed Description

A series of static methods designed to compress objects and reduce their memory consumption or file size.


Typically objects are added to a BinaryCompressionObject which does something with the data and allows this function to be safely used in a mutlithreaded envirnoment.

Definition at line 73 of file Compressor.h.

Member Function Documentation

◆ Compress() [1/2]

template<class t_type, class t_memory_manager>
std::enable_if< ObjectInfo< t_type >::Buffer >::type Compressor::Compress ( BinaryCompressionObject & object,
Buffer< uint01 > & compression_data,
const Buffer< t_type, t_memory_manager > & data )
inlinestatic

Compresses a buffer of buffer-type elements (nested buffers) by flattening sub-buffer sizes and contents, then compressing each part separately.

A linked BinaryCompressionObject is created to hold the size data, while the main object holds the combined element data.

Parameters
[in]objectThe compression object to populate and compress into.
[in]compression_dataOutput buffer that receives all compressed byte data.
[in]dataThe source buffer of nested buffers to compress.

Definition at line 267 of file Compressor.h.

References cast(), Compress(), BinaryCompressionObject::compressed_data, BinaryCompressionObject::compressed_size, and BinaryCompressionObject::compression_link.

◆ Compress() [2/2]

template<class t_type, class t_memory_manager>
std::enable_if<!ObjectInfo< t_type >::Buffer >::type Compressor::Compress ( BinaryCompressionObject & object,
Buffer< uint01 > & compression_data,
const Buffer< t_type, t_memory_manager > & data )
inlinestatic

Compresses a buffer of non-buffer (flat) elements into the given compression object.

Populates the BinaryCompressionObject with type info and size, selects the appropriate compression mode, then delegates to CompressData to perform the actual compression.

Parameters
[in]objectThe compression object to populate and compress into.
[in]compression_dataOutput buffer that receives the compressed byte data.
[in]dataThe source buffer of elements to compress.

Definition at line 200 of file Compressor.h.

References cast(), CompressData(), e_string_compression, e_string_reference, GetTypeInfo(), and PickCompressionMode().

Referenced by Compress(), TableColumnBuffer< t_type >::compress(), and CompressString().

◆ CompressString()

template<class t_memory_manager>
void Compressor::CompressString ( BinaryCompressionObject & object,
Buffer< uint01 > & compression_data,
const Buffer< String, t_memory_manager > & data )
inlinestatic

Compresses a buffer of strings by adding each to the shared string table and then compressing the resulting index buffer.

Parameters
[in]objectThe compression object that holds the string reference table.
[in]compression_dataOutput buffer that receives the compressed index data.
[in]dataThe source buffer of strings to compress.

Definition at line 244 of file Compressor.h.

References AddString(), Compress(), and CompressedStringInfo::index.

◆ GetString() [1/2]

char * Compressor::GetString ( BinaryCompressionObject & data,
const Bounds< 1, uint04 > & bounds )
static

Retrieves a raw string pointer from the compression object using byte offset bounds.

Parameters
[in]dataThe compression object containing the string data.
[in]boundsThe byte offset bounds identifying the string within the buffer.
Returns
A pointer to the null-terminated string data.

◆ GetString() [2/2]

char * Compressor::GetString ( BinaryCompressionObject & data,
uint04 index )
static

Retrieves a raw string pointer from the compression object by reference index.

Parameters
[in]dataThe compression object containing the string data.
[in]indexThe reference index of the string to retrieve.
Returns
A pointer to the null-terminated string data.

◆ GetStringLength()

uint04 Compressor::GetStringLength ( BinaryCompressionObject & data,
uint04 index )
static

Returns the length of a stored string identified by its reference index.

Parameters
[in]dataThe compression object containing the string data.
[in]indexThe reference index of the string.
Returns
The length of the string in characters.

◆ PickCompressionMode()

template<class t_type>
CompressionMode Compressor::PickCompressionMode ( CompressionMode compression_mode = e_default_compression)
inlinestatic

Selects the most appropriate compression mode for the given type.

If the requested mode is e_best_compression or e_default_compression, this method inspects the type traits to pick a specialized mode (e.g., string reference or ZFP floating-point).

Parameters
[in]compression_modeThe initial or requested compression mode.
Returns
The resolved compression mode best suited for t_type.

Definition at line 147 of file Compressor.h.

References e_best_compression, e_default_compression, e_floating_point_compression_1_fltp04, e_floating_point_compression_1_fltp08, e_floating_point_compression_2_fltp04, e_floating_point_compression_2_fltp08, e_floating_point_compression_3_fltp04, e_floating_point_compression_3_fltp08, e_floating_point_compression_4_fltp04, e_floating_point_compression_4_fltp08, and e_string_reference.

Referenced by Compress(), BinaryFile::write(), and BinaryFile::write().

◆ ZLibCompressFile()

sint04 Compressor::ZLibCompressFile ( File src,
File output,
const PasswordString & password = PasswordString() )
static

Compresses a file or folder and writes it to an output.

Optionally, a password may be used to ensure contents are protected. This will not destroy or alter the original source file.

Exceptions
FileExceptionif the output_dir is not a directory or if IO operations fail.

◆ ZLibDecompressFile()

sint04 Compressor::ZLibDecompressFile ( File src,
File output_dir,
const PasswordString & password = PasswordString() )
static

Decompresses a file or folder and writes it to an output directory.

Optionally, a password may be used to decode the data. This will not destroy or alter the original zip file.

Exceptions
FileExceptionif the output_dir is not a directory or if IO operations fail.

The documentation for this class was generated from the following file: