X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftrans.h;h=4463a316138484090b524deb65c3d278d6386083;hb=e94889a041628203c50b66b9a4add63210de6928;hp=839caa462cc256b8aa65f1eb236826bfc079f9b3;hpb=dfe1bc44b44903faf77ef454c98c4c3e56c1d5e3;p=lyx.git diff --git a/src/trans.h b/src/trans.h index 839caa462c..4463a31613 100644 --- a/src/trans.h +++ b/src/trans.h @@ -1,103 +1,84 @@ // -*- 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 -/** - 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&); -}; +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(); + bool isDefined() const; /// - const string& GetName(); + std::string const & getName() const; /// - string process(char,TransManager&); + std::string const process(char, TransManager &); /// - bool isAccentDefined(tex_accent,KmodInfo&); - + bool isAccentDefined(tex_accent, KmodInfo &) const; + private: /// - typedef KmodInfo kmod_list_decl; + void addDeadkey(tex_accent, std::string const &); /// - typedef KmodException keyexc; - + void freeKeymap(); /// - void AddDeadkey(tex_accent, const string&, const string&); + int load(LyXLex &); /// - void FreeKeymap(); + std::string const & match(unsigned char c); /// - int Load(LyXLex &); - /// - inline char* Match(char c); - /// - void InsertException(keyexc &exclist, char c, - const string& 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_; /// - 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 +std::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 std::string dummy; + return dummy; } -#endif +#endif // TRANS_H