1 /* 2 * Copyright (c) 2024 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 16 #include "i18n_phone_number_format_impl.h" 17 18 namespace OHOS { 19 namespace Global { 20 namespace I18n { 21 extern "C" 22 { FfiI18nPhoneNumberFormat(std::unique_ptr<PhoneNumberFormat> phoneNumberFormat)23 FfiI18nPhoneNumberFormat::FfiI18nPhoneNumberFormat 24 (std::unique_ptr<PhoneNumberFormat> phoneNumberFormat) 25 { 26 phoneNumberFormat_ = std::move(phoneNumberFormat); 27 } 28 format(std::string number)29 char* FfiI18nPhoneNumberFormat::format(std::string number) 30 { 31 return MallocCString(phoneNumberFormat_->format(number)); 32 } 33 isValidNumber(std::string number)34 bool FfiI18nPhoneNumberFormat::isValidNumber(std::string number) 35 { 36 return phoneNumberFormat_->isValidPhoneNumber(number); 37 } 38 getLocationName(std::string number,std::string locale)39 char* FfiI18nPhoneNumberFormat::getLocationName(std::string number, std::string locale) 40 { 41 return MallocCString(phoneNumberFormat_->getLocationName(number, locale)); 42 } 43 } 44 } // namespace I18n 45 } // namespace Global 46 } // namespace OHOS