Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 void CopyFrom(const Rule& rule); | 45 void CopyFrom(const Rule& rule); |
| 46 | 46 |
| 47 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid | 47 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid |
| 48 // format (JSON dictionary). | 48 // format (JSON dictionary). |
| 49 bool ParseSerializedRule(const std::string& serialized_rule); | 49 bool ParseSerializedRule(const std::string& serialized_rule); |
| 50 | 50 |
| 51 // Returns the address format for this rule. The format can include the | 51 // Returns the address format for this rule. The format can include the |
| 52 // NEWLINE extension for AddressField enum. | 52 // NEWLINE extension for AddressField enum. |
| 53 const std::vector<AddressField>& GetFormat() const { return format_; } | 53 const std::vector<AddressField>& GetFormat() const { return format_; } |
| 54 | 54 |
| 55 // Returns the required fields for this rule. | |
| 56 const std::vector<AddressField>& GetRequired() const { return required_; } | |
| 57 | |
| 55 // Returns the sub-keys for this rule, which are the administrative areas of a | 58 // Returns the sub-keys for this rule, which are the administrative areas of a |
| 56 // country, the localities of an administrative area, or the dependent | 59 // country, the localities of an administrative area, or the dependent |
| 57 // localities of a locality. For example, the rules for "US" have sub-keys of | 60 // localities of a locality. For example, the rules for "US" have sub-keys of |
| 58 // "CA", "NY", "TX", etc. | 61 // "CA", "NY", "TX", etc. |
| 59 const std::vector<std::string>& GetSubKeys() const { return sub_keys_; } | 62 const std::vector<std::string>& GetSubKeys() const { return sub_keys_; } |
| 60 | 63 |
| 61 // Returns all of the language codes for which this rule has custom rules, for | 64 // Returns all of the language codes for which this rule has custom rules, for |
| 62 // example ["de", "fr", "it"]. | 65 // example ["de", "fr", "it"]. |
| 63 const std::vector<std::string>& GetLanguages() const { return languages_; } | 66 const std::vector<std::string>& GetLanguages() const { return languages_; } |
| 64 | 67 |
| 65 // Returns the language code of this rule, for example "de". | 68 // Returns the language code of this rule, for example "de". |
| 66 const std::string& GetLanguage() const { return language_; } | 69 const std::string& GetLanguage() const { return language_; } |
| 67 | 70 |
| 71 // Returns examples of valid postal codes, for example "95014,22162-1010". | |
| 72 const std::string& GetPostalCodeExamples() const { | |
|
Evan Stade
2013/12/13 23:34:29
how is this useful?
please use gerrit instead
2013/12/16 20:49:56
Left out until we decided to use the error message
| |
| 73 return postal_code_examples_; | |
| 74 } | |
| 75 | |
| 76 // Returns the postal code format, for example "\\d{5}([ \\-]\\d{4})?". | |
| 77 const std::string& GetPostalCodeFormat() const { return postal_code_format_; } | |
| 78 | |
| 79 // Returns the URL that helps determine the postal code for an address. This | |
| 80 // URL should be shown to the user. For example: | |
| 81 // https://tools.usps.com/go/ZipLookupAction!input.action | |
| 82 const std::string& GetPostalCodesUrl() const { return postal_codes_url_; } | |
|
Evan Stade
2013/12/13 23:34:29
how is this useful?
Please leave this out until w
please use gerrit instead
2013/12/16 20:49:56
Left out until we decided to use the error message
| |
| 83 | |
| 68 // The message string identifier for admin area name. If not set, then | 84 // The message string identifier for admin area name. If not set, then |
| 69 // INVALID_MESSAGE_ID. | 85 // INVALID_MESSAGE_ID. |
| 70 int GetAdminAreaNameMessageId() const { return admin_area_name_message_id_; } | 86 int GetAdminAreaNameMessageId() const { return admin_area_name_message_id_; } |
| 71 | 87 |
| 72 // The message string identifier for postal code name. If not set, then | 88 // The message string identifier for postal code name. If not set, then |
| 73 // INVALID_MESSAGE_ID. | 89 // INVALID_MESSAGE_ID. |
| 74 int GetPostalCodeNameMessageId() const { | 90 int GetPostalCodeNameMessageId() const { |
| 75 return postal_code_name_message_id_; | 91 return postal_code_name_message_id_; |
| 76 } | 92 } |
| 77 | 93 |
| 78 private: | 94 private: |
| 79 std::vector<AddressField> format_; | 95 std::vector<AddressField> format_; |
| 96 std::vector<AddressField> required_; | |
| 80 std::vector<std::string> sub_keys_; | 97 std::vector<std::string> sub_keys_; |
| 81 std::vector<std::string> languages_; | 98 std::vector<std::string> languages_; |
| 82 std::string language_; | 99 std::string language_; |
| 100 std::string postal_code_examples_; | |
| 101 std::string postal_code_format_; | |
| 102 std::string postal_codes_url_; | |
| 83 int admin_area_name_message_id_; | 103 int admin_area_name_message_id_; |
| 84 int postal_code_name_message_id_; | 104 int postal_code_name_message_id_; |
| 85 | 105 |
| 86 DISALLOW_COPY_AND_ASSIGN(Rule); | 106 DISALLOW_COPY_AND_ASSIGN(Rule); |
| 87 }; | 107 }; |
| 88 | 108 |
| 89 } // namespace addressinput | 109 } // namespace addressinput |
| 90 } // namespace i18n | 110 } // namespace i18n |
| 91 | 111 |
| 92 #endif // I18N_ADDRESSINPUT_RULE_H_ | 112 #endif // I18N_ADDRESSINPUT_RULE_H_ |
| OLD | NEW |