2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TYPE_WRAPPERS_H
18 #define __TYPE_WRAPPERS_H
20 #include <androidfw/ResourceTypes.h>
25 TypeVariant(const ResTable_type* data)
30 iterator& operator=(const iterator& rhs) {
31 mTypeVariant = rhs.mTypeVariant;
35 bool operator==(const iterator& rhs) const {
36 return mTypeVariant == rhs.mTypeVariant && mIndex == rhs.mIndex;
39 bool operator!=(const iterator& rhs) const {
40 return mTypeVariant != rhs.mTypeVariant || mIndex != rhs.mIndex;
43 iterator operator++(int) {
44 uint32_t prevIndex = mIndex;
46 return iterator(mTypeVariant, prevIndex);
49 const ResTable_entry* operator->() const {
53 uint32_t index() const {
57 iterator& operator++();
58 const ResTable_entry* operator*() const;
61 friend struct TypeVariant;
62 iterator(const TypeVariant* tv, uint32_t index)
63 : mTypeVariant(tv), mIndex(index) {}
64 const TypeVariant* mTypeVariant;
68 iterator beginEntries() const {
69 return iterator(this, 0);
72 iterator endEntries() const {
73 return iterator(this, dtohl(data->entryCount));
76 const ResTable_type* data;
79 } // namespace android
81 #endif // __TYPE_WRAPPERS_H