7#include "iso_15924_intf.hpp"
8#include "../utility/utility.hpp"
9#include "../algorithm/module.hpp"
10#include "../macros.hpp"
13hi_export_module(hikogui.i18n.iso_15924 : impl);
15namespace hi {
inline namespace v1 {
23 constexpr iso_15924_info(
char const (&code4)[5],
char const (&code4_open_type)[5], uint16_t number)
noexcept :
24 code4{to_title(
fixed_string(code4))}, code4_open_type{code4_open_type}, number(number)
53 {
"beng",
"bng2", 325},
73 {
"deva",
"dev2", 315},
92 {
"gujr",
"gjr2", 320},
93 {
"guru",
"gur2", 310},
121 {
"knda",
"knd2", 345},
126 {
"laoo",
"lao ", 356},
149 {
"mlym",
"mlm2", 347},
156 {
"mymr",
"mym2", 350},
163 {
"nkoo",
"nko ", 165},
168 {
"orya",
"ory2", 327},
187 {
"qabv",
"byzm", 947},
188 {
"qabw",
"musc", 948},
220 {
"taml",
"tml2", 346},
223 {
"telu",
"tel2", 340},
234 {
"vaii",
"vai ", 470},
243 {
"yiii",
"yi ", 460},
246 {
"zmth",
"math", 995},
250 {
"zyyy",
"DFLT", 998},
254 constexpr auto data_size =
sizeof(data) /
sizeof(data[0]);
265constexpr auto iso_15924_infos = iso_15924_infos_init();
271 for (hilet&
info : iso_15924_infos) {
282 for (hilet&
info : iso_15924_infos) {
283 r[
info.number] =
info.code4_open_type;
291 constexpr size_t array_size = std::tuple_size_v<
decltype(iso_15924_infos)>;
295 for (
auto i = 0
_uz; i != iso_15924_infos.size(); ++i) {
296 r[i] = {iso_15924_infos[i].code4, iso_15924_infos[i].number};
298 std::sort(r.begin(), r.end(), [](hilet& a, hilet& b) {
299 return a.first < b.first;
305constexpr auto iso_15924_code4_by_number = iso_15924_code4_by_number_init();
306constexpr auto iso_15924_code4_open_type_by_number = iso_15924_code4_open_type_by_number_init();
307constexpr auto iso_15924_number_by_code4 = iso_15924_number_by_code4_init();
311constexpr iso_15924::iso_15924(std::string_view code4)
314 throw parse_error(std::format(
"Invalid script '{}'",
code4));
320 detail::iso_15924_number_by_code4.
begin(),
321 detail::iso_15924_number_by_code4.
end(),
323 [](hilet& item, hilet& value) {
324 return item.first < value;
327 if (
it == detail::iso_15924_number_by_code4.
end()
or it->first !=
code4_) {
328 throw parse_error(std::format(
"Unknown script '{}'",
code4));
336 hi_assert(_v < 1000);
337 return detail::iso_15924_code4_by_number[_v];
342 hi_assert(_v < 1000);
343 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.
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr std::string to_title(std::string_view rhs) noexcept
Convert the current string to using title case.
Definition strings.hpp:159
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Definition iso_15924_impl.hpp:18
constexpr bool left_to_right() const noexcept
Is this script written left-to-right.
Definition iso_15924_impl.hpp:346
constexpr std::string code4_open_type() const noexcept
Get the 4-letter code used by open-type.
Definition iso_15924_impl.hpp:340
constexpr std::string code4() const noexcept
Get the iso-15924 4-letter code.
Definition iso_15924_impl.hpp:334
A string which may be used as a none-type template parameter.
Definition fixed_string.hpp:41