7#include "iso_15924_intf.hpp"
8#include "../utility/utility.hpp"
9#include "../algorithm/algorithm.hpp"
10#include "../macros.hpp"
16hi_export_module(hikogui.i18n.iso_15924 : impl);
18hi_export
namespace hi {
inline namespace v1 {
26 constexpr iso_15924_info(
char const (&code4)[5],
char const (&code4_open_type)[5], uint16_t number) noexcept :
27 code4{to_title(
fixed_string(code4))}, code4_open_type{code4_open_type}, number(number)
36[[nodiscard]]
consteval auto iso_15924_infos_init() noexcept
56 {
"beng",
"bng2", 325},
76 {
"deva",
"dev2", 315},
95 {
"gujr",
"gjr2", 320},
96 {
"guru",
"gur2", 310},
124 {
"knda",
"knd2", 345},
129 {
"laoo",
"lao ", 356},
152 {
"mlym",
"mlm2", 347},
159 {
"mymr",
"mym2", 350},
166 {
"nkoo",
"nko ", 165},
171 {
"orya",
"ory2", 327},
190 {
"qabv",
"byzm", 947},
191 {
"qabw",
"musc", 948},
223 {
"taml",
"tml2", 346},
226 {
"telu",
"tel2", 340},
237 {
"vaii",
"vai ", 470},
246 {
"yiii",
"yi ", 460},
249 {
"zmth",
"math", 995},
253 {
"zyyy",
"DFLT", 998},
257 constexpr auto data_size =
sizeof(data) /
sizeof(data[0]);
261 for (
auto i = 0_uz; i != data_size; ++i) {
268constexpr auto iso_15924_infos = iso_15924_infos_init();
270[[nodiscard]]
consteval auto iso_15924_code4_by_number_init() noexcept
274 for (
auto const& info : iso_15924_infos) {
275 r[info.number] = info.code4;
281[[nodiscard]]
consteval auto iso_15924_code4_open_type_by_number_init() noexcept
285 for (
auto const& info : iso_15924_infos) {
286 r[info.number] = info.code4_open_type;
292[[nodiscard]]
consteval auto iso_15924_number_by_code4_init() noexcept
294 constexpr auto array_size = std::tuple_size_v<
decltype(iso_15924_infos)>;
298 for (
auto i = 0_uz; i != iso_15924_infos.size(); ++i) {
299 r[i] = {iso_15924_infos[i].code4, iso_15924_infos[i].number};
301 std::sort(r.begin(), r.end(), [](
auto const& a,
auto const& b) {
302 return a.first < b.first;
308constexpr auto iso_15924_code4_by_number = iso_15924_code4_by_number_init();
309constexpr auto iso_15924_code4_open_type_by_number = iso_15924_code4_open_type_by_number_init();
310constexpr auto iso_15924_number_by_code4 = iso_15924_number_by_code4_init();
314constexpr iso_15924::iso_15924(std::string_view code4)
317 throw parse_error(std::format(
"Invalid script '{}'",
code4));
323 detail::iso_15924_number_by_code4.
begin(),
324 detail::iso_15924_number_by_code4.
end(),
326 [](
auto const& item,
auto const& value) {
327 return item.first < value;
330 if (it == detail::iso_15924_number_by_code4.
end() or it->first != code4_) {
331 throw parse_error(std::format(
"Unknown script '{}'",
code4));
339 hi_assert(_v < 1000);
340 return detail::iso_15924_code4_by_number[_v];
345 hi_assert(_v < 1000);
346 return detail::iso_15924_code4_open_type_by_number[_v];
@ end
Start from the end of the file.
@ begin
Start from the beginning of the file.
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
constexpr std::string to_title(std::string_view rhs) noexcept
Convert the current string to using title case.
Definition strings.hpp:159
Definition iso_15924_impl.hpp:21
constexpr bool left_to_right() const noexcept
Is this script written left-to-right.
Definition iso_15924_impl.hpp:349
constexpr std::string code4_open_type() const noexcept
Get the 4-letter code used by open-type.
Definition iso_15924_impl.hpp:343
constexpr std::string code4() const noexcept
Get the iso-15924 4-letter code.
Definition iso_15924_impl.hpp:337
A string which may be used as a none-type template parameter.
Definition fixed_string.hpp:42