Botan 3.14.1
Crypto and TLS for C&
Botan::Deflate_Compression Class Referencefinal

#include <zlib.h>

Inheritance diagram for Botan::Deflate_Compression:
Botan::Stream_Compression Botan::Compression_Algorithm

Public Member Functions

void clear () final
void finish (secure_vector< uint8_t > &buf, size_t offset) final
std::string name () const override
void update (secure_vector< uint8_t > &buf, size_t offset, bool flush) final

Static Public Member Functions

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

Detailed Description

Deflate Compression

Definition at line 41 of file zlib.h.

Member Function Documentation

◆ clear()

void Botan::Stream_Compression::clear ( )
finalvirtualinherited

Reset the state and abort the current message

Implements Botan::Compression_Algorithm.

Definition at line 83 of file compress_utils.cpp.

83 {
84 m_stream.reset();
85}

Referenced by finish().

◆ create()

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

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

Definition at line 28 of file compression.cpp.

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

Create an instance based on a name

Parameters
algo_specalgorithm name Throws Lookup_Error if not found.

Definition at line 58 of file compression.cpp.

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

References create().

◆ finish()

void Botan::Stream_Compression::finish ( secure_vector< uint8_t > & buf,
size_t offset )
finalvirtualinherited

Finish compressing

Parameters
bufin/out parameter which will possibly be resized or swapped
offsetan offset into buf to begin processing

Implements Botan::Compression_Algorithm.

Definition at line 144 of file compress_utils.cpp.

144 {
145 BOTAN_ASSERT(m_stream, "Initialized");
146 process(buf, offset, m_stream->finish_flag());
147 clear();
148}
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:69

References BOTAN_ASSERT, and clear().

◆ name()

std::string Botan::Deflate_Compression::name ( ) const
inlineoverridevirtual

Return the name of this compression algorithm

Returns
name of the compression algorithm

Implements Botan::Compression_Algorithm.

Definition at line 43 of file zlib.h.

43{ return "Deflate_Compression"; }

◆ update()

void Botan::Stream_Compression::update ( secure_vector< uint8_t > & buf,
size_t offset,
bool flush )
finalvirtualinherited

Compress some data

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

Implements Botan::Compression_Algorithm.

Definition at line 139 of file compress_utils.cpp.

139 {
140 BOTAN_ASSERT(m_stream, "Initialized");
141 process(buf, offset, flush ? m_stream->flush_flag() : m_stream->run_flag());
142}

References BOTAN_ASSERT.


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