Botan 3.0.0-alpha0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | List of all members
Botan::Zlib_Decompression Class Referencefinal

#include <zlib.h>

Inheritance diagram for Botan::Zlib_Decompression:
Botan::Stream_Decompression Botan::Decompression_Algorithm

Public Member Functions

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

Static Public Member Functions

static std::unique_ptr< Decompression_Algorithmcreate (const std::string &algo_spec)
 
static std::unique_ptr< Decompression_Algorithmcreate_or_throw (const std::string &algo_spec)
 

Detailed Description

Zlib Decompression

Definition at line 30 of file zlib.h.

Member Function Documentation

◆ clear()

void Botan::Stream_Decompression::clear ( )
finaloverridevirtualinherited

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

Implements Botan::Decompression_Algorithm.

Definition at line 125 of file compress_utils.cpp.

126 {
127 m_stream.reset();
128 }

◆ create()

std::unique_ptr< Decompression_Algorithm > Botan::Decompression_Algorithm::create ( const std::string &  algo_spec)
staticinherited

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

Definition at line 67 of file compression.cpp.

68 {
69#if defined(BOTAN_HAS_ZLIB)
70 if(name == "Zlib" || name == "zlib")
71 return std::make_unique<Zlib_Decompression>();
72 if(name == "Gzip" || name == "gzip" || name == "gz")
73 return std::make_unique<Gzip_Decompression>();
74 if(name == "Deflate" || name == "deflate")
75 return std::make_unique<Deflate_Decompression>();
76#endif
77
78#if defined(BOTAN_HAS_BZIP2)
79 if(name == "bzip2" || name == "bz2" || name == "Bzip2")
80 return std::make_unique<Bzip2_Decompression>();
81#endif
82
83#if defined(BOTAN_HAS_LZMA)
84 if(name == "lzma" || name == "xz" || name == "LZMA")
85 return std::make_unique<LZMA_Decompression>();
86#endif
87
89 return nullptr;
90 }
#define BOTAN_UNUSED(...)
Definition: assert.h:141
virtual std::string name() const =0

References BOTAN_UNUSED, and Botan::Decompression_Algorithm::name().

Referenced by Botan::Decompression_Algorithm::create_or_throw(), and Botan::make_decompressor().

◆ create_or_throw()

std::unique_ptr< Decompression_Algorithm > Botan::Decompression_Algorithm::create_or_throw ( const std::string &  algo_spec)
staticinherited

Create an instance based on a name

Parameters
algo_specalgorithm name Throws Lookup_Error if not found.

Definition at line 94 of file compression.cpp.

95 {
96 if(auto decompressor = Decompression_Algorithm::create(algo))
97 {
98 return decompressor;
99 }
100 throw Lookup_Error("Decompression", algo, "");
101 }
static std::unique_ptr< Decompression_Algorithm > create(const std::string &algo_spec)
Definition: compression.cpp:67

References Botan::Decompression_Algorithm::create().

◆ finish()

void Botan::Stream_Decompression::finish ( secure_vector< uint8_t > &  final_block,
size_t  offset 
)
finaloverridevirtualinherited

Finish decompressing

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

Implements Botan::Decompression_Algorithm.

Definition at line 187 of file compress_utils.cpp.

188 {
189 if(buf.size() != offset || m_stream.get())
190 process(buf, offset, m_stream->finish_flag());
191
192 if(m_stream.get())
193 throw Invalid_State(name() + " finished but not at stream end");
194 }

References Botan::Decompression_Algorithm::name().

◆ name()

std::string Botan::Zlib_Decompression::name ( ) const
inlineoverridevirtual
Returns
name of the decompression algorithm

Implements Botan::Decompression_Algorithm.

Definition at line 33 of file zlib.h.

33{ return "Zlib_Decompression"; }

◆ update()

void Botan::Stream_Decompression::update ( secure_vector< uint8_t > &  buf,
size_t  offset 
)
finaloverridevirtualinherited

Process some data.

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

Implements Botan::Decompression_Algorithm.

Definition at line 182 of file compress_utils.cpp.

183 {
184 process(buf, offset, m_stream->run_flag());
185 }

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