Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Side by Side Diff: third_party/libaddressinput/chromium/cpp/src/rule.h

Issue 106763007: [rac] Parse postal code formats and required fields in libaddressinput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Omit postal code examples and URL. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 the postal code format, for example "\\d{5}([ \\-]\\d{4})?".
72 const std::string& GetPostalCodeFormat() const { return postal_code_format_; }
73
68 // The message string identifier for admin area name. If not set, then 74 // The message string identifier for admin area name. If not set, then
69 // INVALID_MESSAGE_ID. 75 // INVALID_MESSAGE_ID.
70 int GetAdminAreaNameMessageId() const { return admin_area_name_message_id_; } 76 int GetAdminAreaNameMessageId() const { return admin_area_name_message_id_; }
71 77
72 // The message string identifier for postal code name. If not set, then 78 // The message string identifier for postal code name. If not set, then
73 // INVALID_MESSAGE_ID. 79 // INVALID_MESSAGE_ID.
74 int GetPostalCodeNameMessageId() const { 80 int GetPostalCodeNameMessageId() const {
75 return postal_code_name_message_id_; 81 return postal_code_name_message_id_;
76 } 82 }
77 83
78 private: 84 private:
79 std::vector<AddressField> format_; 85 std::vector<AddressField> format_;
86 std::vector<AddressField> required_;
80 std::vector<std::string> sub_keys_; 87 std::vector<std::string> sub_keys_;
81 std::vector<std::string> languages_; 88 std::vector<std::string> languages_;
82 std::string language_; 89 std::string language_;
90 std::string postal_code_format_;
83 int admin_area_name_message_id_; 91 int admin_area_name_message_id_;
84 int postal_code_name_message_id_; 92 int postal_code_name_message_id_;
85 93
86 DISALLOW_COPY_AND_ASSIGN(Rule); 94 DISALLOW_COPY_AND_ASSIGN(Rule);
87 }; 95 };
88 96
89 } // namespace addressinput 97 } // namespace addressinput
90 } // namespace i18n 98 } // namespace i18n
91 99
92 #endif // I18N_ADDRESSINPUT_RULE_H_ 100 #endif // I18N_ADDRESSINPUT_RULE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698