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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 case DEPENDENT_LOCALITY: | 369 case DEPENDENT_LOCALITY: |
370 return IDS_LIBADDRESSINPUT_I18N_INVALID_DEPENDENT_LOCALITY_LABEL; | 370 return IDS_LIBADDRESSINPUT_I18N_INVALID_DEPENDENT_LOCALITY_LABEL; |
371 case POSTAL_CODE: | 371 case POSTAL_CODE: |
372 return invalid_postal_code_message_id_; | 372 return invalid_postal_code_message_id_; |
373 default: | 373 default: |
374 return IDS_LIBADDRESSINPUT_I18N_INVALID_ENTRY; | 374 return IDS_LIBADDRESSINPUT_I18N_INVALID_ENTRY; |
375 } | 375 } |
376 } | 376 } |
377 | 377 |
378 bool Rule::CanonicalizeSubKey(const std::string& user_input, | 378 bool Rule::CanonicalizeSubKey(const std::string& user_input, |
379 bool canonicalize_latin_name, | |
Evan Stade
2014/04/16 21:55:46
|canonicalize_latin_name| is not quite optimal imo
please use gerrit instead
2014/04/16 22:53:27
Done.
| |
379 std::string* sub_key) const { | 380 std::string* sub_key) const { |
381 assert(sub_key != NULL); | |
382 | |
380 if (sub_keys_.empty()) { | 383 if (sub_keys_.empty()) { |
381 *sub_key = user_input; | 384 *sub_key = user_input; |
382 return true; | 385 return true; |
383 } | 386 } |
384 | 387 |
385 return GetMatchingSubKey(user_input, sub_keys_, sub_key) || | 388 return GetMatchingSubKey(user_input, sub_keys_, sub_key) || |
386 GetMatchingSubKey(user_input, sub_names_, sub_key) || | 389 GetMatchingSubKey(user_input, sub_names_, sub_key) || |
387 GetMatchingSubKey(user_input, sub_lnames_, sub_key); | 390 (canonicalize_latin_name && |
391 GetMatchingSubKey(user_input, sub_lnames_, sub_key)) || | |
392 GetMatchingValue(user_input, sub_lnames_, sub_key); | |
388 } | 393 } |
389 | 394 |
390 bool Rule::GetMatchingSubKey(const std::string& target, | 395 bool Rule::GetMatchingSubKey(const std::string& target, |
Evan Stade
2014/04/16 21:55:46
seems like GetMatchingSubKey and GetMatchingValue
please use gerrit instead
2014/04/16 22:53:27
Done.
| |
391 const std::vector<std::string>& values, | 396 const std::vector<std::string>& values, |
392 std::string* sub_key) const { | 397 std::string* sub_key) const { |
398 assert(sub_key != NULL); | |
393 for (size_t i = 0; i < values.size(); ++i) { | 399 for (size_t i = 0; i < values.size(); ++i) { |
394 if (LooseStringCompare(values[i], target)) { | 400 if (LooseStringCompare(values[i], target)) { |
395 *sub_key = sub_keys_[i]; | 401 *sub_key = sub_keys_[i]; |
396 return true; | 402 return true; |
397 } | 403 } |
398 } | 404 } |
399 return false; | 405 return false; |
400 } | 406 } |
401 | 407 |
408 bool Rule::GetMatchingValue(const std::string& target, | |
409 const std::vector<std::string>& values, | |
410 std::string* value) const { | |
411 assert(value != NULL); | |
412 for (size_t i = 0; i < values.size(); ++i) { | |
413 if (LooseStringCompare(values[i], target)) { | |
414 *value = values[i]; | |
415 return true; | |
416 } | |
417 } | |
418 return false; | |
419 } | |
420 | |
402 } // namespace addressinput | 421 } // namespace addressinput |
403 } // namespace i18n | 422 } // namespace i18n |
OLD | NEW |