| 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. | 51 // Returns the address format for this rule. |
| 47 const std::vector<std::vector<AddressField> >& GetFormat() const { | 52 const std::vector<std::vector<AddressField> >& GetFormat() const { |
| 48 return format_; | 53 return format_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int admin_area_name_message_id_; | 92 int admin_area_name_message_id_; |
| 88 int postal_code_name_message_id_; | 93 int postal_code_name_message_id_; |
| 89 | 94 |
| 90 DISALLOW_COPY_AND_ASSIGN(Rule); | 95 DISALLOW_COPY_AND_ASSIGN(Rule); |
| 91 }; | 96 }; |
| 92 | 97 |
| 93 } // namespace addressinput | 98 } // namespace addressinput |
| 94 } // namespace i18n | 99 } // namespace i18n |
| 95 | 100 |
| 96 #endif // I18N_ADDRESSINPUT_RULE_H_ | 101 #endif // I18N_ADDRESSINPUT_RULE_H_ |
| OLD | NEW |