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_XLIFF_XML_PULL_PARSER_H 18 #define AAPT_XLIFF_XML_PULL_PARSER_H 19 20 #include "XmlPullParser.h" 21 22 #include <memory> 23 #include <string> 24 25 namespace aapt { 26 27 /** 28 * Strips xliff elements and provides the caller with a view of the 29 * underlying XML without xliff. 30 */ 31 class XliffXmlPullParser : public XmlPullParser { 32 public: 33 XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser); 34 XliffXmlPullParser(const XliffXmlPullParser& rhs) = delete; 35 36 Event getEvent() const override; 37 const std::string& getLastError() const override; 38 Event next() override; 39 40 const std::u16string& getComment() const override; 41 size_t getLineNumber() const override; 42 size_t getDepth() const override; 43 44 const std::u16string& getText() const override; 45 46 const std::u16string& getNamespacePrefix() const override; 47 const std::u16string& getNamespaceUri() const override; 48 bool applyPackageAlias(std::u16string* package, const std::u16string& defaultPackage) 49 const override; 50 51 const std::u16string& getElementNamespace() const override; 52 const std::u16string& getElementName() const override; 53 54 const_iterator beginAttributes() const override; 55 const_iterator endAttributes() const override; 56 size_t getAttributeCount() const override; 57 58 private: 59 std::shared_ptr<XmlPullParser> mParser; 60 }; 61 62 } // namespace aapt 63 64 #endif // AAPT_XLIFF_XML_PULL_PARSER_H 65