From 2b6d054360ac36eae47003e12d347ccfd207de78 Mon Sep 17 00:00:00 2001 From: KarolJakubKrawiec Date: Wed, 29 Jan 2025 10:41:03 +0100 Subject: [PATCH] ParseWithOptions Opensource CPP Version We created a new function that allows the user for customized parsing. You can choose based on what you want the numbers to be parsed. --- cpp/src/phonenumbers/phonenumberutil.cc | 2 +- cpp/src/phonenumbers/phonenumberutil.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cpp/src/phonenumbers/phonenumberutil.cc b/cpp/src/phonenumbers/phonenumberutil.cc index d83def3ea..f1e0dfc5c 100644 --- a/cpp/src/phonenumbers/phonenumberutil.cc +++ b/cpp/src/phonenumbers/phonenumberutil.cc @@ -2134,7 +2134,7 @@ PhoneNumberUtil::ErrorType PhoneNumberUtil::Parse(const string& number_to_parse, number); } -PhoneNumberUtil::ErrorType PhoneNumberUtil::ParseWithOptions(const absl::string_view number_to_parse, +PhoneNumberUtil::ErrorType PhoneNumberUtil::ParseWithOptions(const string& number_to_parse, const ParsingOptions& options, PhoneNumber* number) const { DCHECK(number); diff --git a/cpp/src/phonenumbers/phonenumberutil.h b/cpp/src/phonenumbers/phonenumberutil.h index 346c86990..9f6b81688 100644 --- a/cpp/src/phonenumbers/phonenumberutil.h +++ b/cpp/src/phonenumbers/phonenumberutil.h @@ -723,7 +723,7 @@ class PhoneNumberUtil : public Singleton { // Parses a string and returns it in proto buffer format. This method differs // from Parse() in that it allows the caller to change the behavior of the // parser. See ParsingOptions for more details. - ErrorType ParseWithOptions(const absl::string_view number_to_parse, + ErrorType ParseWithOptions(const string& number_to_parse, const ParsingOptions& options, PhoneNumber* number) const; @@ -981,11 +981,13 @@ class PhoneNumberUtil : public Singleton { bool check_region, PhoneNumber* phone_number) const; + ErrorType ParseHelper(const absl::string_view number_to_parse, const string& default_region, bool keep_raw_input, bool check_region, PhoneNumber* phone_number) const; + absl::optional ExtractPhoneContext( const string& number_to_extract_from,