13920e296Sopenharmony_ci/*
23920e296Sopenharmony_ci * Copyright (c) 2021 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_KEY_PARSER_H
173920e296Sopenharmony_ci#define OHOS_RESTOOL_KEY_PARSER_H
183920e296Sopenharmony_ci
193920e296Sopenharmony_ci#include <vector>
203920e296Sopenharmony_ci#include "resource_data.h"
213920e296Sopenharmony_ci
223920e296Sopenharmony_cinamespace OHOS {
233920e296Sopenharmony_cinamespace Global {
243920e296Sopenharmony_cinamespace Restool {
253920e296Sopenharmony_ciclass KeyParser {
263920e296Sopenharmony_cipublic:
273920e296Sopenharmony_ci    static bool Parse(const std::string &folderName, std::vector<KeyParam> &keyparams);
283920e296Sopenharmony_ci    static bool ParseLimit(const std::string &func, std::vector<std::string> &limitValues,
293920e296Sopenharmony_ci        TargetConfig &targetConfig);
303920e296Sopenharmony_ci
313920e296Sopenharmony_ciprivate:
323920e296Sopenharmony_ci    typedef bool (*parse_key_founction)(const std::string &folderName, std::vector<KeyParam> &keyparams);
333920e296Sopenharmony_ci    static bool ParseMatch(const std::vector<std::string> &keys,
343920e296Sopenharmony_ci        std::vector<KeyParam> &keyparams, const std::vector<parse_key_founction> &founctions);
353920e296Sopenharmony_ci    static bool ParseMatchBySeq(const std::vector<std::string> &keys,
363920e296Sopenharmony_ci        std::vector<KeyParam> &keyparams, const std::vector<parse_key_founction> &founctions);
373920e296Sopenharmony_ci
383920e296Sopenharmony_ci    static bool ParseMccMnc(const std::string &folderName, std::vector<KeyParam> &keyparams);
393920e296Sopenharmony_ci    static bool ParseMcc(const std::string &folderName, std::vector<KeyParam> &keyparams);
403920e296Sopenharmony_ci    static bool ParseMnc(const std::string &folderName, std::vector<KeyParam> &keyparams);
413920e296Sopenharmony_ci    static bool ParseLSR(const std::string &folderName, std::vector<KeyParam> &keyparams);
423920e296Sopenharmony_ci    static bool ParseLanguage(const std::string &folderName, std::vector<KeyParam> &keyparams);
433920e296Sopenharmony_ci    static bool ParseScript(const std::string &folderName, std::vector<KeyParam> &keyparams);
443920e296Sopenharmony_ci    static bool ParseRegion(const std::string &folderName, std::vector<KeyParam> &keyparams);
453920e296Sopenharmony_ci    static bool ParseOrientation(const std::string &folderName, std::vector<KeyParam> &keyparams);
463920e296Sopenharmony_ci    static bool ParseDeviceType(const std::string &folderName, std::vector<KeyParam> &keyparams);
473920e296Sopenharmony_ci    static bool ParseNightMode(const std::string &folderName, std::vector<KeyParam> &keyparams);
483920e296Sopenharmony_ci    static bool ParseInputDevice(const std::string &folderName, std::vector<KeyParam> &keyparams);
493920e296Sopenharmony_ci    static bool ParseResolution(const std::string &folderName, std::vector<KeyParam> &keyparams);
503920e296Sopenharmony_ci
513920e296Sopenharmony_ci    static void PushMccMnc(const std::string &folderName, KeyType type, std::vector<KeyParam> &keyparams);
523920e296Sopenharmony_ci    static void PushLSR(const std::string &folderName, KeyType type, std::vector<KeyParam> &keyparams);
533920e296Sopenharmony_ci    static void PushValue(uint32_t value, KeyType type, std::vector<KeyParam> &keyparams);
543920e296Sopenharmony_ci    static const int32_t MCC_MNC_KEY_LENGHT = 3;
553920e296Sopenharmony_ci    static const int32_t SCRIPT_LENGHT = 4;
563920e296Sopenharmony_ci    static const int32_t MIN_REGION_LENGHT = 2;
573920e296Sopenharmony_ci    static const int32_t MAX_REGION_LENGHT = 3;
583920e296Sopenharmony_ci    static std::map<std::string, std::vector<KeyParam>> caches_;
593920e296Sopenharmony_ci};
603920e296Sopenharmony_ci}
613920e296Sopenharmony_ci}
623920e296Sopenharmony_ci}
633920e296Sopenharmony_ci#endif
64