11767c5feSopenharmony_ci// Copyright (C) 2009 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// Utility for international phone numbers.
161767c5feSopenharmony_ci
171767c5feSopenharmony_ci#ifndef I18N_PHONENUMBERS_PHONENUMBERUTIL_H_
181767c5feSopenharmony_ci#define I18N_PHONENUMBERS_PHONENUMBERUTIL_H_
191767c5feSopenharmony_ci
201767c5feSopenharmony_ci#include <stddef.h>
211767c5feSopenharmony_ci#include <list>
221767c5feSopenharmony_ci#include <map>
231767c5feSopenharmony_ci#include <set>
241767c5feSopenharmony_ci#include <string>
251767c5feSopenharmony_ci#include <utility>
261767c5feSopenharmony_ci#include <vector>
271767c5feSopenharmony_ci
281767c5feSopenharmony_ci#include "phonenumbers/base/basictypes.h"
291767c5feSopenharmony_ci#include "phonenumbers/base/memory/scoped_ptr.h"
301767c5feSopenharmony_ci#include "phonenumbers/base/memory/singleton.h"
311767c5feSopenharmony_ci#include "phonenumbers/phonenumber.pb.h"
321767c5feSopenharmony_ci
331767c5feSopenharmony_ciclass TelephoneNumber;
341767c5feSopenharmony_ci
351767c5feSopenharmony_cinamespace i18n {
361767c5feSopenharmony_cinamespace phonenumbers {
371767c5feSopenharmony_ci
381767c5feSopenharmony_ciusing google::protobuf::RepeatedPtrField;
391767c5feSopenharmony_ciusing std::string;
401767c5feSopenharmony_ci
411767c5feSopenharmony_ciclass AsYouTypeFormatter;
421767c5feSopenharmony_ciclass Logger;
431767c5feSopenharmony_ciclass MatcherApi;
441767c5feSopenharmony_ciclass NumberFormat;
451767c5feSopenharmony_ciclass PhoneMetadata;
461767c5feSopenharmony_ciclass PhoneNumberDesc;
471767c5feSopenharmony_ciclass PhoneNumberRegExpsAndMappings;
481767c5feSopenharmony_ciclass RegExp;
491767c5feSopenharmony_ci
501767c5feSopenharmony_ci// NOTE: A lot of methods in this class require Region Code strings. These must
511767c5feSopenharmony_ci// be provided using CLDR two-letter region-code format. These should be in
521767c5feSopenharmony_ci// upper-case. The list of the codes can be found here:
531767c5feSopenharmony_ci// http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html
541767c5feSopenharmony_ci
551767c5feSopenharmony_ciclass PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
561767c5feSopenharmony_ci private:
571767c5feSopenharmony_ci  friend class AsYouTypeFormatter;
581767c5feSopenharmony_ci  friend class PhoneNumberMatcher;
591767c5feSopenharmony_ci  friend class PhoneNumberMatcherRegExps;
601767c5feSopenharmony_ci  friend class PhoneNumberMatcherTest;
611767c5feSopenharmony_ci  friend class PhoneNumberRegExpsAndMappings;
621767c5feSopenharmony_ci  friend class PhoneNumberUtilTest;
631767c5feSopenharmony_ci  friend class ShortNumberInfo;
641767c5feSopenharmony_ci  friend class ShortNumberInfoTest;
651767c5feSopenharmony_ci  friend class Singleton<PhoneNumberUtil>;
661767c5feSopenharmony_ci
671767c5feSopenharmony_ci public:
681767c5feSopenharmony_ci  // This type is neither copyable nor movable.
691767c5feSopenharmony_ci  PhoneNumberUtil(const PhoneNumberUtil&) = delete;
701767c5feSopenharmony_ci  PhoneNumberUtil& operator=(const PhoneNumberUtil&) = delete;
711767c5feSopenharmony_ci
721767c5feSopenharmony_ci  ~PhoneNumberUtil();
731767c5feSopenharmony_ci  static const char kRegionCodeForNonGeoEntity[];
741767c5feSopenharmony_ci
751767c5feSopenharmony_ci  // INTERNATIONAL and NATIONAL formats are consistent with the definition
761767c5feSopenharmony_ci  // in ITU-T Recommendation E.123. However we follow local conventions such as
771767c5feSopenharmony_ci  // using '-' instead of whitespace as separators. For example, the number of
781767c5feSopenharmony_ci  // the Google Switzerland office will be written as "+41 44 668 1800" in
791767c5feSopenharmony_ci  // INTERNATIONAL format, and as "044 668 1800" in NATIONAL format. E164
801767c5feSopenharmony_ci  // format is as per INTERNATIONAL format but with no formatting applied e.g.
811767c5feSopenharmony_ci  // "+41446681800". RFC3966 is as per INTERNATIONAL format, but with all spaces
821767c5feSopenharmony_ci  // and other separating symbols replaced with a hyphen, and with any phone
831767c5feSopenharmony_ci  // number extension appended with ";ext=". It also will have a prefix of
841767c5feSopenharmony_ci  // "tel:" added, e.g. "tel:+41-44-668-1800".
851767c5feSopenharmony_ci  enum PhoneNumberFormat {
861767c5feSopenharmony_ci    E164,
871767c5feSopenharmony_ci    INTERNATIONAL,
881767c5feSopenharmony_ci    NATIONAL,
891767c5feSopenharmony_ci    RFC3966
901767c5feSopenharmony_ci  };
911767c5feSopenharmony_ci
921767c5feSopenharmony_ci  static const PhoneNumberFormat kMaxNumberFormat = RFC3966;
931767c5feSopenharmony_ci
941767c5feSopenharmony_ci  // Type of phone numbers.
951767c5feSopenharmony_ci  enum PhoneNumberType {
961767c5feSopenharmony_ci    FIXED_LINE,
971767c5feSopenharmony_ci    MOBILE,
981767c5feSopenharmony_ci    // In some regions (e.g. the USA), it is impossible to distinguish between
991767c5feSopenharmony_ci    // fixed-line and mobile numbers by looking at the phone number itself.
1001767c5feSopenharmony_ci    FIXED_LINE_OR_MOBILE,
1011767c5feSopenharmony_ci    // Freephone lines
1021767c5feSopenharmony_ci    TOLL_FREE,
1031767c5feSopenharmony_ci    PREMIUM_RATE,
1041767c5feSopenharmony_ci    // The cost of this call is shared between the caller and the recipient, and
1051767c5feSopenharmony_ci    // is hence typically less than PREMIUM_RATE calls. See
1061767c5feSopenharmony_ci    // http://en.wikipedia.org/wiki/Shared_Cost_Service for more information.
1071767c5feSopenharmony_ci    SHARED_COST,
1081767c5feSopenharmony_ci    // Voice over IP numbers. This includes TSoIP (Telephony Service over IP).
1091767c5feSopenharmony_ci    VOIP,
1101767c5feSopenharmony_ci    // A personal number is associated with a particular person, and may be
1111767c5feSopenharmony_ci    // routed to either a MOBILE or FIXED_LINE number. Some more information can
1121767c5feSopenharmony_ci    // be found here: http://en.wikipedia.org/wiki/Personal_Numbers
1131767c5feSopenharmony_ci    PERSONAL_NUMBER,
1141767c5feSopenharmony_ci    PAGER,
1151767c5feSopenharmony_ci    // Used for "Universal Access Numbers" or "Company Numbers". They may be
1161767c5feSopenharmony_ci    // further routed to specific offices, but allow one number to be used for a
1171767c5feSopenharmony_ci    // company.
1181767c5feSopenharmony_ci    UAN,
1191767c5feSopenharmony_ci    // Used for "Voice Mail Access Numbers".
1201767c5feSopenharmony_ci    VOICEMAIL,
1211767c5feSopenharmony_ci    // A phone number is of type UNKNOWN when it does not fit any of the known
1221767c5feSopenharmony_ci    // patterns for a specific region.
1231767c5feSopenharmony_ci    UNKNOWN
1241767c5feSopenharmony_ci  };
1251767c5feSopenharmony_ci
1261767c5feSopenharmony_ci  static const PhoneNumberType kMaxNumberType = UNKNOWN;
1271767c5feSopenharmony_ci
1281767c5feSopenharmony_ci  // Types of phone number matches. See detailed description beside the
1291767c5feSopenharmony_ci  // IsNumberMatch() method.
1301767c5feSopenharmony_ci  enum MatchType {
1311767c5feSopenharmony_ci    INVALID_NUMBER,  // NOT_A_NUMBER in the java version.
1321767c5feSopenharmony_ci    NO_MATCH,
1331767c5feSopenharmony_ci    SHORT_NSN_MATCH,
1341767c5feSopenharmony_ci    NSN_MATCH,
1351767c5feSopenharmony_ci    EXACT_MATCH,
1361767c5feSopenharmony_ci  };
1371767c5feSopenharmony_ci
1381767c5feSopenharmony_ci  static const MatchType kMaxMatchType = EXACT_MATCH;
1391767c5feSopenharmony_ci
1401767c5feSopenharmony_ci  enum ErrorType {
1411767c5feSopenharmony_ci    NO_PARSING_ERROR,
1421767c5feSopenharmony_ci    INVALID_COUNTRY_CODE_ERROR,  // INVALID_COUNTRY_CODE in the java version.
1431767c5feSopenharmony_ci    NOT_A_NUMBER,
1441767c5feSopenharmony_ci    TOO_SHORT_AFTER_IDD,
1451767c5feSopenharmony_ci    TOO_SHORT_NSN,
1461767c5feSopenharmony_ci    TOO_LONG_NSN,  // TOO_LONG in the java version.
1471767c5feSopenharmony_ci  };
1481767c5feSopenharmony_ci
1491767c5feSopenharmony_ci  static const ErrorType kMaxErrorType = TOO_LONG_NSN;
1501767c5feSopenharmony_ci
1511767c5feSopenharmony_ci  // Possible outcomes when testing if a PhoneNumber is possible.
1521767c5feSopenharmony_ci  enum ValidationResult {
1531767c5feSopenharmony_ci    // The number length matches that of valid numbers for this region.
1541767c5feSopenharmony_ci    IS_POSSIBLE,
1551767c5feSopenharmony_ci    // The number length matches that of local numbers for this region only
1561767c5feSopenharmony_ci    // (i.e. numbers that may be able to be dialled within an area, but do not
1571767c5feSopenharmony_ci    // have all the information to be dialled from anywhere inside or outside
1581767c5feSopenharmony_ci    // the country).
1591767c5feSopenharmony_ci    IS_POSSIBLE_LOCAL_ONLY,
1601767c5feSopenharmony_ci    // The number has an invalid country calling code.
1611767c5feSopenharmony_ci    INVALID_COUNTRY_CODE,
1621767c5feSopenharmony_ci    // The number is shorter than all valid numbers for this region.
1631767c5feSopenharmony_ci    TOO_SHORT,
1641767c5feSopenharmony_ci    // The number is longer than the shortest valid numbers for this region,
1651767c5feSopenharmony_ci    // shorter than the longest valid numbers for this region, and does not
1661767c5feSopenharmony_ci    // itself have a number length that matches valid numbers for this region.
1671767c5feSopenharmony_ci    // This can also be returned in the case where
1681767c5feSopenharmony_ci    // IsPossibleNumberForTypeWithReason was called, and there are no numbers of
1691767c5feSopenharmony_ci    // this type at all for this region.
1701767c5feSopenharmony_ci    INVALID_LENGTH,
1711767c5feSopenharmony_ci    // The number is longer than all valid numbers for this region.
1721767c5feSopenharmony_ci    TOO_LONG,
1731767c5feSopenharmony_ci  };
1741767c5feSopenharmony_ci
1751767c5feSopenharmony_ci  static const ValidationResult kMaxValidationResult = TOO_LONG;
1761767c5feSopenharmony_ci
1771767c5feSopenharmony_ci  // Returns all regions the library has metadata for.
1781767c5feSopenharmony_ci  // @returns an unordered set of the two-letter region codes for every
1791767c5feSopenharmony_ci  // geographical region the library supports
1801767c5feSopenharmony_ci  void GetSupportedRegions(
1811767c5feSopenharmony_ci      std::set<string>* regions) const;
1821767c5feSopenharmony_ci
1831767c5feSopenharmony_ci  // Returns all global network calling codes the library has metadata for.
1841767c5feSopenharmony_ci  // @returns an unordered set of the country calling codes for every
1851767c5feSopenharmony_ci  // non-geographical entity the library supports
1861767c5feSopenharmony_ci  void GetSupportedGlobalNetworkCallingCodes(
1871767c5feSopenharmony_ci      std::set<int>* calling_codes) const;
1881767c5feSopenharmony_ci
1891767c5feSopenharmony_ci  // Returns all country calling codes the library has metadata for, covering
1901767c5feSopenharmony_ci  // both non-geographical entities (global network calling codes) and those
1911767c5feSopenharmony_ci  // used for geographical entities. This could be used to populate a drop-down
1921767c5feSopenharmony_ci  // box of country calling codes for a phone-number widget, for instance.
1931767c5feSopenharmony_ci  void GetSupportedCallingCodes(std::set<int>* calling_codes) const;
1941767c5feSopenharmony_ci
1951767c5feSopenharmony_ci  // Returns the types for a given region which the library has metadata for.
1961767c5feSopenharmony_ci  // Will not include FIXED_LINE_OR_MOBILE (if numbers for this non-geographical
1971767c5feSopenharmony_ci  // entity could be classified as FIXED_LINE_OR_MOBILE, both FIXED_LINE and
1981767c5feSopenharmony_ci  // MOBILE would be present) and UNKNOWN.
1991767c5feSopenharmony_ci  //
2001767c5feSopenharmony_ci  // No types will be returned for invalid or unknown region codes.
2011767c5feSopenharmony_ci  void GetSupportedTypesForRegion(
2021767c5feSopenharmony_ci      const string& region_code,
2031767c5feSopenharmony_ci      std::set<PhoneNumberType>* types) const;
2041767c5feSopenharmony_ci
2051767c5feSopenharmony_ci  // Returns the types for a country-code belonging to a non-geographical entity
2061767c5feSopenharmony_ci  // which the library has metadata for. Will not include FIXED_LINE_OR_MOBILE
2071767c5feSopenharmony_ci  // (instead both FIXED_LINE and FIXED_LINE_OR_MOBILE (if numbers for this
2081767c5feSopenharmony_ci  // non-geographical entity could be classified as FIXED_LINE_OR_MOBILE, both
2091767c5feSopenharmony_ci  // FIXED_LINE and MOBILE would be present) and UNKNOWN.
2101767c5feSopenharmony_ci  //
2111767c5feSopenharmony_ci  // No types will be returned for country calling codes that do not map to a
2121767c5feSopenharmony_ci  // known non-geographical entity.
2131767c5feSopenharmony_ci  void GetSupportedTypesForNonGeoEntity(
2141767c5feSopenharmony_ci      int country_calling_code,
2151767c5feSopenharmony_ci      std::set<PhoneNumberType>* types) const;
2161767c5feSopenharmony_ci
2171767c5feSopenharmony_ci  // Gets a PhoneNumberUtil instance to carry out international phone number
2181767c5feSopenharmony_ci  // formatting, parsing, or validation. The instance is loaded with phone
2191767c5feSopenharmony_ci  // number metadata for a number of most commonly used regions, as specified by
2201767c5feSopenharmony_ci  // DEFAULT_REGIONS_.
2211767c5feSopenharmony_ci  //
2221767c5feSopenharmony_ci  // The PhoneNumberUtil is implemented as a singleton. Therefore, calling
2231767c5feSopenharmony_ci  // GetInstance multiple times will only result in one instance being created.
2241767c5feSopenharmony_ci  static PhoneNumberUtil* GetInstance();
2251767c5feSopenharmony_ci
2261767c5feSopenharmony_ci  // Returns true if the number is a valid vanity (alpha) number such as 800
2271767c5feSopenharmony_ci  // MICROSOFT. A valid vanity number will start with at least 3 digits and will
2281767c5feSopenharmony_ci  // have three or more alpha characters. This does not do region-specific
2291767c5feSopenharmony_ci  // checks - to work out if this number is actually valid for a region, it
2301767c5feSopenharmony_ci  // should be parsed and methods such as IsPossibleNumberWithReason or
2311767c5feSopenharmony_ci  // IsValidNumber should be used.
2321767c5feSopenharmony_ci  bool IsAlphaNumber(const string& number) const;
2331767c5feSopenharmony_ci
2341767c5feSopenharmony_ci  // Converts all alpha characters in a number to their respective digits on
2351767c5feSopenharmony_ci  // a keypad, but retains existing formatting.
2361767c5feSopenharmony_ci  void ConvertAlphaCharactersInNumber(string* number) const;
2371767c5feSopenharmony_ci
2381767c5feSopenharmony_ci  // Normalizes a string of characters representing a phone number. This
2391767c5feSopenharmony_ci  // converts wide-ascii and arabic-indic numerals to European numerals, and
2401767c5feSopenharmony_ci  // strips punctuation and alpha characters.
2411767c5feSopenharmony_ci  void NormalizeDigitsOnly(string* number) const;
2421767c5feSopenharmony_ci
2431767c5feSopenharmony_ci  // Normalizes a string of characters representing a phone number. This strips
2441767c5feSopenharmony_ci  // all characters which are not diallable on a mobile phone keypad (including
2451767c5feSopenharmony_ci  // all non-ASCII digits).
2461767c5feSopenharmony_ci  void NormalizeDiallableCharsOnly(string* number) const;
2471767c5feSopenharmony_ci
2481767c5feSopenharmony_ci  // Gets the national significant number of a phone number. Note a national
2491767c5feSopenharmony_ci  // significant number doesn't contain a national prefix or any formatting.
2501767c5feSopenharmony_ci  void GetNationalSignificantNumber(const PhoneNumber& number,
2511767c5feSopenharmony_ci                                    string* national_significant_num) const;
2521767c5feSopenharmony_ci
2531767c5feSopenharmony_ci  // Gets the length of the geographical area code from the PhoneNumber object
2541767c5feSopenharmony_ci  // passed in, so that clients could use it to split a national significant
2551767c5feSopenharmony_ci  // number into geographical area code and subscriber number. It works in such
2561767c5feSopenharmony_ci  // a way that the resultant subscriber number should be diallable, at least on
2571767c5feSopenharmony_ci  // some devices. An example of how this could be used:
2581767c5feSopenharmony_ci  //
2591767c5feSopenharmony_ci  // const PhoneNumberUtil& phone_util(*PhoneNumberUtil::GetInstance());
2601767c5feSopenharmony_ci  // PhoneNumber number;
2611767c5feSopenharmony_ci  // phone_util.Parse("16502530000", "US", &number);
2621767c5feSopenharmony_ci  // string national_significant_number;
2631767c5feSopenharmony_ci  // phone_util.GetNationalSignificantNumber(number,
2641767c5feSopenharmony_ci  //                                         &national_significant_number);
2651767c5feSopenharmony_ci  // string area_code;
2661767c5feSopenharmony_ci  // string subscriber_number;
2671767c5feSopenharmony_ci  //
2681767c5feSopenharmony_ci  // int area_code_length = phone_util.GetLengthOfGeographicalAreaCode(number);
2691767c5feSopenharmony_ci  // if (area_code_length > 0) {
2701767c5feSopenharmony_ci  //   area_code = national_significant_number.substr(0, area_code_length);
2711767c5feSopenharmony_ci  //   subscriber_number = national_significant_number.substr(
2721767c5feSopenharmony_ci  //       area_code_length, string::npos);
2731767c5feSopenharmony_ci  // } else {
2741767c5feSopenharmony_ci  //   area_code = "";
2751767c5feSopenharmony_ci  //   subscriber_number = national_significant_number;
2761767c5feSopenharmony_ci  // }
2771767c5feSopenharmony_ci  //
2781767c5feSopenharmony_ci  // N.B.: area code is a very ambiguous concept, so the authors generally
2791767c5feSopenharmony_ci  // recommend against using it for most purposes, but recommend using the
2801767c5feSopenharmony_ci  // more general national_number instead. Read the following carefully before
2811767c5feSopenharmony_ci  // deciding to use this method:
2821767c5feSopenharmony_ci  //
2831767c5feSopenharmony_ci  //  - geographical area codes change over time, and this method honors those
2841767c5feSopenharmony_ci  //    changes; therefore, it doesn't guarantee the stability of the result it
2851767c5feSopenharmony_ci  //    produces.
2861767c5feSopenharmony_ci  //  - subscriber numbers may not be diallable from all devices (notably mobile
2871767c5feSopenharmony_ci  //    devices, which typically requires the full national_number to be dialled
2881767c5feSopenharmony_ci  //    in most regions).
2891767c5feSopenharmony_ci  //  - most non-geographical numbers have no area codes, including numbers
2901767c5feSopenharmony_ci  //    from non-geographical entities.
2911767c5feSopenharmony_ci  //  - some geographical numbers have no area codes.
2921767c5feSopenharmony_ci  int GetLengthOfGeographicalAreaCode(const PhoneNumber& number) const;
2931767c5feSopenharmony_ci
2941767c5feSopenharmony_ci  // Gets the length of the national destination code (NDC) from the PhoneNumber
2951767c5feSopenharmony_ci  // object passed in, so that clients could use it to split a national
2961767c5feSopenharmony_ci  // significant number into NDC and subscriber number. The NDC of a phone
2971767c5feSopenharmony_ci  // number is normally the first group of digit(s) right after the country
2981767c5feSopenharmony_ci  // calling code when the number is formatted in the international format, if
2991767c5feSopenharmony_ci  // there is a subscriber number part that follows.
3001767c5feSopenharmony_ci  //
3011767c5feSopenharmony_ci  // N.B.: similar to an area code, not all numbers have an NDC!
3021767c5feSopenharmony_ci  //
3031767c5feSopenharmony_ci  // An example of how this could be used:
3041767c5feSopenharmony_ci  //
3051767c5feSopenharmony_ci  // const PhoneNumberUtil& phone_util(*PhoneNumberUtil::GetInstance());
3061767c5feSopenharmony_ci  // PhoneNumber number;
3071767c5feSopenharmony_ci  // phone_util.Parse("16502530000", "US", &number);
3081767c5feSopenharmony_ci  // string national_significant_number;
3091767c5feSopenharmony_ci  // phone_util.GetNationalSignificantNumber(number,
3101767c5feSopenharmony_ci  //                                         &national_significant_number);
3111767c5feSopenharmony_ci  // string national_destination_code;
3121767c5feSopenharmony_ci  // string subscriber_number;
3131767c5feSopenharmony_ci  //
3141767c5feSopenharmony_ci  // int national_destination_code_length =
3151767c5feSopenharmony_ci  //     phone_util.GetLengthOfNationalDestinationCode(number);
3161767c5feSopenharmony_ci  // if (national_destination_code_length > 0) {
3171767c5feSopenharmony_ci  //   national_destination_code = national_significant_number.substr(
3181767c5feSopenharmony_ci  //       0, national_destination_code_length);
3191767c5feSopenharmony_ci  //   subscriber_number = national_significant_number.substr(
3201767c5feSopenharmony_ci  //       national_destination_code_length, string::npos);
3211767c5feSopenharmony_ci  // } else {
3221767c5feSopenharmony_ci  //   national_destination_code = "";
3231767c5feSopenharmony_ci  //   subscriber_number = national_significant_number;
3241767c5feSopenharmony_ci  // }
3251767c5feSopenharmony_ci  //
3261767c5feSopenharmony_ci  // Refer to the unittests to see the difference between this function and
3271767c5feSopenharmony_ci  // GetLengthOfGeographicalAreaCode().
3281767c5feSopenharmony_ci  int GetLengthOfNationalDestinationCode(const PhoneNumber& number) const;
3291767c5feSopenharmony_ci
3301767c5feSopenharmony_ci  // Returns the mobile token for the provided country calling code if it has
3311767c5feSopenharmony_ci  // one, otherwise returns an empty string. A mobile token is a number inserted
3321767c5feSopenharmony_ci  // before the area code when dialing a mobile number from that country from
3331767c5feSopenharmony_ci  // abroad.
3341767c5feSopenharmony_ci  void GetCountryMobileToken(int country_calling_code,
3351767c5feSopenharmony_ci                             string* mobile_token) const;
3361767c5feSopenharmony_ci
3371767c5feSopenharmony_ci  // Formats a phone number in the specified format using default rules. Note
3381767c5feSopenharmony_ci  // that this does not promise to produce a phone number that the user can
3391767c5feSopenharmony_ci  // dial from where they are - although we do format in either NATIONAL or
3401767c5feSopenharmony_ci  // INTERNATIONAL format depending on what the client asks for, we do not
3411767c5feSopenharmony_ci  // currently support a more abbreviated format, such as for users in the
3421767c5feSopenharmony_ci  // same area who could potentially dial the number without area code.
3431767c5feSopenharmony_ci  void Format(const PhoneNumber& number,
3441767c5feSopenharmony_ci              PhoneNumberFormat number_format,
3451767c5feSopenharmony_ci              string* formatted_number) const;
3461767c5feSopenharmony_ci
3471767c5feSopenharmony_ci  // Formats a phone number in the specified format using client-defined
3481767c5feSopenharmony_ci  // formatting rules.
3491767c5feSopenharmony_ci  void FormatByPattern(
3501767c5feSopenharmony_ci      const PhoneNumber& number,
3511767c5feSopenharmony_ci      PhoneNumberFormat number_format,
3521767c5feSopenharmony_ci      const RepeatedPtrField<NumberFormat>& user_defined_formats,
3531767c5feSopenharmony_ci      string* formatted_number) const;
3541767c5feSopenharmony_ci
3551767c5feSopenharmony_ci  // Formats a phone number in national format for dialing using the carrier as
3561767c5feSopenharmony_ci  // specified in the carrier_code. The carrier_code will always be used
3571767c5feSopenharmony_ci  // regardless of whether the phone number already has a preferred domestic
3581767c5feSopenharmony_ci  // carrier code stored. If carrier_code contains an empty string, return the
3591767c5feSopenharmony_ci  // number in national format without any carrier code.
3601767c5feSopenharmony_ci  void FormatNationalNumberWithCarrierCode(const PhoneNumber& number,
3611767c5feSopenharmony_ci                                           const string& carrier_code,
3621767c5feSopenharmony_ci                                           string* formatted_number) const;
3631767c5feSopenharmony_ci
3641767c5feSopenharmony_ci  // Formats a phone number in national format for dialing using the carrier as
3651767c5feSopenharmony_ci  // specified in the preferred_domestic_carrier_code field of the PhoneNumber
3661767c5feSopenharmony_ci  // object passed in. If that is missing, use the fallback_carrier_code passed
3671767c5feSopenharmony_ci  // in instead. If there is no preferred_domestic_carrier_code, and the
3681767c5feSopenharmony_ci  // fallback_carrier_code contains an empty string, return the number in
3691767c5feSopenharmony_ci  // national format without any carrier code.
3701767c5feSopenharmony_ci  //
3711767c5feSopenharmony_ci  // Use FormatNationalNumberWithCarrierCode instead if the carrier code passed
3721767c5feSopenharmony_ci  // in should take precedence over the number's preferred_domestic_carrier_code
3731767c5feSopenharmony_ci  // when formatting.
3741767c5feSopenharmony_ci  void FormatNationalNumberWithPreferredCarrierCode(
3751767c5feSopenharmony_ci      const PhoneNumber& number,
3761767c5feSopenharmony_ci      const string& fallback_carrier_code,
3771767c5feSopenharmony_ci      string* formatted_number) const;
3781767c5feSopenharmony_ci
3791767c5feSopenharmony_ci  // Returns a number formatted in such a way that it can be dialed from a
3801767c5feSopenharmony_ci  // mobile phone in a specific region. If the number cannot be reached from
3811767c5feSopenharmony_ci  // the region (e.g. some countries block toll-free numbers from being called
3821767c5feSopenharmony_ci  // outside of the country), the method returns an empty string.
3831767c5feSopenharmony_ci  void FormatNumberForMobileDialing(
3841767c5feSopenharmony_ci      const PhoneNumber& number,
3851767c5feSopenharmony_ci      const string& region_calling_from,
3861767c5feSopenharmony_ci      bool with_formatting,
3871767c5feSopenharmony_ci      string* formatted_number) const;
3881767c5feSopenharmony_ci
3891767c5feSopenharmony_ci  // Formats a phone number for out-of-country dialing purposes.
3901767c5feSopenharmony_ci  //
3911767c5feSopenharmony_ci  // Note this function takes care of the case for calling inside of NANPA
3921767c5feSopenharmony_ci  // and between Russia and Kazakhstan (who share the same country calling
3931767c5feSopenharmony_ci  // code). In those cases, no international prefix is used. For regions which
3941767c5feSopenharmony_ci  // have multiple international prefixes, the number in its INTERNATIONAL
3951767c5feSopenharmony_ci  // format will be returned instead.
3961767c5feSopenharmony_ci  void FormatOutOfCountryCallingNumber(
3971767c5feSopenharmony_ci      const PhoneNumber& number,
3981767c5feSopenharmony_ci      const string& calling_from,
3991767c5feSopenharmony_ci      string* formatted_number) const;
4001767c5feSopenharmony_ci
4011767c5feSopenharmony_ci  // Formats a phone number using the original phone number format (e.g.
4021767c5feSopenharmony_ci  // INTERNATIONAL or NATIONAL) that the number is parsed from, provided that
4031767c5feSopenharmony_ci  // the number has been parsed with ParseAndKeepRawInput. Otherwise the number
4041767c5feSopenharmony_ci  // will be formatted in NATIONAL format. The original format is embedded in
4051767c5feSopenharmony_ci  // the country_code_source field of the PhoneNumber object passed in, which is
4061767c5feSopenharmony_ci  // only set when parsing keeps the raw input. When we don't have a formatting
4071767c5feSopenharmony_ci  // pattern for the number, the method falls back to returning the raw input.
4081767c5feSopenharmony_ci  // When the number is an invalid number, the method returns the raw input when
4091767c5feSopenharmony_ci  // it is available.
4101767c5feSopenharmony_ci  void FormatInOriginalFormat(const PhoneNumber& number,
4111767c5feSopenharmony_ci                              const string& region_calling_from,
4121767c5feSopenharmony_ci                              string* formatted_number) const;
4131767c5feSopenharmony_ci
4141767c5feSopenharmony_ci  // Formats a phone number for out-of-country dialing purposes.
4151767c5feSopenharmony_ci  //
4161767c5feSopenharmony_ci  // Note that in this version, if the number was entered originally using alpha
4171767c5feSopenharmony_ci  // characters and this version of the number is stored in raw_input, this
4181767c5feSopenharmony_ci  // representation of the number will be used rather than the digit
4191767c5feSopenharmony_ci  // representation. Grouping information, as specified by characters such as
4201767c5feSopenharmony_ci  // "-" and " ", will be retained.
4211767c5feSopenharmony_ci  //
4221767c5feSopenharmony_ci  // Caveats:
4231767c5feSopenharmony_ci  // 1) This will not produce good results if the country calling code is both
4241767c5feSopenharmony_ci  // present in the raw input _and_ is the start of the national number. This
4251767c5feSopenharmony_ci  // is not a problem in the regions which typically use alpha numbers.
4261767c5feSopenharmony_ci  // 2) This will also not produce good results if the raw input has any
4271767c5feSopenharmony_ci  // grouping information within the first three digits of the national number,
4281767c5feSopenharmony_ci  // and if the function needs to strip preceding digits/words in the raw input
4291767c5feSopenharmony_ci  // before these digits. Normally people group the first three digits together
4301767c5feSopenharmony_ci  // so this is not a huge problem - and will be fixed if it proves to be so.
4311767c5feSopenharmony_ci  void FormatOutOfCountryKeepingAlphaChars(
4321767c5feSopenharmony_ci      const PhoneNumber& number,
4331767c5feSopenharmony_ci      const string& calling_from,
4341767c5feSopenharmony_ci      string* formatted_number) const;
4351767c5feSopenharmony_ci
4361767c5feSopenharmony_ci  // Attempts to extract a valid number from a phone number that is too long to
4371767c5feSopenharmony_ci  // be valid, and resets the PhoneNumber object passed in to that valid
4381767c5feSopenharmony_ci  // version. If no valid number could be extracted, the PhoneNumber object
4391767c5feSopenharmony_ci  // passed in will not be modified. It returns true if a valid phone number can
4401767c5feSopenharmony_ci  // be successfully extracted.
4411767c5feSopenharmony_ci  bool TruncateTooLongNumber(PhoneNumber* number) const;
4421767c5feSopenharmony_ci
4431767c5feSopenharmony_ci  // Gets the type of a valid phone number, or UNKNOWN if it is invalid.
4441767c5feSopenharmony_ci  PhoneNumberType GetNumberType(const PhoneNumber& number) const;
4451767c5feSopenharmony_ci
4461767c5feSopenharmony_ci  // Tests whether a phone number matches a valid pattern. Note this doesn't
4471767c5feSopenharmony_ci  // verify the number is actually in use, which is impossible to tell by just
4481767c5feSopenharmony_ci  // looking at a number itself.
4491767c5feSopenharmony_ci  // It only verifies whether the parsed, canonicalised number is valid: not
4501767c5feSopenharmony_ci  // whether a particular series of digits entered by the user is diallable from
4511767c5feSopenharmony_ci  // the region provided when parsing. For example, the number +41 (0) 78 927
4521767c5feSopenharmony_ci  // 2696 can be parsed into a number with country code "41" and national
4531767c5feSopenharmony_ci  // significant number "789272696". This is valid, while the original string
4541767c5feSopenharmony_ci  // is not diallable.
4551767c5feSopenharmony_ci  bool IsValidNumber(const PhoneNumber& number) const;
4561767c5feSopenharmony_ci
4571767c5feSopenharmony_ci  // Tests whether a phone number is valid for a certain region. Note this
4581767c5feSopenharmony_ci  // doesn't verify the number is actually in use, which is impossible to tell
4591767c5feSopenharmony_ci  // by just looking at a number itself. If the country calling code is not the
4601767c5feSopenharmony_ci  // same as the country calling code for the region, this immediately exits
4611767c5feSopenharmony_ci  // with false. After this, the specific number pattern rules for the region
4621767c5feSopenharmony_ci  // are examined.
4631767c5feSopenharmony_ci  // This is useful for determining for example whether a particular number is
4641767c5feSopenharmony_ci  // valid for Canada, rather than just a valid NANPA number.
4651767c5feSopenharmony_ci  // Warning: In most cases, you want to use IsValidNumber instead. For
4661767c5feSopenharmony_ci  // example, this method will mark numbers from British Crown dependencies
4671767c5feSopenharmony_ci  // such as the Isle of Man as invalid for the region "GB" (United Kingdom),
4681767c5feSopenharmony_ci  // since it has its own region code, "IM", which may be undesirable.
4691767c5feSopenharmony_ci  bool IsValidNumberForRegion(
4701767c5feSopenharmony_ci      const PhoneNumber& number,
4711767c5feSopenharmony_ci      const string& region_code) const;
4721767c5feSopenharmony_ci
4731767c5feSopenharmony_ci  // Returns the region where a phone number is from. This could be used for
4741767c5feSopenharmony_ci  // geocoding at the region level. Only guarantees correct results for valid,
4751767c5feSopenharmony_ci  // full numbers (not short-codes, or invalid numbers).
4761767c5feSopenharmony_ci  void GetRegionCodeForNumber(const PhoneNumber& number,
4771767c5feSopenharmony_ci                              string* region_code) const;
4781767c5feSopenharmony_ci
4791767c5feSopenharmony_ci  // Returns the country calling code for a specific region. For example,
4801767c5feSopenharmony_ci  // this would be 1 for the United States, and 64 for New Zealand.
4811767c5feSopenharmony_ci  int GetCountryCodeForRegion(const string& region_code) const;
4821767c5feSopenharmony_ci
4831767c5feSopenharmony_ci  // Returns the region code that matches the specific country code. Note that
4841767c5feSopenharmony_ci  // it is possible that several regions share the same country calling code
4851767c5feSopenharmony_ci  // (e.g. US and Canada), and in that case, only one of the regions (normally
4861767c5feSopenharmony_ci  // the one with the largest population) is returned. If the
4871767c5feSopenharmony_ci  // countryCallingCode entered is valid but doesn't match a specific region
4881767c5feSopenharmony_ci  // (such as in the case of non-geographical calling codes like 800) the
4891767c5feSopenharmony_ci  // RegionCode 001 will be returned (corresponding to the value for World in
4901767c5feSopenharmony_ci  // the UN M.49 schema).
4911767c5feSopenharmony_ci  void GetRegionCodeForCountryCode(int country_code, string* region_code) const;
4921767c5feSopenharmony_ci
4931767c5feSopenharmony_ci  // Populates a list with the region codes that match the specific country
4941767c5feSopenharmony_ci  // calling code. For non-geographical country calling codes, the region code
4951767c5feSopenharmony_ci  // 001 is returned. Also, in the case of no region code being found, the list
4961767c5feSopenharmony_ci  // is left unchanged.
4971767c5feSopenharmony_ci  void GetRegionCodesForCountryCallingCode(
4981767c5feSopenharmony_ci      int country_calling_code,
4991767c5feSopenharmony_ci      std::list<string>* region_codes) const;
5001767c5feSopenharmony_ci
5011767c5feSopenharmony_ci  // Checks if this is a region under the North American Numbering Plan
5021767c5feSopenharmony_ci  // Administration (NANPA).
5031767c5feSopenharmony_ci  bool IsNANPACountry(const string& region_code) const;
5041767c5feSopenharmony_ci
5051767c5feSopenharmony_ci  // Returns the national dialling prefix for a specific region. For example,
5061767c5feSopenharmony_ci  // this would be 1 for the United States, and 0 for New Zealand. Set
5071767c5feSopenharmony_ci  // strip_non_digits to true to strip symbols like "~" (which indicates a wait
5081767c5feSopenharmony_ci  // for a dialling tone) from the prefix returned. If no national prefix is
5091767c5feSopenharmony_ci  // present, we return an empty string.
5101767c5feSopenharmony_ci  void GetNddPrefixForRegion(const string& region_code,
5111767c5feSopenharmony_ci                             bool strip_non_digits,
5121767c5feSopenharmony_ci                             string* national_prefix) const;
5131767c5feSopenharmony_ci
5141767c5feSopenharmony_ci  // Checks whether a phone number is a possible number. It provides a more
5151767c5feSopenharmony_ci  // lenient check than IsValidNumber() in the following sense:
5161767c5feSopenharmony_ci  //   1. It only checks the length of phone numbers. In particular, it doesn't
5171767c5feSopenharmony_ci  //      check starting digits of the number.
5181767c5feSopenharmony_ci  //   2. It doesn't attempt to figure out the type of the number, but uses
5191767c5feSopenharmony_ci  //      general rules which applies to all types of phone numbers in a
5201767c5feSopenharmony_ci  //      region. Therefore, it is much faster than IsValidNumber().
5211767c5feSopenharmony_ci  //   3. For some numbers (particularly fixed-line), many regions have the
5221767c5feSopenharmony_ci  //      concept of area code, which together with subscriber number constitute
5231767c5feSopenharmony_ci  //      the national significant number. It is sometimes okay to dial only the
5241767c5feSopenharmony_ci  //      subscriber number when dialing in the same area. This function will
5251767c5feSopenharmony_ci  //      return IS_POSSIBLE_LOCAL_ONLY if the subscriber-number-only version is
5261767c5feSopenharmony_ci  //      passed in. On the other hand, because IsValidNumber() validates using
5271767c5feSopenharmony_ci  //      information on both starting digits (for fixed line numbers, that
5281767c5feSopenharmony_ci  //      would most likely be area codes) and length (obviously includes the
5291767c5feSopenharmony_ci  //      length of area codes for fixed line numbers), it will return false for
5301767c5feSopenharmony_ci  //      the subscriber-number-only version.
5311767c5feSopenharmony_ci  ValidationResult IsPossibleNumberWithReason(const PhoneNumber& number) const;
5321767c5feSopenharmony_ci
5331767c5feSopenharmony_ci  // Convenience wrapper around IsPossibleNumberWithReason(). Instead of
5341767c5feSopenharmony_ci  // returning the reason for failure, this method returns true if the number is
5351767c5feSopenharmony_ci  // either a possible fully-qualified number (containing the area code and
5361767c5feSopenharmony_ci  // country code), or if the number could be a possible local number (with a
5371767c5feSopenharmony_ci  // country code, but missing an area code). Local numbers are considered
5381767c5feSopenharmony_ci  // possible if they could be possibly dialled in this format: if the area code
5391767c5feSopenharmony_ci  // is needed for a call to connect, the number is not considered possible
5401767c5feSopenharmony_ci  // without it.
5411767c5feSopenharmony_ci  bool IsPossibleNumber(const PhoneNumber& number) const;
5421767c5feSopenharmony_ci
5431767c5feSopenharmony_ci  // Check whether a phone number is a possible number of a particular type. For
5441767c5feSopenharmony_ci  // types that don't exist in a particular region, this will return a result
5451767c5feSopenharmony_ci  // that isn't so useful; it is recommended that you use
5461767c5feSopenharmony_ci  // GetSupportedTypesForRegion() or GetSupportedTypesForNonGeoEntity()
5471767c5feSopenharmony_ci  // respectively before calling this method to determine whether you should
5481767c5feSopenharmony_ci  // call it for this number at all.
5491767c5feSopenharmony_ci  //
5501767c5feSopenharmony_ci  // This provides a more lenient check than IsValidNumber() in the following
5511767c5feSopenharmony_ci  // sense:
5521767c5feSopenharmony_ci  //
5531767c5feSopenharmony_ci  //   1. It only checks the length of phone numbers. In particular, it doesn't
5541767c5feSopenharmony_ci  //      check starting digits of the number.
5551767c5feSopenharmony_ci  //   2. For some numbers (particularly fixed-line), many regions have the
5561767c5feSopenharmony_ci  //      concept of area code, which together with subscriber number constitute
5571767c5feSopenharmony_ci  //      the national significant number. It is sometimes okay to dial only the
5581767c5feSopenharmony_ci  //      subscriber number when dialing in the same area. This function will
5591767c5feSopenharmony_ci  //      return IS_POSSIBLE_LOCAL_ONLY if the subscriber-number-only version is
5601767c5feSopenharmony_ci  //      passed in. On the other hand, because IsValidNumber() validates using
5611767c5feSopenharmony_ci  //      information on both starting digits (for fixed line numbers, that
5621767c5feSopenharmony_ci  //      would most likely be area codes) and length (obviously includes the
5631767c5feSopenharmony_ci  //      length of area codes for fixed line numbers), it will return false for
5641767c5feSopenharmony_ci  //      the subscriber-number-only version.
5651767c5feSopenharmony_ci  ValidationResult IsPossibleNumberForTypeWithReason(
5661767c5feSopenharmony_ci      const PhoneNumber& number, PhoneNumberType type) const;
5671767c5feSopenharmony_ci
5681767c5feSopenharmony_ci  // Convenience wrapper around IsPossibleNumberForTypeWithReason(). Instead of
5691767c5feSopenharmony_ci  // returning the reason for failure, this method returns true if the number is
5701767c5feSopenharmony_ci  // either a possible fully-qualified number (containing the area code and
5711767c5feSopenharmony_ci  // country code), or if the number could be a possible local number (with a
5721767c5feSopenharmony_ci  // country code, but missing an area code). Local numbers are considered
5731767c5feSopenharmony_ci  // possible if they could be possibly dialled in this format: if the area code
5741767c5feSopenharmony_ci  // is needed for a call to connect, the number is not considered possible
5751767c5feSopenharmony_ci  // without it.
5761767c5feSopenharmony_ci  bool IsPossibleNumberForType(const PhoneNumber& number,
5771767c5feSopenharmony_ci                               PhoneNumberType type) const;
5781767c5feSopenharmony_ci
5791767c5feSopenharmony_ci  // Checks whether a phone number is a possible number given a number in the
5801767c5feSopenharmony_ci  // form of a string, and the country where the number could be dialed from.
5811767c5feSopenharmony_ci  // It provides a more lenient check than IsValidNumber(). See
5821767c5feSopenharmony_ci  // IsPossibleNumber(const PhoneNumber& number) for details.
5831767c5feSopenharmony_ci  //
5841767c5feSopenharmony_ci  // This method first parses the number, then invokes
5851767c5feSopenharmony_ci  // IsPossibleNumber(const PhoneNumber& number) with the resultant PhoneNumber
5861767c5feSopenharmony_ci  // object.
5871767c5feSopenharmony_ci  //
5881767c5feSopenharmony_ci  // region_dialing_from represents the region that we are expecting the number
5891767c5feSopenharmony_ci  // to be dialed from. Note this is different from the region where the number
5901767c5feSopenharmony_ci  // belongs. For example, the number +1 650 253 0000 is a number that belongs
5911767c5feSopenharmony_ci  // to US. When written in this form, it could be dialed from any region. When
5921767c5feSopenharmony_ci  // it is written as 00 1 650 253 0000, it could be dialed from any region
5931767c5feSopenharmony_ci  // which uses an international dialling prefix of 00. When it is written as
5941767c5feSopenharmony_ci  // 650 253 0000, it could only be dialed from within the US, and when written
5951767c5feSopenharmony_ci  // as 253 0000, it could only be dialed from within a smaller area in the US
5961767c5feSopenharmony_ci  // (Mountain View, CA, to be more specific).
5971767c5feSopenharmony_ci  bool IsPossibleNumberForString(
5981767c5feSopenharmony_ci      const string& number,
5991767c5feSopenharmony_ci      const string& region_dialing_from) const;
6001767c5feSopenharmony_ci
6011767c5feSopenharmony_ci  // Returns true if the number can be dialled from outside the region, or
6021767c5feSopenharmony_ci  // unknown. If the number can only be dialled from within the region, returns
6031767c5feSopenharmony_ci  // false. Does not check the number is a valid number. Note that, at the
6041767c5feSopenharmony_ci  // moment, this method does not handle short numbers (which are currently all
6051767c5feSopenharmony_ci  // presumed to not be diallable from outside their country).
6061767c5feSopenharmony_ci  bool CanBeInternationallyDialled(const PhoneNumber& number) const;
6071767c5feSopenharmony_ci
6081767c5feSopenharmony_ci  // Tests whether a phone number has a geographical association. It checks if
6091767c5feSopenharmony_ci  // the number is associated with a certain region in the country to which it
6101767c5feSopenharmony_ci  // belongs. Note that this doesn't verify if the number is actually in use.
6111767c5feSopenharmony_ci  bool IsNumberGeographical(const PhoneNumber& phone_number) const;
6121767c5feSopenharmony_ci
6131767c5feSopenharmony_ci  // Overload of IsNumberGeographical(PhoneNumber), since calculating the phone
6141767c5feSopenharmony_ci  // number type is expensive; if we have already done this, we don't want to do
6151767c5feSopenharmony_ci  // it again.
6161767c5feSopenharmony_ci  bool IsNumberGeographical(PhoneNumberType phone_number_type,
6171767c5feSopenharmony_ci                            int country_calling_code) const;
6181767c5feSopenharmony_ci
6191767c5feSopenharmony_ci  // Gets a valid fixed-line number for the specified region. Returns false if
6201767c5feSopenharmony_ci  // the region was unknown, or the region 001 is passed in. For 001
6211767c5feSopenharmony_ci  // (representing non-geographical numbers), call
6221767c5feSopenharmony_ci  // GetExampleNumberForNonGeoEntity instead.
6231767c5feSopenharmony_ci  bool GetExampleNumber(const string& region_code,
6241767c5feSopenharmony_ci                        PhoneNumber* number) const;
6251767c5feSopenharmony_ci
6261767c5feSopenharmony_ci  // Gets an invalid number for the specified region. This is useful for
6271767c5feSopenharmony_ci  // unit-testing purposes, where you want to test that will happen with an
6281767c5feSopenharmony_ci  // invalid number. Note that the number that is returned will always be able
6291767c5feSopenharmony_ci  // to be parsed and will have the correct country code. It may also be a valid
6301767c5feSopenharmony_ci  // *short* number/code for this region. Validity checking such
6311767c5feSopenharmony_ci  // numbers is handled with ShortNumberInfo.
6321767c5feSopenharmony_ci  //
6331767c5feSopenharmony_ci  // Returns false when an unsupported region or the region 001 (Earth) is
6341767c5feSopenharmony_ci  // passed in.
6351767c5feSopenharmony_ci  bool GetInvalidExampleNumber(const string& region_code,
6361767c5feSopenharmony_ci                               PhoneNumber* number) const;
6371767c5feSopenharmony_ci
6381767c5feSopenharmony_ci  // Gets a valid number of the specified type for the specified region.
6391767c5feSopenharmony_ci  // Returns false if the region was unknown or 001, or if no example number of
6401767c5feSopenharmony_ci  // that type could be found. For 001 (representing non-geographical numbers),
6411767c5feSopenharmony_ci  // call GetExampleNumberForNonGeoEntity instead.
6421767c5feSopenharmony_ci  bool GetExampleNumberForType(const string& region_code,
6431767c5feSopenharmony_ci                               PhoneNumberType type,
6441767c5feSopenharmony_ci                               PhoneNumber* number) const;
6451767c5feSopenharmony_ci
6461767c5feSopenharmony_ci  // Gets a valid number for the specified type (it may belong to any country).
6471767c5feSopenharmony_ci  // Returns false when the metadata does not contain such information.  This
6481767c5feSopenharmony_ci  // should only happen when no numbers of this type are allocated anywhere in
6491767c5feSopenharmony_ci  // the world anymore.
6501767c5feSopenharmony_ci  bool GetExampleNumberForType(PhoneNumberType type,
6511767c5feSopenharmony_ci                               PhoneNumber* number) const;
6521767c5feSopenharmony_ci
6531767c5feSopenharmony_ci  // Gets a valid number for the specified country calling code for a
6541767c5feSopenharmony_ci  // non-geographical entity. Returns false if the metadata does not contain
6551767c5feSopenharmony_ci  // such information, or the country calling code passed in does not belong to
6561767c5feSopenharmony_ci  // a non-geographical entity.
6571767c5feSopenharmony_ci  bool GetExampleNumberForNonGeoEntity(
6581767c5feSopenharmony_ci      int country_calling_code, PhoneNumber* number) const;
6591767c5feSopenharmony_ci
6601767c5feSopenharmony_ci  // Parses a string and returns it as a phone number in proto buffer format.
6611767c5feSopenharmony_ci  // The method is quite lenient and looks for a number in the input text
6621767c5feSopenharmony_ci  // (raw input) and does not check whether the string is definitely only a
6631767c5feSopenharmony_ci  // phone number. To do this, it ignores punctuation and white-space, as well
6641767c5feSopenharmony_ci  // as any text before the number (e.g. a leading “Tel: ”) and trims the
6651767c5feSopenharmony_ci  // non-number bits. It will accept a number in any format (E164, national,
6661767c5feSopenharmony_ci  // international etc), assuming it can be interpreted with the defaultRegion
6671767c5feSopenharmony_ci  // supplied. It also attempts to convert any alpha characters into digits
6681767c5feSopenharmony_ci  // if it thinks this is a vanity number of the type "1800 MICROSOFT".
6691767c5feSopenharmony_ci  //
6701767c5feSopenharmony_ci  // This method will return an error if the number is not considered to be a
6711767c5feSopenharmony_ci  // possible number, and NO_PARSING_ERROR if it is parsed correctly.
6721767c5feSopenharmony_ci  // Note that validation of whether the number is actually a valid number for
6731767c5feSopenharmony_ci  // a particular region is not performed. This can be done separately with
6741767c5feSopenharmony_ci  // IsValidNumber().
6751767c5feSopenharmony_ci  //
6761767c5feSopenharmony_ci  // Note this method canonicalizes the phone number such that different
6771767c5feSopenharmony_ci  // representations can be easily compared, no matter what form it was
6781767c5feSopenharmony_ci  // originally entered in (e.g. national, international). If you want to record
6791767c5feSopenharmony_ci  // context about the number being parsed, such as the raw input that was
6801767c5feSopenharmony_ci  // entered, how the country code was derived etc. then call
6811767c5feSopenharmony_ci  // ParseAndKeepRawInput() instead.
6821767c5feSopenharmony_ci  //
6831767c5feSopenharmony_ci  // number_to_parse can contain formatting such as +, ( and -, as well as a
6841767c5feSopenharmony_ci  // phone number extension. It can also be provided in RFC3966 format.
6851767c5feSopenharmony_ci  //
6861767c5feSopenharmony_ci  // default_region represents the country that we are expecting the number to
6871767c5feSopenharmony_ci  // be from. This is only used if the number being parsed is not written in
6881767c5feSopenharmony_ci  // international format. The country_code for the number in this case would be
6891767c5feSopenharmony_ci  // stored as that of the default country supplied. If the number is guaranteed
6901767c5feSopenharmony_ci  // to start with a '+' followed by the country calling code, then
6911767c5feSopenharmony_ci  // "ZZ" can be supplied.
6921767c5feSopenharmony_ci  //
6931767c5feSopenharmony_ci  // Returns an error if the string is not considered to be a viable phone
6941767c5feSopenharmony_ci  // number (e.g.too few or too many digits) or if no default region was
6951767c5feSopenharmony_ci  // supplied and the number is not in international format (does not start with
6961767c5feSopenharmony_ci  // +).
6971767c5feSopenharmony_ci  ErrorType Parse(const string& number_to_parse,
6981767c5feSopenharmony_ci                  const string& default_region,
6991767c5feSopenharmony_ci                  PhoneNumber* number) const;
7001767c5feSopenharmony_ci  // Parses a string and returns it in proto buffer format. This method differs
7011767c5feSopenharmony_ci  // from Parse() in that it always populates the raw_input field of the
7021767c5feSopenharmony_ci  // protocol buffer with number_to_parse as well as the country_code_source
7031767c5feSopenharmony_ci  // field.
7041767c5feSopenharmony_ci  ErrorType ParseAndKeepRawInput(const string& number_to_parse,
7051767c5feSopenharmony_ci                                 const string& default_region,
7061767c5feSopenharmony_ci                                 PhoneNumber* number) const;
7071767c5feSopenharmony_ci
7081767c5feSopenharmony_ci  // Takes two phone numbers and compares them for equality.
7091767c5feSopenharmony_ci  //
7101767c5feSopenharmony_ci  // Returns EXACT_MATCH if the country calling code, NSN, presence of a leading
7111767c5feSopenharmony_ci  // zero for Italian numbers and any extension present are the same.
7121767c5feSopenharmony_ci  // Returns NSN_MATCH if either or both has no country calling code specified,
7131767c5feSopenharmony_ci  // and the NSNs and extensions are the same.
7141767c5feSopenharmony_ci  // Returns SHORT_NSN_MATCH if either or both has no country calling code
7151767c5feSopenharmony_ci  // specified, or the country calling code specified is the same, and one NSN
7161767c5feSopenharmony_ci  // could be a shorter version of the other number. This includes the case
7171767c5feSopenharmony_ci  // where one has an extension specified, and the other does not.
7181767c5feSopenharmony_ci  // Returns NO_MATCH otherwise.
7191767c5feSopenharmony_ci  // For example, the numbers +1 345 657 1234 and 657 1234 are a
7201767c5feSopenharmony_ci  // SHORT_NSN_MATCH. The numbers +1 345 657 1234 and 345 657 are a NO_MATCH.
7211767c5feSopenharmony_ci  MatchType IsNumberMatch(const PhoneNumber& first_number,
7221767c5feSopenharmony_ci                          const PhoneNumber& second_number) const;
7231767c5feSopenharmony_ci
7241767c5feSopenharmony_ci  // Takes two phone numbers as strings and compares them for equality. This
7251767c5feSopenharmony_ci  // is a convenience wrapper for IsNumberMatch(PhoneNumber firstNumber,
7261767c5feSopenharmony_ci  // PhoneNumber secondNumber). No default region is known.
7271767c5feSopenharmony_ci  // Returns INVALID_NUMBER if either number cannot be parsed into a phone
7281767c5feSopenharmony_ci  // number.
7291767c5feSopenharmony_ci  MatchType IsNumberMatchWithTwoStrings(const string& first_number,
7301767c5feSopenharmony_ci                                        const string& second_number) const;
7311767c5feSopenharmony_ci
7321767c5feSopenharmony_ci  // Takes two phone numbers and compares them for equality. This is a
7331767c5feSopenharmony_ci  // convenience wrapper for IsNumberMatch(PhoneNumber firstNumber,
7341767c5feSopenharmony_ci  // PhoneNumber secondNumber). No default region is known.
7351767c5feSopenharmony_ci  // Returns INVALID_NUMBER if second_number cannot be parsed into a phone
7361767c5feSopenharmony_ci  // number.
7371767c5feSopenharmony_ci  MatchType IsNumberMatchWithOneString(const PhoneNumber& first_number,
7381767c5feSopenharmony_ci                                       const string& second_number) const;
7391767c5feSopenharmony_ci
7401767c5feSopenharmony_ci  // Overrides the default logging system. This takes ownership of the provided
7411767c5feSopenharmony_ci  // logger.
7421767c5feSopenharmony_ci  void SetLogger(Logger* logger);
7431767c5feSopenharmony_ci
7441767c5feSopenharmony_ci  // Gets an AsYouTypeFormatter for the specific region.
7451767c5feSopenharmony_ci  // Returns an AsYouTypeFormatter object, which could be used to format phone
7461767c5feSopenharmony_ci  // numbers in the specific region "as you type".
7471767c5feSopenharmony_ci  // The deletion of the returned instance is under the responsibility of the
7481767c5feSopenharmony_ci  // caller.
7491767c5feSopenharmony_ci  AsYouTypeFormatter* GetAsYouTypeFormatter(const string& region_code) const;
7501767c5feSopenharmony_ci
7511767c5feSopenharmony_ci  friend bool ConvertFromTelephoneNumberProto(
7521767c5feSopenharmony_ci      const TelephoneNumber& proto_to_convert,
7531767c5feSopenharmony_ci      PhoneNumber* new_proto);
7541767c5feSopenharmony_ci  friend bool ConvertToTelephoneNumberProto(const PhoneNumber& proto_to_convert,
7551767c5feSopenharmony_ci                                            TelephoneNumber* resulting_proto);
7561767c5feSopenharmony_ci
7571767c5feSopenharmony_ci protected:
7581767c5feSopenharmony_ci  bool IsNumberMatchingDesc(const string& national_number,
7591767c5feSopenharmony_ci                            const PhoneNumberDesc& number_desc) const;
7601767c5feSopenharmony_ci
7611767c5feSopenharmony_ci  PhoneNumberUtil::PhoneNumberType GetNumberTypeHelper(
7621767c5feSopenharmony_ci      const string& national_number, const PhoneMetadata& metadata) const;
7631767c5feSopenharmony_ci
7641767c5feSopenharmony_ci private:
7651767c5feSopenharmony_ci  scoped_ptr<Logger> logger_;
7661767c5feSopenharmony_ci
7671767c5feSopenharmony_ci  typedef std::pair<int, std::list<string>*> IntRegionsPair;
7681767c5feSopenharmony_ci
7691767c5feSopenharmony_ci  // The minimum and maximum length of the national significant number.
7701767c5feSopenharmony_ci  static const size_t kMinLengthForNsn = 2;
7711767c5feSopenharmony_ci  // The ITU says the maximum length should be 15, but we have found longer
7721767c5feSopenharmony_ci  // numbers in Germany.
7731767c5feSopenharmony_ci  static const size_t kMaxLengthForNsn = 17;
7741767c5feSopenharmony_ci  // The maximum length of the country calling code.
7751767c5feSopenharmony_ci  static const size_t kMaxLengthCountryCode = 3;
7761767c5feSopenharmony_ci
7771767c5feSopenharmony_ci  static const char kPlusChars[];
7781767c5feSopenharmony_ci  // Regular expression of acceptable punctuation found in phone numbers. This
7791767c5feSopenharmony_ci  // excludes punctuation found as a leading character only. This consists of
7801767c5feSopenharmony_ci  // dash characters, white space characters, full stops, slashes, square
7811767c5feSopenharmony_ci  // brackets, parentheses and tildes. It also includes the letter 'x' as that
7821767c5feSopenharmony_ci  // is found as a placeholder for carrier information in some phone numbers.
7831767c5feSopenharmony_ci  // Full-width variants are also present.
7841767c5feSopenharmony_ci  static const char kValidPunctuation[];
7851767c5feSopenharmony_ci
7861767c5feSopenharmony_ci  // Regular expression of characters typically used to start a second phone
7871767c5feSopenharmony_ci  // number for the purposes of parsing. This allows us to strip off parts of
7881767c5feSopenharmony_ci  // the number that are actually the start of another number, such as for:
7891767c5feSopenharmony_ci  // (530) 583-6985 x302/x2303 -> the second extension here makes this actually
7901767c5feSopenharmony_ci  // two phone numbers, (530) 583-6985 x302 and (530) 583-6985 x2303. We remove
7911767c5feSopenharmony_ci  // the second extension so that the first number is parsed correctly. The
7921767c5feSopenharmony_ci  // string preceding this is captured.
7931767c5feSopenharmony_ci  // This corresponds to SECOND_NUMBER_START in the java version.
7941767c5feSopenharmony_ci  static const char kCaptureUpToSecondNumberStart[];
7951767c5feSopenharmony_ci
7961767c5feSopenharmony_ci  // An API for validation checking.
7971767c5feSopenharmony_ci  scoped_ptr<MatcherApi> matcher_api_;
7981767c5feSopenharmony_ci
7991767c5feSopenharmony_ci  // Helper class holding useful regular expressions and character mappings.
8001767c5feSopenharmony_ci  scoped_ptr<PhoneNumberRegExpsAndMappings> reg_exps_;
8011767c5feSopenharmony_ci
8021767c5feSopenharmony_ci  // A mapping from a country calling code to a RegionCode object which denotes
8031767c5feSopenharmony_ci  // the region represented by that country calling code. Note regions under
8041767c5feSopenharmony_ci  // NANPA share the country calling code 1 and Russia and Kazakhstan share the
8051767c5feSopenharmony_ci  // country calling code 7. Under this map, 1 is mapped to region code "US" and
8061767c5feSopenharmony_ci  // 7 is mapped to region code "RU". This is implemented as a sorted vector to
8071767c5feSopenharmony_ci  // achieve better performance.
8081767c5feSopenharmony_ci  scoped_ptr<std::vector<IntRegionsPair> >
8091767c5feSopenharmony_ci      country_calling_code_to_region_code_map_;
8101767c5feSopenharmony_ci
8111767c5feSopenharmony_ci  // The set of regions that share country calling code 1.
8121767c5feSopenharmony_ci  scoped_ptr<std::set<string> > nanpa_regions_;
8131767c5feSopenharmony_ci  static const int kNanpaCountryCode = 1;
8141767c5feSopenharmony_ci
8151767c5feSopenharmony_ci  // A mapping from a region code to a PhoneMetadata for that region.
8161767c5feSopenharmony_ci  scoped_ptr<std::map<string, PhoneMetadata> > region_to_metadata_map_;
8171767c5feSopenharmony_ci
8181767c5feSopenharmony_ci  // A mapping from a country calling code for a non-geographical entity to the
8191767c5feSopenharmony_ci  // PhoneMetadata for that country calling code. Examples of the country
8201767c5feSopenharmony_ci  // calling codes include 800 (International Toll Free Service) and 808
8211767c5feSopenharmony_ci  // (International Shared Cost Service).
8221767c5feSopenharmony_ci  scoped_ptr<std::map<int, PhoneMetadata> >
8231767c5feSopenharmony_ci      country_code_to_non_geographical_metadata_map_;
8241767c5feSopenharmony_ci
8251767c5feSopenharmony_ci  PhoneNumberUtil();
8261767c5feSopenharmony_ci
8271767c5feSopenharmony_ci  // Returns a regular expression for the possible extensions that may be found
8281767c5feSopenharmony_ci  // in a number, for use when matching.
8291767c5feSopenharmony_ci  const string& GetExtnPatternsForMatching() const;
8301767c5feSopenharmony_ci
8311767c5feSopenharmony_ci  // Checks if a number matches the plus chars pattern.
8321767c5feSopenharmony_ci  bool StartsWithPlusCharsPattern(const string& number) const;
8331767c5feSopenharmony_ci
8341767c5feSopenharmony_ci  void SetItalianLeadingZerosForPhoneNumber(
8351767c5feSopenharmony_ci      const string& national_number, PhoneNumber* phone_number) const;
8361767c5feSopenharmony_ci
8371767c5feSopenharmony_ci  // Checks whether a string contains only valid digits.
8381767c5feSopenharmony_ci  bool ContainsOnlyValidDigits(const string& s) const;
8391767c5feSopenharmony_ci
8401767c5feSopenharmony_ci  // Checks if a format is eligible to be used by the AsYouTypeFormatter. This
8411767c5feSopenharmony_ci  // method is here rather than in asyoutypeformatter.h since it depends on the
8421767c5feSopenharmony_ci  // valid punctuation declared by the phone number util.
8431767c5feSopenharmony_ci  bool IsFormatEligibleForAsYouTypeFormatter(const string& format) const;
8441767c5feSopenharmony_ci
8451767c5feSopenharmony_ci  // Helper function to check if the national prefix formatting rule has the
8461767c5feSopenharmony_ci  // first group only, i.e., does not start with the national prefix.
8471767c5feSopenharmony_ci  bool FormattingRuleHasFirstGroupOnly(
8481767c5feSopenharmony_ci      const string& national_prefix_formatting_rule) const;
8491767c5feSopenharmony_ci
8501767c5feSopenharmony_ci  // Trims unwanted end characters from a phone number string.
8511767c5feSopenharmony_ci  void TrimUnwantedEndChars(string* number) const;
8521767c5feSopenharmony_ci
8531767c5feSopenharmony_ci  // Helper function to check region code is not unknown or null.
8541767c5feSopenharmony_ci  bool IsValidRegionCode(const string& region_code) const;
8551767c5feSopenharmony_ci
8561767c5feSopenharmony_ci  // Helper function to check the country calling code is valid.
8571767c5feSopenharmony_ci  bool HasValidCountryCallingCode(int country_calling_code) const;
8581767c5feSopenharmony_ci
8591767c5feSopenharmony_ci  const i18n::phonenumbers::PhoneMetadata* GetMetadataForRegion(
8601767c5feSopenharmony_ci      const string& region_code) const;
8611767c5feSopenharmony_ci
8621767c5feSopenharmony_ci  const i18n::phonenumbers::PhoneMetadata* GetMetadataForNonGeographicalRegion(
8631767c5feSopenharmony_ci      int country_calling_code) const;
8641767c5feSopenharmony_ci
8651767c5feSopenharmony_ci  const i18n::phonenumbers::PhoneMetadata* GetMetadataForRegionOrCallingCode(
8661767c5feSopenharmony_ci      int country_calling_code,
8671767c5feSopenharmony_ci      const string& region_code) const;
8681767c5feSopenharmony_ci
8691767c5feSopenharmony_ci  // As per GetCountryCodeForRegion, but assumes the validity of the region_code
8701767c5feSopenharmony_ci  // has already been checked.
8711767c5feSopenharmony_ci  int GetCountryCodeForValidRegion(const string& region_code) const;
8721767c5feSopenharmony_ci
8731767c5feSopenharmony_ci  const NumberFormat* ChooseFormattingPatternForNumber(
8741767c5feSopenharmony_ci      const RepeatedPtrField<NumberFormat>& available_formats,
8751767c5feSopenharmony_ci      const string& national_number) const;
8761767c5feSopenharmony_ci
8771767c5feSopenharmony_ci  void FormatNsnUsingPatternWithCarrier(
8781767c5feSopenharmony_ci      const string& national_number,
8791767c5feSopenharmony_ci      const NumberFormat& formatting_pattern,
8801767c5feSopenharmony_ci      PhoneNumberUtil::PhoneNumberFormat number_format,
8811767c5feSopenharmony_ci      const string& carrier_code,
8821767c5feSopenharmony_ci      string* formatted_number) const;
8831767c5feSopenharmony_ci
8841767c5feSopenharmony_ci  void FormatNsnUsingPattern(
8851767c5feSopenharmony_ci      const string& national_number,
8861767c5feSopenharmony_ci      const NumberFormat& formatting_pattern,
8871767c5feSopenharmony_ci      PhoneNumberUtil::PhoneNumberFormat number_format,
8881767c5feSopenharmony_ci      string* formatted_number) const;
8891767c5feSopenharmony_ci
8901767c5feSopenharmony_ci  // Check if raw_input, which is assumed to be in the national format, has a
8911767c5feSopenharmony_ci  // national prefix. The national prefix is assumed to be in digits-only form.
8921767c5feSopenharmony_ci  bool RawInputContainsNationalPrefix(
8931767c5feSopenharmony_ci      const string& raw_input,
8941767c5feSopenharmony_ci      const string& national_prefix,
8951767c5feSopenharmony_ci      const string& region_code) const;
8961767c5feSopenharmony_ci
8971767c5feSopenharmony_ci  bool HasFormattingPatternForNumber(const PhoneNumber& number) const;
8981767c5feSopenharmony_ci
8991767c5feSopenharmony_ci  // Simple wrapper of FormatNsnWithCarrier for the common case of
9001767c5feSopenharmony_ci  // no carrier code.
9011767c5feSopenharmony_ci  void FormatNsn(const string& number,
9021767c5feSopenharmony_ci                 const PhoneMetadata& metadata,
9031767c5feSopenharmony_ci                 PhoneNumberFormat number_format,
9041767c5feSopenharmony_ci                 string* formatted_number) const;
9051767c5feSopenharmony_ci
9061767c5feSopenharmony_ci  void FormatNsnWithCarrier(const string& number,
9071767c5feSopenharmony_ci                            const PhoneMetadata& metadata,
9081767c5feSopenharmony_ci                            PhoneNumberFormat number_format,
9091767c5feSopenharmony_ci                            const string& carrier_code,
9101767c5feSopenharmony_ci                            string* formatted_number) const;
9111767c5feSopenharmony_ci
9121767c5feSopenharmony_ci  void MaybeAppendFormattedExtension(
9131767c5feSopenharmony_ci      const PhoneNumber& number,
9141767c5feSopenharmony_ci      const PhoneMetadata& metadata,
9151767c5feSopenharmony_ci      PhoneNumberFormat number_format,
9161767c5feSopenharmony_ci      string* extension) const;
9171767c5feSopenharmony_ci
9181767c5feSopenharmony_ci  void GetRegionCodeForNumberFromRegionList(
9191767c5feSopenharmony_ci      const PhoneNumber& number,
9201767c5feSopenharmony_ci      const std::list<string>& region_codes,
9211767c5feSopenharmony_ci      string* region_code) const;
9221767c5feSopenharmony_ci
9231767c5feSopenharmony_ci  // Strips the IDD from the start of the number if present. Helper function
9241767c5feSopenharmony_ci  // used by MaybeStripInternationalPrefixAndNormalize.
9251767c5feSopenharmony_ci  bool ParsePrefixAsIdd(const RegExp& idd_pattern, string* number) const;
9261767c5feSopenharmony_ci
9271767c5feSopenharmony_ci  void Normalize(string* number) const;
9281767c5feSopenharmony_ci
9291767c5feSopenharmony_ci  PhoneNumber::CountryCodeSource MaybeStripInternationalPrefixAndNormalize(
9301767c5feSopenharmony_ci      const string& possible_idd_prefix,
9311767c5feSopenharmony_ci      string* number) const;
9321767c5feSopenharmony_ci
9331767c5feSopenharmony_ci  bool MaybeStripNationalPrefixAndCarrierCode(
9341767c5feSopenharmony_ci      const PhoneMetadata& metadata,
9351767c5feSopenharmony_ci      string* number,
9361767c5feSopenharmony_ci      string* carrier_code) const;
9371767c5feSopenharmony_ci
9381767c5feSopenharmony_ci  void ExtractPossibleNumber(const string& number,
9391767c5feSopenharmony_ci                             string* extracted_number) const;
9401767c5feSopenharmony_ci
9411767c5feSopenharmony_ci  bool IsViablePhoneNumber(const string& number) const;
9421767c5feSopenharmony_ci
9431767c5feSopenharmony_ci  bool MaybeStripExtension(string* number, string* extension) const;
9441767c5feSopenharmony_ci
9451767c5feSopenharmony_ci  int ExtractCountryCode(string* national_number) const;
9461767c5feSopenharmony_ci  ErrorType MaybeExtractCountryCode(
9471767c5feSopenharmony_ci      const PhoneMetadata* default_region_metadata,
9481767c5feSopenharmony_ci      bool keepRawInput,
9491767c5feSopenharmony_ci      string* national_number,
9501767c5feSopenharmony_ci      PhoneNumber* phone_number) const;
9511767c5feSopenharmony_ci
9521767c5feSopenharmony_ci  bool CheckRegionForParsing(
9531767c5feSopenharmony_ci      const string& number_to_parse,
9541767c5feSopenharmony_ci      const string& default_region) const;
9551767c5feSopenharmony_ci
9561767c5feSopenharmony_ci  ErrorType ParseHelper(const string& number_to_parse,
9571767c5feSopenharmony_ci                        const string& default_region,
9581767c5feSopenharmony_ci                        bool keep_raw_input,
9591767c5feSopenharmony_ci                        bool check_region,
9601767c5feSopenharmony_ci                        PhoneNumber* phone_number) const;
9611767c5feSopenharmony_ci
9621767c5feSopenharmony_ci  void BuildNationalNumberForParsing(const string& number_to_parse,
9631767c5feSopenharmony_ci                                          string* national_number) const;
9641767c5feSopenharmony_ci
9651767c5feSopenharmony_ci  bool IsShorterThanPossibleNormalNumber(const PhoneMetadata* country_metadata,
9661767c5feSopenharmony_ci                                         const string& number) const;
9671767c5feSopenharmony_ci
9681767c5feSopenharmony_ci};
9691767c5feSopenharmony_ci
9701767c5feSopenharmony_ci}  // namespace phonenumbers
9711767c5feSopenharmony_ci}  // namespace i18n
9721767c5feSopenharmony_ci
9731767c5feSopenharmony_ci#endif  // I18N_PHONENUMBERS_PHONENUMBERUTIL_H_
974