2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00
Files
tdesktop/Telegram/SourceFiles/countries/countries_instance.h
2021-08-29 21:01:10 +03:00

43 lines
949 B
C++

/*
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
namespace Countries {
struct Info {
const char *name = nullptr;
const char *iso2 = nullptr;
const char *code = nullptr;
const char *alternativeName = nullptr;
};
class CountriesInstance final {
public:
using Map = QHash<QString, const Info *>;
CountriesInstance() = default;
[[nodiscard]] const std::array<Info, 231> &list();
[[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:
Map _byCode;
Map _byISO2;
};
CountriesInstance &Instance();
} // namespace Countries