1 // Copyright (C) 2012 The Libphonenumber Authors 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 // Author: Patrick Mezard 16 17 #include "phonenumbers/geocoding/default_map_storage.h" 18 19 #include "phonenumbers/base/basictypes.h" 20 #include "phonenumbers/base/logging.h" 21 #include "phonenumbers/geocoding/geocoding_data.h" 22 23 namespace i18n { 24 namespace phonenumbers { 25 26 DefaultMapStorage::DefaultMapStorage() { 27 } 28 29 DefaultMapStorage::~DefaultMapStorage() { 30 } 31 32 int32 DefaultMapStorage::GetPrefix(int index) const { 33 DCHECK_GE(index, 0); 34 DCHECK_LT(index, prefixes_size_); 35 return prefixes_[index]; 36 } 37 38 const char* DefaultMapStorage::GetDescription(int index) const { 39 DCHECK_GE(index, 0); 40 DCHECK_LT(index, prefixes_size_); 41 return descriptions_[index]; 42 } 43 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; 50 } 51 52 int DefaultMapStorage::GetNumOfEntries() const { 53 return prefixes_size_; 54 } 55 56 const int* DefaultMapStorage::GetPossibleLengths() const { 57 return possible_lengths_; 58 } 59 60 int DefaultMapStorage::GetPossibleLengthsSize() const { 61 return possible_lengths_size_; 62 } 63 64 } // namespace phonenumbers 65 } // namespace i18n 66