HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
unicode_bidi_class.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include <cstdint>
8#include <string_view>
9#include "../utility/module.hpp"
10
11namespace hi::inline v1 {
12
16enum class unicode_bidi_class : uint8_t {
17 unknown = 0,
18 L = 1,
19 R = 2,
20 AL = 3,
21 EN = 4,
22 ES = 5,
23 ET = 6,
24 AN = 7,
25 CS = 8,
26 NSM = 9,
27 BN = 10,
28 B = 11,
29 S = 12,
30 WS = 13,
31 ON = 14,
32 // Explicit values.
33 LRE,
34 LRO,
35 RLE,
36 RLO,
37 PDF,
38 LRI,
39 RLI,
40 FSI,
41 PDI
42};
43
44[[nodiscard]] constexpr bool is_isolate_starter(unicode_bidi_class const &rhs) noexcept
45{
46 using enum unicode_bidi_class;
47 return rhs == LRI || rhs == RLI || rhs == FSI;
48}
49
50[[nodiscard]] constexpr bool is_isolate_formatter(unicode_bidi_class const &rhs) noexcept
51{
52 using enum unicode_bidi_class;
53 return is_isolate_starter(rhs) || rhs == PDI;
54}
55
56[[nodiscard]] constexpr bool is_NI(unicode_bidi_class const &rhs) noexcept
57{
58 using enum unicode_bidi_class;
59 return rhs == B || rhs == S || rhs == WS || rhs == ON || rhs == FSI || rhs == LRI || rhs == RLI || rhs == PDI;
60}
61
62[[nodiscard]] constexpr bool is_control(unicode_bidi_class const &rhs) noexcept
63{
64 using enum unicode_bidi_class;
65 return rhs == RLE or rhs == LRE or rhs == RLO or rhs == LRO or rhs == PDF or rhs == BN;
66}
67
68[[nodiscard]] constexpr unicode_bidi_class unicode_bidi_class_from_string(std::string_view str) noexcept
69{
70 using enum unicode_bidi_class;
71
72 if (str == "L") {
73 return L;
74 } else if (str == "R") {
75 return R;
76 } else if (str == "AL") {
77 return AL;
78 } else if (str == "EN") {
79 return EN;
80 } else if (str == "ES") {
81 return ES;
82 } else if (str == "ET") {
83 return ET;
84 } else if (str == "AN") {
85 return AN;
86 } else if (str == "CS") {
87 return CS;
88 } else if (str == "NSM") {
89 return NSM;
90 } else if (str == "BN") {
91 return BN;
92 } else if (str == "B") {
93 return B;
94 } else if (str == "S") {
95 return S;
96 } else if (str == "WS") {
97 return WS;
98 } else if (str == "ON") {
99 return ON;
100 } else if (str == "LRE") {
101 return LRE;
102 } else if (str == "LRO") {
103 return LRO;
104 } else if (str == "RLE") {
105 return RLE;
106 } else if (str == "RLO") {
107 return RLO;
108 } else if (str == "PDF") {
109 return PDF;
110 } else if (str == "LRI") {
111 return LRI;
112 } else if (str == "RLI") {
113 return RLI;
114 } else if (str == "FSI") {
115 return FSI;
116 } else if (str == "PDI") {
117 return PDI;
118 } else {
120 }
121}
122
123} // namespace hi::inline v1
#define hi_no_default(...)
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:264
DOXYGEN BUG.
Definition algorithm.hpp:13
unicode_bidi_class
Bidirectional class Unicode Standard Annex #9: https://unicode.org/reports/tr9/.
Definition unicode_bidi_class.hpp:16
@ LRO
Left-to-Right Override.
@ ES
European Number Separator.
@ FSI
First Strong Isolate.
@ RLE
Right-to-Left Embedding.
@ LRI
Left-to-Right Isolate.
@ CS
Common Number Separator.
@ ON
Other Neutrals.
@ NSM
Nonspacing Mark.
@ PDI
Pop Directional Isolate.
@ EN
European Number.
@ ET
European Number Terminator.
@ RLI
Right-to-Left Isolate.
@ PDF
Pop Directional Format.
@ RLO
Right-to-left Override.
@ AN
Arabic Number.
@ AL
Right-to-Left Arabic.
@ LRE
Left-to-Right Embedding.
@ BN
Boundary Neutral.