| Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| Adam Lesinski | 4670805 | 2017-09-29 14:49:15 -0700 | [diff] [blame] | 17 | #ifndef AAPT_FORMAT_PROTO_PROTOSERIALIZE_H |
| 18 | #define AAPT_FORMAT_PROTO_PROTOSERIALIZE_H |
| Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 19 | |
| Adam Lesinski | ce5e56e2 | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 20 | #include "android-base/macros.h" |
| Adam Lesinski | ce5e56e2 | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 21 | |
| Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 22 | #include "ConfigDescription.h" |
| 23 | #include "Configuration.pb.h" |
| Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 24 | #include "ResourceTable.h" |
| Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 25 | #include "ResourceValues.h" |
| 26 | #include "Resources.pb.h" |
| 27 | #include "ResourcesInternal.pb.h" |
| 28 | #include "StringPool.h" |
| 29 | #include "xml/XmlDom.h" |
| 30 | |
| Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 31 | namespace aapt { |
| 32 | |
| Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 33 | // Serializes a Value to its protobuf representation. An optional StringPool will hold the |
| 34 | // source path string. |
| 35 | void SerializeValueToPb(const Value& value, pb::Value* out_value, StringPool* src_pool = nullptr); |
| 36 | |
| 37 | // Serialize an Item into its protobuf representation. pb::Item does not store the source path nor |
| 38 | // comments of an Item. |
| 39 | void SerializeItemToPb(const Item& item, pb::Item* out_item); |
| 40 | |
| 41 | // Serializes an XML element into its protobuf representation. |
| 42 | void SerializeXmlToPb(const xml::Element& el, pb::XmlNode* out_node); |
| 43 | |
| 44 | // Serializes an XmlResource into its protobuf representation. The ResourceFile is NOT serialized. |
| 45 | void SerializeXmlResourceToPb(const xml::XmlResource& resource, pb::XmlNode* out_node); |
| 46 | |
| 47 | // Serializes a StringPool into its protobuf representation, which is really just the binary |
| 48 | // ResStringPool representation stuffed into a bytes field. |
| 49 | void SerializeStringPoolToPb(const StringPool& pool, pb::StringPool* out_pb_pool); |
| 50 | |
| 51 | // Serializes a ConfigDescription into its protobuf representation. |
| 52 | void SerializeConfig(const ConfigDescription& config, pb::Configuration* out_pb_config); |
| 53 | |
| 54 | // Serializes a ResourceTable into its protobuf representation. |
| 55 | void SerializeTableToPb(const ResourceTable& table, pb::ResourceTable* out_table); |
| 56 | |
| 57 | // Serializes a ResourceFile into its protobuf representation. |
| 58 | void SerializeCompiledFileToPb(const ResourceFile& file, pb::internal::CompiledFile* out_file); |
| 59 | |
| Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 60 | } // namespace aapt |
| Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 61 | |
| Adam Lesinski | 4670805 | 2017-09-29 14:49:15 -0700 | [diff] [blame] | 62 | #endif /* AAPT_FORMAT_PROTO_PROTOSERIALIZE_H */ |