diff --git a/cpp/src/phonenumbers/phonenumberutil.cc b/cpp/src/phonenumbers/phonenumberutil.cc index 69e6ce562..e1fda9c8b 100644 --- a/cpp/src/phonenumbers/phonenumberutil.cc +++ b/cpp/src/phonenumbers/phonenumberutil.cc @@ -298,7 +298,7 @@ void GetSupportedTypesForMetadata( const PhoneMetadata& metadata, std::set* types) { DCHECK(types); - for (int i = 0; i < static_cast(PhoneNumberUtil::UNKNOWN); ++i) { + for (int i = 0; i < static_cast(PhoneNumberUtil::kMaxNumberType); ++i) { PhoneNumberUtil::PhoneNumberType type = static_cast(i); if (type == PhoneNumberUtil::FIXED_LINE_OR_MOBILE || diff --git a/cpp/src/phonenumbers/phonenumberutil.h b/cpp/src/phonenumbers/phonenumberutil.h index 54ae8bec2..9f9360efa 100644 --- a/cpp/src/phonenumbers/phonenumberutil.h +++ b/cpp/src/phonenumbers/phonenumberutil.h @@ -84,6 +84,8 @@ class PhoneNumberUtil : public Singleton { RFC3966 }; + static const PhoneNumberFormat kMaxNumberFormat = RFC3966; + // Type of phone numbers. enum PhoneNumberType { FIXED_LINE, @@ -116,6 +118,8 @@ class PhoneNumberUtil : public Singleton { UNKNOWN }; + static const PhoneNumberType kMaxNumberType = UNKNOWN; + // Types of phone number matches. See detailed description beside the // IsNumberMatch() method. enum MatchType { @@ -126,6 +130,8 @@ class PhoneNumberUtil : public Singleton { EXACT_MATCH, }; + static const MatchType kMaxMatchType = EXACT_MATCH; + enum ErrorType { NO_PARSING_ERROR, INVALID_COUNTRY_CODE_ERROR, // INVALID_COUNTRY_CODE in the java version. @@ -135,6 +141,8 @@ class PhoneNumberUtil : public Singleton { TOO_LONG_NSN, // TOO_LONG in the java version. }; + static const ErrorType kMaxErrorType = TOO_LONG_NSN; + // Possible outcomes when testing if a PhoneNumber is possible. enum ValidationResult { // The number length matches that of valid numbers for this region. @@ -159,6 +167,8 @@ class PhoneNumberUtil : public Singleton { TOO_LONG, }; + static const ValidationResult kMaxValidationResult = TOO_LONG; + // Returns all regions the library has metadata for. // @returns an unordered set of the two-letter region codes for every // geographical region the library supports diff --git a/pending_code_changes.txt b/pending_code_changes.txt index bdc86680c..e629dc397 100644 --- a/pending_code_changes.txt +++ b/pending_code_changes.txt @@ -4,3 +4,4 @@ Code changes: INVALID_LENGTH). Enables e.g. adding Iran short-codes starting with "096" without the need to hack IR's national prefix parsing config. - Logging changes: Don't log client-provided phone numbers. + - Add constants for C++ PhoneNumberUtil enums' max values.