XmlFlattener.h revision ce5e56e243d262a9b65459c3bd0bb9eaadd40628
11ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski/* 21ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * Copyright (C) 2015 The Android Open Source Project 31ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * 41ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * Licensed under the Apache License, Version 2.0 (the "License"); 51ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * you may not use this file except in compliance with the License. 61ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * You may obtain a copy of the License at 71ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * 81ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * http://www.apache.org/licenses/LICENSE-2.0 91ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * 101ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * Unless required by applicable law or agreed to in writing, software 111ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * distributed under the License is distributed on an "AS IS" BASIS, 121ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * See the License for the specific language governing permissions and 141ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * limitations under the License. 151ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski */ 161ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 171ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski#ifndef AAPT_FLATTEN_XMLFLATTENER_H 181ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski#define AAPT_FLATTEN_XMLFLATTENER_H 191ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 20ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski#include "android-base/macros.h" 21ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski 221ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski#include "process/IResourceTableConsumer.h" 23467f171315f9c2037fcd3eb5edcfabc40671bf7bAdam Lesinski#include "util/BigBuffer.h" 24467f171315f9c2037fcd3eb5edcfabc40671bf7bAdam Lesinski#include "xml/XmlDom.h" 251ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 261ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinskinamespace aapt { 271ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 281ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinskistruct XmlFlattenerOptions { 29cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski /** 30cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski * Keep attribute raw string values along with typed values. 31cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski */ 32ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski bool keep_raw_values = false; 33cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski 34cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski /** 35cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski * If set, the max SDK level of attribute to flatten. All others are ignored. 36cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski */ 37ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski Maybe<size_t> max_sdk_level; 381ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski}; 391ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 401ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinskiclass XmlFlattener : public IXmlResourceConsumer { 41cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski public: 42cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski XmlFlattener(BigBuffer* buffer, XmlFlattenerOptions options) 43ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski : buffer_(buffer), options_(options) {} 441ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 45ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski bool Consume(IAaptContext* context, xml::XmlResource* resource) override; 461ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 47cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski private: 48ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski DISALLOW_COPY_AND_ASSIGN(XmlFlattener); 49ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski 50ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski bool Flatten(IAaptContext* context, xml::Node* node); 511ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 52ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski BigBuffer* buffer_; 53ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski XmlFlattenerOptions options_; 541ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski}; 551ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 56cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski} // namespace aapt 571ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 581ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski#endif /* AAPT_FLATTEN_XMLFLATTENER_H */ 59