2019-06-22 14:01:54 +02:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-26 17:46:24 +03:00
|
|
|
namespace Countries {
|
2019-06-22 14:01:54 +02:00
|
|
|
|
2021-08-26 17:53:59 +03:00
|
|
|
struct Info {
|
2021-08-26 19:01:31 +03:00
|
|
|
QString name;
|
|
|
|
QString iso2;
|
|
|
|
QString code;
|
|
|
|
QString alternativeName;
|
2019-06-22 14:01:54 +02:00
|
|
|
};
|
|
|
|
|
2021-08-26 18:15:49 +03:00
|
|
|
class CountriesInstance final {
|
|
|
|
public:
|
|
|
|
using Map = QHash<QString, const Info *>;
|
2019-06-22 14:01:54 +02:00
|
|
|
|
2021-08-26 18:22:54 +03:00
|
|
|
CountriesInstance();
|
|
|
|
[[nodiscard]] const std::vector<Info> &list();
|
|
|
|
void setList(std::vector<Info> &&infos);
|
2019-06-22 14:01:54 +02:00
|
|
|
|
2021-08-26 18:15:49 +03:00
|
|
|
[[nodiscard]] const Map &byCode();
|
|
|
|
[[nodiscard]] const Map &byISO2();
|
|
|
|
|
|
|
|
[[nodiscard]] QString validPhoneCode(QString fullCode);
|
|
|
|
[[nodiscard]] QString countryNameByISO2(const QString &iso);
|
|
|
|
[[nodiscard]] QString countryISO2ByPhone(const QString &phone);
|
|
|
|
|
|
|
|
private:
|
2021-08-26 18:22:54 +03:00
|
|
|
std::vector<Info> _list;
|
|
|
|
|
2021-08-26 18:15:49 +03:00
|
|
|
Map _byCode;
|
|
|
|
Map _byISO2;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
CountriesInstance &Instance();
|
2019-06-22 14:01:54 +02:00
|
|
|
|
2021-08-26 17:46:24 +03:00
|
|
|
} // namespace Countries
|