• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_VALUE_TRANSFORMER_IMPL_H
18 #define AAPT_VALUE_TRANSFORMER_IMPL_H
19 
20 namespace aapt {
21 
ValueTransformer(StringPool * new_pool)22 inline ValueTransformer::ValueTransformer(StringPool* new_pool) : pool_(new_pool) {
23 }
24 
25 template <typename Derived, typename Base>
Transform(ValueTransformer & transformer)26 inline std::unique_ptr<Derived> TransformableValue<Derived, Base>::Transform(
27     ValueTransformer& transformer) const {
28   return transformer.TransformDerived(static_cast<const Derived*>(this));
29 }
30 
31 template <typename Derived, typename Base>
TransformValueImpl(ValueTransformer & transformer)32 Value* TransformableValue<Derived, Base>::TransformValueImpl(ValueTransformer& transformer) const {
33   auto self = static_cast<const Derived*>(this);
34   auto transformed = transformer.TransformValue(self);
35   return transformed.release();
36 }
37 
38 template <typename Derived, typename Base>
TransformItemImpl(ValueTransformer & transformer)39 Item* TransformableItem<Derived, Base>::TransformItemImpl(ValueTransformer& transformer) const {
40   auto self = static_cast<const Derived*>(this);
41   auto transformed = transformer.TransformItem(self);
42   return transformed.release();
43 }
44 
45 }  // namespace aapt
46 
47 #endif  // AAPT_VALUE_TRANSFORMER_IMPL_H