19596a2c1Sopenharmony_ci/* 29596a2c1Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 39596a2c1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 49596a2c1Sopenharmony_ci * you may not use this file except in compliance with the License. 59596a2c1Sopenharmony_ci * You may obtain a copy of the License at 69596a2c1Sopenharmony_ci * 79596a2c1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 89596a2c1Sopenharmony_ci * 99596a2c1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 109596a2c1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 119596a2c1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 129596a2c1Sopenharmony_ci * See the License for the specific language governing permissions and 139596a2c1Sopenharmony_ci * limitations under the License. 149596a2c1Sopenharmony_ci */ 159596a2c1Sopenharmony_ci#ifndef GLOBAL_I18N_PLURAL_RULES_H 169596a2c1Sopenharmony_ci#define GLOBAL_I18N_PLURAL_RULES_H 179596a2c1Sopenharmony_ci 189596a2c1Sopenharmony_ci#include <vector> 199596a2c1Sopenharmony_ci#include <string> 209596a2c1Sopenharmony_ci#include <map> 219596a2c1Sopenharmony_ci#include <set> 229596a2c1Sopenharmony_ci 239596a2c1Sopenharmony_ci#include "locale_info.h" 249596a2c1Sopenharmony_ci#include "memory" 259596a2c1Sopenharmony_ci#include "unicode/locid.h" 269596a2c1Sopenharmony_ci#include "unicode/numberformatter.h" 279596a2c1Sopenharmony_ci#include "unicode/plurrule.h" 289596a2c1Sopenharmony_ci 299596a2c1Sopenharmony_cinamespace OHOS { 309596a2c1Sopenharmony_cinamespace Global { 319596a2c1Sopenharmony_cinamespace I18n { 329596a2c1Sopenharmony_ciclass PluralRules { 339596a2c1Sopenharmony_cipublic: 349596a2c1Sopenharmony_ci PluralRules(std::vector<std::string> &localeTags, std::map<std::string, std::string> &options); 359596a2c1Sopenharmony_ci ~PluralRules(); 369596a2c1Sopenharmony_ci std::string Select(double number); 379596a2c1Sopenharmony_ci 389596a2c1Sopenharmony_ciprivate: 399596a2c1Sopenharmony_ci std::string localeStr; 409596a2c1Sopenharmony_ci std::unique_ptr<LocaleInfo> localeInfo = nullptr; 419596a2c1Sopenharmony_ci icu::Locale locale; 429596a2c1Sopenharmony_ci icu::PluralRules *pluralRules = nullptr; 439596a2c1Sopenharmony_ci icu::number::LocalizedNumberFormatter numberFormatter; 449596a2c1Sopenharmony_ci 459596a2c1Sopenharmony_ci std::string localeMatcher; 469596a2c1Sopenharmony_ci std::string type; 479596a2c1Sopenharmony_ci int minInteger; 489596a2c1Sopenharmony_ci int minFraction; 499596a2c1Sopenharmony_ci int maxFraction; 509596a2c1Sopenharmony_ci int minSignificant; 519596a2c1Sopenharmony_ci int maxSignificant; 529596a2c1Sopenharmony_ci bool createSuccess = false; 539596a2c1Sopenharmony_ci 549596a2c1Sopenharmony_ci std::set<std::string> GetValidLocales(); 559596a2c1Sopenharmony_ci std::string ParseOption(std::map<std::string, std::string> &options, const std::string &key); 569596a2c1Sopenharmony_ci void ParseAllOptions(std::map<std::string, std::string> &options); 579596a2c1Sopenharmony_ci void InitPluralRules(std::vector<std::string> &localeTags, std::map<std::string, std::string> &options); 589596a2c1Sopenharmony_ci void InitNumberFormatter(); 599596a2c1Sopenharmony_ci int GetValidInteger(std::string &integerStr, int minValue, int maxValue, int defaultValue); 609596a2c1Sopenharmony_ci}; 619596a2c1Sopenharmony_ci} // namespace I18n 629596a2c1Sopenharmony_ci} // namespace Global 639596a2c1Sopenharmony_ci} // namespace OHOS 649596a2c1Sopenharmony_ci#endif 65