blob: 2d4256a17496aaae3f3968c1e88a7f21dcf74727 [file] [log] [blame]
Adam Lesinski769de982015-04-10 19:43:55 -07001/*
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_BINARY_XML_PULL_PARSER_H
18#define AAPT_BINARY_XML_PULL_PARSER_H
19
20#include "XmlPullParser.h"
21
22#include <androidfw/ResourceTypes.h>
23#include <memory>
24#include <string>
25#include <vector>
26
27namespace aapt {
28
29/**
30 * Wraps a ResTable into the canonical XmlPullParser interface.
31 */
32class BinaryXmlPullParser : public XmlPullParser {
33public:
34 BinaryXmlPullParser(const std::shared_ptr<android::ResXMLTree>& parser);
35 BinaryXmlPullParser(const BinaryXmlPullParser& rhs) = delete;
36
37 Event getEvent() const;
38 const std::string& getLastError() const;
39 Event next();
40
41 const std::u16string& getComment() const;
42 size_t getLineNumber() const;
43 size_t getDepth() const;
44
45 const std::u16string& getText() const;
46
47 const std::u16string& getNamespacePrefix() const;
48 const std::u16string& getNamespaceUri() const;
49
50 const std::u16string& getElementNamespace() const;
51 const std::u16string& getElementName() const;
52
53 const_iterator beginAttributes() const;
54 const_iterator endAttributes() const;
55 size_t getAttributeCount() const;
56
57private:
58 void copyAttributes();
59
60 std::shared_ptr<android::ResXMLTree> mParser;
61 std::u16string mStr1;
62 std::u16string mStr2;
63 std::vector<Attribute> mAttributes;
64 Event mEvent;
65 bool mHasComment;
66 const std::u16string sEmpty;
67 const std::string sEmpty8;
68 size_t mDepth;
69};
70
71} // namespace aapt
72
73#endif // AAPT_BINARY_XML_PULL_PARSER_H