diff options
author | Baligh Uddin <baligh@google.com> | 2013-11-01 16:01:38 -0700 |
---|---|---|
committer | Baligh Uddin <baligh@google.com> | 2013-11-01 16:01:38 -0700 |
commit | eaa1197a14e08a6751abaf5fd84991efe1289d32 (patch) | |
tree | 42f5a1c48217830a0cca92b4ec4a62273e927976 /geocoding/default_map_storage.h | |
parent | 017baecf6dbbeb2e4290fcc6a374e1a82d35b7ae (diff) | |
parent | dbba40937755d507fc4ce0697065bcabadab803a (diff) | |
download | phonenumbers-eaa1197a14e08a6751abaf5fd84991efe1289d32.tar.gz |
Merge remote-tracking branch 'origin/kitkat-dev'chromium_org-pre-replicationidea133
Diffstat (limited to 'geocoding/default_map_storage.h')
-rw-r--r-- | geocoding/default_map_storage.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/geocoding/default_map_storage.h b/geocoding/default_map_storage.h new file mode 100644 index 0000000..750985c --- /dev/null +++ b/geocoding/default_map_storage.h @@ -0,0 +1,76 @@ +// Copyright (C) 2012 The Libphonenumber Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Author: Patrick Mezard +// +// Default class for storing area codes. + +#ifndef I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_ +#define I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_ + +#include "phonenumbers/base/basictypes.h" + +namespace i18n { +namespace phonenumbers { + +struct PrefixDescriptions; + +// Default area code map storage strategy that is used for data not +// containing description duplications. It is mainly intended to avoid +// the overhead of the string table management when it is actually +// unnecessary (i.e no string duplication). +class DefaultMapStorage { + public: + DefaultMapStorage(); + virtual ~DefaultMapStorage(); + + // Returns the phone number prefix located at the provided index. + int32 GetPrefix(int index) const; + + // Gets the description corresponding to the phone number prefix located + // at the provided index. If the description is not available in the current + // language an empty string is returned. + const char* GetDescription(int index) const; + + // Sets the internal state of the underlying storage implementation from the + // provided area_codes that maps phone number prefixes to description strings. + void ReadFromMap(const PrefixDescriptions* descriptions); + + // Returns the number of entries contained in the area code map. + int GetNumOfEntries() const; + + // Returns an array containing the possible lengths of prefixes sorted in + // ascending order. + const int* GetPossibleLengths() const; + + // Returns the number of elements in GetPossibleLengths() array. + int GetPossibleLengthsSize() const; + + private: + // Sorted sequence of phone number prefixes. + const int32* prefixes_; + int prefixes_size_; + // Sequence of prefix descriptions, in the same order than prefixes_. + const char** descriptions_; + // Sequence of unique possible lengths in ascending order. + const int32* possible_lengths_; + int possible_lengths_size_; + + DISALLOW_COPY_AND_ASSIGN(DefaultMapStorage); +}; + +} // namespace phonenumbers +} // namespace i18n + +#endif /* I18N_PHONENUMBERS_DEFAULT_MAP_STORAGE_H_ */ |