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 #include "XliffXmlPullParser.h" 18 19 #include <string> 20 21 namespace aapt { 22 XliffXmlPullParser(const std::shared_ptr<XmlPullParser> & parser)23XliffXmlPullParser::XliffXmlPullParser(const std::shared_ptr<XmlPullParser>& parser) : 24 mParser(parser) { 25 } 26 next()27XmlPullParser::Event XliffXmlPullParser::next() { 28 while (XmlPullParser::isGoodEvent(mParser->next())) { 29 Event event = mParser->getEvent(); 30 if (event != Event::kStartElement && event != Event::kEndElement) { 31 break; 32 } 33 34 if (mParser->getElementNamespace() != 35 u"urn:oasis:names:tc:xliff:document:1.2") { 36 break; 37 } 38 39 const std::u16string& name = mParser->getElementName(); 40 if (name != u"bpt" 41 && name != u"ept" 42 && name != u"it" 43 && name != u"ph" 44 && name != u"g" 45 && name != u"bx" 46 && name != u"ex" 47 && name != u"x") { 48 break; 49 } 50 51 // We hit a tag that was ignored, so get the next event. 52 } 53 return mParser->getEvent(); 54 } 55 getEvent() const56XmlPullParser::Event XliffXmlPullParser::getEvent() const { 57 return mParser->getEvent(); 58 } 59 getLastError() const60const std::string& XliffXmlPullParser::getLastError() const { 61 return mParser->getLastError(); 62 } 63 getComment() const64const std::u16string& XliffXmlPullParser::getComment() const { 65 return mParser->getComment(); 66 } 67 getLineNumber() const68size_t XliffXmlPullParser::getLineNumber() const { 69 return mParser->getLineNumber(); 70 } 71 getDepth() const72size_t XliffXmlPullParser::getDepth() const { 73 return mParser->getDepth(); 74 } 75 getText() const76const std::u16string& XliffXmlPullParser::getText() const { 77 return mParser->getText(); 78 } 79 getNamespacePrefix() const80const std::u16string& XliffXmlPullParser::getNamespacePrefix() const { 81 return mParser->getNamespacePrefix(); 82 } 83 getNamespaceUri() const84const std::u16string& XliffXmlPullParser::getNamespaceUri() const { 85 return mParser->getNamespaceUri(); 86 } 87 applyPackageAlias(std::u16string * package,const std::u16string & defaultPackage) const88bool XliffXmlPullParser::applyPackageAlias(std::u16string* package, 89 const std::u16string& defaultPackage) const { 90 return mParser->applyPackageAlias(package, defaultPackage); 91 } 92 getElementNamespace() const93const std::u16string& XliffXmlPullParser::getElementNamespace() const { 94 return mParser->getElementNamespace(); 95 } 96 getElementName() const97const std::u16string& XliffXmlPullParser::getElementName() const { 98 return mParser->getElementName(); 99 } 100 getAttributeCount() const101size_t XliffXmlPullParser::getAttributeCount() const { 102 return mParser->getAttributeCount(); 103 } 104 beginAttributes() const105XmlPullParser::const_iterator XliffXmlPullParser::beginAttributes() const { 106 return mParser->beginAttributes(); 107 } 108 endAttributes() const109XmlPullParser::const_iterator XliffXmlPullParser::endAttributes() const { 110 return mParser->endAttributes(); 111 } 112 113 } // namespace aapt 114