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;
331ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski};
341ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski
351ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinskiclass XmlFlattener : public IXmlResourceConsumer {
36cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski public:
37cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski  XmlFlattener(BigBuffer* buffer, XmlFlattenerOptions options)
38ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski      : buffer_(buffer), options_(options) {}
391ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski
40ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski  bool Consume(IAaptContext* context, xml::XmlResource* resource) override;
411ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski
42cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski private:
43ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski  DISALLOW_COPY_AND_ASSIGN(XmlFlattener);
44ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski
45ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski  bool Flatten(IAaptContext* context, xml::Node* node);
461ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski
47ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski  BigBuffer* buffer_;
48ce5e56e243d262a9b65459c3bd0bb9eaadd40628Adam Lesinski  XmlFlattenerOptions options_;
491ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski};
501ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski
51cacb28f2d60858106e2819cc7d95a65e8bda890bAdam Lesinski}  // namespace aapt
521ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski
531ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski#endif /* AAPT_FLATTEN_XMLFLATTENER_H */
54