summaryrefslogtreecommitdiff
path: root/asyoutypeformatter.h
diff options
context:
space:
mode:
authorlararennie@google.com <lararennie@google.com@ee073f10-1060-11df-b6a4-87a95322a99c>2012-09-06 09:48:57 +0000
committerlararennie@google.com <lararennie@google.com@ee073f10-1060-11df-b6a4-87a95322a99c>2012-09-06 09:48:57 +0000
commit35bd393fb78215a9c6dbeb158913def01eb58985 (patch)
treeb60002e80ee45f49280e32bb80c093f758564e63 /asyoutypeformatter.h
parent4e977e466a54faa8a3016700d6dd9d265a497cb9 (diff)
downloadphonenumbers-35bd393fb78215a9c6dbeb158913def01eb58985.tar.gz
CPP: libphonenumber v5.1
git-svn-id: http://libphonenumber.googlecode.com/svn/trunk/cpp/src/phonenumbers@518 ee073f10-1060-11df-b6a4-87a95322a99c
Diffstat (limited to 'asyoutypeformatter.h')
-rw-r--r--asyoutypeformatter.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/asyoutypeformatter.h b/asyoutypeformatter.h
index 0121f4f..690bb9c 100644
--- a/asyoutypeformatter.h
+++ b/asyoutypeformatter.h
@@ -24,8 +24,9 @@
// asyoutypeformatter_test.cc for more details on how the formatter is to be
// used.
//
-// This is a direct port from AsYouTypeFormatter.java. Changes to this class
-// should also happen to the Java version, whenever it makes sense.
+// This is a direct port from AsYouTypeFormatter.java.
+// Changes to this class should also happen to the Java version, whenever it
+// makes sense.
//
// This class is NOT THREAD SAFE.
@@ -96,6 +97,10 @@ class AsYouTypeFormatter {
void NarrowDownPossibleFormats(const string& leading_digits);
+ // Calculates whether we should be adding a space after the national prefix
+ // for this formatting rule or not.
+ void SetShouldAddSpaceAfterNationalPrefix(const NumberFormat& format);
+
bool CreateFormattingTemplate(const NumberFormat& format);
// Gets a formatting template which could be used to efficiently format a
@@ -115,8 +120,18 @@ class AsYouTypeFormatter {
// can extract a longer version here.
bool AbleToExtractLongerNdd();
+ // Check to see if there is an exact pattern match for these digits. If so, we
+ // should use this instead of any other formatting template whose
+ // leadingDigitsPattern also matches the input.
void AttemptToFormatAccruedDigits(string* formatted_number);
+ // Combines the national number with any prefix (IDD/+ and country code or
+ // national prefix) that was collected. A space will be inserted between them
+ // if the current formatting template indicates this to be suitable.
+ // The result will be stored in phone_number.
+ void AppendNationalNumber(const string& national_number,
+ string* phone_number) const;
+
// Attempts to set the formatting template and assigns the passed-in string
// parameter to the formatted version of the digits entered so far.
void AttemptToChooseFormattingPattern(string* formatted_number);
@@ -125,6 +140,10 @@ class AsYouTypeFormatter {
// assigns the passed-in string parameter to a formatted string in the end.
void InputAccruedNationalNumber(string* number);
+ // Returns true if the current country is a NANPA country and the national
+ // number begins with the national prefix.
+ bool IsNanpaNumberWithNationalPrefix() const;
+
// Extracts the national prefix into national_prefix, or sets it to empty
// string if a national prefix is not present.
void RemoveNationalPrefixFromNationalNumber(string* national_prefix);
@@ -170,7 +189,11 @@ class AsYouTypeFormatter {
// Set to true when users enter their own formatting. AsYouTypeFormatter will
// do no formatting at all when this is set to true.
bool input_has_formatting_;
- bool is_international_formatting_;
+ // This is set to true when we know the user is entering a full national
+ // significant number, since we have either detected a national prefix or an
+ // international dialing prefix. When this is true, we will no longer use
+ // local number formatting patterns.
+ bool is_complete_number_;
bool is_expecting_country_code_;
const PhoneNumberUtil& phone_util_;
@@ -196,6 +219,7 @@ class AsYouTypeFormatter {
// significant number, and it is formatted (e.g. with space inserted). For
// example, this can contain IDD, country code, and/or NDD, etc.
string prefix_before_national_number_;
+ bool should_add_space_after_national_prefix_;
// This contains the national prefix that has been extracted. It contains only
// digits without formatting.
string national_prefix_extracted_;