|
HDK
|
#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) | |
| Take an uncompressed string and store the compressed result. More... | |
| UT_ZString (const UT_StringRef &src, Style style, const UT::source_is_compressed &, exint original_size, bool force_compressed=false) | |
| void | clear () |
| Clear storage and reset values. More... | |
| Style | compress (const UT_StringRef &s, Style style=GZIP, int level=1) |
| UT_StringHolder | uncompress () const |
| Return the uncompressed contents. More... | |
| void | setCompressedData (const UT_StringHolder &z, Style s, exint original_size, bool force_compressed=false) |
| Set the class to hold an already compressed string. More... | |
| SYS_FORCE_INLINE bool | isstring () const |
| The z-string has a string if the original size is non-zero. More... | |
| SYS_FORCE_INLINE SYS_SAFE_BOOL | operator bool () const |
| Test whether the string is defined or not. More... | |
| const UT_StringHolder & | compressedString () const |
| Style | compressedStyle () const |
| exint | originalSize () const |
Static Public Member Functions | |
| static const char * | style (Style s) |
| Map the enum to a string. More... | |
| static Style | style (const char *s) |
| Map the string to an enum value. More... | |
| 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) |
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:
Definition at line 38 of file UT_ZString.h.
| enum UT_ZString::Style |
| Enumerator | |
|---|---|
| NONE | |
| GZIP | |
| BLOSC | |
Definition at line 41 of file UT_ZString.h.
|
default |
|
inline |
Take an uncompressed string and store the compressed result.
Definition at line 56 of file UT_ZString.h.
|
inline |
Set the compressed data given the original style. If the original_size == src.length() then we assume the string is uncompressed (unless the force_compressed flag is true).
This matches the semantics of compress() (which stores the uncompressed string if the compression results in a larger buffer).
Definition at line 66 of file UT_ZString.h.
|
inline |
Clear storage and reset values.
Definition at line 75 of file UT_ZString.h.
| 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).
|
inline |
Member data access
Definition at line 101 of file UT_ZString.h.
|
inline |
Member data access
Definition at line 102 of file UT_ZString.h.
|
inline |
Standard "string" type operations.
Definition at line 116 of file UT_ZString.h.
|
inline |
Standard "string" type operations.
Definition at line 121 of file UT_ZString.h.
|
inline |
The z-string has a string if the original size is non-zero.
Definition at line 108 of file UT_ZString.h.
|
inline |
Test whether the string is defined or not.
Definition at line 112 of file UT_ZString.h.
|
inline |
Standard "string" type operations.
Definition at line 129 of file UT_ZString.h.
|
inline |
Member data access
Definition at line 103 of file UT_ZString.h.
| void UT_ZString::setCompressedData | ( | const UT_StringHolder & | z, |
| Style | s, | ||
| exint | original_size, | ||
| bool | force_compressed = false |
||
| ) |
Set the class to hold an already compressed string.
|
static |
Map the enum to a string.
|
static |
Map the string to an enum value.
| UT_StringHolder UT_ZString::uncompress | ( | ) | const |
Return the uncompressed contents.
|
friend |
Standard "string" type operations.
Definition at line 128 of file UT_ZString.h.