1 // Copyright (c) 1997 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4 
5 #ifndef TranslateCodingSystem_INCLUDED
6 #define TranslateCodingSystem_INCLUDED 1
7 
8 #include "CodingSystem.h"
9 #include "Ptr.h"
10 #include "CharMap.h"
11 #include "CharsetRegistry.h"
12 #include "types.h"
13 
14 #ifdef SP_NAMESPACE
15 namespace SP_NAMESPACE {
16 #endif
17 
18 class SP_API TranslateCodingSystem : public CodingSystem {
19 public:
20   struct Desc {
21     CharsetRegistry::ISORegistrationNumber number;
22     // How much to add to the values in the base set.
23     Char add;
24   };
25   // codingSystem is the underlying BCTF
26   // desc describes the meaning of the bit combinations produced by that BCTF
27   // charset is the system character set
28   // replacementChar is character in systemCharset that should be used to represent
29   // characters that do not exist in the systemCharset.
30   // illegalChar is a code that can never be produced by the underlying BCTF.
31   TranslateCodingSystem(const CodingSystem *codingSystem,
32 			const Desc *desc,
33 			const CharsetInfo *charset,
34 			Char illegalChar,
35 			Char replacementChar);
36   Decoder *makeDecoder() const;
37   Encoder *makeEncoder() const;
38   unsigned fixedBytesPerChar() const;
39 private:
40   ConstPtr<CharMapResource<Char> > decodeMap_;
41   ConstPtr<CharMapResource<Char> > encodeMap_;
42   const CodingSystem *sub_;
43   const Desc *desc_;
44   const CharsetInfo *charset_;
45   Char illegalChar_;
46   Char replacementChar_;
47 };
48 
49 #ifdef SP_NAMESPACE
50 }
51 #endif
52 
53 #endif /* not TranslateCodingSystem_INCLUDED */
54