1#ifndef HOST_PSEUDOLOCALIZE_H
2#define HOST_PSEUDOLOCALIZE_H
3
4#include <android-base/macros.h>
5#include "StringPool.h"
6
7class 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};
15
16class 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
25class PseudoMethodBidi : public PseudoMethodImpl {
26 public:
27  String16 text(const String16& text);
28  String16 placeholder(const String16& text);
29};
30
31class 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
44class Pseudolocalizer {
45 public:
46  Pseudolocalizer(PseudolocalizationMethod m);
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};
56
57#endif // HOST_PSEUDOLOCALIZE_H
58
59