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 #ifndef I18N_PHONENUMBERS_UPDATE_METADATA_H_ 17 #define I18N_PHONENUMBERS_UPDATE_METADATA_H_ 18 19 #include <map> 20 #include <string> 21 #include "phonenumbers/base/memory/scoped_ptr.h" 22 #include "phonenumbers/phonemetadata.pb.h" 23 24 namespace i18n { 25 namespace phonenumbers { 26 class UpdateMetadata { 27 public: 28 static void UpdateShortNumber(scoped_ptr<std::map<std::string, PhoneMetadata>>& metadataMap); 29 static void UpdatePhoneNumber(scoped_ptr<std::map<int, PhoneMetadata>>& countryMetadataMap, 30 scoped_ptr<std::map<std::string, PhoneMetadata>>& regionMetadataMap); 31 static void UpdateAlternateFormat(std::map<int, const PhoneMetadata*>& metadataMap); 32 static void LoadUpdatedMetadata(int fd); 33 34 private: 35 static const std::string METADATA_NAME; 36 static const std::string SHORT_METADATA_TYPE; 37 static const std::string PHONE_METADATA_TYPE; 38 static const std::string ALTERNATE_METADATA_TYPE; 39 static const std::string REGION_CODE_NONGEO; 40 static PhoneMetadataCollection* phoneMetadataCollection; 41 static std::map<std::string, PhoneMetadata>* shortMetadata; 42 static std::map<std::string, PhoneMetadata>* regionMetadata; 43 static std::map<int, PhoneMetadata>* countryMetadata; 44 static std::map<int, PhoneMetadata>* alterMetadata; 45 }; 46 } // namespace phonenumbers 47 } // namespace i18n 48 #endif // I18N_PHONENUMBERS_UPDATE_METADATA_H_ 49