]> git.lyx.org Git - lyx.git/blob - src/encoding.h
John's msg3.diff
[lyx.git] / src / encoding.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef ENCODING_H
13 #define ENCODING_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "LString.h"
20 #include "lyxrc.h"
21
22 ///
23 typedef unsigned short int Uchar;
24
25 ///
26 class Encoding {
27 public:
28         ///
29         Encoding() {}
30         ///
31         Encoding(string const & n, string const & l, Uchar const * e)
32                 : Name_(n), LatexName_(l) {
33                 for (int i = 0; i < 256; ++i)
34                         encoding_table[i] = e[i];
35         }
36         ///
37         string const & Name() const {
38                 return Name_;
39         }
40         ///
41         string const & LatexName() const {
42                 return LatexName_;
43         }
44         ///
45         Uchar ucs(unsigned char c) const {
46                 return encoding_table[c];
47         }
48 private:
49         ///
50         string Name_;
51         ///
52         string LatexName_;
53         ///
54         Uchar encoding_table[256];
55 };
56
57 extern Encoding symbol_encoding;
58
59 class Encodings {
60 public:
61         ///
62         typedef std::map<string, Encoding> EncodingList;
63         ///
64         Encodings();
65         ///
66         void read(string const & filename);
67         ///
68         Encoding const * getEncoding(string const & encoding) const;
69         ///
70         Encoding const * symbol_encoding() {
71                 return &symbol_encoding_;
72         }
73
74         ///
75         enum Letter_Form {
76                 ///
77                 FORM_ISOLATED,
78                 ///
79                 FORM_FINAL,
80                 ///
81                 FORM_INITIAL,
82                 ///
83                 FORM_MEDIAL
84         };
85         ///
86         static
87         bool IsComposeChar_hebrew(unsigned char c);
88         ///
89         static
90         bool IsComposeChar_arabic(unsigned char c);
91         ///
92         static
93         bool is_arabic(unsigned char c);
94         ///
95         static
96         unsigned char TransformChar(unsigned char c, Letter_Form form);
97
98 private:
99         ///
100         EncodingList encodinglist;
101         ///
102         Encoding symbol_encoding_;
103 };
104
105 extern Encodings encodings;
106
107 #endif