Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Unified Diff: third_party/libaddressinput/chromium/cpp/src/address_data.cc

Issue 389863002: Remove Chrome's own version of libaddressinput in favor of the upstream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/cpp/src/address_data.cc
diff --git a/third_party/libaddressinput/chromium/cpp/src/address_data.cc b/third_party/libaddressinput/chromium/cpp/src/address_data.cc
deleted file mode 100644
index a3549ed9b660102d3eb15d6a16ed53c0dc183ed6..0000000000000000000000000000000000000000
--- a/third_party/libaddressinput/chromium/cpp/src/address_data.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (C) 2014 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <libaddressinput/address_data.h>
-
-#include <libaddressinput/address_field.h>
-#include <libaddressinput/util/basictypes.h>
-
-#include <algorithm>
-#include <cassert>
-#include <cstddef>
-#include <functional>
-#include <ostream>
-#include <string>
-#include <vector>
-
-#include <re2/re2.h>
-
-namespace i18n {
-namespace addressinput {
-
-namespace {
-
-// Mapping from AddressField value to pointer to AddressData member.
-std::string AddressData::*kStringField[] = {
- &AddressData::region_code,
- &AddressData::administrative_area,
- &AddressData::locality,
- &AddressData::dependent_locality,
- &AddressData::sorting_code,
- &AddressData::postal_code,
- NULL,
- &AddressData::recipient
-};
-
-// Mapping from AddressField value to pointer to AddressData member.
-const std::vector<std::string> AddressData::*kVectorStringField[] = {
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- &AddressData::address_line,
- NULL
-};
-
-COMPILE_ASSERT(arraysize(kStringField) == arraysize(kVectorStringField),
- field_mapping_array_size_mismatch);
-
-// A string is considered to be "empty" not only if it actually is empty, but
-// also if it contains nothing but whitespace.
-bool IsStringEmpty(const std::string& str) {
- static const RE2 kMatcher("\\S");
- return str.empty() || !RE2::PartialMatch(str, kMatcher);
-}
-
-} // namespace
-
-bool AddressData::IsFieldEmpty(AddressField field) const {
- assert(field >= 0);
- assert(static_cast<size_t>(field) < arraysize(kStringField));
- if (kStringField[field] != NULL) {
- const std::string& value = GetFieldValue(field);
- 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();
- }
-}
-
-const std::string& AddressData::GetFieldValue(
- AddressField field) const {
- assert(field >= 0);
- assert(static_cast<size_t>(field) < arraysize(kStringField));
- assert(kStringField[field] != NULL);
- return this->*kStringField[field];
-}
-
-void AddressData::SetFieldValue(AddressField field, const std::string& value) {
- assert(field >= 0);
- assert(static_cast<size_t>(field) < arraysize(kStringField));
- assert(kStringField[field] != NULL);
- (this->*kStringField[field]).assign(value);
-}
-
-const std::vector<std::string>& AddressData::GetRepeatedFieldValue(
- AddressField field) const {
- assert(IsRepeatedFieldValue(field));
- return this->*kVectorStringField[field];
-}
-
-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;
-}
-
-// static
-bool AddressData::IsRepeatedFieldValue(AddressField field) {
- assert(field >= 0);
- assert(static_cast<size_t>(field) < arraysize(kVectorStringField));
- return kVectorStringField[field] != NULL;
-}
-
-} // namespace addressinput
-} // namespace i18n
-
-std::ostream& operator<<(std::ostream& o,
- const i18n::addressinput::AddressData& address) {
- o << "region_code: \"" << address.region_code << "\"\n"
- "administrative_area: \"" << address.administrative_area << "\"\n"
- "locality: \"" << address.locality << "\"\n"
- "dependent_locality: \"" << address.dependent_locality << "\"\n"
- "postal_code: \"" << address.postal_code << "\"\n"
- "sorting_code: \"" << address.sorting_code << "\"\n";
-
- // TODO: Update the field order in the .h file to match the order they are
- // printed out here, for consistency.
- for (std::vector<std::string>::const_iterator it =
- address.address_line.begin();
- it != address.address_line.end(); ++it) {
- o << "address_line: \"" << *it << "\"\n";
- }
-
- o << "language_code: \"" << address.language_code << "\"\n"
- "recipient: \"" << address.recipient << "\"\n";
-
- return o;
-}

Powered by Google App Engine
This is Rietveld 408576698