-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create new class ParseWithOptions #3730
base: master
Are you sure you want to change the base?
Changes from 11 commits
ed15e47
f5c2748
809f889
45cb5e4
90270c7
5155f58
9d7975a
1a8629e
ddcfb51
2b6d054
65f0f44
35f998d
d9d2ef0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "phonenumbers/parsingoptions.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add the license header. |
||
|
||
namespace i18n { | ||
namespace phonenumbers { | ||
|
||
ParsingOptions& ParsingOptions::SetDefaultRegion( | ||
const std::string& default_region) { | ||
default_region_ = default_region; | ||
return *this; | ||
} | ||
|
||
ParsingOptions& ParsingOptions::SetKeepRawInput(bool keep_raw_input) { | ||
keep_raw_input_ = keep_raw_input; | ||
return *this; | ||
} | ||
|
||
} // namespace phonenumbers | ||
} // namespace i18n |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||||
#ifndef I18N_PHONENUMBERS_PARSINGOPTIONS_H_ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add the license header. |
||||||
#define I18N_PHONENUMBERS_PARSINGOPTIONS_H_ | ||||||
|
||||||
#include <string> | ||||||
|
||||||
namespace i18n { | ||||||
namespace phonenumbers { | ||||||
|
||||||
// Options for parsing a phone number. To be used with the ParseWithOptions | ||||||
// method. | ||||||
// Example: | ||||||
// ParsingOptions().SetDefaultRegion(RegionCode::US()).SetKeepRawInput(true); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the example to use a string for the region code. |
||||||
class ParsingOptions { | ||||||
public: | ||||||
ParsingOptions() : default_region_("ZZ"), keep_raw_input_(false) {}; | ||||||
|
||||||
// Set the value for default_region_. | ||||||
ParsingOptions& SetDefaultRegion( | ||||||
const std::string& default_region); | ||||||
|
||||||
// Set the value for keep_raw_input_. | ||||||
ParsingOptions& SetKeepRawInput(bool keep_raw_input); | ||||||
|
||||||
private: | ||||||
friend class PhoneNumberUtil; | ||||||
|
||||||
// The region we are expecting the number to be from. This is ignored if the | ||||||
// number being parsed is written in international format. In case of national | ||||||
// format, the country_code will be set to the one of this default region. If | ||||||
// the number is guaranteed to start with a '+' followed by the country | ||||||
// calling code, then RegionCode.ZZ or null can be supplied. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
std::string default_region_; | ||||||
|
||||||
// Whether the raw input should be kept in the PhoneNumber object. If true, | ||||||
// the raw_input field and country_code_source fields will be populated. | ||||||
bool keep_raw_input_; | ||||||
}; | ||||||
|
||||||
} // namespace phonenumbers | ||||||
} // namespace i18n | ||||||
|
||||||
#endif // I1 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this auto-generated file.