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

Side by Side Diff: third_party/libaddressinput/chromium/cpp/src/rule.h

Issue 140823005: [rac] Download country code data in a single HTTP request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Temporarily switch to staging URL. Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (C) 2013 Google Inc. 1 // Copyright (C) 2013 Google Inc.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 // 14 //
15 // An object to store validation rules. 15 // An object to store validation rules.
16 16
17 #ifndef I18N_ADDRESSINPUT_RULE_H_ 17 #ifndef I18N_ADDRESSINPUT_RULE_H_
18 #define I18N_ADDRESSINPUT_RULE_H_ 18 #define I18N_ADDRESSINPUT_RULE_H_
19 19
20 #include <libaddressinput/address_field.h> 20 #include <libaddressinput/address_field.h>
21 #include <libaddressinput/util/basictypes.h> 21 #include <libaddressinput/util/basictypes.h>
22 22
23 #include <string> 23 #include <string>
24 #include <vector> 24 #include <vector>
25 25
26 namespace i18n { 26 namespace i18n {
27 namespace addressinput { 27 namespace addressinput {
28 28
29 class Json;
30
29 // Stores an element in the format of an address as it should be displayed on an 31 // Stores an element in the format of an address as it should be displayed on an
30 // envelope. The element can be either a literal string, like " ", or a field, 32 // envelope. The element can be either a literal string, like " ", or a field,
31 // like ADMIN_AREA. 33 // like ADMIN_AREA.
32 struct FormatElement { 34 struct FormatElement {
33 // Builds an element of address format for |field|. 35 // Builds an element of address format for |field|.
34 explicit FormatElement(AddressField field); 36 explicit FormatElement(AddressField field);
35 37
36 // Builds an element of address format for |literal|. The literal should not 38 // Builds an element of address format for |literal|. The literal should not
37 // be empty. 39 // be empty.
38 explicit FormatElement(const std::string& literal); 40 explicit FormatElement(const std::string& literal);
(...skipping 29 matching lines...) Expand all
68 // instead. 70 // instead.
69 static const Rule& GetDefault(); 71 static const Rule& GetDefault();
70 72
71 // Copies all data from |rule|. 73 // Copies all data from |rule|.
72 void CopyFrom(const Rule& rule); 74 void CopyFrom(const Rule& rule);
73 75
74 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid 76 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid
75 // format (JSON dictionary). 77 // format (JSON dictionary).
76 bool ParseSerializedRule(const std::string& serialized_rule); 78 bool ParseSerializedRule(const std::string& serialized_rule);
77 79
80 // Parses |json_rule|, which must contain parsed serialized rule.
81 void ParseJsonRule(const Json& json_rule);
82
78 // Returns the format of the address as it should appear on an envelope. 83 // Returns the format of the address as it should appear on an envelope.
79 const std::vector<std::vector<FormatElement> >& GetFormat() const { 84 const std::vector<std::vector<FormatElement> >& GetFormat() const {
80 return format_; 85 return format_;
81 } 86 }
82 87
83 // Returns the required fields for this rule. 88 // Returns the required fields for this rule.
84 const std::vector<AddressField>& GetRequired() const { return required_; } 89 const std::vector<AddressField>& GetRequired() const { return required_; }
85 90
86 // Returns the sub-keys for this rule, which are the administrative areas of a 91 // Returns the sub-keys for this rule, which are the administrative areas of a
87 // country, the localities of an administrative area, or the dependent 92 // country, the localities of an administrative area, or the dependent
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 int postal_code_name_message_id_; 141 int postal_code_name_message_id_;
137 int invalid_postal_code_message_id_; 142 int invalid_postal_code_message_id_;
138 143
139 DISALLOW_COPY_AND_ASSIGN(Rule); 144 DISALLOW_COPY_AND_ASSIGN(Rule);
140 }; 145 };
141 146
142 } // namespace addressinput 147 } // namespace addressinput
143 } // namespace i18n 148 } // namespace i18n
144 149
145 #endif // I18N_ADDRESSINPUT_RULE_H_ 150 #endif // I18N_ADDRESSINPUT_RULE_H_
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/cpp/src/retriever.h ('k') | third_party/libaddressinput/chromium/cpp/src/rule.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698