+
+/**
+A helper class to provide some common functionality.
+*/
+template<typename C>
+class StandardCodec: public Codec
+{
+private:
+ ErrorMode err_mode;
+
+protected:
+ StandardCodec(ErrorMode em): err_mode(em==DEFAULT ? THROW_ON_ERROR : em) { }
+
+ ErrorMode get_error_mode(ErrorMode em = DEFAULT) const
+ { return (em==DEFAULT ? err_mode : em); }
+
+public:
+ virtual Encoder *create_encoder(ErrorMode em = DEFAULT) const
+ { return new typename C::Encoder(get_error_mode(em)); }
+
+ virtual Decoder *create_decoder(ErrorMode em = DEFAULT) const
+ { return new typename C::Decoder(get_error_mode(em)); }
+};
+
+