9#include <botan/filters.h> 
   11#include <botan/assert.h> 
   12#include <botan/exceptn.h> 
   13#include <botan/internal/fmt.h> 
   15#if defined(BOTAN_HAS_COMPRESSION) 
   16   #include <botan/compression.h> 
   21#if defined(BOTAN_HAS_COMPRESSION) 
   23Compression_Filter::Compression_Filter(std::string_view type, 
size_t level, 
size_t bs) :
 
   24      m_comp(
Compression_Algorithm::create(type)), m_buffersize(std::max<size_t>(bs, 256)), m_level(level) {
 
   26      throw Invalid_Argument(
fmt(
"Compression type '{}' not found", type));
 
   30Compression_Filter::~Compression_Filter() = 
default;
 
   32std::string Compression_Filter::name()
 const {
 
   33   return m_comp->name();
 
   36void Compression_Filter::start_msg() {
 
   37   m_comp->start(m_level);
 
   40void Compression_Filter::write(
const uint8_t input[], 
size_t input_length) {
 
   41   while(input_length > 0) {
 
   42      const size_t take = std::min(m_buffersize, input_length);
 
   45      m_buffer.assign(input, input + take);
 
   46      m_comp->update(m_buffer);
 
   55void Compression_Filter::flush() {
 
   57   m_comp->update(m_buffer, 0, 
true);
 
   61void Compression_Filter::end_msg() {
 
   63   m_comp->finish(m_buffer);
 
   67Decompression_Filter::Decompression_Filter(std::string_view type, 
size_t bs) :
 
   68      m_comp(Decompression_Algorithm::create(type)), m_buffersize(std::max<size_t>(bs, 256)) {
 
   70      throw Invalid_Argument(
fmt(
"Compression type '{}' not found", type));
 
   74Decompression_Filter::~Decompression_Filter() = 
default;
 
   76std::string Decompression_Filter::name()
 const {
 
   77   return m_comp->name();
 
   80void Decompression_Filter::start_msg() {
 
   84void Decompression_Filter::write(
const uint8_t input[], 
size_t input_length) {
 
   85   while(input_length > 0) {
 
   86      const size_t take = std::min(m_buffersize, input_length);
 
   89      m_buffer.assign(input, input + take);
 
   90      m_comp->update(m_buffer);
 
   99void Decompression_Filter::end_msg() {
 
  101   m_comp->finish(m_buffer);
 
#define BOTAN_ASSERT(expr, assertion_made)
 
std::string fmt(std::string_view format, const T &... args)