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 16 #ifndef OHOS_RESTOOL_REFERENCE_PARSER_H 17 #define OHOS_RESTOOL_REFERENCE_PARSER_H 18 19 #include "id_worker.h" 20 #include "resource_item.h" 21 22 namespace OHOS { 23 namespace Global { 24 namespace Restool { 25 class ReferenceParser { 26 public: 27 ReferenceParser(); 28 virtual ~ReferenceParser(); 29 uint32_t ParseRefInSolidXml(const std::vector<std::string> &solidXmlFolders) const; 30 uint32_t ParseRefInElement(std::map<int32_t, std::vector<ResourceItem>> &items) const; 31 uint32_t ParseRefInString(std::string &value, bool &update) const; 32 uint32_t ParseRefInProfile(const std::string &output) const; 33 uint32_t ParseRefInJson(const std::string &filePath) const; 34 uint32_t ParseRefInJson(const std::string &from, const std::string &to) const; 35 uint32_t ParseRefInResourceItem(ResourceItem &resourceItem) const; 36 private: 37 bool ParseRefResourceItem(ResourceItem &resourceItem) const; 38 bool ParseRefResourceItemData(const ResourceItem &resourceItem, std::string &data, bool &update) const; 39 bool IsStringOfResourceItem(ResType resType) const; 40 bool IsArrayOfResourceItem(ResType resType) const; 41 bool IsNotElement(ResType resType) const; 42 bool ParseRefString(std::string &key) const; 43 bool ParseRefString(std::string &key, bool &update) const; 44 bool ParseRefImpl(std::string &key, const std::map<std::string, ResType> &refs, bool isSystem) const; 45 bool ParseRefJsonImpl(Json::Value &root, bool &needSave) const; 46 const IdWorker &idWorker_; 47 static const std::map<std::string, ResType> ID_REFS; 48 static const std::map<std::string, ResType> ID_OHOS_REFS; 49 }; 50 } 51 } 52 } 53 #endif