]> git.lyx.org Git - lyx.git/blob - src/trans.h
6ff2ac3cecf0588e4c4fe14daf478337b3ffe759
[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 "tex-accent.h"
10 #include "LString.h"
11 #include "trans_decl.h"
12
13 class LyXLex;
14
15 class TransManager;
16
17 /**
18   TransInterface: the interface that every translation class
19   should obey too.
20   Visitor pattern applied here
21   */
22 class TransInterface {
23 public:
24         ///
25         virtual string process(char,TransManager&)=0;
26         ///
27         virtual bool isAccentDefined(tex_accent,KmodInfo&)=0;
28 };
29
30 /**
31   DefaultTrans: the default translation class. Hols info
32   on tex-accents. Monostate
33   */
34 class DefaultTrans: public TransInterface {
35 private:
36         ///
37         static bool init_;
38 public:
39         ///
40         DefaultTrans();
41         ///
42         virtual string process(char,TransManager&);
43 };
44
45
46 /**
47   Trans: holds a .kmap file 
48   */
49 class Trans:public TransInterface {
50 public:
51         ///
52         Trans();
53         ///
54         virtual ~Trans();
55
56         ///
57         int Load(string const &language);
58         ///
59         bool IsDefined();
60         ///
61         const string& GetName();
62         ///
63         string process(char,TransManager&);
64         ///
65         bool isAccentDefined(tex_accent,KmodInfo&);
66     
67 private:
68         ///
69         typedef KmodInfo kmod_list_decl;
70         ///
71         typedef KmodException keyexc;
72     
73         ///
74         void AddDeadkey(tex_accent, const string&, const string&);
75         ///
76         void FreeKeymap();
77         ///
78         int Load(LyXLex &);
79         ///
80         inline char* Match(char c);
81         ///
82         void InsertException(keyexc &exclist, char c,
83                              const string& data, bool = false,
84                              tex_accent = TEX_NOACCENT);
85         ///
86         void FreeException(keyexc& exclist);
87
88         ///
89         string name_;
90         ///
91         char *keymap_[256];
92         ///
93         kmod_list_decl *kmod_list_[TEX_MAX_ACCENT+1];
94
95 };
96
97
98 char* Trans::Match(char c)
99 {
100         return keymap_[(unsigned char)c];
101 }
102
103 #endif