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_RESOLVER_H 18 #define AAPT_RESOLVER_H 19 20 #include "Maybe.h" 21 #include "Resource.h" 22 #include "ResourceValues.h" 23 24 #include <androidfw/ResourceTypes.h> 25 26 namespace aapt { 27 28 /** 29 * Resolves symbolic references (package:type/entry) into resource IDs/objects. 30 */ 31 class IResolver { 32 public: 33 virtual ~IResolver() {}; 34 35 /** 36 * Holds the result of a resource name lookup. 37 */ 38 struct Entry { 39 /** 40 * The ID of the resource. ResourceId::isValid() may 41 * return false if the resource has not been assigned 42 * an ID. 43 */ 44 ResourceId id; 45 46 /** 47 * If the resource is an attribute, this will point 48 * to a valid Attribute object, or else it will be 49 * nullptr. 50 */ 51 const Attribute* attr; 52 }; 53 54 /** 55 * Returns a ResourceID if the name is found. The ResourceID 56 * may not be valid if the resource was not assigned an ID. 57 */ 58 virtual Maybe<ResourceId> findId(const ResourceName& name) = 0; 59 60 /** 61 * Returns an Entry if the name is found. Entry::attr 62 * may be nullptr if the resource is not an attribute. 63 */ 64 virtual Maybe<Entry> findAttribute(const ResourceName& name) = 0; 65 66 /** 67 * Find a resource by ID. Resolvers may contain resources without 68 * resource IDs assigned to them. 69 */ 70 virtual Maybe<ResourceName> findName(ResourceId resId) = 0; 71 }; 72 73 } // namespace aapt 74 75 #endif // AAPT_RESOLVER_H 76