1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:07:46 +00:00

LibChess: Return ErrorOr<String> from to-algebraic/fen methods

Also, avoid creating temporary Strings for numbers, and stop appending
empty StringViews.
This commit is contained in:
Sam Atkins 2023-04-24 12:51:33 +01:00 committed by Andreas Kling
parent 5f6dd87163
commit a10cc37ef0
4 changed files with 59 additions and 58 deletions

View file

@ -93,7 +93,7 @@ struct Square {
char file_char() const;
char rank_char() const;
DeprecatedString to_algebraic() const;
ErrorOr<String> to_algebraic() const;
};
class Board;
@ -118,8 +118,8 @@ struct Move {
bool operator==(Move const& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; }
static Move from_algebraic(StringView algebraic, const Color turn, Board const& board);
DeprecatedString to_long_algebraic() const;
DeprecatedString to_algebraic() const;
ErrorOr<String> to_long_algebraic() const;
ErrorOr<String> to_algebraic() const;
};
class Board {
@ -138,7 +138,7 @@ public:
bool apply_move(Move const&, Color color = Color::None);
Optional<Move> const& last_move() const { return m_last_move; }
DeprecatedString to_fen() const;
ErrorOr<String> to_fen() const;
enum class Result {
CheckMate,