HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
unicode_break_opportunity.hpp
1// Copyright Take Vos 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/utility.hpp"
8#include "../macros.hpp"
9#include <format>
10#include <ostream>
11#include <vector>
12
13hi_export_module(hikogui.unicode.unicode_break_opportunity);
14
15
16hi_export namespace hi::inline v1 {
17
18enum class unicode_break_opportunity : uint8_t {
19 no,
20 yes,
21 mandatory,
22 unassigned,
23};
24
25using unicode_break_vector = std::vector<unicode_break_opportunity>;
26using unicode_break_iterator = unicode_break_vector::iterator;
27using unicode_break_const_iterator = unicode_break_vector::const_iterator;
28
29inline std::ostream &operator<<(std::ostream &lhs, unicode_break_opportunity const &rhs) {
30 auto const *s = [&] () {
31 switch (rhs) {
32 using enum unicode_break_opportunity;
33 case no: return "X";
34 case yes: return ":";
35 case mandatory: return "!";
36 case unassigned: return "-";
37 default: hi_no_default();
38 }
39 }();
40 return lhs << s;
41}
42
43}
44
45// XXX #617 MSVC bug does not handle partial specialization in modules.
46hi_export template<>
47struct std::formatter<hi::unicode_break_opportunity, char> : std::formatter<char const *, char> {
48 auto format(hi::unicode_break_opportunity const &t, auto &fc) const
49 {
50 auto const *s = [&]() {
51 switch (t) {
52 using enum hi::unicode_break_opportunity;
53 case no: return "X";
54 case yes: return ":";
55 case mandatory: return "!";
56 case unassigned: return "-";
57 default: hi_no_default();
58 }
59 }();
60 return std::formatter<char const *, char>::format(s, fc);
61 }
62};
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20