summaryrefslogtreecommitdiff
path: root/decoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'decoder.h')
-rw-r--r--decoder.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/decoder.h b/decoder.h
index a7aaad9..3694053 100644
--- a/decoder.h
+++ b/decoder.h
@@ -7,32 +7,35 @@
#include <boost/functional/value_factory.hpp>
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/operations.hpp>
+#include <boost/shared_ptr.hpp>
#include <string>
class DecoderBase {
public:
+ typedef boost::shared_ptr<DecoderBase> p;
virtual size_t decode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size) = 0;
};
class DecoderFilter : public boost::iostreams::multichar_input_filter {
private:
- DecoderBase& decoder;
+ DecoderBase::p decoder;
public:
- DecoderFilter(DecoderBase& decoder_) : decoder(decoder_) {};
+ typedef boost::shared_ptr<DecoderFilter> p;
+ DecoderFilter(DecoderBase::p decoder_);
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 decoder.decode((const uint8_t*)src_data, src_read, (uint8_t*)s, n);
- };
+ return decoder->decode((const uint8_t*)src_data, src_read, (uint8_t*)s, n);
+ }
};
namespace decoder {
void init();
- DecoderBase *get_decoder(const std::string& name);
+ DecoderFilter::p get_decoder(const std::string& name);
};
#endif