Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / libaddressinput / src / cpp / include / libaddressinput / address_data.h
1 // Copyright (C) 2014 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // A struct for storing address data: country code, administrative area,
16 // locality, etc. The field names correspond to the OASIS xAL standard:
17 // https://www.oasis-open.org/committees/ciq/download.shtml
18
19 #ifndef I18N_ADDRESSINPUT_ADDRESS_DATA_H_
20 #define I18N_ADDRESSINPUT_ADDRESS_DATA_H_
21
22 #include <libaddressinput/address_field.h>
23
24 #include <iosfwd>
25 #include <string>
26 #include <vector>
27
28 namespace i18n {
29 namespace addressinput {
30
31 struct AddressData {
32   // CLDR (Common Locale Data Repository) region code.
33   std::string region_code;
34
35   // The address lines represent the most specific part of any address.
36   std::vector<std::string> address_line;
37
38   // Top-level administrative subdivision of this country.
39   std::string administrative_area;
40
41   // Generally refers to the city/town portion of an address.
42   std::string locality;
43
44   // Dependent locality or sublocality. Used for UK dependent localities, or
45   // neighborhoods or boroughs in other locations.
46   std::string dependent_locality;
47
48   // Values are frequently alphanumeric.
49   std::string postal_code;
50
51   // This corresponds to the SortingCode sub-element of the xAL
52   // PostalServiceElements element. Use is very country-specific.
53   std::string sorting_code;
54
55   // Language code of the address. Should be in BCP-47 format.
56   std::string language_code;
57
58   // The organization, firm, company, or institution at this address. This
59   // corresponds to the FirmName sub-element of the xAL FirmType element.
60   std::string organization;
61
62   // Name of recipient or contact person. Not present in xAL.
63   std::string recipient;
64
65   // Returns whether the |field| is empty.
66   bool IsFieldEmpty(AddressField field) const;
67
68   // Returns the value of the |field|. The parameter must not be STREET_ADDRESS,
69   // which comprises multiple fields (will crash otherwise).
70   const std::string& GetFieldValue(AddressField field) const;
71
72   // Copies |value| into the |field|. The parameter must not be STREET_ADDRESS,
73   // which comprises multiple fields (will crash otherwise).
74   void SetFieldValue(AddressField field, const std::string& value);
75
76   // Returns the value of the |field|. The parameter must be STREET_ADDRESS,
77   // which comprises multiple fields (will crash otherwise).
78   const std::vector<std::string>& GetRepeatedFieldValue(
79       AddressField field) const;
80
81   bool operator==(const AddressData& other) const;
82
83   // Returns true if the parameter comprises multiple fields, false otherwise.
84   // Use it to determine whether to call |GetFieldValue| or
85   // |GetRepeatedFieldValue|.
86   static bool IsRepeatedFieldValue(AddressField field);
87 };
88
89 }  // namespace addressinput
90 }  // namespace i18n
91
92 // Produces human-readable output in logging, for example in unit tests.
93 std::ostream& operator<<(std::ostream& o,
94                          const i18n::addressinput::AddressData& address);
95
96 #endif  // I18N_ADDRESSINPUT_ADDRESS_DATA_H_