Botan 1.10.17
Botan::Bzip_Compression Class Reference

#include <bzip2.h>

Inheritance diagram for Botan::Bzip_Compression:
Botan::Filter

Public Member Functions

virtual bool attachable ()
 Bzip_Compression (size_t=9)
void end_msg ()
void flush ()
std::string name () const
void start_msg ()
void write (const byte input[], size_t length)
 ~Bzip_Compression ()

Protected Member Functions

void send (byte in)
void send (const byte in[], size_t length)
void send (const MemoryRegion< byte > &in)
void send (const MemoryRegion< byte > &in, size_t length)

Detailed Description

Bzip Compression Filter

Definition at line 19 of file bzip2.h.

Constructor & Destructor Documentation

◆ Bzip_Compression()

Botan::Bzip_Compression::Bzip_Compression ( size_t l = 9)

Definition at line 95 of file bzip2.cpp.

95 :
96 level((l >= 9) ? 9 : l), buffer(DEFAULT_BUFFERSIZE)
97 {
98 bz = 0;
99 }

◆ ~Bzip_Compression()

Botan::Bzip_Compression::~Bzip_Compression ( )
inline

Definition at line 31 of file bzip2.h.

31{ clear(); }

Member Function Documentation

◆ attachable()

virtual bool Botan::Filter::attachable ( )
inlinevirtualinherited

Check whether this filter is an attachable filter.

Returns
true if this filter is attachable, false otherwise

Reimplemented in Botan::DataSink, and Botan::SecureQueue.

Definition at line 50 of file filter.h.

50{ return true; }

◆ end_msg()

void Botan::Bzip_Compression::end_msg ( )
virtual

Notify that the current message is finished; flush buffers and do end-of-message processing (if any).

Reimplemented from Botan::Filter.

Definition at line 132 of file bzip2.cpp.

133 {
134 bz->stream.next_in = 0;
135 bz->stream.avail_in = 0;
136
137 int rc = BZ_OK;
138 while(rc != BZ_STREAM_END)
139 {
140 bz->stream.next_out = reinterpret_cast<char*>(buffer.begin());
141 bz->stream.avail_out = buffer.size();
142 rc = BZ2_bzCompress(&(bz->stream), BZ_FINISH);
143 send(buffer, buffer.size() - bz->stream.avail_out);
144 }
145 clear();
146 }
void send(const byte in[], size_t length)
Definition filter.cpp:28

References Botan::Filter::send().

◆ flush()

void Botan::Bzip_Compression::flush ( )

Definition at line 151 of file bzip2.cpp.

152 {
153 bz->stream.next_in = 0;
154 bz->stream.avail_in = 0;
155
156 int rc = BZ_OK;
157 while(rc != BZ_RUN_OK)
158 {
159 bz->stream.next_out = reinterpret_cast<char*>(buffer.begin());
160 bz->stream.avail_out = buffer.size();
161 rc = BZ2_bzCompress(&(bz->stream), BZ_FLUSH);
162 send(buffer, buffer.size() - bz->stream.avail_out);
163 }
164 }

References Botan::Filter::send().

◆ name()

std::string Botan::Bzip_Compression::name ( ) const
inlinevirtual
Returns
descriptive name for this filter

Implements Botan::Filter.

Definition at line 22 of file bzip2.h.

22{ return "Bzip_Compression"; }

◆ send() [1/4]

void Botan::Filter::send ( byte in)
inlineprotectedinherited
Parameters
insome input for the filter

Definition at line 63 of file filter.h.

63{ send(&in, 1); }

References send().

Referenced by send().

◆ send() [2/4]

void Botan::Filter::send ( const byte in[],
size_t length )
protectedinherited

◆ send() [3/4]

void Botan::Filter::send ( const MemoryRegion< byte > & in)
inlineprotectedinherited
Parameters
insome input for the filter

Definition at line 68 of file filter.h.

68{ send(&in[0], in.size()); }

References send(), and Botan::MemoryRegion< T >::size().

Referenced by send().

◆ send() [4/4]

void Botan::Filter::send ( const MemoryRegion< byte > & in,
size_t length )
inlineprotectedinherited
Parameters
insome input for the filter
lengththe number of bytes of in to send

Definition at line 74 of file filter.h.

75 {
76 send(&in[0], length);
77 }

References send().

◆ start_msg()

void Botan::Bzip_Compression::start_msg ( )
virtual

Start a new message. Must be closed by end_msg() before another message can be started.

Reimplemented from Botan::Filter.

Definition at line 104 of file bzip2.cpp.

105 {
106 clear();
107 bz = new Bzip_Stream;
108 if(BZ2_bzCompressInit(&(bz->stream), level, 0, 0) != BZ_OK)
109 throw Memory_Exhaustion();
110 }

◆ write()

void Botan::Bzip_Compression::write ( const byte input[],
size_t length )
virtual

Write a portion of a message to this filter.

Parameters
inputthe input as a byte array
lengththe length of the byte array input

Implements Botan::Filter.

Definition at line 115 of file bzip2.cpp.

116 {
117 bz->stream.next_in = reinterpret_cast<char*>(const_cast<byte*>(input));
118 bz->stream.avail_in = length;
119
120 while(bz->stream.avail_in != 0)
121 {
122 bz->stream.next_out = reinterpret_cast<char*>(buffer.begin());
123 bz->stream.avail_out = buffer.size();
124 BZ2_bzCompress(&(bz->stream), BZ_RUN);
125 send(buffer, buffer.size() - bz->stream.avail_out);
126 }
127 }

References Botan::Filter::send().


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