114cf0368Sopenharmony_ci/*
214cf0368Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
314cf0368Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
414cf0368Sopenharmony_ci * you may not use this file except in compliance with the License.
514cf0368Sopenharmony_ci * You may obtain a copy of the License at
614cf0368Sopenharmony_ci *
714cf0368Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
814cf0368Sopenharmony_ci *
914cf0368Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1014cf0368Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1114cf0368Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214cf0368Sopenharmony_ci * See the License for the specific language governing permissions and
1314cf0368Sopenharmony_ci * limitations under the License.
1414cf0368Sopenharmony_ci */
1514cf0368Sopenharmony_ci
1614cf0368Sopenharmony_ci#ifndef UDMF_CUSTOM_UTD_JSON_PARSER_H
1714cf0368Sopenharmony_ci#define UDMF_CUSTOM_UTD_JSON_PARSER_H
1814cf0368Sopenharmony_ci#include <string>
1914cf0368Sopenharmony_ci#include <vector>
2014cf0368Sopenharmony_ci#include <set>
2114cf0368Sopenharmony_ci#include <map>
2214cf0368Sopenharmony_ci#include <cstdint>
2314cf0368Sopenharmony_ci#include "visibility.h"
2414cf0368Sopenharmony_ci#include "cJSON.h"
2514cf0368Sopenharmony_ci#include "utd_common.h"
2614cf0368Sopenharmony_cinamespace OHOS {
2714cf0368Sopenharmony_cinamespace UDMF {
2814cf0368Sopenharmony_ciclass API_EXPORT CustomUtdJsonParser {
2914cf0368Sopenharmony_cipublic:
3014cf0368Sopenharmony_ci    using json = cJSON;
3114cf0368Sopenharmony_ci    CustomUtdJsonParser();
3214cf0368Sopenharmony_ci    ~CustomUtdJsonParser();
3314cf0368Sopenharmony_ci    bool ParseStoredCustomUtdJson(const std::string &jsonData, std::vector<TypeDescriptorCfg> &typesCfg);
3414cf0368Sopenharmony_ci    bool ParseUserCustomUtdJson(const std::string &jsonData, std::vector<TypeDescriptorCfg> &typesDeclarations,
3514cf0368Sopenharmony_ci                          std::vector<TypeDescriptorCfg> &typesReference);
3614cf0368Sopenharmony_ci    bool ConvertUtdCfgsToJson(const std::vector<TypeDescriptorCfg> &typesCfg, std::string &jsonData);
3714cf0368Sopenharmony_ci
3814cf0368Sopenharmony_ciprivate:
3914cf0368Sopenharmony_ci    bool AddJsonStringArray(const std::vector<std::string> &datas, const std::string &nodeName, json &node);
4014cf0368Sopenharmony_ci    bool GetTypeDescriptors(const json &jsonRoot, const std::string &nodeName,
4114cf0368Sopenharmony_ci                            std::vector<TypeDescriptorCfg> &typesCfg);
4214cf0368Sopenharmony_ci    std::string GetStringValue(const json &node, const std::string &nodeName);
4314cf0368Sopenharmony_ci    std::vector<std::string> GetStringArrayValue(const json &node, const std::string &nodeName);
4414cf0368Sopenharmony_ci};
4514cf0368Sopenharmony_ci} // namespace UDMF
4614cf0368Sopenharmony_ci} // namespace OHOS
4714cf0368Sopenharmony_ci#endif // UDMF_CUSTOM_UTD_JSON_PARSER_H