blob: ccbb737059f92fbe9a305a6512336decac524358 [file] [log] [blame]
Adam Lesinski6f6ceb72014-11-14 14:48:12 -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_TABLE_FLATTENER_H
18#define AAPT_TABLE_FLATTENER_H
19
20#include "BigBuffer.h"
21#include "ResourceTable.h"
22
23namespace aapt {
24
Adam Lesinskid5c4f872015-04-21 13:56:10 -070025using SymbolEntryVector = std::vector<std::pair<ResourceNameRef, uint32_t>>;
26
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080027struct FlatEntry;
28
29/**
30 * Flattens a ResourceTable into a binary format suitable
31 * for loading into a ResTable on the host or device.
32 */
33struct TableFlattener {
34 /**
35 * A set of options for this TableFlattener.
36 */
37 struct Options {
38 /**
39 * Specifies whether to output extended chunks, like
40 * source information and mising symbol entries. Default
41 * is true.
42 *
43 * Set this to false when emitting the final table to be used
44 * on device.
45 */
46 bool useExtendedChunks = true;
47 };
48
49 TableFlattener(Options options);
50
51 bool flatten(BigBuffer* out, const ResourceTable& table);
52
53private:
Adam Lesinskid5c4f872015-04-21 13:56:10 -070054 bool flattenValue(BigBuffer* out, const FlatEntry& flatEntry, SymbolEntryVector* symbols);
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080055
56 Options mOptions;
57};
58
59} // namespace aapt
60
61#endif // AAPT_TABLE_FLATTENER_H