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