X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fiso2022jp.h;h=f3c273669a67f62ffe24af0c13128fdaa3022a44;hp=8ded0d845d2c87200577351acb57ded2466c9f2d;hb=f47bc86e6ce900c5323e593db003c93110538268;hpb=51b84c0c2c3abb0cf7e815c5ae259face40ac977 diff --git a/source/iso2022jp.h b/source/iso2022jp.h index 8ded0d8..f3c2736 100644 --- a/source/iso2022jp.h +++ b/source/iso2022jp.h @@ -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(): 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 switch_mode(Mode, std::string &); + virtual void transliterate(UnicodeChar, std::string &); }; - class Decoder: public StringCodec::Decoder + class Decoder: public Codec::Decoder { public: - Decoder(); - void decode_char(const std::string &, std::string::const_iterator &); - void sync(); - void reset(); + Decoder(ErrorMode =THROW_ON_ERROR); + 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() const { return new Encoder; } - Decoder *create_decoder() const { return new Decoder; } + 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