mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Restrict the interface to not allow algorithm selection
llvm-svn: 18248
This commit is contained in:
parent
1e5db2e2da
commit
0fd67aa7c9
@ -19,32 +19,23 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
/// This class provides an abstraction for compressing a block of memory using
|
/// This class provides an abstraction for compression and decompression of
|
||||||
/// a standard compression utility such as bzip2 or libz. This interface
|
/// a block of memory. The algorithm used here is currently bzip2 but that
|
||||||
/// allows us to abstract the notion of compression and deal with alternate
|
/// may change without notice. Should newer algorithms prove to compress
|
||||||
/// compression scheme availability depending on the configured platform. This
|
/// bytecode better than bzip2, that newer algorithm will be added, but won't
|
||||||
/// facility will always favor a bzip2 implementation if its available.
|
/// replace bzip2. This interface allows us to abstract the notion of
|
||||||
/// Otherwise, libz will be used if it is available. If neither zlib nor bzip2
|
/// compression and deal with alternate compression schemes over time.
|
||||||
/// are available, a very simple algorithm provided by the Compressor class
|
/// The type of compression used can be determined by inspecting the
|
||||||
/// will be used. The type of compression used can be determined by inspecting
|
/// first byte of the compressed output. Currently value '0' means no
|
||||||
/// the first byte of the compressed output. ASCII values '0', '1', and '2',
|
/// compression was used (for very small files) and value '2' means bzip2
|
||||||
/// denote the compression type as given in the Algorithm enumeration below.
|
/// compression was used. The Compressor is intended for use with memory
|
||||||
/// The Compressor is intended for use with memory mapped files where the
|
/// mapped files where the entire data block to be compressed or decompressed
|
||||||
/// entire data block to be compressed or decompressed is available in
|
/// is available in memory. However, output can be gathered in repeated calls
|
||||||
/// memory. However, output can be gathered in repeated calls to a callback.
|
/// to a callback. Utilities for sending compressed or decompressed output
|
||||||
|
/// to a stream or directly to a memory block are also provided.
|
||||||
/// @since 1.4
|
/// @since 1.4
|
||||||
/// @brief An abstraction for memory to memory data (de)compression
|
/// @brief An abstraction for memory to memory data (de)compression
|
||||||
class Compressor {
|
class Compressor {
|
||||||
/// @name Types
|
|
||||||
/// @{
|
|
||||||
public:
|
|
||||||
enum Algorithm {
|
|
||||||
COMP_TYPE_SIMPLE = '0', ///< Use simple but ubiquitous algorithm
|
|
||||||
COMP_TYPE_ZLIB = '1', ///< Use zlib algorithm, if available
|
|
||||||
COMP_TYPE_BZIP2 = '2', ///< Use bzip2 algorithm (preferred)
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @}
|
|
||||||
/// @name High Level Interface
|
/// @name High Level Interface
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
@ -58,9 +49,7 @@ namespace llvm {
|
|||||||
static uint64_t compressToNewBuffer(
|
static uint64_t compressToNewBuffer(
|
||||||
const char* in, ///< The buffer to be compressed
|
const char* in, ///< The buffer to be compressed
|
||||||
unsigned size, ///< The size of the buffer to be compressed
|
unsigned size, ///< The size of the buffer to be compressed
|
||||||
char*&out, ///< The returned output buffer
|
char*&out ///< The returned output buffer
|
||||||
Algorithm hint ///< Hint for type of compression to perform
|
|
||||||
= COMP_TYPE_BZIP2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/// This method compresses a block of memory pointed to by \p in with
|
/// This method compresses a block of memory pointed to by \p in with
|
||||||
@ -73,9 +62,7 @@ namespace llvm {
|
|||||||
static uint64_t compressToStream(
|
static uint64_t compressToStream(
|
||||||
const char*in, ///< The buffer to be compressed
|
const char*in, ///< The buffer to be compressed
|
||||||
unsigned size, ///< The size of the buffer to be compressed
|
unsigned size, ///< The size of the buffer to be compressed
|
||||||
std::ostream& out, ///< The output stream to write data on
|
std::ostream& out ///< The output stream to write data on
|
||||||
Algorithm hint ///< Hint for type of compression to perform
|
|
||||||
= COMP_TYPE_BZIP2
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/// This method decompresses a block of memory pointed to by \p in with
|
/// This method decompresses a block of memory pointed to by \p in with
|
||||||
@ -140,10 +127,7 @@ namespace llvm {
|
|||||||
const char* in, ///< The buffer to be compressed
|
const char* in, ///< The buffer to be compressed
|
||||||
unsigned size, ///< The size of the buffer to be compressed
|
unsigned size, ///< The size of the buffer to be compressed
|
||||||
OutputDataCallback* cb, ///< Call back for memory allocation
|
OutputDataCallback* cb, ///< Call back for memory allocation
|
||||||
Algorithm hint ///< Hint for type of compression to perform
|
void* context = 0 ///< Context for callback
|
||||||
= COMP_TYPE_BZIP2,
|
|
||||||
void* context ///< Context for callback
|
|
||||||
= 0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/// This function does the decompression work. The block of memory
|
/// This function does the decompression work. The block of memory
|
||||||
@ -163,8 +147,7 @@ namespace llvm {
|
|||||||
const char *in, ///< The buffer to be decompressed
|
const char *in, ///< The buffer to be decompressed
|
||||||
unsigned size, ///< Size of the buffer to be decompressed
|
unsigned size, ///< Size of the buffer to be decompressed
|
||||||
OutputDataCallback* cb, ///< Call back for memory allocation
|
OutputDataCallback* cb, ///< Call back for memory allocation
|
||||||
void* context ///< Context for callback
|
void* context = 0 ///< Context for callback
|
||||||
= 0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user