]> git.tdb.fi Git - libs/core.git/blob - source/stringcodec/iso2022jp.h
Replace earlier options sharing the same short or long name
[libs/core.git] / source / stringcodec / iso2022jp.h
1 #ifndef MSP_STRINGCODEC_ISO2022JP_H_
2 #define MSP_STRINGCODEC_ISO2022JP_H_
3
4 #include "codec.h"
5
6 namespace Msp {
7 namespace StringCodec {
8
9 class Iso2022Jp: public StandardCodec<Iso2022Jp>
10 {
11 public:
12         enum Mode
13         {
14                 ASCII,
15                 JISX0201,
16                 JISX0208
17         };
18
19         class Encoder: public Codec::Encoder
20         {
21         private:
22                 Mode mode;
23
24         public:
25                 Encoder(ErrorMode em = THROW_ON_ERROR): Codec::Encoder(em), mode(ASCII) { }
26
27                 virtual void encode_char(unichar, std::string &);
28                 virtual void sync(std::string &);
29                 virtual void reset();
30         private:
31                 void switch_mode(Mode, std::string &);
32                 virtual void transliterate(unichar, std::string &);
33         };
34
35         class Decoder: public Codec::Decoder
36         {
37         private:
38                 Mode mode;
39                 Codec::Decoder *dec;
40
41         public:
42                 Decoder(ErrorMode =THROW_ON_ERROR);
43
44                 virtual unichar decode_char(const std::string &, std::string::const_iterator &);
45                 virtual void reset();
46         private:
47                 void switch_mode(Mode);
48         };
49
50         Iso2022Jp(ErrorMode em = THROW_ON_ERROR): StandardCodec<Iso2022Jp>(em) { }
51
52         virtual const char *get_name() const { return "ISO-2022-JP"; }
53 };
54
55 } // namespace StringCodec
56 } // namespace Msp
57
58 #endif