- virtual Encoder *create_encoder() const =0;
- virtual Decoder *create_decoder() const =0;
- virtual bool detect(const std::string &) const;
- virtual ~StringCodec() { }
+ virtual ~Codec() { }
+
+ /**
+ Returns the name of the encoding handled by this codec.
+ */
+ virtual const char *get_name() const =0;
+
+ /**
+ Creates an encoder for this codec.
+ */
+ virtual Encoder *create_encoder(ErrorMode err_mode=THROW_ON_ERROR) const =0;
+
+ /**
+ Creates a decoder for this codec.
+ */
+ virtual Decoder *create_decoder(ErrorMode err_mode=THROW_ON_ERROR) const =0;
+
+ /**
+ Determines whether the given string can be successfully decoded with this
+ codec. Note that this function returning true does not guarantee that the
+ string was actually encoded with this codec. In particular, many 8-bit
+ encodings are indistinguishable.
+ */
+ virtual bool detect(const std::string &) const;