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 // Default class for storing area codes.
19 #ifndef I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_
20 #define I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_
27 #include "base/basictypes.h"
28 #include "phonenumbers/geocoding/area_code_map_storage_strategy.h"
31 namespace phonenumbers {
38 // Default area code map storage strategy that is used for data not
39 // containing description duplications. It is mainly intended to avoid
40 // the overhead of the string table management when it is actually
41 // unnecessary (i.e no string duplication).
42 class DefaultMapStorage : public AreaCodeMapStorageStrategy {
45 virtual ~DefaultMapStorage();
47 virtual int GetPrefix(int index) const;
48 virtual const string& GetDescription(int index) const;
49 virtual void ReadFromMap(const map<int, string>& area_codes);
50 virtual int GetNumOfEntries() const;
51 virtual const set<int>& GetPossibleLengths() const;
54 // Sorted sequence of phone number prefixes.
55 vector<int> prefixes_;
56 // Sequence of prefix descriptions, in the same order than prefixes_.
57 vector<string> descriptions_;
58 // Sequence of unique possible lengths in ascending order.
59 set<int> possible_lengths_;
61 DISALLOW_COPY_AND_ASSIGN(DefaultMapStorage);
64 } // namespace phonenumbers
67 #endif /* I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_ */