Browse Source

Add constants for C++ util's enum's max values (#1904)

pull/1908/head
Keghani Kouzoujian 8 years ago
committed by GitHub
parent
commit
11ad0018a9
3 changed files with 12 additions and 1 deletions
  1. +1
    -1
      cpp/src/phonenumbers/phonenumberutil.cc
  2. +10
    -0
      cpp/src/phonenumbers/phonenumberutil.h
  3. +1
    -0
      pending_code_changes.txt

+ 1
- 1
cpp/src/phonenumbers/phonenumberutil.cc View File

@ -298,7 +298,7 @@ void GetSupportedTypesForMetadata(
const PhoneMetadata& metadata,
std::set<PhoneNumberUtil::PhoneNumberType>* types) {
DCHECK(types);
for (int i = 0; i < static_cast<int>(PhoneNumberUtil::UNKNOWN); ++i) {
for (int i = 0; i < static_cast<int>(PhoneNumberUtil::kMaxNumberType); ++i) {
PhoneNumberUtil::PhoneNumberType type =
static_cast<PhoneNumberUtil::PhoneNumberType>(i);
if (type == PhoneNumberUtil::FIXED_LINE_OR_MOBILE ||


+ 10
- 0
cpp/src/phonenumbers/phonenumberutil.h View File

@ -84,6 +84,8 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
RFC3966
};
static const PhoneNumberFormat kMaxNumberFormat = RFC3966;
// Type of phone numbers.
enum PhoneNumberType {
FIXED_LINE,
@ -116,6 +118,8 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
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<PhoneNumberUtil> {
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<PhoneNumberUtil> {
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<PhoneNumberUtil> {
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


+ 1
- 0
pending_code_changes.txt View File

@ -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.

Loading…
Cancel
Save