diff options
author | roubert@google.com <roubert@google.com@38ededc0-08b8-5190-f2ac-b31f878777ad> | 2014-07-22 18:07:42 +0000 |
---|---|---|
committer | roubert@google.com <roubert@google.com@38ededc0-08b8-5190-f2ac-b31f878777ad> | 2014-07-22 18:07:42 +0000 |
commit | 000aa6dbb70273ccefa77a5d4cd1a400939a2666 (patch) | |
tree | 5fdc12751d64ef97855ecd3debb979089a95acbd | |
parent | f02f934fdc353f6f4c13e1d282239e1238ab6a2d (diff) | |
download | src-000aa6dbb70273ccefa77a5d4cd1a400939a2666.tar.gz |
Improved code formatting.
These changes were created using the clang-format tool, and then
manually selecting from the changes made by the tool.
R=rouslan@chromium.org
BUG=
Review URL: https://codereview.appspot.com/118080043
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@314 38ededc0-08b8-5190-f2ac-b31f878777ad
-rw-r--r-- | cpp/src/address_data.cc | 24 | ||||
-rw-r--r-- | cpp/src/address_formatter.cc | 6 | ||||
-rw-r--r-- | cpp/src/address_input_helper.cc | 2 | ||||
-rw-r--r-- | cpp/src/address_ui.cc | 12 | ||||
-rw-r--r-- | cpp/src/language.cc | 8 | ||||
-rw-r--r-- | cpp/src/lookup_key.cc | 5 | ||||
-rw-r--r-- | cpp/src/post_box_matchers.cc | 2 | ||||
-rw-r--r-- | cpp/src/region_data_builder.cc | 27 | ||||
-rw-r--r-- | cpp/src/region_data_constants.cc | 6 | ||||
-rw-r--r-- | cpp/src/rule.h | 8 | ||||
-rw-r--r-- | cpp/src/util/json.cc | 4 | ||||
-rw-r--r-- | cpp/src/validating_util.cc | 2 | ||||
-rw-r--r-- | cpp/src/validation_task.cc | 5 | ||||
-rw-r--r-- | cpp/src/validation_task.h | 6 | ||||
-rw-r--r-- | cpp/test/address_input_helper_test.cc | 12 | ||||
-rw-r--r-- | cpp/test/address_normalizer_test.cc | 1 | ||||
-rw-r--r-- | cpp/test/address_validator_test.cc | 4 | ||||
-rw-r--r-- | cpp/test/fake_downloader.cc | 5 | ||||
-rw-r--r-- | cpp/test/ondemand_supply_task_test.cc | 8 | ||||
-rw-r--r-- | cpp/test/supplier_test.cc | 4 | ||||
-rw-r--r-- | cpp/test/validating_storage_test.cc | 2 |
21 files changed, 73 insertions, 80 deletions
diff --git a/cpp/src/address_data.cc b/cpp/src/address_data.cc index a3549ed..644000e 100644 --- a/cpp/src/address_data.cc +++ b/cpp/src/address_data.cc @@ -76,9 +76,9 @@ bool AddressData::IsFieldEmpty(AddressField field) const { return IsStringEmpty(value); } else { const std::vector<std::string>& value = GetRepeatedFieldValue(field); - return std::find_if(value.begin(), value.end(), - std::not1(std::ptr_fun(&IsStringEmpty))) == - value.end(); + return std::find_if(value.begin(), + value.end(), + std::not1(std::ptr_fun(&IsStringEmpty))) == value.end(); } } @@ -104,16 +104,14 @@ const std::vector<std::string>& AddressData::GetRepeatedFieldValue( } bool AddressData::operator==(const AddressData& other) const { - return - region_code == other.region_code && - address_line == other.address_line && - administrative_area == other.administrative_area && - locality == other.locality && - dependent_locality == other.dependent_locality && - postal_code == other.postal_code && - sorting_code == other.sorting_code && - language_code == other.language_code && - recipient == other.recipient; + return region_code == other.region_code && + address_line == other.address_line && + administrative_area == other.administrative_area && + locality == other.locality && + dependent_locality == other.dependent_locality && + postal_code == other.postal_code && + sorting_code == other.sorting_code && + language_code == other.language_code && recipient == other.recipient; } // static diff --git a/cpp/src/address_formatter.cc b/cpp/src/address_formatter.cc index 3440288..b866b8d 100644 --- a/cpp/src/address_formatter.cc +++ b/cpp/src/address_formatter.cc @@ -143,7 +143,8 @@ void GetFormattedNationalAddress( // explicitly tagged as being Latin, then use the latinized formatting rules. const std::vector<FormatElement>& format = language.has_latin_script && !rule.GetLatinFormat().empty() - ? rule.GetLatinFormat() : rule.GetFormat(); + ? rule.GetLatinFormat() + : rule.GetFormat(); std::string line; for (size_t i = 0; i < format.size(); ++i) { @@ -162,7 +163,8 @@ void GetFormattedNationalAddress( lines->push_back(line); line.clear(); } - lines->insert(lines->end(), address_data.address_line.begin(), + lines->insert(lines->end(), + address_data.address_line.begin(), address_data.address_line.end()); } else { line.append(address_data.GetFieldValue(field)); diff --git a/cpp/src/address_input_helper.cc b/cpp/src/address_input_helper.cc index 39a6264..c492760 100644 --- a/cpp/src/address_input_helper.cc +++ b/cpp/src/address_input_helper.cc @@ -99,7 +99,7 @@ void FillAddressFromMatchedRules( AddressInputHelper::AddressInputHelper(PreloadSupplier* supplier) : supplier_(supplier) { - assert(supplier_ != NULL); + assert(supplier_ != NULL); } AddressInputHelper::~AddressInputHelper() { diff --git a/cpp/src/address_ui.cc b/cpp/src/address_ui.cc index 06baac5..bf76cfd 100644 --- a/cpp/src/address_ui.cc +++ b/cpp/src/address_ui.cc @@ -98,9 +98,9 @@ std::vector<AddressUiComponent> BuildComponents( *best_address_language_tag = best_address_language.tag; const std::vector<FormatElement>& format = - !rule.GetLatinFormat().empty() && - best_address_language.has_latin_script - ? rule.GetLatinFormat() : rule.GetFormat(); + !rule.GetLatinFormat().empty() && best_address_language.has_latin_script + ? rule.GetLatinFormat() + : rule.GetFormat(); // For avoiding showing an input field twice, when the field is displayed // twice on an envelope. @@ -126,8 +126,10 @@ std::vector<AddressUiComponent> BuildComponents( : AddressUiComponent::HINT_SHORT; preceded_by_newline = false; component.field = format_it->GetField(); - component.name = GetLabelForField(localization, format_it->GetField(), - rule.GetAdminAreaNameMessageId(), rule.GetPostalCodeNameMessageId()); + component.name = GetLabelForField(localization, + format_it->GetField(), + rule.GetAdminAreaNameMessageId(), + rule.GetPostalCodeNameMessageId()); result.push_back(component); } diff --git a/cpp/src/language.cc b/cpp/src/language.cc index 9e456f0..28817dc 100644 --- a/cpp/src/language.cc +++ b/cpp/src/language.cc @@ -32,13 +32,13 @@ Language::Language(const std::string& language_tag) : tag(language_tag), // legacy code generates tags with '_' instead of '-'. static const char kSubtagsSeparator = '-'; static const char kAlternativeSubtagsSeparator = '_'; - std::replace(tag.begin(), tag.end(), kAlternativeSubtagsSeparator, - kSubtagsSeparator); + std::replace( + tag.begin(), tag.end(), kAlternativeSubtagsSeparator, kSubtagsSeparator); // OK to use 'tolower' because BCP 47 tags are always in ASCII. std::string lowercase = tag; - std::transform(lowercase.begin(), lowercase.end(), lowercase.begin(), - tolower); + std::transform( + lowercase.begin(), lowercase.end(), lowercase.begin(), tolower); base = lowercase.substr(0, lowercase.find(kSubtagsSeparator)); diff --git a/cpp/src/lookup_key.cc b/cpp/src/lookup_key.cc index acde828..d793a2b 100644 --- a/cpp/src/lookup_key.cc +++ b/cpp/src/lookup_key.cc @@ -98,8 +98,9 @@ void LookupKey::FromAddress(const AddressData& address) { } } Language address_language(address.language_code); - std::string language_tag_no_latn = address_language.has_latin_script ? - address_language.base : address_language.tag; + std::string language_tag_no_latn = address_language.has_latin_script + ? address_language.base + : address_language.tag; if (ShouldSetLanguageForKey(language_tag_no_latn, address.region_code)) { language_ = language_tag_no_latn; } diff --git a/cpp/src/post_box_matchers.cc b/cpp/src/post_box_matchers.cc index e8628b5..f1ad6dd 100644 --- a/cpp/src/post_box_matchers.cc +++ b/cpp/src/post_box_matchers.cc @@ -97,7 +97,7 @@ std::map<std::string, const RE2ptr*> InitMatchers() { return matchers; } -} // namespace +} // namespace // static std::vector<const RE2ptr*> PostBoxMatchers::GetMatchers( diff --git a/cpp/src/region_data_builder.cc b/cpp/src/region_data_builder.cc index 82d223c..cf49c71 100644 --- a/cpp/src/region_data_builder.cc +++ b/cpp/src/region_data_builder.cc @@ -59,8 +59,8 @@ void BuildRegionTreeRecursively(PreloadSupplier* supplier, ? rule->GetLatinName() : local_name; RegionData* region = parent_region->AddSubRegion(*key_it, name); if (!rule->GetSubKeys().empty()) { - BuildRegionTreeRecursively(supplier, lookup_key, region, - rule->GetSubKeys(), prefer_latin_name); + BuildRegionTreeRecursively( + supplier, lookup_key, region, rule->GetSubKeys(), prefer_latin_name); } } } @@ -82,8 +82,11 @@ RegionData* BuildRegion(PreloadSupplier* supplier, assert(rule != NULL); RegionData* region = new RegionData(region_code); - BuildRegionTreeRecursively(supplier, lookup_key, region, - rule->GetSubKeys(), language.has_latin_script); + BuildRegionTreeRecursively(supplier, + lookup_key, + region, + rule->GetSubKeys(), + language.has_latin_script); return region; } @@ -127,17 +130,21 @@ const RegionData& RegionDataBuilder::Build( Rule rule; rule.ParseSerializedRule(RegionDataConstants::GetRegionData(region_code)); static const Language kUndefinedLanguage("und"); - const Language& best_language = rule.GetLanguages().empty() - ? kUndefinedLanguage - : ChooseBestAddressLanguage(rule, Language(ui_language_tag)); + const Language& best_language = + rule.GetLanguages().empty() + ? kUndefinedLanguage + : ChooseBestAddressLanguage(rule, Language(ui_language_tag)); *best_region_tree_language_tag = best_language.tag; LanguageRegionMap::const_iterator language_it = region_it->second->find(best_language.tag); if (language_it == region_it->second->end()) { - language_it = region_it->second->insert(std::make_pair( - best_language.tag, - BuildRegion(supplier_, region_code, best_language))).first; + language_it = + region_it->second->insert(std::make_pair(best_language.tag, + BuildRegion(supplier_, + region_code, + best_language))) + .first; } return *language_it->second; diff --git a/cpp/src/region_data_constants.cc b/cpp/src/region_data_constants.cc index 1dce6c3..3557536 100644 --- a/cpp/src/region_data_constants.cc +++ b/cpp/src/region_data_constants.cc @@ -1397,8 +1397,10 @@ struct SelectFirst { std::vector<std::string> InitRegionCodes() { std::vector<std::string> region_codes(GetAllRegionData().size()); - std::transform(GetAllRegionData().begin(), GetAllRegionData().end(), - region_codes.begin(), SelectFirst()); + std::transform(GetAllRegionData().begin(), + GetAllRegionData().end(), + region_codes.begin(), + SelectFirst()); return region_codes; } diff --git a/cpp/src/rule.h b/cpp/src/rule.h index 10615f4..1286bcb 100644 --- a/cpp/src/rule.h +++ b/cpp/src/rule.h @@ -98,9 +98,7 @@ class Rule { } // Returns the sole postal code for this rule, if there is one. - const std::string& GetSolePostalCode() const { - return sole_postal_code_; - } + const std::string& GetSolePostalCode() const { return sole_postal_code_; } // The message string identifier for admin area name. If not set, then // INVALID_MESSAGE_ID. @@ -126,9 +124,7 @@ class Rule { } // Returns the post service URL string for this rule. - const std::string& GetPostServiceUrl() const { - return post_service_url_; - } + const std::string& GetPostServiceUrl() const { return post_service_url_; } private: std::string id_; diff --git a/cpp/src/util/json.cc b/cpp/src/util/json.cc index 352c62b..4f26069 100644 --- a/cpp/src/util/json.cc +++ b/cpp/src/util/json.cc @@ -85,9 +85,7 @@ class Json::JsonImpl { (void)inserted; } - const std::vector<std::string>& GetKeys() const { - return keys_; - } + const std::vector<std::string>& GetKeys() const { return keys_; } private: void BuildKeyList() { diff --git a/cpp/src/validating_util.cc b/cpp/src/validating_util.cc index df3fc06..084c09c 100644 --- a/cpp/src/validating_util.cc +++ b/cpp/src/validating_util.cc @@ -111,7 +111,7 @@ bool ValidatingUtil::UnwrapTimestamp(std::string* data, time_t now) { std::string timestamp_string; if (!UnwrapHeader( - kTimestampPrefix, kTimestampPrefixLength, data, ×tamp_string)) { + kTimestampPrefix, kTimestampPrefixLength, data, ×tamp_string)) { return false; } diff --git a/cpp/src/validation_task.cc b/cpp/src/validation_task.cc index 074847b..727de6a 100644 --- a/cpp/src/validation_task.cc +++ b/cpp/src/validation_task.cc @@ -256,9 +256,10 @@ void ValidationTask::ReportProblemMaybe(AddressField field, bool ValidationTask::ShouldReport(AddressField field, AddressProblem problem) const { return filter_ == NULL || filter_->empty() || - std::find(filter_->begin(), filter_->end(), + std::find(filter_->begin(), + filter_->end(), FieldProblemMap::value_type(field, problem)) != - filter_->end(); + filter_->end(); } } // namespace addressinput diff --git a/cpp/src/validation_task.h b/cpp/src/validation_task.h index 5ab1b8f..1658678 100644 --- a/cpp/src/validation_task.h +++ b/cpp/src/validation_task.h @@ -65,16 +65,14 @@ class ValidationTask { void CheckMissingRequiredField(const std::string& region_code) const; // Checks the hierarchical fields for UNKNOWN_VALUE problems. - void CheckUnknownValue( - const Supplier::RuleHierarchy& hierarchy) const; + void CheckUnknownValue(const Supplier::RuleHierarchy& hierarchy) const; // Checks the POSTAL_CODE field for problems. void CheckPostalCodeFormatAndValue( const Supplier::RuleHierarchy& hierarchy) const; // Checks the STREET_ADDRESS field for USES_P_O_BOX problems. - void CheckUsesPoBox( - const Supplier::RuleHierarchy& hierarchy) const; + void CheckUsesPoBox(const Supplier::RuleHierarchy& hierarchy) const; // Writes (|field|,|problem|) to |problems_|. void ReportProblem(AddressField field, AddressProblem problem) const; diff --git a/cpp/test/address_input_helper_test.cc b/cpp/test/address_input_helper_test.cc index bb683da..5580ec7 100644 --- a/cpp/test/address_input_helper_test.cc +++ b/cpp/test/address_input_helper_test.cc @@ -65,9 +65,7 @@ class AddressInputHelperTest : public testing::Test { private: // Used to preload data that we need. - void Loaded(bool success, const std::string&, int) { - ASSERT_TRUE(success); - } + void Loaded(bool success, const std::string&, int) { ASSERT_TRUE(success); } PreloadSupplier supplier_; const AddressInputHelper address_input_helper_; @@ -194,8 +192,8 @@ TEST_F(AddressInputHelperTest, AddressWithPostalCodeMatchingMultipleValues) { address.postal_code = "527-111"; AddressData expected = address; - /* The province, Jeonnam - 전라남도 - is known, but we have several locality - * matches so none of them are populated. */ + /* The province, Jeonnam - 전라남도 - is known, but we have several locality + * matches so none of them are populated. */ expected.administrative_area = "\xEC\xA0\x84\xEB\x9D\xBC\xEB\x82\xA8\xEB\x8F\x84"; FillAddress(&address); @@ -271,9 +269,7 @@ class AddressInputHelperMockDataTest : public testing::Test { private: // Our mock downloader we assume will always succeed. - void Loaded(bool success, const std::string&, int) { - ASSERT_TRUE(success); - } + void Loaded(bool success, const std::string&, int) { ASSERT_TRUE(success); } PreloadSupplier supplier_; const AddressInputHelper address_input_helper_; diff --git a/cpp/test/address_normalizer_test.cc b/cpp/test/address_normalizer_test.cc index 4253867..c4ffeba 100644 --- a/cpp/test/address_normalizer_test.cc +++ b/cpp/test/address_normalizer_test.cc @@ -93,7 +93,6 @@ TEST_F(AddressNormalizerTest, GangwonKoreanName) { EXPECT_EQ("강원도", address.administrative_area); } - TEST_F(AddressNormalizerTest, DontSwitchLatinScriptForUnknownLanguage) { supplier_.LoadRules("KR", *loaded_); AddressData address; diff --git a/cpp/test/address_validator_test.cc b/cpp/test/address_validator_test.cc index fce9777..b90eef9 100644 --- a/cpp/test/address_validator_test.cc +++ b/cpp/test/address_validator_test.cc @@ -132,9 +132,7 @@ class PreloadValidatorWrapper : public ValidatorWrapper { validator_(&supplier_), loaded_(BuildCallback(this, &PreloadValidatorWrapper::Loaded)) {} - void Loaded(bool success, const std::string&, int) { - ASSERT_TRUE(success); - } + void Loaded(bool success, const std::string&, int) { ASSERT_TRUE(success); } PreloadSupplier supplier_; const AddressValidator validator_; diff --git a/cpp/test/fake_downloader.cc b/cpp/test/fake_downloader.cc index 2f18db7..ae16b77 100644 --- a/cpp/test/fake_downloader.cc +++ b/cpp/test/fake_downloader.cc @@ -101,8 +101,9 @@ std::map<std::string, std::string> InitData() { kDataKeyPrefixLength) == 0) { // Example aggregate URL: // test:///aggregate/data/CH - const std::string& aggregate_url = GetAggregateLookupKeyUtil() - .GetUrlForKey(key.substr(0, kAggregateDataKeyLength)); + const std::string& aggregate_url = + GetAggregateLookupKeyUtil().GetUrlForKey( + key.substr(0, kAggregateDataKeyLength)); std::map<std::string, std::string>::iterator aggregate_data_it = data.find(aggregate_url); diff --git a/cpp/test/ondemand_supply_task_test.cc b/cpp/test/ondemand_supply_task_test.cc index 84b2f65..64f55d0 100644 --- a/cpp/test/ondemand_supply_task_test.cc +++ b/cpp/test/ondemand_supply_task_test.cc @@ -67,13 +67,9 @@ class OndemandSupplyTaskTest : public testing::Test { } } - void Queue(const std::string& key) { - task_->Queue(key); - } + void Queue(const std::string& key) { task_->Queue(key); } - void Retrieve() { - task_->Retrieve(*retriever_); - } + void Retrieve() { task_->Retrieve(*retriever_); } bool success_; // Expected status from MockDownloader. LookupKey lookup_key_; // Stub. diff --git a/cpp/test/supplier_test.cc b/cpp/test/supplier_test.cc index c51c5f7..f1e2704 100644 --- a/cpp/test/supplier_test.cc +++ b/cpp/test/supplier_test.cc @@ -112,9 +112,7 @@ class PreloadSupplierWrapper : public SupplierWrapper { new NullStorage), loaded_(BuildCallback(this, &PreloadSupplierWrapper::Loaded)) {} - void Loaded(bool success, const std::string&, int) { - ASSERT_TRUE(success); - } + void Loaded(bool success, const std::string&, int) { ASSERT_TRUE(success); } PreloadSupplier preload_supplier_; const scoped_ptr<const PreloadSupplier::Callback> loaded_; diff --git a/cpp/test/validating_storage_test.cc b/cpp/test/validating_storage_test.cc index f1be1cf..36f85d9 100644 --- a/cpp/test/validating_storage_test.cc +++ b/cpp/test/validating_storage_test.cc @@ -46,7 +46,7 @@ const char kStaleWrappedData[] = "timestamp=" OLD_TIMESTAMP "\n" const char kEmptyData[] = ""; // Tests for ValidatingStorage object. -class ValidatingStorageTest : public testing::Test { +class ValidatingStorageTest : public testing::Test { protected: ValidatingStorageTest() : wrapped_storage_(new FakeStorage), |