HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
unicode_general_category.hpp
1// Copyright Take Vos 2020-2022.
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 "../utility.hpp"
8#include <cstdint>
9
10namespace hi::inline v1 {
11
12enum class unicode_general_category : uint8_t {
13 Lu,
14 Ll,
15 Lt,
16 Lm,
17 Lo,
18 Mn,
19 Mc,
20 Me,
21 Nd,
22 Nl,
23 No,
24 Pc,
25 Pd,
26 Ps,
27 Pe,
28 Pi,
29 Pf,
30 Po,
31 Sm,
32 Sc,
33 Sk,
34 So,
35 Zs,
36 Zl,
37 Zp,
38 Cc,
39 Cf,
40 Cs,
41 Co,
42 Cn
43};
44
45[[nodiscard]] constexpr bool is_LC(unicode_general_category const &rhs) noexcept
46{
47 using enum unicode_general_category;
48 return rhs >= Lu and rhs <= Lt;
49}
50
51[[nodiscard]] constexpr bool is_L(unicode_general_category const &rhs) noexcept
52{
53 using enum unicode_general_category;
54 return rhs >= Lu and rhs <= Lo;
55}
56
57[[nodiscard]] constexpr bool is_M(unicode_general_category const &rhs) noexcept
58{
59 using enum unicode_general_category;
60 return rhs >= Mn and rhs <= Me;
61}
62
63[[nodiscard]] constexpr bool is_Mn_or_Mc(unicode_general_category const &rhs) noexcept
64{
65 using enum unicode_general_category;
66 return rhs == Mn or rhs == Mc;
67}
68
69[[nodiscard]] constexpr bool is_N(unicode_general_category const &rhs) noexcept
70{
71 using enum unicode_general_category;
72 return rhs >= Nd and rhs <= No;
73}
74
75[[nodiscard]] constexpr bool is_P(unicode_general_category const &rhs) noexcept
76{
77 using enum unicode_general_category;
78 return rhs >= Pc and rhs <= Po;
79}
80
81[[nodiscard]] constexpr bool is_S(unicode_general_category const &rhs) noexcept
82{
83 using enum unicode_general_category;
84 return rhs >= Sm and rhs <= So;
85}
86
87[[nodiscard]] constexpr bool is_Z(unicode_general_category const &rhs) noexcept
88{
89 using enum unicode_general_category;
90 return rhs >= Zs and rhs <= Zp;
91}
92
93[[nodiscard]] constexpr bool is_Zp_or_Zl(unicode_general_category const &rhs) noexcept
94{
95 using enum unicode_general_category;
96 return rhs == Zp or rhs == Zl;
97}
98
99[[nodiscard]] constexpr bool is_C(unicode_general_category const &rhs) noexcept
100{
101 using enum unicode_general_category;
102 return rhs >= Cc and rhs <= Cn;
103}
104
105[[nodiscard]] constexpr bool is_visible(unicode_general_category const &rhs) noexcept
106{
107 using enum unicode_general_category;
108 return rhs < Zs or rhs == Co;
109}
110
111[[nodiscard]] constexpr bool is_noncharacter(char32_t rhs) noexcept
112{
113 hilet rhs_ = static_cast<uint32_t>(rhs);
114 return rhs_ >= 0x11'0000 or (rhs_ & 0xfffe) == 0xfffe or (rhs >= 0xfdd0 and rhs <= 0xfdef);
115}
116
117} // namespace hi::inline v1
Utilities used by the HikoGUI library itself.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15