All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ZString Class Reference

#include <UT_ZString.h>

Public Types

enum  Style { NONE, GZIP, BLOSC }

Public Member Functions

 UT_ZString ()=default
 UT_ZString (const UT_StringRef &src, Style style=GZIP, int level=9)
Style compress (const UT_StringRef &s, Style style=GZIP, int level=1)
UT_StringHolder uncompress () const
 Return the uncompressed contents. More...
const UT_StringHoldercompressedString () const
Style compressedStyle () const
exint originalSize () const

Static Public Member Functions

static const char * style (Style s)
static Style style (const char *s)
int64 getMemoryUsage (bool inclusive) const
SYS_HashType hash () const
bool operator== (const UT_ZString &s) const
std::size_t hash_value (const UT_ZString &s)

Detailed Description

Storage to hold compressed data.

This class will take a buffer of data and compress it. You can access the raw compressed data using compressedString(), or easily get a copy of the uncompressed data by calling uncompress().

Since UT_StringRef can hold binary data, this is a convenient way of compressing data that has infrequent access (or possibly never accessed). For example:

void *binary_data;
UT_ZString z(UT_StringRef((const char *)binary_data, binary_size));
BLOSC compression typically works best on larger buffers with numeric data. It's faster than GZIP compression, but has worse compression.

Definition at line 32 of file UT_ZString.h.

Member Enumeration Documentation


Definition at line 35 of file UT_ZString.h.

Constructor & Destructor Documentation

UT_ZString::UT_ZString ( )
UT_ZString::UT_ZString ( const UT_StringRef src,
Style  style = GZIP,
int  level = 9 

Definition at line 46 of file UT_ZString.h.

Member Function Documentation

Style UT_ZString::compress ( const UT_StringRef s,
Style  style = GZIP,
int  level = 1 

Store a string as compressed data, returning the compressed style. If no compression is done, the returned style will be NONE.

For GZIP compression, level can be between 1 and 9. 1 is faster, 9 is better compression (but can be significantly slower).

const UT_StringHolder& UT_ZString::compressedString ( ) const

Member data access

Definition at line 65 of file UT_ZString.h.

Style UT_ZString::compressedStyle ( ) const

Member data access

Definition at line 66 of file UT_ZString.h.

int64 UT_ZString::getMemoryUsage ( bool  inclusive) const

Standard "string" type operations.

Definition at line 72 of file UT_ZString.h.

SYS_HashType UT_ZString::hash ( ) const

Standard "string" type operations.

Definition at line 77 of file UT_ZString.h.

bool UT_ZString::operator== ( const UT_ZString s) const

Standard "string" type operations.

Definition at line 85 of file UT_ZString.h.

exint UT_ZString::originalSize ( ) const

Member data access

Definition at line 67 of file UT_ZString.h.

static const char* UT_ZString::style ( Style  s)
static Style UT_ZString::style ( const char *  s)
UT_StringHolder UT_ZString::uncompress ( ) const

Return the uncompressed contents.

Friends And Related Function Documentation

std::size_t hash_value ( const UT_ZString s)

Standard "string" type operations.

Definition at line 84 of file UT_ZString.h.

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