• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <libaddressinput/region_data.h>
16 
17 #include <cstddef>
18 #include <string>
19 #include <vector>
20 
21 namespace i18n {
22 namespace addressinput {
23 
RegionData(const std::string & region_code)24 RegionData::RegionData(const std::string& region_code)
25     : key_(region_code),
26       name_(region_code),
27       parent_(NULL),
28       sub_regions_() {}
29 
~RegionData()30 RegionData::~RegionData() {
31   for (std::vector<const RegionData*>::const_iterator it = sub_regions_.begin();
32        it != sub_regions_.end(); ++it) {
33     delete *it;
34   }
35 }
36 
AddSubRegion(const std::string & key,const std::string & name)37 RegionData* RegionData::AddSubRegion(const std::string& key,
38                                      const std::string& name) {
39   RegionData* sub_region = new RegionData(key, name, this);
40   sub_regions_.push_back(sub_region);
41   return sub_region;
42 }
43 
RegionData(const std::string & key,const std::string & name,RegionData * parent)44 RegionData::RegionData(const std::string& key,
45                        const std::string& name,
46                        RegionData* parent)
47     : key_(key), name_(name), parent_(parent), sub_regions_() {}
48 
49 }  // namespace addressinput
50 }  // namespace i18n
51