1 /*
2  * Copyright (C) 2017 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_FORMAT_PROTO_PROTODESERIALIZE_H
18 #define AAPT_FORMAT_PROTO_PROTODESERIALIZE_H
19 
20 #include "android-base/macros.h"
21 #include "androidfw/ResourceTypes.h"
22 
23 #include "ConfigDescription.h"
24 #include "Configuration.pb.h"
25 #include "ResourceTable.h"
26 #include "ResourceValues.h"
27 #include "Resources.pb.h"
28 #include "ResourcesInternal.pb.h"
29 #include "StringPool.h"
30 #include "io/File.h"
31 #include "xml/XmlDom.h"
32 
33 namespace aapt {
34 
35 std::unique_ptr<Value> DeserializeValueFromPb(const pb::Value& pb_value,
36                                               const android::ResStringPool& src_pool,
37                                               const ConfigDescription& config,
38                                               StringPool* value_pool, io::IFileCollection* files,
39                                               std::string* out_error);
40 
41 std::unique_ptr<Item> DeserializeItemFromPb(const pb::Item& pb_item,
42                                             const android::ResStringPool& src_pool,
43                                             const ConfigDescription& config, StringPool* value_pool,
44                                             io::IFileCollection* files, std::string* out_error);
45 
46 std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode& pb_node,
47                                                                std::string* out_error);
48 
49 bool DeserializeXmlFromPb(const pb::XmlNode& pb_node, xml::Element* out_el, StringPool* value_pool,
50                           std::string* out_error);
51 
52 bool DeserializeConfigFromPb(const pb::Configuration& pb_config, ConfigDescription* out_config,
53                              std::string* out_error);
54 
55 // Optional io::IFileCollection used to lookup references to files in the ResourceTable.
56 bool DeserializeTableFromPb(const pb::ResourceTable& pb_table, io::IFileCollection* files,
57                             ResourceTable* out_table, std::string* out_error);
58 
59 bool DeserializeCompiledFileFromPb(const pb::internal::CompiledFile& pb_file,
60                                    ResourceFile* out_file, std::string* out_error);
61 
62 }  // namespace aapt
63 
64 #endif /* AAPT_FORMAT_PROTO_PROTODESERIALIZE_H */
65