Browse Source

Fully quality std::* names.

pull/585/head
David Yonge-Mallo 11 years ago
parent
commit
902cc6bf4c
7 changed files with 80 additions and 92 deletions
  1. +9
    -10
      cpp/src/phonenumbers/default_logger.cc
  2. +1
    -2
      cpp/src/phonenumbers/phonenumbermatcher.cc
  3. +58
    -61
      cpp/src/phonenumbers/phonenumberutil.cc
  4. +1
    -2
      cpp/src/phonenumbers/regexp_cache.cc
  5. +1
    -2
      cpp/src/phonenumbers/shortnumberinfo.cc
  6. +0
    -2
      cpp/test/phonenumbers/phonenumberutil_test.cc
  7. +10
    -13
      cpp/test/phonenumbers/test_util.cc

+ 9
- 10
cpp/src/phonenumbers/default_logger.cc View File

@ -21,11 +21,10 @@
namespace i18n {
namespace phonenumbers {
using std::cout;
using std::string;
void StdoutLogger::WriteMessage(const string& msg) {
cout << " " << msg;
std::cout << " " << msg;
}
void StdoutLogger::WriteLevel() {
@ -34,24 +33,24 @@ void StdoutLogger::WriteLevel() {
verbosity_level = LOG_FATAL;
}
cout << "[";
std::cout << "[";
// Handle verbose logs first.
if (verbosity_level > LOG_DEBUG) {
cout << "VLOG" << (verbosity_level - LOG_DEBUG);
std::cout << "VLOG" << (verbosity_level - LOG_DEBUG);
} else {
switch (verbosity_level) {
case LOG_FATAL: cout << "FATAL"; break;
case LOG_FATAL: std::cout << "FATAL"; break;
#ifdef ERROR // In case ERROR is defined by MSVC (i.e not set to LOG_ERROR).
case ERROR:
#endif
case LOG_ERROR: cout << "ERROR"; break;
case LOG_WARNING: cout << "WARNING"; break;
case LOG_INFO: cout << "INFO"; break;
case LOG_DEBUG: cout << "DEBUG"; break;
case LOG_ERROR: std::cout << "ERROR"; break;
case LOG_WARNING: std::cout << "WARNING"; break;
case LOG_INFO: std::cout << "INFO"; break;
case LOG_DEBUG: std::cout << "DEBUG"; break;
}
}
cout << "]";
std::cout << "]";
}
} // namespace phonenumbers


+ 1
- 2
cpp/src/phonenumbers/phonenumbermatcher.cc View File

@ -55,7 +55,6 @@
#include "phonenumbers/regexp_adapter_re2.h"
#endif // I18N_PHONENUMBERS_USE_RE2_AND_ICU
using std::make_pair;
using std::map;
using std::numeric_limits;
using std::string;
@ -372,7 +371,7 @@ class AlternateFormats : public Singleton<AlternateFormats> {
it != format_data_.metadata().end();
++it) {
calling_code_to_alternate_formats_map_.insert(
make_pair(it->country_code(), &*it));
std::make_pair(it->country_code(), &*it));
}
}


+ 58
- 61
cpp/src/phonenumbers/phonenumberutil.cc View File

