1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_RESOURCE_MANAGER_RESOURCEMANAGER_H 16 #define OHOS_RESOURCE_MANAGER_RESOURCEMANAGER_H 17 18 #include <map> 19 #include <string> 20 #include <vector> 21 #include "res_config.h" 22 23 namespace OHOS { 24 namespace Global { 25 namespace Resource { 26 class ResourceManager { 27 public: 28 29 virtual ~ResourceManager() = 0; 30 31 virtual bool AddResource(const char *path) = 0; 32 33 virtual RState UpdateResConfig(ResConfig &resConfig) = 0; 34 35 virtual void GetResConfig(ResConfig &resConfig) = 0; 36 37 virtual RState GetStringById(uint32_t id, std::string &outValue) = 0; 38 39 virtual RState GetStringByName(const char *name, std::string &outValue) = 0; 40 41 virtual RState GetStringFormatById(std::string &outValue, uint32_t id, ...) = 0; 42 43 virtual RState GetStringFormatByName(std::string &outValue, const char *name, ...) = 0; 44 45 virtual RState GetStringArrayById(uint32_t id, std::vector<std::string> &outValue) = 0; 46 47 virtual RState GetStringArrayByName(const char *name, std::vector<std::string> &outValue) = 0; 48 49 virtual RState GetPatternById(uint32_t id, std::map<std::string, std::string> &outValue) = 0; 50 51 virtual RState GetPatternByName(const char *name, std::map<std::string, std::string> &outValue) = 0; 52 53 virtual RState GetPluralStringById(uint32_t id, int quantity, std::string &outValue) = 0; 54 55 virtual RState GetPluralStringByName(const char *name, int quantity, std::string &outValue) = 0; 56 57 virtual RState GetPluralStringByIdFormat(std::string &outValue, uint32_t id, int quantity, ...) = 0; 58 59 virtual RState GetPluralStringByNameFormat(std::string &outValue, const char *name, int quantity, ...) = 0; 60 61 virtual RState GetThemeById(uint32_t id, std::map<std::string, std::string> &outValue) = 0; 62 63 virtual RState GetThemeByName(const char *name, std::map<std::string, std::string> &outValue) = 0; 64 65 virtual RState GetBooleanById(uint32_t id, bool &outValue) = 0; 66 67 virtual RState GetBooleanByName(const char *name, bool &outValue) = 0; 68 69 virtual RState GetIntegerById(uint32_t id, int &outValue) = 0; 70 71 virtual RState GetIntegerByName(const char *name, int &outValue) = 0; 72 73 virtual RState GetFloatById(uint32_t id, float &outValue) = 0; 74 75 virtual RState GetFloatByName(const char *name, float &outValue) = 0; 76 77 virtual RState GetIntArrayById(uint32_t id, std::vector<int> &outValue) = 0; 78 79 virtual RState GetIntArrayByName(const char *name, std::vector<int> &outValue) = 0; 80 81 virtual RState GetColorById(uint32_t id, uint32_t &outValue) = 0; 82 83 virtual RState GetColorByName(const char *name, uint32_t &outValue) = 0; 84 85 virtual RState GetProfileById(uint32_t id, std::string &outValue) = 0; 86 87 virtual RState GetProfileByName(const char *name, std::string &outValue) = 0; 88 89 virtual RState GetMediaById(uint32_t id, std::string &outValue) = 0; 90 91 virtual RState GetMediaByName(const char *name, std::string &outValue) = 0; 92 }; 93 94 ResourceManager *CreateResourceManager(); 95 } // namespace Resource 96 } // namespace Global 97 } // namespace OHOS 98 #endif