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// Sample program using the geocoding functionality. This is used to test that 161767c5feSopenharmony_ci// the geocoding library is compiled correctly. 171767c5feSopenharmony_ci 181767c5feSopenharmony_ci#include <iostream> 191767c5feSopenharmony_ci#include <string> 201767c5feSopenharmony_ci 211767c5feSopenharmony_ci#include "phonenumbers/base/logging.h" 221767c5feSopenharmony_ci#include "phonenumbers/geocoding/phonenumber_offline_geocoder.h" 231767c5feSopenharmony_ci#include "phonenumbers/phonenumber.pb.h" 241767c5feSopenharmony_ci#include "phonenumbers/phonenumberutil.h" 251767c5feSopenharmony_ci 261767c5feSopenharmony_ciusing i18n::phonenumbers::PhoneNumber; 271767c5feSopenharmony_ciusing i18n::phonenumbers::PhoneNumberOfflineGeocoder; 281767c5feSopenharmony_ciusing i18n::phonenumbers::PhoneNumberUtil; 291767c5feSopenharmony_ci 301767c5feSopenharmony_ciint main() { 311767c5feSopenharmony_ci PhoneNumber number; 321767c5feSopenharmony_ci const PhoneNumberUtil& phone_util = *PhoneNumberUtil::GetInstance(); 331767c5feSopenharmony_ci const PhoneNumberUtil::ErrorType status = phone_util.Parse( 341767c5feSopenharmony_ci "16502530000", "US", &number); 351767c5feSopenharmony_ci CHECK_EQ(status, PhoneNumberUtil::NO_PARSING_ERROR); 361767c5feSopenharmony_ci IGNORE_UNUSED(status); 371767c5feSopenharmony_ci 381767c5feSopenharmony_ci const std::string description = 391767c5feSopenharmony_ci PhoneNumberOfflineGeocoder().GetDescriptionForNumber( 401767c5feSopenharmony_ci number, icu::Locale("en", "GB")); 411767c5feSopenharmony_ci std::cout << description << std::endl; 421767c5feSopenharmony_ci CHECK_EQ(description, "Mountain View, CA"); 431767c5feSopenharmony_ci return 0; 441767c5feSopenharmony_ci} 45