]> git.tdb.fi Git - libs/core.git/blobdiff - source/stringcodec/jisx0208.h
Let the base classes decide the default error mode
[libs/core.git] / source / stringcodec / jisx0208.h
index 0c4c4a6d06ea04a86ba3a9f5c4b80de1c44b1404..293d2774304d1c27a41c061f9801e76a50260b22 100644 (file)
@@ -1,48 +1,40 @@
-/* $Id$
-
-This file is part of libmspstrings
-Copyright © 2006-2007 Mikko Rasa
-Distributed under the LGPL
-*/
-
-#ifndef MSP_STRINGS_JISX0208_H_
-#define MSP_STRINGS_JISX0208_H_
+#ifndef MSP_STRINGCODEC_JISX0208_H_
+#define MSP_STRINGCODEC_JISX0208_H_
 
 #include "codec.h"
 
 namespace Msp {
-namespace Codecs {
+namespace StringCodec {
 
 /**
 Codec for the JIS X 0208 encoding.  This is not particularly useful as a
 stand-alone codec, due to lack of a linefeed character among other things,
 but is included as part of some other encodings.
 */
-class JisX0208: public Codec
+class JisX0208: public StandardCodec<JisX0208>
 {
 public:
        class Encoder: public Codec::Encoder
        {
        public:
-               Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em) { }
+               Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { }
 
-               virtual void encode_char(UnicodeChar, std::string &);
+               virtual void encode_char(unichar, std::string &);
        private:
-               virtual void transliterate(UnicodeChar, std::string &);
+               virtual void transliterate(unichar, std::string &);
        };
 
        class Decoder: public Codec::Decoder
        {
        public:
-               Decoder(ErrorMode em = THROW_ON_ERROR): Codec::Decoder(em) { }
+               Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { }
 
-               virtual UnicodeChar decode_char(const std::string &, std::string::const_iterator &);
+               virtual unichar decode_char(const std::string &, std::string::const_iterator &);
        };
 
-       virtual const char *get_name() const { return "JIS X 0208"; }
+       JisX0208(ErrorMode em = DEFAULT): StandardCodec<JisX0208>(em) { }
 
-       virtual Encoder *create_encoder(ErrorMode em = THROW_ON_ERROR) const { return new Encoder(em); }
-       virtual Decoder *create_decoder(ErrorMode em = THROW_ON_ERROR) const { return new Decoder(em); }
+       virtual const char *get_name() const { return "JIS X 0208"; }
 };
 
 
@@ -56,10 +48,10 @@ struct Kuten
        operator bool() { return ku!=0 && ten!=0; }
 };
 
-extern UnicodeChar jisx0208_to_ucs(Kuten);
-extern Kuten ucs_to_jisx0208(UnicodeChar);
+unichar jisx0208_to_ucs(Kuten);
+Kuten ucs_to_jisx0208(unichar);
 
-} // namespace Codecs
+} // namespace StringCodec
 } // namespace Msp
 
 #endif