• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_I18N_PHONE_NUMBER_FORMAT_H
16 #define OHOS_GLOBAL_I18N_PHONE_NUMBER_FORMAT_H
17 
18 #include <map>
19 #include <string>
20 
21 #include "memory"
22 #include "cpp/src/phonenumbers/phonenumberutil.h"
23 
24 namespace OHOS {
25 namespace Global {
26 namespace I18n {
27 using i18n::phonenumbers::PhoneNumberUtil;
28 
29 class PhoneNumberFormat {
30 public:
31     PhoneNumberFormat(const std::string &countryTag, const std::map<std::string, std::string> &options);
32     virtual ~PhoneNumberFormat();
33     bool isValidPhoneNumber(const std::string &number) const;
34     std::string format(const std::string &number) const;
35     static std::unique_ptr<PhoneNumberFormat> CreateInstance(const std::string &countryTag,
36                                                              const std::map<std::string, std::string> &options);
37     std::string getLocationName(const std::string &number, const std::string &locale) const;
38 
39 private:
40     PhoneNumberUtil* GetPhoneNumberUtil();
41     PhoneNumberUtil *util;
42     std::string country;
43     PhoneNumberUtil::PhoneNumberFormat phoneNumberFormat;
44 };
45 } // namespace I18n
46 } // namespace Global
47 } // namespace OHOS
48 #endif
49