• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef HOST_PSEUDOLOCALIZE_H
2 #define HOST_PSEUDOLOCALIZE_H
3 
4 #include <android-base/macros.h>
5 #include "StringPool.h"
6 
7 class PseudoMethodImpl {
8  public:
~PseudoMethodImpl()9   virtual ~PseudoMethodImpl() {}
start()10   virtual String16 start() { return String16(); }
end()11   virtual String16 end() { return String16(); }
12   virtual String16 text(const String16& text) = 0;
13   virtual String16 placeholder(const String16& text) = 0;
14 };
15 
16 class PseudoMethodNone : public PseudoMethodImpl {
17  public:
PseudoMethodNone()18   PseudoMethodNone() {}
text(const String16 & text)19   String16 text(const String16& text) { return text; }
placeholder(const String16 & 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:
PseudoMethodAccent()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:
46   Pseudolocalizer(PseudolocalizationMethod m);
~Pseudolocalizer()47   ~Pseudolocalizer() { if (mImpl) delete mImpl; }
48   void setMethod(PseudolocalizationMethod m);
start()49   String16 start() { return mImpl->start(); }
end()50   String16 end() { return mImpl->end(); }
51   String16 text(const String16& text);
52  private:
53   PseudoMethodImpl *mImpl;
54   size_t mLastDepth;
55 };
56 
57 #endif // HOST_PSEUDOLOCALIZE_H
58 
59