X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftrans.h;h=2db65e41c038f4bc09dabda5ee3d1796f49fe249;hb=ee2966faba5563fb853f31f4d3d1785d380e1332;hp=bb896ee9a79880fb15a93b87bcd6f8770de58107;hpb=6396f9a204bfa7a154729dfaa17dc7abc619f7d0;p=lyx.git diff --git a/src/trans.h b/src/trans.h index bb896ee9a7..2db65e41c0 100644 --- a/src/trans.h +++ b/src/trans.h @@ -1,108 +1,90 @@ // -*- 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; +#include -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; -}; +namespace lyx { -/** - 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; + bool isDefined() const; /// - string const & GetName() const; + std::string const & getName() const; /// - string const process(char, TransManager &); + docstring const process(char_type, TransManager &); /// bool isAccentDefined(tex_accent, KmodInfo &) const; - + private: /// - typedef KmodInfo kmod_list_decl; + void addDeadkey(tex_accent, docstring const &); /// - typedef KmodException keyexc; -#if 0 + void freeKeymap(); /// - void AddDeadkey(tex_accent, string const &, string const &); -#else + int load(LyXLex &); /// - void AddDeadkey(tex_accent, string const &); -#endif + docstring const & match(char_type c); /// - void FreeKeymap(); - /// - int Load(LyXLex &); - /// - inline string const & Match(unsigned char c); - /// - void InsertException(keyexc & exclist, char c, - string const & data, bool = false, + void insertException(KmodException & exclist, char_type c, + docstring 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 keymap_; /// - kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1]; - + std::map kmod_list_; }; /// -string const & Trans::Match(unsigned char c) +inline +docstring const & Trans::match(char_type c) { - return keymap_[c]; + std::map::iterator it = keymap_.find(c); + if (it != keymap_.end()) { + return it->second; + } + static docstring dummy; + return dummy; } -#endif + +} // namespace lyx + +#endif // TRANS_H