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

Unified Diff: third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h

Issue 368243007: Reland of "Use address_data.h from upstream libaddressinput". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update BUILD.gn, fix a test. 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/include/libaddressinput/address_data.h
diff --git a/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h b/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h
index 9638b91520601c7d85aaa146748d1d3c6a37d656..e2d057a09bba1e059b4fcec0e0356cd762051a4c 100644
--- a/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h
+++ b/third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2013 Google Inc.
+// 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.
@@ -12,93 +12,81 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-// An object to store a single address: country code, administrative area,
-// locality, etc. The field names correspond to OASIS xAL standard:
-// https://www.oasis-open.org/committees/ciq/Downloads/ciq_html_docs.zip
+// A struct for storing address data: country code, administrative area,
+// locality, etc. The field names correspond to the OASIS xAL standard:
+// https://www.oasis-open.org/committees/ciq/download.shtml
#ifndef I18N_ADDRESSINPUT_ADDRESS_DATA_H_
#define I18N_ADDRESSINPUT_ADDRESS_DATA_H_
#include <libaddressinput/address_field.h>
+#include <iosfwd>
#include <string>
#include <vector>
namespace i18n {
namespace addressinput {
-// Stores an address. Sample usage:
-// AddressData address;
-// address.recipient = "Chen-Kang Yang";
-// address.address_lines.push_back("1098 Alta Ave");
-// address.administrative_area = "CA";
-// address.locality = "Mountain View";
-// address.postal_code = "94043";
-// address.country_code = "US";
-// address.language_code = "en";
-// Process(address);
struct AddressData {
- // Clears |lines| and populates it with the lines of the address as they
- // should appear on an envelope for |country_code|. The |lines| parameter
- // should not be NULL.
- //
- // If there're no address formatting rules for |country_code|, then the
- // default rules are used:
- // https://i18napis.appspot.com/ssl-address/data/ZZ
- void FormatForDisplay(std::vector<std::string>* lines) const;
-
- // Returns the value of the |field|. The parameter should not be
- // STREET_ADDRESS, which comprises multiple fields.
- const std::string& GetFieldValue(AddressField field) const;
-
- // Sets the |field| to |value|. The parameter should not be STREET_ADDRESS,
- // which comprises multiple fields.
- void SetFieldValue(AddressField field, const std::string& value);
-
- // Returns true if all required fields are present (non-empty).
- bool HasAllRequiredFields() const;
-
- // The BCP 47 language code used to guide how the address is formatted for
- // display. The same address may have different representations in different
- // languages.
- // For example, the French name of "New Mexico" is "Nouveau-Mexique".
- std::string language_code;
+ // CLDR (Common Locale Data Repository) region code.
+ std::string region_code;
- // The uppercase CLDR country/region code.
- // For example, "US" for United States.
- // (Note: Use "GB", not "UK", for Great Britain.)
- std::string country_code;
+ // The address lines represent the most specific part of any address.
+ std::vector<std::string> address_line;
// Top-level administrative subdivision of this country.
- // Examples: US state, IT region, UK constituent nation, JP prefecture.
std::string administrative_area;
// Generally refers to the city/town portion of an address.
- // Examples: US city, IT comune, UK post town.
std::string locality;
// Dependent locality or sublocality. Used for UK dependent localities, or
// neighborhoods or boroughs in other locations.
std::string dependent_locality;
- // Identifies recipients of large volumes of mail. Used in only a few
- // countries.
- // Examples: FR CEDEX.
- std::string sorting_code;
-
- // The alphanumeric value generally assigned to geographical areas, but
- // sometimes also assigned to individual addresses.
- // Examples: "94043", "94043-1351", "SW1W", "SW1W 9TQ".
+ // Values are frequently alphanumeric.
std::string postal_code;
- // The free format street address lines.
- std::vector<std::string> address_lines;
+ // This corresponds to the SortingCode sub-element of the xAL
+ // PostalServiceElements element. Use is very country-specific.
+ std::string sorting_code;
+
+ // Language code of the address. Should be in BCP-47 format.
+ std::string language_code;
- // The name of the recipient or contact person. Not present in xAL.
+ // Name of recipient or contact person. Not present in xAL.
std::string recipient;
+
+ // Returns whether the |field| is empty.
+ bool IsFieldEmpty(AddressField field) const;
+
+ // Returns the value of the |field|. The parameter must not be STREET_ADDRESS,
+ // which comprises multiple fields (will crash otherwise).
+ const std::string& GetFieldValue(AddressField field) const;
+
+ // Copies |value| into the |field|. The parameter must not be STREET_ADDRESS,
+ // which comprises multiple fields (will crash otherwise).
+ void SetFieldValue(AddressField field, const std::string& value);
+
+ // Returns the value of the |field|. The parameter must be STREET_ADDRESS,
+ // which comprises multiple fields (will crash otherwise).
+ const std::vector<std::string>& GetRepeatedFieldValue(
+ AddressField field) const;
+
+ bool operator==(const AddressData& other) const;
+
+ // Returns true if the parameter comprises multiple fields, false otherwise.
+ // Use it to determine whether to call |GetFieldValue| or
+ // |GetRepeatedFieldValue|.
+ static bool IsRepeatedFieldValue(AddressField field);
};
} // namespace addressinput
} // namespace i18n
+// Produces human-readable output in logging, for example in unit tests.
+std::ostream& operator<<(std::ostream& o,
+ const i18n::addressinput::AddressData& address);
+
#endif // I18N_ADDRESSINPUT_ADDRESS_DATA_H_

Powered by Google App Engine
This is Rietveld 408576698