Debian Codegraph @

tools/aapt2/split/TableSplitter.h

raw symbols SCIP
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
17 #ifndef AAPT_SPLIT_TABLESPLITTER_H
18 #define AAPT_SPLIT_TABLESPLITTER_H
19
20 #include <set>
21 #include <vector>
22 #include "android-base/macros.h"
23 #include "androidfw/ConfigDescription.h"
24
25 #include "ResourceTable.h"
26 #include "filter/ConfigFilter.h"
27 #include "process/IResourceTableConsumer.h"
28
29 namespace aapt {
30
31 struct SplitConstraints {
32 std::set<android::ConfigDescription> configs;
33 std::string name;
34 };
35
36 struct TableSplitterOptions {
37 /**
38 * The preferred densities to keep in the table, stripping out all others.
39 * If empty, no stripping is done.
40 */
41 std::vector<uint16_t> preferred_densities;
42
43 /**
44 * Configuration filter that determines which resource configuration values
45 * end up in the final table.
46 */
47 IConfigFilter* config_filter = nullptr;
48 };
49
50 class TableSplitter {
51 public:
52 TableSplitter(const std::vector<SplitConstraints>& splits,
53 const TableSplitterOptions& options)
54 : split_constraints_(splits), options_(options) {
55 for (size_t i = 0; i < split_constraints_.size(); i++) {
56 splits_.push_back(util::make_unique<ResourceTable>());
57 }
58 }
59
60 bool VerifySplitConstraints(IAaptContext* context);
61
62 void SplitTable(ResourceTable* original_table);
63
64 std::vector<std::unique_ptr<ResourceTable>>& splits() { return splits_; }
65
66 private:
67 std::vector<SplitConstraints> split_constraints_;
68 std::vector<std::unique_ptr<ResourceTable>> splits_;
69 TableSplitterOptions options_;
70
71 DISALLOW_COPY_AND_ASSIGN(TableSplitter);
72 };
73 }
74
75 #endif /* AAPT_SPLIT_TABLESPLITTER_H */