mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:07:34 +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:
parent
5f6dd87163
commit
a10cc37ef0
4 changed files with 59 additions and 58 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue