summaryrefslogtreecommitdiff
path: root/encoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'encoder.h')
-rw-r--r--encoder.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/encoder.h b/encoder.h
index 7021cdc..1ff0879 100644
--- a/encoder.h
+++ b/encoder.h
@@ -7,33 +7,36 @@
#include <boost/functional/value_factory.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/operations.hpp>
+#include <boost/shared_ptr.hpp>
#include <string>
class EncoderBase {
public:
+ typedef boost::shared_ptr<EncoderBase> 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& encoder;
+ EncoderBase::p encoder;
public:
- EncoderFilter(EncoderBase& encoder_) : encoder(encoder_) {};
+ typedef boost::shared_ptr<EncoderFilter> p;
+ EncoderFilter(EncoderBase::p encoder_);
template<typename Source>
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);
+ return encoder->encode((const uint8_t*)src_data, src_read, (uint8_t*)s, n);
};
};
namespace encoder {
void init();
- EncoderBase *get_encoder(const std::string& name);
+ EncoderFilter::p get_encoder(const std::string& name);
};
#endif