40 unicode_general_category general_category,
41 unicode_grapheme_cluster_break grapheme_cluster_break,
43 unicode_word_break_property word_break_property,
44 unicode_sentence_break_property sentence_break_property,
45 unicode_east_asian_width east_asian_width,
46 unicode_script script,
49 char32_t bidi_mirroring_glyph,
50 uint8_t canonical_combining_class,
52 uint32_t decomposition_index,
53 uint16_t composition_index) noexcept :
54 _general_category(to_underlying(general_category)),
55 _grapheme_cluster_break(to_underlying(grapheme_cluster_break)),
56 _line_break_class(to_underlying(line_break_class)),
57 _word_break_property(to_underlying(word_break_property)),
58 _sentence_break_property(to_underlying(sentence_break_property)),
59 _east_asian_width(to_underlying(east_asian_width)),
60 _script(to_underlying(script)),
61 _bidi_class(to_underlying(bidi_class)),
62 _bidi_bracket_type(to_underlying(bidi_bracket_type)),
63 _bidi_mirroring_glyph(truncate<uint32_t>(bidi_mirroring_glyph)),
64 _canonical_combining_class(truncate<uint32_t>(canonical_combining_class)),
65 _decomposition_type(to_underlying(decomposition_type)),
66 _decomposition_index(truncate<uint32_t>(decomposition_index)),
67 _composition_index(truncate<uint16_t>(composition_index))
69 hi_assert(to_underlying(general_category) <= 0x1f);
70 hi_assert(to_underlying(grapheme_cluster_break) <= 0x0f);
71 hi_assert(to_underlying(line_break_class) <= 0x3f);
72 hi_assert(to_underlying(word_break_property) <= 0x1f);
73 hi_assert(to_underlying(sentence_break_property) <= 0xf);
74 hi_assert(to_underlying(east_asian_width) <= 0x7);
76 hi_assert(to_underlying(bidi_class) <= 0x1f);
77 hi_assert(to_underlying(bidi_bracket_type) <= 0x03);
78 hi_assert(
static_cast<uint32_t
>(bidi_mirroring_glyph) <= 0xffff);
79 hi_assert(
static_cast<uint32_t
>(canonical_combining_class) <= 0xff);
80 hi_assert(to_underlying(decomposition_type) <= 0x1f);
81 hi_assert(
static_cast<uint32_t
>(decomposition_index) <= 0x1f'ffff);
82 hi_assert(
static_cast<uint32_t
>(composition_index) <= 0x3fff);
93 return static_cast<unicode_general_category
>(_general_category);
104 return static_cast<unicode_grapheme_cluster_break
>(_grapheme_cluster_break);
112 [[nodiscard]]
constexpr unicode_word_break_property word_break_property() const noexcept
114 return static_cast<unicode_word_break_property
>(_word_break_property);
117 [[nodiscard]]
constexpr unicode_sentence_break_property sentence_break_property() const noexcept
119 return static_cast<unicode_sentence_break_property
>(_sentence_break_property);
122 [[nodiscard]]
constexpr unicode_east_asian_width east_asian_width() const noexcept
124 return static_cast<unicode_east_asian_width
>(_east_asian_width);
140 [[nodiscard]]
constexpr unicode_script
script() const noexcept
142 return static_cast<unicode_script
>(_script);
161 return truncate<char32_t>(_bidi_mirroring_glyph);
183 return truncate<uint8_t>(_canonical_combining_class);
197 [[nodiscard]]
char32_t compose(
char32_t other) const noexcept;
205 [[nodiscard]] constexpr
char32_t canonical_equivalent() const noexcept
207 if (decomposition_type() == unicode_decomposition_type::canonical and _decomposition_index <= 0x1f'ffff) {
208 return truncate<char32_t>(_decomposition_index);
226 [[nodiscard]]
friend bool operator==(
unicode_description const& lhs, unicode_general_category
const& rhs)
noexcept
228 return lhs.general_category() == rhs;
233 return lhs.decomposition_type() == rhs;
236 [[nodiscard]]
friend bool operator==(unicode_description
const& lhs, unicode_bidi_bracket_type
const& rhs)
noexcept
238 return lhs.bidi_bracket_type() == rhs;
241 [[nodiscard]]
friend bool operator==(unicode_description
const& lhs, unicode_bidi_class
const& rhs)
noexcept
243 return lhs.bidi_class() == rhs;
245 [[nodiscard]]
friend bool operator==(unicode_description
const& lhs, unicode_east_asian_width
const& rhs)
noexcept
247 return lhs.east_asian_width() == rhs;
250 [[nodiscard]]
friend bool operator==(unicode_description
const& lhs, unicode_sentence_break_property
const& rhs)
noexcept
252 return lhs.sentence_break_property() == rhs;
255 [[nodiscard]]
friend bool operator==(unicode_description
const& lhs, unicode_line_break_class
const& rhs)
noexcept
257 return lhs.line_break_class() == rhs;
260 [[nodiscard]]
friend bool operator==(unicode_description
const& lhs, unicode_word_break_property
const& rhs)
noexcept
262 return lhs.word_break_property() == rhs;
265 [[nodiscard]]
friend bool operator==(unicode_description
const& lhs, unicode_grapheme_cluster_break
const& rhs)
noexcept
267 return lhs.grapheme_cluster_break() == rhs;
270 [[nodiscard]]
friend bool is_C(unicode_description
const& rhs)
noexcept
272 return is_C(rhs.general_category());
277 uint64_t _general_category : 5;
278 uint64_t _grapheme_cluster_break : 4;
279 uint64_t _line_break_class : 6;
280 uint64_t _word_break_property : 5;
281 uint64_t _sentence_break_property : 4;
282 uint64_t _east_asian_width : 3;
283 uint64_t _bidi_class : 5;
284 uint64_t _bidi_bracket_type : 2;
285 uint64_t _bidi_mirroring_glyph : 16;
286 uint64_t _canonical_combining_class : 8;
287 uint64_t _word0_reserved : 6 = 0;
290 uint64_t _script : 8;
291 uint64_t _decomposition_type : 5;
292 uint64_t _decomposition_index : 21;
293 uint64_t _composition_index : 14;
294 uint64_t _word1_reserved : 16 = 0;