JAVA/JS/CPP: Metadata updates (v5.0.2)
[platform/upstream/libphonenumber.git] / cpp / src / phonenumbers / geocoding / area_code_map_storage_strategy.h
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 // Interface for phone numbers area prefixes storage classes.
18
19 #ifndef I18N_PHONENUMBERS_AREA_CODE_MAP_STRATEGY_H_
20 #define I18N_PHONENUMBERS_AREA_CODE_MAP_STRATEGY_H_
21
22 #include <map>
23 #include <set>
24 #include <string>
25
26 namespace i18n {
27 namespace phonenumbers {
28
29 using std::map;
30 using std::set;
31 using std::string;
32
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 {
37  public:
38   virtual ~AreaCodeMapStorageStrategy() {}
39
40   // Returns the phone number prefix located at the provided index.
41   virtual int GetPrefix(int index) const = 0;
42
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;
47
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;
51
52   // Returns the number of entries contained in the area code map.
53   virtual int GetNumOfEntries() const = 0;
54
55   // Returns the set containing the possible lengths of prefixes.
56   virtual const set<int>& GetPossibleLengths() const = 0;
57 };
58
59 }  // namespace phonenumbers
60 }  // namespace i18n
61
62 #endif  // I18N_PHONENUMBERS_AREA_CODE_MAP_STRATEGY_H_