@ -52,9 +52,6 @@
namespace i18n {
namespace phonenumbers {
using std::make_pair;
using std::sort;
using google::protobuf::RepeatedPtrField;
// static constants
@ -289,70 +286,70 @@ void PhoneNumberUtil::SetLogger(Logger* logger) {
class PhoneNumberRegExpsAndMappings {
private:
void InitializeMapsAndSets() {
diallable_char_mappings_.insert(make_pair('+', '+'));
diallable_char_mappings_.insert(make_pair('*', '*'));
diallable_char_mappings_.insert(std::make_pair('+', '+'));
diallable_char_mappings_.insert(std::make_pair('*', '*'));
// Here we insert all punctuation symbols that we wish to respect when
// formatting alpha numbers, as they show the intended number groupings.
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("-"), '-'));
std::make_pair(ToUnicodeCodepoint("-"), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xEF\xBC\x8D" /* "-" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xEF\xBC\x8D" /* "-" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x80\x90" /* "‐" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x90" /* "‐" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x80\x91" /* "‑" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x91" /* "‑" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x80\x92" /* "‒" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x92" /* "‒" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x80\x93" /* "–" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x93" /* "–" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x80\x94" /* "—" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x94" /* "—" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x80\x95" /* "―" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xE2\x80\x95" /* "―" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x88\x92" /* "−" */), '-'));
std::make_pair(ToUnicodeCodepoint("\xE2\x88\x92" /* "−" */), '-'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("/"), '/'));
std::make_pair(ToUnicodeCodepoint("/"), '/'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xEF\xBC\x8F" /* "/" */), '/'));
std::make_pair(ToUnicodeCodepoint("\xEF\xBC\x8F" /* "/" */), '/'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint(" "), ' '));
std::make_pair(ToUnicodeCodepoint(" "), ' '));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE3\x80\x80" /* " " */), ' '));
std::make_pair(ToUnicodeCodepoint("\xE3\x80\x80" /* " " */), ' '));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xE2\x81\xA0"), ' '));
std::make_pair(ToUnicodeCodepoint("\xE2\x81\xA0"), ' '));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("."), '.'));
std::make_pair(ToUnicodeCodepoint("."), '.'));
all_plus_number_grouping_symbols_.insert(
make_pair(ToUnicodeCodepoint("\xEF\xBC\x8E" /* "." */), '.'));
std::make_pair(ToUnicodeCodepoint("\xEF\xBC\x8E" /* "." */), '.'));
// Only the upper-case letters are added here - the lower-case versions are
// added programmatically.
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("A"), '2'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("B"), '2'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("C"), '2'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("D"), '3'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("E"), '3'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("F"), '3'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("G"), '4'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("H"), '4'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("I"), '4'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("J"), '5'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("K"), '5'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("L"), '5'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("M"), '6'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("N"), '6'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("O"), '6'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("P"), '7'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("Q"), '7'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("R"), '7'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("S"), '7'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("T"), '8'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("U"), '8'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("V"), '8'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("W"), '9'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("X"), '9'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("Y"), '9'));
alpha_mappings_.insert(make_pair(ToUnicodeCodepoint("Z"), '9'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("A"), '2'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("B"), '2'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("C"), '2'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("D"), '3'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("E"), '3'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("F"), '3'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("G"), '4'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("H"), '4'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("I"), '4'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("J"), '5'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("K"), '5'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("L"), '5'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("M"), '6'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("N"), '6'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("O"), '6'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("P"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("Q"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("R"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("S"), '7'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("T"), '8'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("U"), '8'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("V"), '8'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("W"), '9'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("X"), '9'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("Y"), '9'));
alpha_mappings_.insert(std::make_pair(ToUnicodeCodepoint("Z"), '9'));
map<char32, char> lower_case_mappings;
map<char32, char> alpha_letters;
for (map<char32, char>::const_iterator it = alpha_mappings_.begin();
@ -362,12 +359,12 @@ class PhoneNumberRegExpsAndMappings {
if (it->first < 128) {
char letter_as_upper = static_cast<char>(it->first);
char32 letter_as_lower = static_cast<char32>(tolower(letter_as_upper));
lower_case_mappings.insert(make_pair(letter_as_lower, it->second));
lower_case_mappings.insert(std::make_pair(letter_as_lower, it->second));
// Add the letters in both variants to the alpha_letters map. This just
// pairs each letter with its upper-case representation so that it can
// be retained when normalising alpha numbers.
alpha_letters.insert(make_pair(letter_as_lower, letter_as_upper));
alpha_letters.insert(make_pair(it->first, letter_as_upper));
alpha_letters.insert(std::make_pair(letter_as_lower, letter_as_upper));
alpha_letters.insert(std::make_pair(it->first, letter_as_upper));
}
}
// In the Java version we don't insert the lower-case mappings in the map,
@ -382,13 +379,13 @@ class PhoneNumberRegExpsAndMappings {
alpha_letters.end());
// Add the ASCII digits so that they don't get deleted by NormalizeHelper().
for (char c = '0'; c <= '9'; ++c) {
diallable_char_mappings_.insert(make_pair(c, c));
alpha_phone_mappings_.insert(make_pair(c, c));
all_plus_number_grouping_symbols_.insert(make_pair(c, c));
diallable_char_mappings_.insert(std::make_pair(c, c));
alpha_phone_mappings_.insert(std::make_pair(c, c));
all_plus_number_grouping_symbols_.insert(std::make_pair(c, c));
}
mobile_token_mappings_.insert(make_pair(52, '1'));
mobile_token_mappings_.insert(make_pair(54, '9'));
mobile_token_mappings_.insert(std::make_pair(52, '1'));
mobile_token_mappings_.insert(std::make_pair(54, '9'));
}
// Small string helpers since StrCat has a maximum number of arguments. These
@ -611,9 +608,9 @@ PhoneNumberUtil::PhoneNumberUtil()
int country_calling_code = it->country_code();
if (kRegionCodeForNonGeoEntity == region_code) {
country_code_to_non_geographical_metadata_map_->insert(
make_pair(country_calling_code, *it));
std::make_pair(country_calling_code, *it));
} else {
region_to_metadata_map_->insert(make_pair(region_code, *it));
region_to_metadata_map_->insert(std::make_pair(region_code, *it));
}
map<int, list<string>* >::iterator calling_code_in_map =
country_calling_code_to_region_map.find(country_calling_code);
@ -628,7 +625,7 @@ PhoneNumberUtil::PhoneNumberUtil()
list<string>* list_with_region_code = new list<string>();
list_with_region_code->push_back(region_code);
country_calling_code_to_region_map.insert(
make_pair(country_calling_code, list_with_region_code));
std::make_pair(country_calling_code, list_with_region_code));
}
if (country_calling_code == kNanpaCountryCode) {
nanpa_regions_->insert(region_code);
@ -640,9 +637,9 @@ PhoneNumberUtil::PhoneNumberUtil()
country_calling_code_to_region_map.begin(),
country_calling_code_to_region_map.end());
// Sort all the pairs in ascending order according to country calling code.
sort(country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end(),
OrderByFirst());
std::sort(country_calling_code_to_region_code_map_->begin(),
country_calling_code_to_region_code_map_->end(),
OrderByFirst());
}
PhoneNumberUtil::~PhoneNumberUtil() {


+ 1
- 2
cpp/src/phonenumbers/regexp_cache.cc View File

@ -23,7 +23,6 @@
#include "phonenumbers/base/synchronization/lock.h"
#include "phonenumbers/regexp_adapter.h"
using std::make_pair;
using std::string;
namespace i18n {
@ -53,7 +52,7 @@ const RegExp& RegExpCache::GetRegExp(const string& pattern) {
if (it != cache_impl_->end()) return *it->second;
const RegExp* regexp = regexp_factory_.CreateRegExp(pattern);
cache_impl_->insert(make_pair(pattern, regexp));
cache_impl_->insert(std::make_pair(pattern, regexp));
return *regexp;
}


+ 1
- 2
cpp/src/phonenumbers/shortnumberinfo.cc View File

@ -32,7 +32,6 @@
namespace i18n {
namespace phonenumbers {
using std::make_pair;
using std::map;
using std::string;
@ -59,7 +58,7 @@ ShortNumberInfo::ShortNumberInfo()
it != metadata_collection.metadata().end();
++it) {
const string& region_code = it->id();
region_to_short_metadata_map_->insert(make_pair(region_code, *it));
region_to_short_metadata_map_->insert(std::make_pair(region_code, *it));
}
regions_where_emergency_numbers_must_be_exact_->insert("BR");
regions_where_emergency_numbers_must_be_exact_->insert("CL");


+ 0
- 2
cpp/test/phonenumbers/phonenumberutil_test.cc View File

@ -39,9 +39,7 @@
namespace i18n {
namespace phonenumbers {
using std::endl;
using std::find;
using std::make_pair;
using std::ostream;
using google::protobuf::RepeatedPtrField;


+ 10
- 13
cpp/test/phonenumbers/test_util.cc View File

@ -20,42 +20,39 @@
#include "phonenumbers/phonenumber.pb.h"
#include "phonenumbers/test_util.h"
using std::cout;
using std::endl;
namespace i18n {
namespace phonenumbers {
ostream& operator<<(ostream& os, const PhoneNumber& number) {
os << endl
<< "country_code: " << number.country_code() << endl
<< "national_number: " << number.national_number() << endl;
os << std::endl
<< "country_code: " << number.country_code() << std::endl
<< "national_number: " << number.national_number() << std::endl;
if (number.has_extension()) {
os << "extension: " << number.extension() << endl;
os << "extension: " << number.extension() << std::endl;
}
if (number.has_italian_leading_zero()) {
os << "italian_leading_zero: " << number.italian_leading_zero() << endl;
os << "italian_leading_zero: " << number.italian_leading_zero() << std::endl;
}
if (number.has_raw_input()) {
os << "raw_input: " << number.raw_input() << endl;
os << "raw_input: " << number.raw_input() << std::endl;
}
if (number.has_country_code_source()) {
os << "country_code_source: " << number.country_code_source() << endl;
os << "country_code_source: " << number.country_code_source() << std::endl;
}
if (number.has_preferred_domestic_carrier_code()) {
os << "preferred_domestic_carrier_code: "
<< number.preferred_domestic_carrier_code() << endl;
<< number.preferred_domestic_carrier_code() << std::endl;
}
return os;
}
ostream& operator<<(ostream& os, const vector<PhoneNumber>& numbers) {
os << "[" << endl;
os << "[" << std::endl;
for (vector<PhoneNumber>::const_iterator it = numbers.begin();
it != numbers.end(); ++it) {
os << *it;
}
os << endl << "]" << endl;
os << std::endl << "]" << std::endl;
return os;
}


Loading…
Cancel
Save