Botan 3.0.0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | List of all members
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 ( )

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)

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.

30 {
31#if defined(BOTAN_HAS_ZLIB)
32 if(name == "Zlib" || name == "zlib")
33 return std::make_unique<Zlib_Compression>();
34 if(name == "Gzip" || name == "gzip" || name == "gz")
35 return std::make_unique<Gzip_Compression>();
36 if(name == "Deflate" || name == "deflate")
37 return std::make_unique<Deflate_Compression>();
40#if defined(BOTAN_HAS_BZIP2)
41 if(name == "bzip2" || name == "bz2" || name == "Bzip2")
42 return std::make_unique<Bzip2_Compression>();
45#if defined(BOTAN_HAS_LZMA)
46 if(name == "lzma" || name == "xz" || name == "LZMA")
47 return std::make_unique<LZMA_Compression>();
51 return nullptr;
52 }
#define BOTAN_UNUSED(...)
Definition: assert.h:141
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)

Create an instance based on a name

algo_specalgorithm name Throws Lookup_Error if not found.

Definition at line 56 of file compression.cpp.

57 {
58 if(auto compressor = Compression_Algorithm::create(algo))
59 {
60 return compressor;
61 }
62 throw Lookup_Error("Compression", algo, "");
63 }
static std::unique_ptr< Compression_Algorithm > create(std::string_view algo_spec)
Definition: compression.cpp:29

References create().

◆ finish()

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

Finish compressing

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
name of the compression algorithm

Implemented in Botan::Bzip2_Compression, Botan::LZMA_Compression, Botan::Zlib_Compression, Botan::Deflate_Compression, and Botan::Gzip_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.

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: