Home | History | Annotate | Download | only in aapt2
      1 /*
      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 
     23 namespace aapt {
     24 
     25 using SymbolEntryVector = std::vector<std::pair<ResourceNameRef, uint32_t>>;
     26 
     27 struct FlatEntry;
     28 
     29 /**
     30  * Flattens a ResourceTable into a binary format suitable
     31  * for loading into a ResTable on the host or device.
     32  */
     33 struct 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 
     53 private:
     54     bool flattenValue(BigBuffer* out, const FlatEntry& flatEntry, SymbolEntryVector* symbols);
     55 
     56     Options mOptions;
     57 };
     58 
     59 } // namespace aapt
     60 
     61 #endif // AAPT_TABLE_FLATTENER_H
     62