7#include "ucd_grapheme_cluster_breaks.hpp"
8#include "unicode_break_opportunity.hpp"
9#include "../macros.hpp"
12namespace hi {
inline namespace v1 {
16 unicode_grapheme_cluster_break previous = unicode_grapheme_cluster_break::Other;
18 bool first_character =
true;
19 bool in_extended_pictograph =
false;
21 constexpr void reset()
noexcept
23 previous = unicode_grapheme_cluster_break::Other;
25 first_character =
true;
26 in_extended_pictograph =
false;
40 using enum unicode_grapheme_cluster_break;
42 hilet lhs = state.previous;
54 bool GB1 = state.first_character;
59 state.first_character =
false;
62 hilet
GB3 = (lhs == CR) && (rhs == LF);
63 hilet
GB4 = (lhs == Control) || (lhs == CR) || (lhs == LF);
64 hilet
GB5 = (rhs == Control) || (rhs == CR) || (rhs == LF);
74 hilet
GB6 = (lhs == L) && ((rhs == L) || (rhs == V) || (rhs == LV) | (rhs == LVT));
75 hilet
GB7 = ((lhs == LV) || (lhs == V)) && ((rhs == V) || (rhs == T));
76 hilet
GB8 = ((lhs == LVT) || (lhs == T)) && (rhs == T);
82 hilet
GB9 = ((rhs == Extend) || (rhs == ZWJ));
86 hilet
GB9a = (rhs == SpacingMark);
87 hilet
GB9b = (lhs == Prepend);
93 hilet
GB11 = state.in_extended_pictograph && (lhs == ZWJ) && (rhs == Extended_Pictographic);
98 if (rhs == Extended_Pictographic) {
99 state.in_extended_pictograph =
true;
100 }
else if (!((rhs == Extend) || (rhs == ZWJ))) {
101 state.in_extended_pictograph =
false;
107 hilet
GB12_13 = (lhs == Regional_Indicator) && (rhs == Regional_Indicator) && ((state.RI_count % 2) == 1);
112 if (rhs == Regional_Indicator) {
123 state.previous = rhs;
134[[
nodiscard]]
constexpr bool breaks_grapheme(
char32_t code_point, grapheme_break_state& state)
noexcept
136 return breaks_grapheme(ucd_get_grapheme_cluster_break(code_point), state);
141template<
typename It,
typename ItEnd>
145 auto state = detail::grapheme_break_state{};
147 for (
auto it = first;
it != last; ++
it) {
148 hilet
opportunity = detail::breaks_grapheme(*
it, state) ? unicode_break_opportunity::yes : unicode_break_opportunity::no;
152 r.push_back(unicode_break_opportunity::yes);
DOXYGEN BUG.
Definition algorithm.hpp:16
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 unicode_grapheme_cluster_break.hpp:15