]> git.lyx.org Git - lyx.git/blobdiff - src/trans.h
fix typo that put too many include paths for most people
[lyx.git] / src / trans.h
index 259433f300c18da2edfa2bcf9204455fb594b348..e0ccbc08baaefb90a333d9a1dd7091cf78821be0 100644 (file)
@@ -6,6 +6,8 @@
 #pragma interface
 #endif
 
+#include <map>
+
 #include "tex-accent.h"
 #include "LString.h"
 #include "trans_decl.h"
@@ -15,89 +17,62 @@ class LyXLex;
 class TransManager;
 
 /**
-  TransInterface: the interface that every translation class
-  should obey too.
-  Visitor pattern applied here
-  */
-class TransInterface {
-public:
-       ///
-       virtual string process(char, TransManager &) = 0;
-       ///
-       virtual bool isAccentDefined(tex_accent, KmodInfo &) = 0;
-};
-
-/**
-  DefaultTrans: the default translation class. Hols info
-  on tex-accents. Monostate
+  Trans: holds a .kmap file
   */
-class DefaultTrans : public TransInterface {
-private:
-       ///
-       static bool init_;
-public:
-       ///
-       DefaultTrans();
-       ///
-       virtual string process(char, TransManager &);
-};
-
-
-/**
-  Trans: holds a .kmap file 
-  */
-class Trans : public TransInterface {
+//class Trans : public TransInterface {
+class Trans {
 public:
        ///
        Trans();
        ///
-       virtual ~Trans();
+       ~Trans();
 
        ///
        int Load(string const & language);
        ///
-       bool IsDefined();
+       bool IsDefined() const;
        ///
-       string const & GetName();
+       string const & GetName() const;
        ///
-       string process(char, TransManager &);
+       string const process(char, TransManager &);
        ///
-       bool isAccentDefined(tex_accent, KmodInfo &);
-    
+       bool isAccentDefined(tex_accent, KmodInfo &) const;
+
 private:
        ///
-       typedef KmodInfo kmod_list_decl;
-       ///
-       typedef KmodException keyexc;
-    
-       ///
-       void AddDeadkey(tex_accent, string const &, string const &);
+       void AddDeadkey(tex_accent, string const &);
        ///
        void FreeKeymap();
        ///
        int Load(LyXLex &);
        ///
-       inline char * Match(char c);
+       string const & Match(unsigned char c);
        ///
-       void InsertException(keyexc & exclist, char c,
+       void InsertException(KmodException & exclist, char c,
                             string const & data, bool = false,
                             tex_accent = TEX_NOACCENT);
        ///
-       void FreeException(keyexc & exclist);
+       void FreeException(KmodException & exclist);
 
        ///
        string name_;
        ///
-       char * keymap_[256];
+       std::map<int, string> keymap_;
        ///
-       kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
-
+       std::map<int, KmodInfo> kmod_list_;
 };
 
 
-char * Trans::Match(char c)
+///
+inline
+string const & Trans::Match(unsigned char c)
 {
-       return keymap_[static_cast<unsigned char>(c)];
+       std::map<int, string>::iterator it = keymap_.find(c);
+       if (it != keymap_.end()) {
+               return it->second;
+       }
+       static string dummy;
+       return dummy;
 }
 
-#endif 
+#endif