OLD | NEW |
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, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // then INVALID_MESSAGE_ID. | 159 // then INVALID_MESSAGE_ID. |
160 int GetInvalidPostalCodeMessageId() const { | 160 int GetInvalidPostalCodeMessageId() const { |
161 return invalid_postal_code_message_id_; | 161 return invalid_postal_code_message_id_; |
162 } | 162 } |
163 | 163 |
164 // Returns the error message string identifier for an invalid |field|. | 164 // Returns the error message string identifier for an invalid |field|. |
165 int GetInvalidFieldMessageId(AddressField field) const; | 165 int GetInvalidFieldMessageId(AddressField field) const; |
166 | 166 |
167 // Outputs the sub key for a given user input. For example, Texas will map to | 167 // Outputs the sub key for a given user input. For example, Texas will map to |
168 // TX. | 168 // TX. |
| 169 // |
| 170 // If |keep_input_latin| is true, then does not convert a latinized region |
| 171 // name into a sub key. For example, tOKYo will change to TOKYO. If |
| 172 // |keep_input_latin| is false, then converts a latinized region name into a |
| 173 // sub key. For example, tOKYo becomes 東京都. |
| 174 // |
| 175 // |sub_key| should not be NULL. |
169 bool CanonicalizeSubKey(const std::string& user_input, | 176 bool CanonicalizeSubKey(const std::string& user_input, |
| 177 bool keep_input_latin, |
170 std::string* sub_key) const; | 178 std::string* sub_key) const; |
171 | 179 |
172 private: | 180 private: |
173 // Finds |target| in |values| and sets |sub_key| to the associated value from | |
174 // |sub_keys_|, or returns false if |target| is not in |values|. | |
175 bool GetMatchingSubKey(const std::string& target, | |
176 const std::vector<std::string>& values, | |
177 std::string* sub_key) const; | |
178 | |
179 std::string key_; | 181 std::string key_; |
180 std::string name_; | 182 std::string name_; |
181 std::string latin_name_; | 183 std::string latin_name_; |
182 std::vector<std::vector<FormatElement> > format_; | 184 std::vector<std::vector<FormatElement> > format_; |
183 std::vector<std::vector<FormatElement> > latin_format_; | 185 std::vector<std::vector<FormatElement> > latin_format_; |
184 std::vector<AddressField> required_; | 186 std::vector<AddressField> required_; |
185 std::vector<std::string> sub_keys_; | 187 std::vector<std::string> sub_keys_; |
186 std::vector<std::string> sub_names_; | 188 std::vector<std::string> sub_names_; |
187 // The Latin names (when |sub_names_| is not in Latin characters). | 189 // The Latin names (when |sub_names_| is not in Latin characters). |
188 std::vector<std::string> sub_lnames_; | 190 std::vector<std::string> sub_lnames_; |
189 std::vector<std::string> languages_; | 191 std::vector<std::string> languages_; |
190 std::vector<std::string> input_languages_; | 192 std::vector<std::string> input_languages_; |
191 std::string language_; | 193 std::string language_; |
192 std::string postal_code_format_; | 194 std::string postal_code_format_; |
193 int admin_area_name_message_id_; | 195 int admin_area_name_message_id_; |
194 int invalid_admin_area_message_id_; | 196 int invalid_admin_area_message_id_; |
195 int postal_code_name_message_id_; | 197 int postal_code_name_message_id_; |
196 int invalid_postal_code_message_id_; | 198 int invalid_postal_code_message_id_; |
197 | 199 |
198 DISALLOW_COPY_AND_ASSIGN(Rule); | 200 DISALLOW_COPY_AND_ASSIGN(Rule); |
199 }; | 201 }; |
200 | 202 |
201 } // namespace addressinput | 203 } // namespace addressinput |
202 } // namespace i18n | 204 } // namespace i18n |
203 | 205 |
204 #endif // I18N_ADDRESSINPUT_RULE_H_ | 206 #endif // I18N_ADDRESSINPUT_RULE_H_ |
OLD | NEW |