1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
1999-11-15 12:01:38 +00:00
|
|
|
#ifndef Trans_h
|
|
|
|
#define Trans_h
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
#include <map>
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "tex-accent.h"
|
|
|
|
#include "LString.h"
|
|
|
|
#include "trans_decl.h"
|
|
|
|
|
|
|
|
class LyXLex;
|
|
|
|
|
|
|
|
class TransManager;
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
/**
|
|
|
|
TransInterface: the interface that every translation class
|
|
|
|
should obey too.
|
|
|
|
Visitor pattern applied here
|
|
|
|
*/
|
|
|
|
class TransInterface {
|
|
|
|
public:
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
virtual string const process(char, TransManager &) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
virtual bool isAccentDefined(tex_accent, KmodInfo &) const = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2001-06-25 00:06:33 +00:00
|
|
|
DefaultTrans: the default translation class. Holds info
|
1999-09-27 18:44:28 +00:00
|
|
|
on tex-accents. Monostate
|
|
|
|
*/
|
1999-11-15 12:01:38 +00:00
|
|
|
class DefaultTrans : public TransInterface {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
DefaultTrans();
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
virtual string const process(char, TransManager &);
|
2000-08-07 20:58:24 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
static bool init_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2001-07-16 15:42:57 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Trans: holds a .kmap file
|
|
|
|
*/
|
2001-07-16 15:42:57 +00:00
|
|
|
//class Trans : public TransInterface {
|
|
|
|
class Trans {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
Trans();
|
|
|
|
///
|
2001-07-16 15:42:57 +00:00
|
|
|
~Trans();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
int Load(string const & language);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
bool IsDefined() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const & GetName() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const process(char, TransManager &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
bool isAccentDefined(tex_accent, KmodInfo &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
private:
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
typedef KmodInfo kmod_list_decl;
|
|
|
|
///
|
|
|
|
typedef KmodException keyexc;
|
2001-07-16 15:42:57 +00:00
|
|
|
#endif
|
2001-07-12 11:11:10 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
void AddDeadkey(tex_accent, string const &, string const &);
|
2001-07-12 11:11:10 +00:00
|
|
|
#else
|
|
|
|
///
|
|
|
|
void AddDeadkey(tex_accent, string const &);
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void FreeKeymap();
|
|
|
|
///
|
|
|
|
int Load(LyXLex &);
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
inline string const & Match(unsigned char c);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-07-16 15:42:57 +00:00
|
|
|
void InsertException(KmodException & exclist, char c,
|
1999-11-15 12:01:38 +00:00
|
|
|
string const & data, bool = false,
|
1999-09-27 18:44:28 +00:00
|
|
|
tex_accent = TEX_NOACCENT);
|
|
|
|
///
|
2001-07-16 15:42:57 +00:00
|
|
|
void FreeException(KmodException & exclist);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string name_;
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string keymap_[256];
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
std::map<int, string> keymap_;
|
|
|
|
#endif
|
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 12:01:38 +00:00
|
|
|
kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
///
|
|
|
|
//KmodInfo * kmod_list_[TEX_MAX_ACCENT+1];
|
|
|
|
std::map<int, KmodInfo> kmod_list_;
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const & Trans::Match(unsigned char c)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-07-16 15:42:57 +00:00
|
|
|
#if 0
|
1999-12-13 00:05:34 +00:00
|
|
|
return keymap_[c];
|
2001-07-16 15:42:57 +00:00
|
|
|
#else
|
|
|
|
std::map<int, string>::iterator it = keymap_.find(c);
|
|
|
|
if (it != keymap_.end()) {
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
static string dummy;
|
|
|
|
return dummy;
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|