Home | History | Annotate | Download | only in proto
      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/ConfigDescription.h"
     22 #include "androidfw/ResourceTypes.h"
     23 
     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 android::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 android::ConfigDescription& config,
     44                                             StringPool* value_pool, io::IFileCollection* files,
     45                                             std::string* out_error);
     46 
     47 std::unique_ptr<xml::XmlResource> DeserializeXmlResourceFromPb(const pb::XmlNode& pb_node,
     48                                                                std::string* out_error);
     49 
     50 bool DeserializeXmlFromPb(const pb::XmlNode& pb_node, xml::Element* out_el, StringPool* value_pool,
     51                           std::string* out_error);
     52 
     53 bool DeserializeConfigFromPb(const pb::Configuration& pb_config,
     54                              android::ConfigDescription* out_config, std::string* out_error);
     55 
     56 // Optional io::IFileCollection used to lookup references to files in the ResourceTable.
     57 bool DeserializeTableFromPb(const pb::ResourceTable& pb_table, io::IFileCollection* files,
     58                             ResourceTable* out_table, std::string* out_error);
     59 
     60 bool DeserializeCompiledFileFromPb(const pb::internal::CompiledFile& pb_file,
     61                                    ResourceFile* out_file, std::string* out_error);
     62 
     63 }  // namespace aapt
     64 
     65 #endif /* AAPT_FORMAT_PROTO_PROTODESERIALIZE_H */
     66