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

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

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 #include "ruleset.h"
16
17 #include <libaddressinput/util/scoped_ptr.h>
18
19 #include <cassert>
20 #include <cstddef>
21 #include <map>
22 #include <string>
23 #include <utility>
24
25 #include "rule.h"
26 #include "util/stl_util.h"
27
28 namespace i18n {
29 namespace addressinput {
30
31 Ruleset::Ruleset(scoped_ptr<Rule> rule)
32 : rule_(rule.Pass()),
33 sub_regions_(),
34 language_codes_() {
35 assert(rule_ != NULL);
36 }
37
38 Ruleset::~Ruleset() {
39 STLDeleteValues(&sub_regions_);
40 STLDeleteValues(&language_codes_);
41 }
42
43 void Ruleset::AddSubRegionRuleset(const std::string& sub_region,
44 scoped_ptr<Ruleset> ruleset) {
45 assert(sub_regions_.find(sub_region) == sub_regions_.end());
46 sub_regions_[sub_region] = ruleset.release();
47 }
48
49 void Ruleset::AddLanguageCodeRule(const std::string& language_code,
50 scoped_ptr<Rule> rule) {
51 assert(language_codes_.find(language_code) == language_codes_.end());
52 language_codes_[language_code] = rule.release();
53 }
54
55 } // namespace addressinput
56 } // namespace i18n
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698