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