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

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

Issue 109323011: [rac] Download all rules for a country code in libaddressinput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a TODO. Created 6 years, 11 months 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
(Empty)
1 // Copyright (C) 2014 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef I18N_ADDRESSINPUT_RULESET_H_
16 #define I18N_ADDRESSINPUT_RULESET_H_
17
18 #include <libaddressinput/util/basictypes.h>
19 #include <libaddressinput/util/scoped_ptr.h>
20
21 #include <map>
22 #include <string>
23
24 namespace i18n {
25 namespace addressinput {
26
27 class Rule;
28
29 // A recursive data structure that stores a set of rules for a region. Can store
30 // the rules for a country, its administrative areas, localities, and dependent
31 // localities, in addition to the language-specific rules.
32 //
33 // Example for Canada and some of its provinces:
34 // CA-->fr
35 // |
36 // -------------------------------------
37 // | | | | |
38 // v v v v v
39 // AB-->fr BC-->fr MB-->fr NB-->fr NL-->fr
40 //
41 // The rules in Canada are in English by default. Each rule also has a French
42 // language version.
43 class Ruleset {
44 public:
45 // Builds a ruleset with a region-wide |rule| in the default language of the
46 // country. The |rule| should not be NULL.
47 explicit Ruleset(scoped_ptr<Rule> rule);
48
49 ~Ruleset();
50
51 // Returns the region-wide rule in the default language of the country.
52 const Rule& rule() const { return *rule_.get(); }
53
54 // Adds and the |ruleset| for |sub_region|.
55 void AddSubRegionRuleset(const std::string& sub_region,
56 scoped_ptr<Ruleset> ruleset);
57
58 // Adds a language-specific |rule| for |language_code| for this region.
59 void AddLanguageCodeRule(const std::string& language_code,
60 scoped_ptr<Rule> rule);
61
62 private:
63 // The region-wide rule in the default language of the country.
64 scoped_ptr<const Rule> rule_;
65
66 // Owned rulesets for sub-regions.
67 std::map<std::string, Ruleset*> sub_regions_;
68
69 // Owned language-specific rules for the region.
70 std::map<std::string, const Rule*> language_codes_;
71
72 DISALLOW_COPY_AND_ASSIGN(Ruleset);
73 };
74
75 } // namespace addressinput
76 } // namespace i18n
77
78 #endif // I18N_ADDRESSINPUT_RULESET_H_
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/cpp/src/rule.cc ('k') | third_party/libaddressinput/chromium/cpp/src/ruleset.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698