Bjorn Bringert | fb903a4 | 2013-03-18 21:17:26 +0000 | [diff] [blame] | 1 | #ifndef HOST_PSEUDOLOCALIZE_H |
| 2 | #define HOST_PSEUDOLOCALIZE_H |
| 3 | |
Elliott Hughes | be5474d | 2015-12-04 15:33:35 -0800 | [diff] [blame] | 4 | #include <android-base/macros.h> |
Anton Krumin | a2ef5c0 | 2014-03-12 14:46:44 -0700 | [diff] [blame] | 5 | #include "StringPool.h" |
| 6 | |
Igor Viarheichyk | cbb1e67 | 2015-05-14 18:47:00 -0700 | [diff] [blame] | 7 | class PseudoMethodImpl { |
| 8 | public: |
| 9 | virtual ~PseudoMethodImpl() {} |
| 10 | virtual String16 start() { return String16(); } |
| 11 | virtual String16 end() { return String16(); } |
| 12 | virtual String16 text(const String16& text) = 0; |
| 13 | virtual String16 placeholder(const String16& text) = 0; |
| 14 | }; |
Bjorn Bringert | fb903a4 | 2013-03-18 21:17:26 +0000 | [diff] [blame] | 15 | |
Igor Viarheichyk | cbb1e67 | 2015-05-14 18:47:00 -0700 | [diff] [blame] | 16 | class PseudoMethodNone : public PseudoMethodImpl { |
| 17 | public: |
| 18 | PseudoMethodNone() {} |
| 19 | String16 text(const String16& text) { return text; } |
| 20 | String16 placeholder(const String16& text) { return text; } |
| 21 | private: |
| 22 | DISALLOW_COPY_AND_ASSIGN(PseudoMethodNone); |
| 23 | }; |
| 24 | |
| 25 | class PseudoMethodBidi : public PseudoMethodImpl { |
| 26 | public: |
| 27 | String16 text(const String16& text); |
| 28 | String16 placeholder(const String16& text); |
| 29 | }; |
| 30 | |
| 31 | class PseudoMethodAccent : public PseudoMethodImpl { |
| 32 | public: |
| 33 | PseudoMethodAccent() : mDepth(0), mWordCount(0), mLength(0) {} |
| 34 | String16 start(); |
| 35 | String16 end(); |
| 36 | String16 text(const String16& text); |
| 37 | String16 placeholder(const String16& text); |
| 38 | private: |
| 39 | size_t mDepth; |
| 40 | size_t mWordCount; |
| 41 | size_t mLength; |
| 42 | }; |
| 43 | |
| 44 | class Pseudolocalizer { |
| 45 | public: |
Chih-Hung Hsieh | 9b8528f | 2016-08-10 14:15:30 -0700 | [diff] [blame] | 46 | explicit Pseudolocalizer(PseudolocalizationMethod m); |
Igor Viarheichyk | cbb1e67 | 2015-05-14 18:47:00 -0700 | [diff] [blame] | 47 | ~Pseudolocalizer() { if (mImpl) delete mImpl; } |
| 48 | void setMethod(PseudolocalizationMethod m); |
| 49 | String16 start() { return mImpl->start(); } |
| 50 | String16 end() { return mImpl->end(); } |
| 51 | String16 text(const String16& text); |
| 52 | private: |
| 53 | PseudoMethodImpl *mImpl; |
| 54 | size_t mLastDepth; |
| 55 | }; |
Bjorn Bringert | fb903a4 | 2013-03-18 21:17:26 +0000 | [diff] [blame] | 56 | |
| 57 | #endif // HOST_PSEUDOLOCALIZE_H |
| 58 | |