]> git.lyx.org Git - lyx.git/blob - src/encoding.h
Small clean-up.
[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 "support/std_string.h"
17 #include <map>
18
19 ///
20 typedef unsigned short int Uchar;
21
22 ///
23 class Encoding {
24 public:
25         ///
26         Encoding() {}
27         ///
28         Encoding(string const & n, string const & l, Uchar const * e)
29                 : Name_(n), LatexName_(l) {
30                 for (int i = 0; i < 256; ++i)
31                         encoding_table[i] = e[i];
32         }
33         ///
34         string const & Name() const {
35                 return Name_;
36         }
37         ///
38         string const & LatexName() const {
39                 return LatexName_;
40         }
41         ///
42         Uchar ucs(unsigned char c) const {
43                 return encoding_table[c];
44         }
45 private:
46         ///
47         string Name_;
48         ///
49         string LatexName_;
50         ///
51         Uchar encoding_table[256];
52 };
53
54 extern Encoding symbol_encoding;
55
56 class Encodings {
57 public:
58         ///
59         typedef std::map<string, Encoding> EncodingList;
60         ///
61         Encodings();
62         ///
63         void read(string const & filename);
64         ///
65         Encoding const * getEncoding(string const & encoding) const;
66         ///
67         Encoding const * symbol_encoding() {
68                 return &symbol_encoding_;
69         }
70
71         ///
72         enum Letter_Form {
73                 ///
74                 FORM_ISOLATED,
75                 ///
76                 FORM_FINAL,
77                 ///
78                 FORM_INITIAL,
79                 ///
80                 FORM_MEDIAL
81         };
82         ///
83         static
84         bool IsComposeChar_hebrew(unsigned char c);
85         ///
86         static
87         bool IsComposeChar_arabic(unsigned char c);
88         ///
89         static
90         bool is_arabic_special(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