11767c5feSopenharmony_ci// Copyright (C) 2012 The Libphonenumber Authors 21767c5feSopenharmony_ci// 31767c5feSopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License"); 41767c5feSopenharmony_ci// you may not use this file except in compliance with the License. 51767c5feSopenharmony_ci// You may obtain a copy of the License at 61767c5feSopenharmony_ci// 71767c5feSopenharmony_ci// http://www.apache.org/licenses/LICENSE-2.0 81767c5feSopenharmony_ci// 91767c5feSopenharmony_ci// Unless required by applicable law or agreed to in writing, software 101767c5feSopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS, 111767c5feSopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121767c5feSopenharmony_ci// See the License for the specific language governing permissions and 131767c5feSopenharmony_ci// limitations under the License. 141767c5feSopenharmony_ci 151767c5feSopenharmony_ci// Author: Patrick Mezard 161767c5feSopenharmony_ci 171767c5feSopenharmony_ci#ifndef I18N_PHONENUMBERS_GEOCODING_MAPPING_FILE_PROVIDER_H_ 181767c5feSopenharmony_ci#define I18N_PHONENUMBERS_GEOCODING_MAPPING_FILE_PROVIDER_H_ 191767c5feSopenharmony_ci 201767c5feSopenharmony_ci#include <string> 211767c5feSopenharmony_ci 221767c5feSopenharmony_ci#include "phonenumbers/base/basictypes.h" 231767c5feSopenharmony_ci 241767c5feSopenharmony_cinamespace i18n { 251767c5feSopenharmony_cinamespace phonenumbers { 261767c5feSopenharmony_ci 271767c5feSopenharmony_ciusing std::string; 281767c5feSopenharmony_ci 291767c5feSopenharmony_cistruct CountryLanguages; 301767c5feSopenharmony_ci 311767c5feSopenharmony_ci// A utility which knows the data files that are available for the geocoder to 321767c5feSopenharmony_ci// use. The data files contain mappings from phone number prefixes to text 331767c5feSopenharmony_ci// descriptions, and are organized by country calling code and language that the 341767c5feSopenharmony_ci// text descriptions are in. 351767c5feSopenharmony_ciclass MappingFileProvider { 361767c5feSopenharmony_ci public: 371767c5feSopenharmony_ci typedef const CountryLanguages* (*country_languages_getter)(int index); 381767c5feSopenharmony_ci 391767c5feSopenharmony_ci // Initializes a MappingFileProvider with country_calling_codes, a sorted 401767c5feSopenharmony_ci // list of country_calling_code_size calling codes, and a function 411767c5feSopenharmony_ci // get_country_languages(int index) returning the CountryLanguage information 421767c5feSopenharmony_ci // related to the country code at index in country_calling_codes. 431767c5feSopenharmony_ci MappingFileProvider(const int* country_calling_codes, 441767c5feSopenharmony_ci int country_calling_code_size, 451767c5feSopenharmony_ci country_languages_getter get_country_languages); 461767c5feSopenharmony_ci 471767c5feSopenharmony_ci // This type is neither copyable nor movable. 481767c5feSopenharmony_ci MappingFileProvider(const MappingFileProvider&) = delete; 491767c5feSopenharmony_ci MappingFileProvider& operator=(const MappingFileProvider&) = delete; 501767c5feSopenharmony_ci 511767c5feSopenharmony_ci // Returns the name of the file that contains the mapping data for the 521767c5feSopenharmony_ci // country_calling_code in the language specified, or an empty string if no 531767c5feSopenharmony_ci // such file can be found. 541767c5feSopenharmony_ci // language is a two or three-letter lowercase language code as defined by ISO 551767c5feSopenharmony_ci // 639. Note that where two different language codes exist (e.g. 'he' and 'iw' 561767c5feSopenharmony_ci // for Hebrew) we use the one that Java/Android canonicalized on ('iw' in this 571767c5feSopenharmony_ci // case). 581767c5feSopenharmony_ci // script is a four-letter titlecase (the first letter is uppercase and the 591767c5feSopenharmony_ci // rest of the letters are lowercase) ISO script code as defined in ISO 15924. 601767c5feSopenharmony_ci // region is a two-letter uppercase ISO country code as defined by ISO 3166-1. 611767c5feSopenharmony_ci const string& GetFileName(int country_calling_code, const string& language, 621767c5feSopenharmony_ci const string& script, const string& region, string* 631767c5feSopenharmony_ci filename) const; 641767c5feSopenharmony_ci 651767c5feSopenharmony_ci private: 661767c5feSopenharmony_ci void FindBestMatchingLanguageCode(const CountryLanguages* languages, 671767c5feSopenharmony_ci const string& language, 681767c5feSopenharmony_ci const string& script, 691767c5feSopenharmony_ci const string& region, 701767c5feSopenharmony_ci string* best_match) const; 711767c5feSopenharmony_ci 721767c5feSopenharmony_ci const int* const country_calling_codes_; 731767c5feSopenharmony_ci const int country_calling_codes_size_; 741767c5feSopenharmony_ci const country_languages_getter get_country_languages_; 751767c5feSopenharmony_ci}; 761767c5feSopenharmony_ci 771767c5feSopenharmony_ci} // namespace phonenumbers 781767c5feSopenharmony_ci} // namespace i18n 791767c5feSopenharmony_ci 801767c5feSopenharmony_ci#endif // I18N_PHONENUMBERS_GEOCODING_MAPPING_FILE_PROVIDER_H_ 81