• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef OHOS_GLOBAL_PHONE_NUMBER_RULE_H
16 #define OHOS_GLOBAL_PHONE_NUMBER_RULE_H
17 
18 #include <string>
19 #include <unicode/regex.h>
20 #include <vector>
21 #include "regex_rule.h"
22 
23 namespace OHOS {
24 namespace Global {
25 namespace I18n {
26 class PhoneNumberRule {
27 public:
28     PhoneNumberRule(std::string& country);
29     ~PhoneNumberRule();
30     void Init();
31 
32     std::vector<RegexRule*> GetBorderRules();
33     std::vector<RegexRule*> GetCodesRules();
34     std::vector<RegexRule*> GetPositiveRules();
35     std::vector<RegexRule*> GetNegativeRules();
36     std::vector<RegexRule*> GetFindRules();
37     // Indicates whether the rules of the country are optimized
38     bool isFixed;
39 
40 private:
41     void InitRule(std::string& xmlPath);
42     void FreePointer(std::vector<RegexRule*> &ruleList);
43     void SetRules(std::string& category, icu::UnicodeString& content, std::string& valid,
44         std::string& handle, std::string& insensitive, std::string& type);
45 
46     std::vector<RegexRule*> negativeRules;
47     std::vector<RegexRule*> positiveRules;
48     std::vector<RegexRule*> borderRules;
49     std::vector<RegexRule*> codesRules;
50     std::vector<RegexRule*> findRules;
51     std::string country;
52     std::string xmlPath;
53     bool commonExit;
54     static std::string xmlCommonPath;
55 };
56 } // namespace I18n
57 } // namespace Global
58 } // namespace OHOS
59 #endif