1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
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
16#ifndef I18N_PHONENUMBERS_UPDATE_GEOCODING_H_
17#define I18N_PHONENUMBERS_UPDATE_GEOCODING_H_
18
19#include <map>
20#include <string>
21#include "geocoding_data.pb.h"
22#include "phonenumbers/geocoding/geocoding_data.h"
23
24namespace i18n {
25namespace phonenumbers {
26class UpdateGeocoding {
27public:
28    static void LoadGeocodingData(int fd);
29    static const PrefixDescriptions* UpdatePrefixDescriptions(const PrefixDescriptions** prePrefixDescriptionsArray,
30        int index);
31    static const char** UpdateLanguageCodes(const char** languageCodes, int languageCodesSize);
32    static int UpdateLanguageCodesSize();
33    static const CountryLanguages* UpdateCountryLanguages(const CountryLanguages** preCountryLanguagesArray,
34        int index);
35    static const int* UpdateCountryCodes(const int* countryCodes, int countryCodesSize);
36    static int UpdateCountryCodesSize();
37
38private:
39    static void AddPrefixDescriptions(const std::string& languageCode, int index);
40    static void ModifyPrefixDescriptions(int32_t* prefixes, const char** descriptions,
41        PrefixesInfo& prefixesInfo, int index);
42    static void ModifyPossibleLengths(int32_t* possibleLengths, PrefixesInfo& prefixesInfo, int index);
43    static void AddCountryLanguages(int countryCode);
44
45    static int FindLanguageCode(const std::string& languageCode);
46    static int FindCountryCode(int countryCode);
47    static bool IsLowerThan(const char* s1, const char* s2);
48    static char* WriteStr(const std::string& str);
49    static std::map<std::string, PrefixDescriptions>* prefixDescriptionsMap;
50    static std::map<std::string, PrefixesInfo>* prefixesInfoMap;
51    static const PrefixDescriptions** prefixDescriptionsArray;
52    static LanguageCodeInfo* languageCodeInfo;
53    static bool isupdatedLanguageCodes;
54    static const char** preLanguageCodes;
55    static const char** curLanguageCodes;
56    static int curLanguageCodesSize;
57    static int preLanguageCodesSize;
58
59    static std::map<int, CountryLanguages>* countryLanguagesMap;
60    static std::map<int, CountriesInfo>* countriesInfoMap;
61    static const CountryLanguages** countryLanguagesArray;
62    static CountryCodeInfo* countryCodeInfo;
63
64    static bool isupdatedCountryCodes;
65    static const int* preCountryCodes;
66    static int* curCountryCodes;
67    static int curCountryCodesSize;
68    static int preCountryCodesSize;
69
70    static GeocodingInfo* geocodingInfo;
71};
72}  // namespace phonenumbers
73}  // namespace i18n
74#endif  // I18N_PHONENUMBERS_UPDATE_GEOCODING_H_