]> git.lyx.org Git - lyx.git/blob - src/trans.h
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / trans.h
1 // -*- C++ -*-
2 #ifndef Trans_h
3 #define Trans_h
4
5 #ifdef __GNUG__
6 #pragma interface
7 #endif
8
9 #include <map>
10
11 #include "tex-accent.h"
12 #include "LString.h"
13 #include "trans_decl.h"
14
15 class LyXLex;
16
17 class TransManager;
18
19 #if 0
20 /**
21   TransInterface: the interface that every translation class
22   should obey too.
23   Visitor pattern applied here
24   */
25 class TransInterface {
26 public:
27         ///
28         virtual string const process(char, TransManager &) = 0;
29         ///
30         virtual bool isAccentDefined(tex_accent, KmodInfo &) const = 0;
31 };
32
33 /**
34   DefaultTrans: the default translation class. Holds info
35   on tex-accents. Monostate
36   */
37 class DefaultTrans : public TransInterface {
38 public:
39         ///
40         DefaultTrans();
41         ///
42         virtual string const process(char, TransManager &);
43 private:
44         ///
45         static bool init_;
46 };
47 #endif
48
49 /**
50   Trans: holds a .kmap file 
51   */
52 //class Trans : public TransInterface {
53 class Trans {
54 public:
55         ///
56         Trans();
57         ///
58         ~Trans();
59
60         ///
61         int Load(string const & language);
62         ///
63         bool IsDefined() const;
64         ///
65         string const & GetName() const;
66         ///
67         string const process(char, TransManager &);
68         ///
69         bool isAccentDefined(tex_accent, KmodInfo &) const;
70     
71 private:
72 #if 0
73         ///
74         typedef KmodInfo kmod_list_decl;
75         ///
76         typedef KmodException keyexc;
77 #endif
78 #if 0
79         ///
80         void AddDeadkey(tex_accent, string const &, string const &);
81 #else
82         ///
83         void AddDeadkey(tex_accent, string const &);
84 #endif
85         ///
86         void FreeKeymap();
87         ///
88         int Load(LyXLex &);
89         ///
90         inline string const & Match(unsigned char c);
91         ///
92         void InsertException(KmodException & exclist, char c,
93                              string const & data, bool = false,
94                              tex_accent = TEX_NOACCENT);
95         ///
96         void FreeException(KmodException & exclist);
97
98         ///
99         string name_;
100 #if 0
101         ///
102         string keymap_[256];
103 #else
104         std::map<int, string> keymap_;
105 #endif
106 #if 0
107         ///
108         kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
109 #else
110         ///
111         //KmodInfo * kmod_list_[TEX_MAX_ACCENT+1];
112         std::map<int, KmodInfo> kmod_list_;
113 #endif
114 };
115
116
117 ///
118 string const & Trans::Match(unsigned char c)
119 {
120 #if 0
121         return keymap_[c];
122 #else
123         std::map<int, string>::iterator it = keymap_.find(c);
124         if (it != keymap_.end()) {
125                 return it->second;
126         }
127         static string dummy;
128         return dummy;
129 #endif
130 }
131
132 #endif