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 25 matching lines...) Expand all Loading... |
36 Rule(); | 36 Rule(); |
37 ~Rule(); | 37 ~Rule(); |
38 | 38 |
39 // Copies all data from |rule|. | 39 // Copies all data from |rule|. |
40 void CopyFrom(const Rule& rule); | 40 void CopyFrom(const Rule& rule); |
41 | 41 |
42 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid | 42 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid |
43 // format (JSON dictionary). | 43 // format (JSON dictionary). |
44 bool ParseSerializedRule(const std::string& serialized_rule); | 44 bool ParseSerializedRule(const std::string& serialized_rule); |
45 | 45 |
46 // Returns the address format for this rule. The format can include the | 46 // Returns the address format for this rule. |
47 // NEWLINE extension for AddressField enum. | 47 const std::vector<std::vector<AddressField> >& GetFormat() const { |
48 const std::vector<AddressField>& GetFormat() const { return format_; } | 48 return format_; |
| 49 } |
| 50 |
| 51 // Returns the required fields for this rule. |
| 52 const std::vector<AddressField>& GetRequired() const { return required_; } |
49 | 53 |
50 // Returns the sub-keys for this rule, which are the administrative areas of a | 54 // Returns the sub-keys for this rule, which are the administrative areas of a |
51 // country, the localities of an administrative area, or the dependent | 55 // country, the localities of an administrative area, or the dependent |
52 // localities of a locality. For example, the rules for "US" have sub-keys of | 56 // localities of a locality. For example, the rules for "US" have sub-keys of |
53 // "CA", "NY", "TX", etc. | 57 // "CA", "NY", "TX", etc. |
54 const std::vector<std::string>& GetSubKeys() const { return sub_keys_; } | 58 const std::vector<std::string>& GetSubKeys() const { return sub_keys_; } |
55 | 59 |
56 // Returns all of the language codes for which this rule has custom rules, for | 60 // Returns all of the language codes for which this rule has custom rules, for |
57 // example ["de", "fr", "it"]. | 61 // example ["de", "fr", "it"]. |
58 const std::vector<std::string>& GetLanguages() const { return languages_; } | 62 const std::vector<std::string>& GetLanguages() const { return languages_; } |
59 | 63 |
60 // Returns the language code of this rule, for example "de". | 64 // Returns the language code of this rule, for example "de". |
61 const std::string& GetLanguage() const { return language_; } | 65 const std::string& GetLanguage() const { return language_; } |
62 | 66 |
| 67 // Returns the postal code format, for example "\\d{5}([ \\-]\\d{4})?". |
| 68 const std::string& GetPostalCodeFormat() const { return postal_code_format_; } |
| 69 |
63 // The message string identifier for admin area name. If not set, then | 70 // The message string identifier for admin area name. If not set, then |
64 // INVALID_MESSAGE_ID. | 71 // INVALID_MESSAGE_ID. |
65 int GetAdminAreaNameMessageId() const { return admin_area_name_message_id_; } | 72 int GetAdminAreaNameMessageId() const { return admin_area_name_message_id_; } |
66 | 73 |
67 // The message string identifier for postal code name. If not set, then | 74 // The message string identifier for postal code name. If not set, then |
68 // INVALID_MESSAGE_ID. | 75 // INVALID_MESSAGE_ID. |
69 int GetPostalCodeNameMessageId() const { | 76 int GetPostalCodeNameMessageId() const { |
70 return postal_code_name_message_id_; | 77 return postal_code_name_message_id_; |
71 } | 78 } |
72 | 79 |
73 private: | 80 private: |
74 std::vector<AddressField> format_; | 81 std::vector<std::vector<AddressField> > format_; |
| 82 std::vector<AddressField> required_; |
75 std::vector<std::string> sub_keys_; | 83 std::vector<std::string> sub_keys_; |
76 std::vector<std::string> languages_; | 84 std::vector<std::string> languages_; |
77 std::string language_; | 85 std::string language_; |
| 86 std::string postal_code_format_; |
78 int admin_area_name_message_id_; | 87 int admin_area_name_message_id_; |
79 int postal_code_name_message_id_; | 88 int postal_code_name_message_id_; |
80 | 89 |
81 DISALLOW_COPY_AND_ASSIGN(Rule); | 90 DISALLOW_COPY_AND_ASSIGN(Rule); |
82 }; | 91 }; |
83 | 92 |
84 } // namespace addressinput | 93 } // namespace addressinput |
85 } // namespace i18n | 94 } // namespace i18n |
86 | 95 |
87 #endif // I18N_ADDRESSINPUT_RULE_H_ | 96 #endif // I18N_ADDRESSINPUT_RULE_H_ |
OLD | NEW |