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

#include <lzma.h>

Inheritance diagram for Botan::LZMA_Compression:
Botan::Stream_Compression Botan::Compression_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, bool flush) final override
 

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

LZMA Compression

Definition at line 20 of file lzma.h.

Member Function Documentation

◆ clear()

void Botan::Stream_Compression::clear ( )
finaloverridevirtualinherited

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

Implements Botan::Compression_Algorithm.

Definition at line 62 of file compress_utils.cpp.

63 {
64 m_stream.reset();
65 }

Referenced by Botan::Stream_Compression::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 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>();
38#endif
39
40#if defined(BOTAN_HAS_BZIP2)
41 if(name == "bzip2" || name == "bz2" || name == "Bzip2")
42 return std::make_unique<Bzip2_Compression>();
43#endif
44
45#if defined(BOTAN_HAS_LZMA)
46 if(name == "lzma" || name == "xz" || name == "LZMA")
47 return std::make_unique<LZMA_Compression>();
48#endif
49
51 return nullptr;
52 }
#define BOTAN_UNUSED(...)
Definition: assert.h:141
virtual std::string name() const =0

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

Referenced by Botan::Compression_Algorithm::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 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 Botan::Compression_Algorithm::create().

◆ finish()

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

Finish compressing

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

Implements Botan::Compression_Algorithm.

Definition at line 130 of file compress_utils.cpp.

131 {
132 BOTAN_ASSERT(m_stream, "Initialized");
133 process(buf, offset, m_stream->finish_flag());
134 clear();
135 }
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:54
void clear() final override

References BOTAN_ASSERT, and Botan::Stream_Compression::clear().

◆ name()

std::string Botan::LZMA_Compression::name ( ) const
inlineoverridevirtual
Returns
name of the compression algorithm

Implements Botan::Compression_Algorithm.

Definition at line 23 of file lzma.h.

23{ return "LZMA_Compression"; }

◆ update()

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

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

Implements Botan::Compression_Algorithm.

Definition at line 124 of file compress_utils.cpp.

125 {
126 BOTAN_ASSERT(m_stream, "Initialized");
127 process(buf, offset, flush ? m_stream->flush_flag() : m_stream->run_flag());
128 }

References BOTAN_ASSERT.


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