]> git.lyx.org Git - lyx.git/blobdiff - src/trans.h
add nls.m4
[lyx.git] / src / trans.h
index a056e1233a42760589321b4fe2463dcec569d5d7..6311e74def6b01cb20f86b934ca9bc9c4fe6900c 100644 (file)
 // -*- C++ -*-
-#ifndef Trans_h
-#define Trans_h
+/**
+ * \file trans.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#ifdef __GNUG__
-#pragma interface
-#endif
+#ifndef TRANS_H
+#define TRANS_H
 
-#include "tex-accent.h"
-#include "LString.h"
 #include "trans_decl.h"
 
-class LyXLex;
-
-class TransManager;
+#include <map>
 
-/**
-  TransInterface: the interface that every translation class
-  should obey too.
-  Visitor pattern applied here
-  */
-class TransInterface {
-public:
-       ///
-       virtual string const process(char, TransManager &) = 0;
-       ///
-       virtual bool isAccentDefined(tex_accent, KmodInfo &) const = 0;
-};
 
-/**
-  DefaultTrans: the default translation class. Holds info
-  on tex-accents. Monostate
-  */
-class DefaultTrans : public TransInterface {
-public:
-       ///
-       DefaultTrans();
-       ///
-       virtual string const process(char, TransManager &);
-private:
-       ///
-       static bool init_;
-};
+class LyXLex;
 
+class TransManager;
 
 /**
-  Trans: holds a .kmap file 
+  Trans: holds a .kmap file
   */
-class Trans : public TransInterface {
+class Trans {
 public:
        ///
        Trans();
        ///
-       virtual ~Trans();
+       ~Trans();
 
        ///
-       int Load(string const & language);
+       int Load(std::string const & language);
        ///
        bool IsDefined() const;
        ///
-       string const & GetName() const;
+       std::string const & GetName() const;
        ///
-       string const process(char, TransManager &);
+       std::string const process(char, TransManager &);
        ///
        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, std::string const &);
        ///
        void FreeKeymap();
        ///
        int Load(LyXLex &);
        ///
-       inline string const & Match(unsigned char c);
+       std::string const & Match(unsigned char c);
        ///
-       void InsertException(keyexc & exclist, char c,
-                            string const & data, bool = false,
+       void InsertException(KmodException & exclist, char c,
+                            std::string const & data, bool = false,
                             tex_accent = TEX_NOACCENT);
        ///
-       void FreeException(keyexc & exclist);
+       void FreeException(KmodException & exclist);
 
        ///
-       string name_;
+       std::string name_;
        ///
-       string keymap_[256];
+       std::map<int, std::string> keymap_;
        ///
-       kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
-
+       std::map<int, KmodInfo> kmod_list_;
 };
 
 
 ///
-string const & Trans::Match(unsigned char c)
+inline
+std::string const & Trans::Match(unsigned char c)
 {
-       return keymap_[c];
+       std::map<int, std::string>::iterator it = keymap_.find(c);
+       if (it != keymap_.end()) {
+               return it->second;
+       }
+       static std::string dummy;
+       return dummy;
 }
 
-#endif 
+#endif // TRANS_H