/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_GLOBAL_RULES_ENGINE_H #define OHOS_GLOBAL_RULES_ENGINE_H #include #include #include #include #include "date_time_rule.h" #include "matched_date_time_info.h" namespace OHOS { namespace Global { namespace I18n { struct RulesSet { public: RulesSet (std::unordered_map rulesMap, std::unordered_map subRules, std::unordered_map param, std::unordered_map paramBackup) { this->rulesMap = rulesMap; this->subRules = subRules; this->param = param; this->paramBackup = paramBackup; } std::unordered_map rulesMap; std::unordered_map subRules; std::unordered_map param; std::unordered_map paramBackup; }; class RulesEngine { public: RulesEngine(); RulesEngine(DateTimeRule* dateTimeRule, RulesSet& rulesSet); ~RulesEngine(); std::vector Match(icu::UnicodeString& message); private: void Init(); std::string InitOptRules(std::string& rule); std::string InitSubRules(std::string& rule); bool InitRules(std::string& rulesValue); DateTimeRule* dateTimeRule; std::unordered_map rulesMap; std::unordered_map subRules; std::unordered_map param; std::unordered_map paramBackup; std::unordered_map patterns; }; } // namespace I18n } // namespace Global } // namespace OHOS #endif