13920e296Sopenharmony_ci/* 23920e296Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 33920e296Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43920e296Sopenharmony_ci * you may not use this file except in compliance with the License. 53920e296Sopenharmony_ci * You may obtain a copy of the License at 63920e296Sopenharmony_ci * 73920e296Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83920e296Sopenharmony_ci * 93920e296Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103920e296Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113920e296Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123920e296Sopenharmony_ci * See the License for the specific language governing permissions and 133920e296Sopenharmony_ci * limitations under the License. 143920e296Sopenharmony_ci */ 153920e296Sopenharmony_ci 163920e296Sopenharmony_ci#ifndef OHOS_RESTOOL_REFERENCE_PARSER_H 173920e296Sopenharmony_ci#define OHOS_RESTOOL_REFERENCE_PARSER_H 183920e296Sopenharmony_ci 193920e296Sopenharmony_ci#include <cJSON.h> 203920e296Sopenharmony_ci#include "id_worker.h" 213920e296Sopenharmony_ci#include "resource_data.h" 223920e296Sopenharmony_ci#include "resource_item.h" 233920e296Sopenharmony_ci 243920e296Sopenharmony_cinamespace OHOS { 253920e296Sopenharmony_cinamespace Global { 263920e296Sopenharmony_cinamespace Restool { 273920e296Sopenharmony_ciclass ReferenceParser { 283920e296Sopenharmony_cipublic: 293920e296Sopenharmony_ci ReferenceParser(); 303920e296Sopenharmony_ci virtual ~ReferenceParser(); 313920e296Sopenharmony_ci uint32_t ParseRefInResources(std::map<int64_t, std::vector<ResourceItem>> &items, const std::string &output); 323920e296Sopenharmony_ci uint32_t ParseRefInResourceItem(ResourceItem &resourceItem) const; 333920e296Sopenharmony_ci uint32_t ParseRefInJsonFile(ResourceItem &resourceItem, const std::string &output, const bool isIncrement = false); 343920e296Sopenharmony_ci uint32_t ParseRefInString(std::string &value, bool &update) const; 353920e296Sopenharmony_ci static std::map<int64_t, std::set<int64_t>> &GetLayerIconIds(); 363920e296Sopenharmony_ciprivate: 373920e296Sopenharmony_ci bool ParseRefJson(const std::string &from, const std::string &to); 383920e296Sopenharmony_ci bool ParseRefResourceItemData(const ResourceItem &resourceItem, std::string &data, bool &update) const; 393920e296Sopenharmony_ci bool IsStringOfResourceItem(ResType resType) const; 403920e296Sopenharmony_ci bool IsArrayOfResourceItem(ResType resType) const; 413920e296Sopenharmony_ci bool IsElementRef(const ResourceItem &resourceItem) const; 423920e296Sopenharmony_ci bool IsMediaRef(const ResourceItem &resourceItem) const; 433920e296Sopenharmony_ci bool IsProfileRef(const ResourceItem &resourceItem) const; 443920e296Sopenharmony_ci bool ParseRefString(std::string &key) const; 453920e296Sopenharmony_ci bool ParseRefString(std::string &key, bool &update) const; 463920e296Sopenharmony_ci bool ParseRefImpl(std::string &key, const std::map<std::string, ResType> &refs, bool isSystem) const; 473920e296Sopenharmony_ci bool ParseRefJsonImpl(cJSON *root, bool &needSave) const; 483920e296Sopenharmony_ci const IdWorker &idWorker_; 493920e296Sopenharmony_ci static const std::map<std::string, ResType> ID_REFS; 503920e296Sopenharmony_ci static const std::map<std::string, ResType> ID_OHOS_REFS; 513920e296Sopenharmony_ci static std::map<int64_t, std::set<int64_t>> layerIconIds_; 523920e296Sopenharmony_ci cJSON *root_; 533920e296Sopenharmony_ci bool isParsingMediaJson_; 543920e296Sopenharmony_ci int64_t mediaJsonId_{ INVALID_ID }; 553920e296Sopenharmony_ci}; 563920e296Sopenharmony_ci} 573920e296Sopenharmony_ci} 583920e296Sopenharmony_ci} 593920e296Sopenharmony_ci#endif