blob: 91d17d174d292b9929bd612914f6e94df5bb80ed [file] [log] [blame]
Adam Lesinski393b5f02015-12-17 13:03:11 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef AAPT_COMPILE_PSEUDOLOCALIZE_H
18#define AAPT_COMPILE_PSEUDOLOCALIZE_H
19
20#include "ResourceValues.h"
21#include "StringPool.h"
22#include "util/StringPiece.h"
23
24#include <android-base/macros.h>
25#include <memory>
26
27namespace aapt {
28
29class PseudoMethodImpl {
30public:
31 virtual ~PseudoMethodImpl() {}
Adam Lesinskid0f116b2016-07-08 15:00:32 -070032 virtual std::string start() { return {}; }
33 virtual std::string end() { return {}; }
34 virtual std::string text(const StringPiece& text) = 0;
35 virtual std::string placeholder(const StringPiece& text) = 0;
Adam Lesinski393b5f02015-12-17 13:03:11 -080036};
37
38class Pseudolocalizer {
39public:
40 enum class Method {
41 kNone,
42 kAccent,
43 kBidi,
44 };
45
Chih-Hung Hsieh470f8fc2016-08-15 12:32:51 -070046 explicit Pseudolocalizer(Method method);
Adam Lesinski393b5f02015-12-17 13:03:11 -080047 void setMethod(Method method);
Adam Lesinskid0f116b2016-07-08 15:00:32 -070048 std::string start() { return mImpl->start(); }
49 std::string end() { return mImpl->end(); }
50 std::string text(const StringPiece& text);
Adam Lesinski393b5f02015-12-17 13:03:11 -080051private:
52 std::unique_ptr<PseudoMethodImpl> mImpl;
53 size_t mLastDepth;
54};
55
56} // namespace aapt
57
58#endif /* AAPT_COMPILE_PSEUDOLOCALIZE_H */