Botan 3.5.0
Crypto and TLS for C&
Botan::Compression_Algorithm Class Referenceabstract

#include <compression.h>

Inheritance diagram for Botan::Compression_Algorithm:
Botan::Stream_Compression Botan::Bzip2_Compression Botan::Deflate_Compression Botan::Gzip_Compression Botan::LZMA_Compression Botan::Zlib_Compression

Public Member Functions

virtual void clear ()=0
 
virtual void finish (secure_vector< uint8_t > &final_block, size_t offset=0)=0
 
virtual std::string name () const =0
 
virtual void start (size_t comp_level=0)=0
 
virtual void update (secure_vector< uint8_t > &buf, size_t offset=0, bool flush=false)=0
 
virtual ~Compression_Algorithm ()=default
 

Static Public Member Functions

static std::unique_ptr< Compression_Algorithmcreate (std::string_view algo_spec)
 
static std::unique_ptr< Compression_Algorithmcreate_or_throw (std::string_view algo_spec)
 

Detailed Description

Interface for a compression algorithm.

Definition at line 20 of file compression.h.

Constructor & Destructor Documentation

◆ ~Compression_Algorithm()

virtual Botan::Compression_Algorithm::~Compression_Algorithm ( )
virtualdefault

Member Function Documentation

◆ clear()

virtual void Botan::Compression_Algorithm::clear ( )
pure virtual

Reset the state and abort the current message; start can be called again to process a new message.

Implemented in Botan::Stream_Compression.

◆ create()

std::unique_ptr< Compression_Algorithm > Botan::Compression_Algorithm::create ( std::string_view algo_spec)
static

Create an instance based on a name, or return null if the algo combination cannot be found.

Definition at line 29 of file compression.cpp.

29 {
30#if defined(BOTAN_HAS_ZLIB)
31 if(name == "Zlib" || name == "zlib") {
32 return std::make_unique<Zlib_Compression>();
33 }
34 if(name == "Gzip" || name == "gzip" || name == "gz") {
35 return std::make_unique<Gzip_Compression>();
36 }
37 if(name == "Deflate" || name == "deflate") {
38 return std::make_unique<Deflate_Compression>();
39 }
40#endif
41
42#if defined(BOTAN_HAS_BZIP2)
43 if(name == "bzip2" || name == "bz2" || name == "Bzip2") {
44 return std::make_unique<Bzip2_Compression>();
45 }
46#endif
47
48#if defined(BOTAN_HAS_LZMA)
49 if(name == "lzma" || name == "xz" || name == "LZMA") {
50 return std::make_unique<LZMA_Compression>();
51 }
52#endif
53
55 return nullptr;
56}
#define BOTAN_UNUSED
Definition assert.h:118
virtual std::string name() const =0

References BOTAN_UNUSED, and name().

Referenced by create_or_throw(), and Botan::make_compressor().

◆ create_or_throw()

std::unique_ptr< Compression_Algorithm > Botan::Compression_Algorithm::create_or_throw ( std::string_view algo_spec)
static

Create an instance based on a name

Parameters
algo_specalgorithm name Throws Lookup_Error if not found.

Definition at line 59 of file compression.cpp.

59 {
60 if(auto compressor = Compression_Algorithm::create(algo)) {
61 return compressor;
62 }
63 throw Lookup_Error("Compression", algo, "");
64}
static std::unique_ptr< Compression_Algorithm > create(std::string_view algo_spec)

References create().

◆ finish()

virtual void Botan::Compression_Algorithm::finish ( secure_vector< uint8_t > & final_block,
size_t offset = 0 )
pure virtual

Finish compressing

Parameters
final_blockin/out parameter
offsetan offset into final_block to begin processing

Implemented in Botan::Stream_Compression.

◆ name()

virtual std::string Botan::Compression_Algorithm::name ( ) const
pure virtual
Returns
name of the compression algorithm

Implemented in Botan::Bzip2_Compression, Botan::Deflate_Compression, Botan::Gzip_Compression, Botan::LZMA_Compression, and Botan::Zlib_Compression.

Referenced by create().

◆ start()

virtual void Botan::Compression_Algorithm::start ( size_t comp_level = 0)
pure virtual

Begin compressing. Most compression algorithms offer a tunable time/compression tradeoff parameter generally represented by an integer in the range of 1 to 9.

If 0 or a value out of range is provided, a compression algorithm specific default is used.

◆ update()

virtual void Botan::Compression_Algorithm::update ( secure_vector< uint8_t > & buf,
size_t offset = 0,
bool flush = false )
pure virtual

Process some data.

Parameters
bufin/out parameter which will possibly be resized or swapped
offsetan offset into blocks to begin processing
flushif true the compressor will be told to flush state

Implemented in Botan::Stream_Compression.


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