Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 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_COMPILE_INLINEXMLFORMATPARSER_H |
| 18 | #define AAPT_COMPILE_INLINEXMLFORMATPARSER_H |
| 19 | |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 20 | #include <memory> |
| 21 | #include <vector> |
| 22 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 23 | #include "android-base/macros.h" |
| 24 | |
| 25 | #include "process/IResourceTableConsumer.h" |
| 26 | |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 27 | namespace aapt { |
| 28 | |
Adam Lesinski | 6b37299 | 2017-08-09 10:54:23 -0700 | [diff] [blame] | 29 | // Extracts Inline XML definitions into their own xml::XmlResource objects. |
| 30 | // |
| 31 | // Inline XML looks like: |
| 32 | // |
| 33 | // <animated-vector xmlns:android="http://schemas.android.com/apk/res/android" |
| 34 | // xmlns:aapt="http://schemas.android.com/aapt" > |
| 35 | // <aapt:attr name="android:drawable" > |
| 36 | // <vector |
| 37 | // android:height="64dp" |
| 38 | // android:width="64dp" |
| 39 | // android:viewportHeight="600" |
| 40 | // android:viewportWidth="600"/> |
| 41 | // </aapt:attr> |
| 42 | // </animated-vector> |
| 43 | // |
| 44 | // The <vector> will be extracted into its own XML file and <animated-vector> will |
| 45 | // gain an attribute 'android:drawable' set to a reference to the extracted <vector> resource. |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 46 | class InlineXmlFormatParser : public IXmlResourceConsumer { |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 47 | public: |
| 48 | explicit InlineXmlFormatParser() = default; |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 49 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 50 | bool Consume(IAaptContext* context, xml::XmlResource* doc) override; |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 51 | |
Adam Lesinski | 6b37299 | 2017-08-09 10:54:23 -0700 | [diff] [blame] | 52 | std::vector<std::unique_ptr<xml::XmlResource>>& GetExtractedInlineXmlDocuments() { |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 53 | return queue_; |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 54 | } |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 55 | |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 56 | private: |
| 57 | DISALLOW_COPY_AND_ASSIGN(InlineXmlFormatParser); |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 58 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 59 | std::vector<std::unique_ptr<xml::XmlResource>> queue_; |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 62 | } // namespace aapt |
Adam Lesinski | 5eeaadd | 2016-08-25 12:26:56 -0700 | [diff] [blame] | 63 | |
| 64 | #endif /* AAPT_COMPILE_INLINEXMLFORMATPARSER_H */ |