| 1 |
// |
| 2 |
// Copyright RIME Developers |
| 3 |
// Distributed under the BSD License |
| 4 |
// |
| 5 |
#ifndef RIME_EXTENDED_CHARSET_FILTER_H_ |
| 6 |
#define RIME_EXTENDED_CHARSET_FILTER_H_ |
| 7 |
|
| 8 |
#include <rime_api.h> |
| 9 |
#include <rime/filter.h> |
| 10 |
#include <rime/translation.h> |
| 11 |
#include <rime/gear/charset_filter.h> |
| 12 |
|
| 13 |
namespace rime { |
| 14 |
|
| 15 |
class ExtendedCharsetFilterTranslation : public CharsetFilterTranslation { |
| 16 |
public: |
| 17 |
ExtendedCharsetFilterTranslation(an<Translation> translation, |
| 18 |
const string& charset); |
| 19 |
|
| 20 |
protected: |
| 21 |
bool FilterCandidate(an<Candidate> cand) override; |
| 22 |
void ParseParameters(const string& charset); |
| 23 |
|
| 24 |
string charset_; |
| 25 |
bool is_emoji_enabled_ = false; |
| 26 |
}; |
| 27 |
|
| 28 |
struct DictEntry; |
| 29 |
|
| 30 |
class ExtendedCharsetFilter : public CharsetFilter { |
| 31 |
public: |
| 32 |
explicit ExtendedCharsetFilter(const Ticket& ticket) |
| 33 |
: CharsetFilter(ticket) {} |
| 34 |
|
| 35 |
an<Translation> Apply(an<Translation> translation, |
| 36 |
CandidateList* candidates) override; |
| 37 |
|
| 38 |
// return true to accept, false to reject the tested item |
| 39 |
RIME_API static bool FilterText(const string& text, |
| 40 |
const string& charset = "", |
| 41 |
bool is_emoji_enabled = false); |
| 42 |
}; |
| 43 |
|
| 44 |
} // namespace rime |
| 45 |
|
| 46 |
#endif // RIME_EXTENDED_CHARSET_FILTER_H_ |