BenBot 1.7.5
A chess engine
Loading...
Searching...
No Matches
UTF8.hpp
Go to the documentation of this file.
1/*
2 * ======================================================================================
3 *
4 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
5 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7 * ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9 * ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
10 * ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
11 *
12 * ======================================================================================
13 */
14
19
24
25#pragma once
26
29#include <string_view>
30
35
36using std::string_view;
37
43namespace white {
44
47
49 inline constexpr string_view PAWN { "\xE2\x99\x99" };
50
52 inline constexpr string_view KNIGHT { "\xE2\x99\x98" };
53
55 inline constexpr string_view BISHOP { "\xE2\x99\x97" };
56
58 inline constexpr string_view ROOK { "\xE2\x99\x96" };
59
61 inline constexpr string_view QUEEN { "\xE2\x99\x95" };
62
64 inline constexpr string_view KING { "\xE2\x99\x94" };
65
67 [[nodiscard, gnu::const]] constexpr auto get(const Type type) noexcept -> string_view
68 {
69 switch (type) {
70 case Type::Knight: return KNIGHT;
71 case Type::Bishop: return BISHOP;
72 case Type::Rook : return ROOK;
73 case Type::Queen : return QUEEN;
74 case Type::King : return KING;
75 case Type::Pawn : return PAWN;
76 default:
77 [[unlikely]];
78 return { };
79 }
80 }
81
83
84} // namespace white
85
91namespace black {
92
95
97 inline constexpr string_view PAWN { "\xE2\x99\x9F" };
98
100 inline constexpr string_view KNIGHT { "\xE2\x99\x9E" };
101
103 inline constexpr string_view BISHOP { "\xE2\x99\x9D" };
104
106 inline constexpr string_view ROOK { "\xE2\x99\x9C" };
107
109 inline constexpr string_view QUEEN { "\xE2\x99\x9B" };
110
112 inline constexpr string_view KING { "\xE2\x99\x9A" };
113
115 [[nodiscard, gnu::const]] constexpr auto get(const Type type) noexcept -> string_view
116 {
117 switch (type) {
118 case Type::Knight: return KNIGHT;
119 case Type::Bishop: return BISHOP;
120 case Type::Rook : return ROOK;
121 case Type::Queen : return QUEEN;
122 case Type::King : return KING;
123 case Type::Pawn : return PAWN;
124 default:
125 [[unlikely]];
126 return { };
127 }
128 }
129
131
132} // namespace black
133
136
138[[nodiscard, gnu::const]] constexpr auto pawn(const Color color) noexcept -> string_view
139{
140 if (color == Color::White)
141 return white::PAWN;
142
143 return black::PAWN;
144}
145
147[[nodiscard, gnu::const]] constexpr auto knight(const Color color) noexcept -> string_view
148{
149 if (color == Color::White)
150 return white::KNIGHT;
151
152 return black::KNIGHT;
153}
154
156[[nodiscard, gnu::const]] constexpr auto bishop(const Color color) noexcept -> string_view
157{
158 if (color == Color::White)
159 return white::BISHOP;
160
161 return black::BISHOP;
162}
163
165[[nodiscard, gnu::const]] constexpr auto rook(const Color color) noexcept -> string_view
166{
167 if (color == Color::White)
168 return white::ROOK;
169
170 return black::ROOK;
171}
172
174[[nodiscard, gnu::const]] constexpr auto queen(const Color color) noexcept -> string_view
175{
176 if (color == Color::White)
177 return white::QUEEN;
178
179 return black::QUEEN;
180}
181
183[[nodiscard, gnu::const]] constexpr auto king(const Color color) noexcept -> string_view
184{
185 if (color == Color::White)
186 return white::KING;
187
188 return black::KING;
189}
190
192
193} // namespace chess::pieces::utf8
@ White
The White player.
Definition Colors.hpp:31
@ Pawn
A White pawn.
constexpr string_view BISHOP
Definition UTF8.hpp:103
constexpr auto get(const Type type) noexcept -> string_view
Definition UTF8.hpp:115
constexpr string_view QUEEN
Definition UTF8.hpp:109
constexpr string_view ROOK
Definition UTF8.hpp:106
constexpr auto pawn(const Color color) noexcept -> string_view
Definition UTF8.hpp:138
constexpr string_view KING
Definition UTF8.hpp:112
constexpr auto rook(const Color color) noexcept -> string_view
Definition UTF8.hpp:165
constexpr string_view QUEEN
Definition UTF8.hpp:61
constexpr string_view KING
Definition UTF8.hpp:64
constexpr auto king(const Color color) noexcept -> string_view
Definition UTF8.hpp:183
constexpr string_view PAWN
Definition UTF8.hpp:97
constexpr string_view PAWN
Definition UTF8.hpp:49
constexpr string_view ROOK
Definition UTF8.hpp:58
constexpr string_view KNIGHT
Definition UTF8.hpp:100
constexpr string_view BISHOP
Definition UTF8.hpp:55
constexpr auto knight(const Color color) noexcept -> string_view
Definition UTF8.hpp:147
constexpr auto queen(const Color color) noexcept -> string_view
Definition UTF8.hpp:174
constexpr auto bishop(const Color color) noexcept -> string_view
Definition UTF8.hpp:156
constexpr auto get(const Type type) noexcept -> string_view
Definition UTF8.hpp:67
constexpr string_view KNIGHT
Definition UTF8.hpp:52