2010-12-09 12:31:50 +00:00
|
|
|
/* This file is (c) 2008-2011 Konstantin Isakov <ikm@goldendict.org>
|
2009-05-06 14:39:08 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __TRANSLITERATION_HH_INCLUDED__
|
|
|
|
#define __TRANSLITERATION_HH_INCLUDED__
|
|
|
|
|
|
|
|
#include "dictionary.hh"
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace Transliteration {
|
|
|
|
|
|
|
|
using std::map;
|
|
|
|
using gd::wstring;
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
class Table: public map< wstring, wstring >
|
|
|
|
{
|
|
|
|
unsigned maxEntrySize;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Table(): maxEntrySize( 0 )
|
|
|
|
{}
|
|
|
|
|
|
|
|
unsigned getMaxEntrySize() const
|
|
|
|
{ return maxEntrySize; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/// Inserts new entry into index. from and to are UTF8-encoded strings.
|
|
|
|
/// Also updates maxEntrySize.
|
|
|
|
void ins( char const * from, char const * to );
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This is a base dictionary class for simple transliteratons
|
|
|
|
class TransliterationDictionary: public Dictionary::Class
|
|
|
|
{
|
|
|
|
string name;
|
2009-05-18 10:36:12 +00:00
|
|
|
QIcon icon;
|
2009-05-06 14:39:08 +00:00
|
|
|
Table const & table;
|
2009-05-14 12:42:06 +00:00
|
|
|
bool caseSensitive;
|
2009-05-06 14:39:08 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
TransliterationDictionary( string const & id, string const & name,
|
2009-05-18 10:36:12 +00:00
|
|
|
QIcon icon,
|
2009-05-14 12:42:06 +00:00
|
|
|
Table const & table,
|
|
|
|
bool caseSensitive = true );
|
2009-05-06 14:39:08 +00:00
|
|
|
|
|
|
|
virtual string getName() throw();
|
|
|
|
|
2009-05-18 10:36:12 +00:00
|
|
|
virtual QIcon getIcon() throw()
|
|
|
|
{ return icon; }
|
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
virtual map< Dictionary::Property, string > getProperties() throw();
|
|
|
|
|
|
|
|
virtual unsigned long getArticleCount() throw();
|
|
|
|
|
|
|
|
virtual unsigned long getWordCount() throw();
|
|
|
|
|
|
|
|
virtual vector< wstring > getAlternateWritings( wstring const & )
|
|
|
|
throw();
|
|
|
|
|
|
|
|
virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & )
|
|
|
|
throw( std::exception );
|
|
|
|
|
|
|
|
virtual sptr< Dictionary::WordSearchRequest > prefixMatch( wstring const &,
|
|
|
|
unsigned long ) throw( std::exception );
|
|
|
|
|
|
|
|
virtual sptr< Dictionary::DataRequest > getArticle( wstring const &,
|
2009-05-29 19:48:50 +00:00
|
|
|
vector< wstring > const &,
|
|
|
|
wstring const & )
|
2009-05-06 14:39:08 +00:00
|
|
|
throw( std::exception );
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|