#ifndef ENCODER_H #define ENCODER_H #include #include #include #include class EncoderBase { public: typedef boost::shared_ptr p; virtual size_t encode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size) = 0; virtual size_t flush(uint8_t *output, size_t output_size) = 0; }; class EncoderFilter : public boost::iostreams::multichar_input_filter { private: EncoderBase::p encoder; public: typedef boost::shared_ptr p; EncoderFilter(EncoderBase::p encoder_); template std::streamsize read(Source& src, char *s, std::streamsize n) { char src_data[0x2000]; std::streamsize src_read = boost::iostreams::read(src, src_data, 0x2000); if(src_read < 0) src_read = 0; return encoder->encode((const uint8_t*)src_data, src_read, (uint8_t*)s, n); }; }; namespace encoder { void init(); EncoderFilter::p get_encoder(const std::string& name); }; #endif