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_
22 #include "base/basictypes.h"
25 namespace phonenumbers {
27 struct PrefixDescriptions;
29 // Default area code map storage strategy that is used for data not
30 // containing description duplications. It is mainly intended to avoid
31 // the overhead of the string table management when it is actually
32 // unnecessary (i.e no string duplication).
33 class DefaultMapStorage {
36 virtual ~DefaultMapStorage();
38 // Returns the phone number prefix located at the provided index.
39 int32 GetPrefix(int index) const;
41 // Gets the description corresponding to the phone number prefix located
42 // at the provided index. If the description is not available in the current
43 // language an empty string is returned.
44 const char* GetDescription(int index) const;
46 // Sets the internal state of the underlying storage implementation from the
47 // provided area_codes that maps phone number prefixes to description strings.
48 void ReadFromMap(const PrefixDescriptions* descriptions);
50 // Returns the number of entries contained in the area code map.
51 int GetNumOfEntries() const;
53 // Returns an array containing the possible lengths of prefixes sorted in
55 const int* GetPossibleLengths() const;
57 // Returns the number of elements in GetPossibleLengths() array.
58 int GetPossibleLengthsSize() const;
61 // Sorted sequence of phone number prefixes.
62 const int32* prefixes_;
64 // Sequence of prefix descriptions, in the same order than prefixes_.
65 const char** descriptions_;
66 // Sequence of unique possible lengths in ascending order.
67 const int32* possible_lengths_;
68 int possible_lengths_size_;
70 DISALLOW_COPY_AND_ASSIGN(DefaultMapStorage);
73 } // namespace phonenumbers
76 #endif /* I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_ */