Botan 3.13.0
Crypto and TLS for C&
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
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) final

Static Public Member Functions

static std::unique_ptr< Decompression_Algorithmcreate (std::string_view algo_spec)
static std::unique_ptr< Decompression_Algorithmcreate_or_throw (std::string_view algo_spec)

Detailed Description

Zlib Decompression

Definition at line 30 of file zlib.h.

Member Function Documentation

◆ clear()

void Botan::Stream_Decompression::clear ( )
finalvirtualinherited

Reset the state and abort the current message

Implements Botan::Decompression_Algorithm.

Definition at line 150 of file compress_utils.cpp.

150 {
151 m_stream.reset();
152}

◆ create()

std::unique_ptr< Decompression_Algorithm > Botan::Decompression_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 67 of file compression.cpp.

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

References BOTAN_UNUSED, and name().

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

◆ create_or_throw()

std::unique_ptr< Decompression_Algorithm > Botan::Decompression_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 97 of file compression.cpp.

97 {
98 if(auto decompressor = Decompression_Algorithm::create(algo)) {
99 return decompressor;
100 }
101 throw Lookup_Error("Decompression", algo, "");
102}
static std::unique_ptr< Decompression_Algorithm > create(std::string_view algo_spec)

References create().

◆ finish()

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

Finish decompressing

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

Implements Botan::Decompression_Algorithm.

Definition at line 216 of file compress_utils.cpp.

216 {
217 if(!m_stream) {
218 if(buf.size() == offset) {
219 return;
220 }
221 // Previous stream ended cleanly; re-initialize for a concatenated stream
222 start();
223 }
224
225 process(buf, offset, m_stream->finish_flag());
226
227 if(m_stream) {
228 throw Invalid_State(fmt("{} finished but not at stream end", name()));
229 }
230}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::fmt(), Botan::Decompression_Algorithm::name(), and Botan::Decompression_Algorithm::start().

◆ name()

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

Return the name of this decompression algorithm

Returns
name of the decompression algorithm

Implements Botan::Decompression_Algorithm.

Definition at line 32 of file zlib.h.

32{ return "Zlib_Decompression"; }

◆ update()

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

Decompress some data

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

Implements Botan::Decompression_Algorithm.

Definition at line 205 of file compress_utils.cpp.

205 {
206 if(!m_stream) {
207 if(buf.size() == offset) {
208 return;
209 }
210 // Previous stream ended cleanly; re-initialize for a concatenated stream
211 start();
212 }
213 process(buf, offset, m_stream->run_flag());
214}

References Botan::Decompression_Algorithm::start().


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