X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftrans.h;h=3d719c255b868e05c4e8ff3566b95cc2b3fa0778;hb=ac103f15a7cead429a7b2ee1f75d67cc988ec81d;hp=6ff2ac3cecf0588e4c4fe14daf478337b3ffe759;hpb=0eccdd1c3613e5170deb77b22174dd0afde833e9;p=lyx.git diff --git a/src/trans.h b/src/trans.h index 6ff2ac3cec..3d719c255b 100644 --- a/src/trans.h +++ b/src/trans.h @@ -1,11 +1,21 @@ // -*- C++ -*- -#ifndef _Trans_h_ -#define _Trans_h_ +/** + * \file trans.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author unknown + */ + +#ifndef TRANS_H +#define TRANS_H #ifdef __GNUG__ #pragma interface #endif +#include + #include "tex-accent.h" #include "LString.h" #include "trans_decl.h" @@ -15,89 +25,61 @@ 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 - */ -class DefaultTrans: public TransInterface { -private: - /// - static bool init_; -public: - /// - DefaultTrans(); - /// - virtual string process(char,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(string const & language); /// - bool IsDefined(); + bool IsDefined() const; /// - const string& 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, const string&, const string&); + 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, - const string& data, bool = false, + 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 keymap_; /// - kmod_list_decl *kmod_list_[TEX_MAX_ACCENT+1]; - + std::map kmod_list_; }; -char* Trans::Match(char c) +/// +inline +string const & Trans::Match(unsigned char c) { - return keymap_[(unsigned char)c]; + std::map::iterator it = keymap_.find(c); + if (it != keymap_.end()) { + return it->second; + } + static string dummy; + return dummy; } -#endif +#endif // TRANS_H