blob: 4dedc700a8e7d2e20e18cb10b87d72f474e08327 [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
Adam Lesinskice5e56e2016-10-21 17:56:45 -070020#include <memory>
21
Jeremy Meyer56f36e82022-05-20 20:35:42 +000022#include "ResourceValues.h"
Adam Lesinskice5e56e2016-10-21 17:56:45 -070023#include "android-base/macros.h"
Adam Lesinskid5083f62017-01-16 15:07:21 -080024#include "androidfw/StringPiece.h"
Jeremy Meyer56f36e82022-05-20 20:35:42 +000025#include "androidfw/StringPool.h"
Adam Lesinski393b5f02015-12-17 13:03:11 -080026
Adam Lesinski393b5f02015-12-17 13:03:11 -080027namespace aapt {
28
29class PseudoMethodImpl {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070030 public:
31 virtual ~PseudoMethodImpl() {}
Adam Lesinskice5e56e2016-10-21 17:56:45 -070032 virtual std::string Start() { return {}; }
33 virtual std::string End() { return {}; }
Adam Lesinskid5083f62017-01-16 15:07:21 -080034 virtual std::string Text(const android::StringPiece& text) = 0;
35 virtual std::string Placeholder(const android::StringPiece& text) = 0;
Adam Lesinski393b5f02015-12-17 13:03:11 -080036};
37
38class Pseudolocalizer {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070039 public:
40 enum class Method {
41 kNone,
42 kAccent,
43 kBidi,
44 };
Adam Lesinski393b5f02015-12-17 13:03:11 -080045
Adam Lesinskicacb28f2016-10-19 12:18:14 -070046 explicit Pseudolocalizer(Method method);
Adam Lesinskice5e56e2016-10-21 17:56:45 -070047 void SetMethod(Method method);
48 std::string Start() { return impl_->Start(); }
49 std::string End() { return impl_->End(); }
Adam Lesinskid5083f62017-01-16 15:07:21 -080050 std::string Text(const android::StringPiece& text);
Adam Lesinskicacb28f2016-10-19 12:18:14 -070051
52 private:
Adam Lesinskice5e56e2016-10-21 17:56:45 -070053 std::unique_ptr<PseudoMethodImpl> impl_;
54 size_t last_depth_;
Adam Lesinski393b5f02015-12-17 13:03:11 -080055};
56
Adam Lesinskicacb28f2016-10-19 12:18:14 -070057} // namespace aapt
Adam Lesinski393b5f02015-12-17 13:03:11 -080058
59#endif /* AAPT_COMPILE_PSEUDOLOCALIZE_H */