X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftrans.h;h=8cb068d90f575367d5bdf5f3592f00631df303fc;hb=21226de2b87a86be19fff025cace3d286a75aa76;hp=bb896ee9a79880fb15a93b87bcd6f8770de58107;hpb=6396f9a204bfa7a154729dfaa17dc7abc619f7d0;p=lyx.git diff --git a/src/trans.h b/src/trans.h index bb896ee9a7..8cb068d90f 100644 --- a/src/trans.h +++ b/src/trans.h @@ -6,6 +6,8 @@ #pragma interface #endif +#include + #include "tex-accent.h" #include "LString.h" #include "trans_decl.h" @@ -14,44 +16,16 @@ class LyXLex; class TransManager; -/** - 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_; -}; - - /** 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); @@ -65,44 +39,40 @@ public: bool isAccentDefined(tex_accent, KmodInfo &) const; private: - /// - typedef KmodInfo kmod_list_decl; - /// - typedef KmodException keyexc; -#if 0 - /// - void AddDeadkey(tex_accent, string const &, string const &); -#else /// void AddDeadkey(tex_accent, string const &); -#endif /// void FreeKeymap(); /// int Load(LyXLex &); /// - inline string const & Match(unsigned 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_; /// - string keymap_[256]; + std::map keymap_; /// - kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1]; - + std::map kmod_list_; }; /// +inline string const & Trans::Match(unsigned char c) { - return keymap_[c]; + std::map::iterator it = keymap_.find(c); + if (it != keymap_.end()) { + return it->second; + } + static string dummy; + return dummy; } #endif