1 // Copyright (C) 2012 The Libphonenumber Authors
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 // Author: Patrick Mezard
17 #include "phonenumbers/geocoding/default_map_storage.h"
19 #include "base/basictypes.h"
20 #include "base/logging.h"
21 #include "phonenumbers/geocoding/geocoding_data.h"
24 namespace phonenumbers {
26 DefaultMapStorage::DefaultMapStorage() {
29 DefaultMapStorage::~DefaultMapStorage() {
32 int32 DefaultMapStorage::GetPrefix(int index) const {
34 DCHECK_LT(index, prefixes_size_);
35 return prefixes_[index];
38 const char* DefaultMapStorage::GetDescription(int index) const {
40 DCHECK_LT(index, prefixes_size_);
41 return descriptions_[index];
44 void DefaultMapStorage::ReadFromMap(const PrefixDescriptions* descriptions) {
45 prefixes_ = descriptions->prefixes;
46 prefixes_size_ = descriptions->prefixes_size;
47 descriptions_ = descriptions->descriptions;
48 possible_lengths_ = descriptions->possible_lengths;
49 possible_lengths_size_ = descriptions->possible_lengths_size;
52 int DefaultMapStorage::GetNumOfEntries() const {
53 return prefixes_size_;
56 const int* DefaultMapStorage::GetPossibleLengths() const {
57 return possible_lengths_;
60 int DefaultMapStorage::GetPossibleLengthsSize() const {
61 return possible_lengths_size_;
64 } // namespace phonenumbers