| 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 18 matching lines...) Expand all Loading... |
| 29 // Stores the validation rules. Sample usage: | 29 // Stores the validation rules. Sample usage: |
| 30 // Rule rule; | 30 // Rule rule; |
| 31 // if (rule.ParseSerializedRule("{\"fmt\": \"%A%n%C%S %Z\"}")) { | 31 // if (rule.ParseSerializedRule("{\"fmt\": \"%A%n%C%S %Z\"}")) { |
| 32 // Process(rule.GetFormat()); | 32 // Process(rule.GetFormat()); |
| 33 // } | 33 // } |
| 34 class Rule { | 34 class Rule { |
| 35 public: | 35 public: |
| 36 Rule(); | 36 Rule(); |
| 37 ~Rule(); | 37 ~Rule(); |
| 38 | 38 |
| 39 // Returns the default rule at a country level. If a country does not specify |
| 40 // address format, for example, then the format from this rule should be used |
| 41 // instead. |
| 42 static const Rule& GetDefault(); |
| 43 |
| 39 // Copies all data from |rule|. | 44 // Copies all data from |rule|. |
| 40 void CopyFrom(const Rule& rule); | 45 void CopyFrom(const Rule& rule); |
| 41 | 46 |
| 42 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid | 47 // Parses |serialized_rule|. Returns |true| if the |serialized_rule| has valid |
| 43 // format (JSON dictionary). | 48 // format (JSON dictionary). |
| 44 bool ParseSerializedRule(const std::string& serialized_rule); | 49 bool ParseSerializedRule(const std::string& serialized_rule); |
| 45 | 50 |
| 46 // 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 |
| 47 // NEWLINE extension for AddressField enum. | 52 // NEWLINE extension for AddressField enum. |
| 48 const std::vector<AddressField>& GetFormat() const { return format_; } | 53 const std::vector<AddressField>& GetFormat() const { return format_; } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 78 int admin_area_name_message_id_; | 83 int admin_area_name_message_id_; |
| 79 int postal_code_name_message_id_; | 84 int postal_code_name_message_id_; |
| 80 | 85 |
| 81 DISALLOW_COPY_AND_ASSIGN(Rule); | 86 DISALLOW_COPY_AND_ASSIGN(Rule); |
| 82 }; | 87 }; |
| 83 | 88 |
| 84 } // namespace addressinput | 89 } // namespace addressinput |
| 85 } // namespace i18n | 90 } // namespace i18n |
| 86 | 91 |
| 87 #endif // I18N_ADDRESSINPUT_RULE_H_ | 92 #endif // I18N_ADDRESSINPUT_RULE_H_ |
| OLD | NEW |