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/module.hpp"
8#include <format>
9#include <ostream>
10#include <vector>
11
12namespace hi::inline v1 {
13
14enum class unicode_break_opportunity : uint8_t {
15 no,
16 yes,
17 mandatory,
18 unassigned,
19};
20
21using unicode_break_vector = std::vector<unicode_break_opportunity>;
22using unicode_break_iterator = unicode_break_vector::iterator;
23using unicode_break_const_iterator = unicode_break_vector::const_iterator;
24
25inline std::ostream &operator<<(std::ostream &lhs, unicode_break_opportunity const &rhs) {
26 hilet *s = [&] () {
27 switch (rhs) {
28 using enum unicode_break_opportunity;
29 case no: return "X";
30 case yes: return ":";
31 case mandatory: return "!";
32 case unassigned: return "-";
33 default: hi_no_default();
34 }
35 }();
36 return lhs << s;
37}
38
39}
40
41template<typename CharT>
42struct std::formatter<hi::unicode_break_opportunity, CharT> : std::formatter<char const *, CharT> {
43 auto format(hi::unicode_break_opportunity const &t, auto &fc)
44 {
45 hilet *s = [&]() {
46 switch (t) {
47 using enum hi::unicode_break_opportunity;
48 case no: return "X";
49 case yes: return ":";
50 case mandatory: return "!";
51 case unassigned: return "-";
52 default: hi_no_default();
53 }
54 }();
55 return std::formatter<char const *, CharT>::format(s, fc);
56 }
57};
#define hi_no_default(...)
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:279
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11