Browse Source

CPP: Refactoring PhoneNumberUtil so that global scoped_ptr variables are now hidden in an internal class.

pull/567/head
Lara Scheidegger 14 years ago
committed by Mihaela Rosca
parent
commit
3b0c906ec7
2 changed files with 371 additions and 336 deletions
  1. +363
    -330
      cpp/src/phonenumbers/phonenumberutil.cc
  2. +8
    -6
      cpp/src/phonenumbers/phonenumberutil.h

+ 363
- 330
cpp/src/phonenumbers/phonenumberutil.cc
File diff suppressed because it is too large
View File


+ 8
- 6
cpp/src/phonenumbers/phonenumberutil.h View File

@ -51,8 +51,8 @@ class AsYouTypeFormatter;
class Logger;
class NumberFormat;
class PhoneMetadata;
class PhoneMetadataCollection;
class PhoneNumber;
class PhoneNumberMatcherRegExps;
class PhoneNumberRegExpsAndMappings;
class RegExp;
// NOTE: A lot of methods in this class require Region Code strings. These must
@ -71,6 +71,7 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
friend class PhoneNumberMatcher;
friend class PhoneNumberMatcherRegExps;
friend class PhoneNumberMatcherTest;
friend class PhoneNumberRegExpsAndMappings;
friend class PhoneNumberUtilTest;
public:
~PhoneNumberUtil();
@ -162,10 +163,6 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
static PhoneNumberUtil* GetInstance();
#endif
// Initialisation helper function used to populate the regular expressions in
// a defined order.
void CreateRegularExpressions() const;
// Returns true if the number is a valid vanity (alpha) number such as 800
// MICROSOFT. A valid vanity number will start with at least 3 digits and will
// have three or more alpha characters. This does not do region-specific
@ -549,6 +546,8 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
bool IsLeadingZeroPossible(int country_calling_code) const;
private:
scoped_ptr<Logger> logger_;
typedef pair<int, list<string>*> IntRegionsPair;
// The minimum and maximum length of the national significant number.
@ -578,6 +577,9 @@ class PhoneNumberUtil : public Singleton<PhoneNumberUtil> {
// This corresponds to SECOND_NUMBER_START in the java version.
static const char kCaptureUpToSecondNumberStart[];
// Helper class holding useful regular expressions and character mappings.
scoped_ptr<PhoneNumberRegExpsAndMappings> reg_exps_;
// A mapping from a country calling code to a RegionCode object which denotes
// the region represented by that country calling code. Note regions under
// NANPA share the country calling code 1 and Russia and Kazakhstan share the


Loading…
Cancel
Save