]> git.tdb.fi Git - libs/core.git/blobdiff - source/iso2022jp.h
Rework the codec API completely to remove the internal buffering
[libs/core.git] / source / iso2022jp.h
index 82803b67e61446de3950575027d1a8c29232e6d4..f3c273669a67f62ffe24af0c13128fdaa3022a44 100644 (file)
@@ -1,11 +1,19 @@
+/* $Id$
+
+This file is part of libmspstrings
+Copyright © 2006-2007 Mikko Rasa
+Distributed under the LGPL
+*/
+
 #ifndef MSP_STRINGS_ISO2022JP_H_
 #define MSP_STRINGS_ISO2022JP_H_
 
 #include "codec.h"
 
 namespace Msp {
+namespace Codecs {
 
-class Iso2022Jp: public StringCodec
+class Iso2022Jp: public Codec
 {
 public:
        enum Mode
@@ -14,38 +22,39 @@ public:
                JISX0201,
                JISX0208
        };
-               
-       class Encoder: public StringCodec::Encoder
+
+       class Encoder: public Codec::Encoder
        {
        public:
-               Encoder(ErrorMode em=THROW_ON_ERROR): StringCodec::Encoder(em), mode(ASCII) { }
-               void encode_char(wchar_t);
-               void sync();
+               Encoder(ErrorMode em=THROW_ON_ERROR): Codec::Encoder(em), mode(ASCII) { }
+               virtual void encode_char(UnicodeChar, std::string &);
+               virtual void sync(std::string &);
+               virtual void reset();
        private:
                Mode mode;
 
-               void switch_mode(Mode);
-               void append_replacement();
+               void switch_mode(Mode, std::string &);
+               virtual void transliterate(UnicodeChar, std::string &);
        };
 
-       class Decoder: public StringCodec::Decoder
+       class Decoder: public Codec::Decoder
        {
        public:
                Decoder(ErrorMode =THROW_ON_ERROR);
-               void decode_char(const std::string &, std::string::const_iterator &);
-               void sync();
+               virtual UnicodeChar decode_char(const std::string &, std::string::const_iterator &);
+               virtual void reset();
        private:
                Mode mode;
-               StringCodec::Decoder *dec;
-               unsigned escape;
+               Codec::Decoder *dec;
 
-               void switch_mode(Mode);
+               virtual void switch_mode(Mode);
        };
 
        Encoder *create_encoder(ErrorMode em=THROW_ON_ERROR) const { return new Encoder(em); }
        Decoder *create_decoder(ErrorMode em=THROW_ON_ERROR) const { return new Decoder(em); }
 };
 
+} // namespace Codecs
 } // namespace Msp
 
 #endif