summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-01-06 02:10:24 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-01-06 02:10:24 +0100
commit70f111b184928feab0c94f762954b5ec83a441c6 (patch)
tree1677f0f8a8e59e4648b9800048efa1fd18e63745
parent102992da75edfcb671eb408bd801703a3f9137d0 (diff)
Decoder/encoder source cleanup.
-rw-r--r--decoder.cpp4
-rw-r--r--decoder.h4
-rw-r--r--encoder.cpp4
-rw-r--r--encoder.h4
4 files changed, 12 insertions, 4 deletions
diff --git a/decoder.cpp b/decoder.cpp
index f01215b..c362745 100644
--- a/decoder.cpp
+++ b/decoder.cpp
@@ -10,7 +10,7 @@ DecoderFilter::DecoderFilter(DecoderBase::p decoder_) {
decoder = decoder_;
}
-typedef boost::function<boost::shared_ptr<DecoderBase>()> DecoderFactory;
+typedef boost::function<DecoderBase::p ()> DecoderFactory;
std::map<std::string, DecoderFactory> decoder_factories;
void decoder::init() {
@@ -20,5 +20,5 @@ void decoder::init() {
//! Construct a filter with the given decoder.
DecoderFilter::p decoder::get_decoder(const std::string& name) {
- return DecoderFilter::p(new DecoderFilter(DecoderBase::p(decoder_factories[name]())));
+ return DecoderFilter::p(new DecoderFilter(decoder_factories[name]()));
}
diff --git a/decoder.h b/decoder.h
index 25dbe56..9faabc1 100644
--- a/decoder.h
+++ b/decoder.h
@@ -11,15 +11,19 @@ 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;
+ virtual ~DecoderBase() {}
+
};
//! Input filter to hold a decoder in a filter chain.
class DecoderFilter : public boost::iostreams::multichar_input_filter {
private:
DecoderBase::p decoder;
+
public:
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];
diff --git a/encoder.cpp b/encoder.cpp
index cd37daa..0f2a5fe 100644
--- a/encoder.cpp
+++ b/encoder.cpp
@@ -10,7 +10,7 @@ EncoderFilter::EncoderFilter(EncoderBase::p encoder_) {
encoder = encoder_;
}
-typedef boost::function<boost::shared_ptr<EncoderBase>()> EncoderFactory;
+typedef boost::function<EncoderBase::p ()> EncoderFactory;
std::map<std::string, EncoderFactory> encoder_factories;
void encoder::init() {
@@ -19,5 +19,5 @@ void encoder::init() {
//! Construct a filter with the given encoder.
EncoderFilter::p encoder::get_encoder(const std::string& name) {
- return EncoderFilter::p(new EncoderFilter(EncoderBase::p(encoder_factories[name]())));
+ return EncoderFilter::p(new EncoderFilter(encoder_factories[name]()));
}
diff --git a/encoder.h b/encoder.h
index 52c50ab..f68d51c 100644
--- a/encoder.h
+++ b/encoder.h
@@ -11,6 +11,8 @@
class EncoderBase {
public:
typedef boost::shared_ptr<EncoderBase> p;
+ virtual ~EncoderBase() {}
+
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;
};
@@ -19,9 +21,11 @@ class EncoderBase {
class EncoderFilter : public boost::iostreams::multichar_input_filter {
private:
EncoderBase::p encoder;
+
public:
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];