mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:17:45 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibChess/Chess.h>
|
||||
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace Chess {
|
||||
|
||||
String char_for_piece(Chess::Type type)
|
||||
DeprecatedString char_for_piece(Chess::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case Type::Knight:
|
||||
|
@ -34,7 +34,7 @@ String char_for_piece(Chess::Type type)
|
|||
|
||||
Chess::Type piece_for_char_promotion(StringView str)
|
||||
{
|
||||
String string = String(str).to_lowercase();
|
||||
DeprecatedString string = DeprecatedString(str).to_lowercase();
|
||||
if (string == "")
|
||||
return Type::None;
|
||||
if (string == "n")
|
||||
|
@ -77,7 +77,7 @@ Square::Square(StringView name)
|
|||
}
|
||||
}
|
||||
|
||||
String Square::to_algebraic() const
|
||||
DeprecatedString Square::to_algebraic() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(file + 'a');
|
||||
|
@ -92,7 +92,7 @@ Move::Move(StringView long_algebraic)
|
|||
{
|
||||
}
|
||||
|
||||
String Move::to_long_algebraic() const
|
||||
DeprecatedString Move::to_long_algebraic() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(from.to_algebraic());
|
||||
|
@ -103,7 +103,7 @@ String Move::to_long_algebraic() const
|
|||
|
||||
Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& board)
|
||||
{
|
||||
String move_string = algebraic;
|
||||
DeprecatedString move_string = algebraic;
|
||||
Move move({ 50, 50 }, { 50, 50 });
|
||||
|
||||
if (move_string.contains('-')) {
|
||||
|
@ -176,7 +176,7 @@ Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& b
|
|||
return move;
|
||||
}
|
||||
|
||||
String Move::to_algebraic() const
|
||||
DeprecatedString Move::to_algebraic() const
|
||||
{
|
||||
if (piece.type == Type::King && from.file == 4) {
|
||||
if (to.file == 2)
|
||||
|
@ -269,7 +269,7 @@ Board Board::clone_without_history() const
|
|||
return result;
|
||||
}
|
||||
|
||||
String Board::to_fen() const
|
||||
DeprecatedString Board::to_fen() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -283,17 +283,17 @@ String Board::to_fen() const
|
|||
continue;
|
||||
}
|
||||
if (empty > 0) {
|
||||
builder.append(String::number(empty));
|
||||
builder.append(DeprecatedString::number(empty));
|
||||
empty = 0;
|
||||
}
|
||||
String piece = char_for_piece(p.type);
|
||||
DeprecatedString piece = char_for_piece(p.type);
|
||||
if (piece == "")
|
||||
piece = "P";
|
||||
|
||||
builder.append(p.color == Color::Black ? piece.to_lowercase() : piece);
|
||||
}
|
||||
if (empty > 0) {
|
||||
builder.append(String::number(empty));
|
||||
builder.append(DeprecatedString::number(empty));
|
||||
empty = 0;
|
||||
}
|
||||
if (rank < 7)
|
||||
|
@ -327,11 +327,11 @@ String Board::to_fen() const
|
|||
builder.append(' ');
|
||||
|
||||
// 5. Halfmove clock
|
||||
builder.append(String::number(min(m_moves_since_capture, m_moves_since_pawn_advance)));
|
||||
builder.append(DeprecatedString::number(min(m_moves_since_capture, m_moves_since_pawn_advance)));
|
||||
builder.append(' ');
|
||||
|
||||
// 6. Fullmove number
|
||||
builder.append(String::number(1 + m_moves.size() / 2));
|
||||
builder.append(DeprecatedString::number(1 + m_moves.size() / 2));
|
||||
|
||||
return builder.to_string();
|
||||
}
|
||||
|
@ -886,7 +886,7 @@ void Board::set_resigned(Chess::Color c)
|
|||
m_resigned = c;
|
||||
}
|
||||
|
||||
String Board::result_to_string(Result result, Color turn)
|
||||
DeprecatedString Board::result_to_string(Result result, Color turn)
|
||||
{
|
||||
switch (result) {
|
||||
case Result::CheckMate:
|
||||
|
@ -915,7 +915,7 @@ String Board::result_to_string(Result result, Color turn)
|
|||
}
|
||||
}
|
||||
|
||||
String Board::result_to_points(Result result, Color turn)
|
||||
DeprecatedString Board::result_to_points(Result result, Color turn)
|
||||
{
|
||||
switch (result) {
|
||||
case Result::CheckMate:
|
||||
|
|
|
@ -25,7 +25,7 @@ enum class Type : u8 {
|
|||
None,
|
||||
};
|
||||
|
||||
String char_for_piece(Type type);
|
||||
DeprecatedString char_for_piece(Type type);
|
||||
Chess::Type piece_for_char_promotion(StringView str);
|
||||
|
||||
enum class Color : u8 {
|
||||
|
@ -85,7 +85,7 @@ struct Square {
|
|||
|
||||
bool in_bounds() const { return rank >= 0 && file >= 0 && rank < 8 && file < 8; }
|
||||
bool is_light() const { return (rank % 2) != (file % 2); }
|
||||
String to_algebraic() const;
|
||||
DeprecatedString to_algebraic() const;
|
||||
};
|
||||
|
||||
class Board;
|
||||
|
@ -110,8 +110,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);
|
||||
String to_long_algebraic() const;
|
||||
String to_algebraic() const;
|
||||
DeprecatedString to_long_algebraic() const;
|
||||
DeprecatedString to_algebraic() const;
|
||||
};
|
||||
|
||||
class Board {
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
bool apply_move(Move const&, Color color = Color::None);
|
||||
Optional<Move> const& last_move() const { return m_last_move; }
|
||||
|
||||
String to_fen() const;
|
||||
DeprecatedString to_fen() const;
|
||||
|
||||
enum class Result {
|
||||
CheckMate,
|
||||
|
@ -145,8 +145,8 @@ public:
|
|||
NotFinished,
|
||||
};
|
||||
|
||||
static String result_to_string(Result, Color turn);
|
||||
static String result_to_points(Result, Color turn);
|
||||
static DeprecatedString result_to_string(Result, Color turn);
|
||||
static DeprecatedString result_to_points(Result, Color turn);
|
||||
|
||||
template<typename Callback>
|
||||
void generate_moves(Callback callback, Color color = Color::None) const;
|
||||
|
|
|
@ -17,7 +17,7 @@ UCICommand UCICommand::from_string(StringView command)
|
|||
return UCICommand();
|
||||
}
|
||||
|
||||
String UCICommand::to_string() const
|
||||
DeprecatedString UCICommand::to_string() const
|
||||
{
|
||||
return "uci\n";
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ DebugCommand DebugCommand::from_string(StringView command)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String DebugCommand::to_string() const
|
||||
DeprecatedString DebugCommand::to_string() const
|
||||
{
|
||||
if (flag() == Flag::On) {
|
||||
return "debug on\n";
|
||||
|
@ -52,7 +52,7 @@ IsReadyCommand IsReadyCommand::from_string(StringView command)
|
|||
return IsReadyCommand();
|
||||
}
|
||||
|
||||
String IsReadyCommand::to_string() const
|
||||
DeprecatedString IsReadyCommand::to_string() const
|
||||
{
|
||||
return "isready\n";
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ SetOptionCommand SetOptionCommand::from_string(StringView command)
|
|||
return SetOptionCommand(name.to_string().trim_whitespace(), value.to_string().trim_whitespace());
|
||||
}
|
||||
|
||||
String SetOptionCommand::to_string() const
|
||||
DeprecatedString SetOptionCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("setoption name "sv);
|
||||
|
@ -115,7 +115,7 @@ PositionCommand PositionCommand::from_string(StringView command)
|
|||
VERIFY(tokens[0] == "position");
|
||||
VERIFY(tokens[2] == "moves");
|
||||
|
||||
Optional<String> fen;
|
||||
Optional<DeprecatedString> fen;
|
||||
if (tokens[1] != "startpos")
|
||||
fen = tokens[1];
|
||||
|
||||
|
@ -126,7 +126,7 @@ PositionCommand PositionCommand::from_string(StringView command)
|
|||
return PositionCommand(fen, moves);
|
||||
}
|
||||
|
||||
String PositionCommand::to_string() const
|
||||
DeprecatedString PositionCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("position "sv);
|
||||
|
@ -190,7 +190,7 @@ GoCommand GoCommand::from_string(StringView command)
|
|||
return go_command;
|
||||
}
|
||||
|
||||
String GoCommand::to_string() const
|
||||
DeprecatedString GoCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("go"sv);
|
||||
|
@ -238,7 +238,7 @@ StopCommand StopCommand::from_string(StringView command)
|
|||
return StopCommand();
|
||||
}
|
||||
|
||||
String StopCommand::to_string() const
|
||||
DeprecatedString StopCommand::to_string() const
|
||||
{
|
||||
return "stop\n";
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ IdCommand IdCommand::from_string(StringView command)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String IdCommand::to_string() const
|
||||
DeprecatedString IdCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("id "sv);
|
||||
|
@ -285,7 +285,7 @@ UCIOkCommand UCIOkCommand::from_string(StringView command)
|
|||
return UCIOkCommand();
|
||||
}
|
||||
|
||||
String UCIOkCommand::to_string() const
|
||||
DeprecatedString UCIOkCommand::to_string() const
|
||||
{
|
||||
return "uciok\n";
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ ReadyOkCommand ReadyOkCommand::from_string(StringView command)
|
|||
return ReadyOkCommand();
|
||||
}
|
||||
|
||||
String ReadyOkCommand::to_string() const
|
||||
DeprecatedString ReadyOkCommand::to_string() const
|
||||
{
|
||||
return "readyok\n";
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ BestMoveCommand BestMoveCommand::from_string(StringView command)
|
|||
return BestMoveCommand(Move(tokens[1]));
|
||||
}
|
||||
|
||||
String BestMoveCommand::to_string() const
|
||||
DeprecatedString BestMoveCommand::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("bestmove "sv);
|
||||
|
@ -326,7 +326,7 @@ InfoCommand InfoCommand::from_string([[maybe_unused]] StringView command)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
String InfoCommand::to_string() const
|
||||
DeprecatedString InfoCommand::to_string() const
|
||||
{
|
||||
// FIXME: Implement this.
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibChess/Chess.h>
|
||||
#include <LibCore/Event.h>
|
||||
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual String to_string() const = 0;
|
||||
virtual DeprecatedString to_string() const = 0;
|
||||
|
||||
virtual ~Command() = default;
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
static UCICommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
};
|
||||
|
||||
class DebugCommand : public Command {
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
static DebugCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
Flag flag() const { return m_flag; }
|
||||
|
||||
|
@ -93,12 +93,12 @@ public:
|
|||
|
||||
static IsReadyCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
};
|
||||
|
||||
class SetOptionCommand : public Command {
|
||||
public:
|
||||
explicit SetOptionCommand(StringView name, Optional<String> value = {})
|
||||
explicit SetOptionCommand(StringView name, Optional<DeprecatedString> value = {})
|
||||
: Command(Command::Type::SetOption)
|
||||
, m_name(name)
|
||||
, m_value(value)
|
||||
|
@ -107,19 +107,19 @@ public:
|
|||
|
||||
static SetOptionCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
Optional<String> const& value() const { return m_value; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
Optional<DeprecatedString> const& value() const { return m_value; }
|
||||
|
||||
private:
|
||||
String m_name;
|
||||
Optional<String> m_value;
|
||||
DeprecatedString m_name;
|
||||
Optional<DeprecatedString> m_value;
|
||||
};
|
||||
|
||||
class PositionCommand : public Command {
|
||||
public:
|
||||
explicit PositionCommand(Optional<String> const& fen, Vector<Chess::Move> const& moves)
|
||||
explicit PositionCommand(Optional<DeprecatedString> const& fen, Vector<Chess::Move> const& moves)
|
||||
: Command(Command::Type::Position)
|
||||
, m_fen(fen)
|
||||
, m_moves(moves)
|
||||
|
@ -128,13 +128,13 @@ public:
|
|||
|
||||
static PositionCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
Optional<String> const& fen() const { return m_fen; }
|
||||
Optional<DeprecatedString> const& fen() const { return m_fen; }
|
||||
Vector<Chess::Move> const& moves() const { return m_moves; }
|
||||
|
||||
private:
|
||||
Optional<String> m_fen;
|
||||
Optional<DeprecatedString> m_fen;
|
||||
Vector<Chess::Move> m_moves;
|
||||
};
|
||||
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
|
||||
static GoCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
Optional<Vector<Chess::Move>> searchmoves;
|
||||
bool ponder { false };
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
|
||||
static StopCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
};
|
||||
|
||||
class IdCommand : public Command {
|
||||
|
@ -191,14 +191,14 @@ public:
|
|||
|
||||
static IdCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
Type field_type() const { return m_field_type; }
|
||||
String const& value() const { return m_value; }
|
||||
DeprecatedString const& value() const { return m_value; }
|
||||
|
||||
private:
|
||||
Type m_field_type;
|
||||
String m_value;
|
||||
DeprecatedString m_value;
|
||||
};
|
||||
|
||||
class UCIOkCommand : public Command {
|
||||
|
@ -210,7 +210,7 @@ public:
|
|||
|
||||
static UCIOkCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
};
|
||||
|
||||
class ReadyOkCommand : public Command {
|
||||
|
@ -222,7 +222,7 @@ public:
|
|||
|
||||
static ReadyOkCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
};
|
||||
|
||||
class BestMoveCommand : public Command {
|
||||
|
@ -235,7 +235,7 @@ public:
|
|||
|
||||
static BestMoveCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
Chess::Move move() const { return m_move; }
|
||||
|
||||
|
@ -252,7 +252,7 @@ public:
|
|||
|
||||
static InfoCommand from_string(StringView command);
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
|
||||
Optional<int> depth;
|
||||
Optional<int> seldepth;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "UCIEndpoint.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/File.h>
|
||||
|
||||
|
@ -23,7 +23,7 @@ Endpoint::Endpoint(NonnullRefPtr<Core::IODevice> in, NonnullRefPtr<Core::IODevic
|
|||
|
||||
void Endpoint::send_command(Command const& command)
|
||||
{
|
||||
dbgln_if(UCI_DEBUG, "{} Sent UCI Command: {}", class_name(), String(command.to_string().characters(), Chomp));
|
||||
dbgln_if(UCI_DEBUG, "{} Sent UCI Command: {}", class_name(), DeprecatedString(command.to_string().characters(), Chomp));
|
||||
m_out->write(command.to_string());
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ void Endpoint::set_in_notifier()
|
|||
|
||||
NonnullOwnPtr<Command> Endpoint::read_command()
|
||||
{
|
||||
String line(ReadonlyBytes(m_in->read_line(4096).bytes()), Chomp);
|
||||
DeprecatedString line(ReadonlyBytes(m_in->read_line(4096).bytes()), Chomp);
|
||||
|
||||
dbgln_if(UCI_DEBUG, "{} Received UCI Command: {}", class_name(), line);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue