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 // Interface for phone numbers area prefixes storage classes.
19 #ifndef I18N_PHONENUMBERS_AREA_CODE_MAP_STRATEGY_H_
20 #define I18N_PHONENUMBERS_AREA_CODE_MAP_STRATEGY_H_
27 namespace phonenumbers {
33 // Abstracts the way area code data is stored into memory. It is used by
34 // AreaCodeMap to support the most space-efficient storage strategy according
35 // to the provided data.
36 class AreaCodeMapStorageStrategy {
38 virtual ~AreaCodeMapStorageStrategy() {}
40 // Returns the phone number prefix located at the provided index.
41 virtual int GetPrefix(int index) const = 0;
43 // Gets the description corresponding to the phone number prefix located
44 // at the provided index. If the description is not available in the current
45 // language an empty string is returned.
46 virtual const string& GetDescription(int index) const = 0;
48 // Sets the internal state of the underlying storage implementation from the
49 // provided area_codes that maps phone number prefixes to description strings.
50 virtual void ReadFromMap(const map<int, string>& area_codes) = 0;
52 // Returns the number of entries contained in the area code map.
53 virtual int GetNumOfEntries() const = 0;
55 // Returns the set containing the possible lengths of prefixes.
56 virtual const set<int>& GetPossibleLengths() const = 0;
59 } // namespace phonenumbers
62 #endif // I18N_PHONENUMBERS_AREA_CODE_MAP_STRATEGY_H_