1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:47:34 +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:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -6,8 +6,8 @@
#include "ChessWidget.h"
#include "PromotionDialog.h"
#include <AK/DeprecatedString.h>
#include <AK/Random.h>
#include <AK/String.h>
#include <LibCore/DateTime.h>
#include <LibCore/File.h>
#include <LibGUI/MessageBox.h>
@ -370,7 +370,7 @@ void ChessWidget::keydown_event(GUI::KeyEvent& event)
update();
}
static String set_path = String("/res/icons/chess/sets/");
static DeprecatedString set_path = DeprecatedString("/res/icons/chess/sets/");
static RefPtr<Gfx::Bitmap> get_piece(StringView set, StringView image)
{
@ -521,7 +521,7 @@ void ChessWidget::playback_move(PlaybackDirection direction)
update();
}
String ChessWidget::get_fen() const
DeprecatedString ChessWidget::get_fen() const
{
return m_playback ? m_board_playback.to_fen() : m_board.to_fen();
}
@ -547,10 +547,10 @@ void ChessWidget::import_pgn(Core::File& file)
bool recursive_annotation = false;
bool future_expansion = false;
Chess::Color turn = Chess::Color::White;
String movetext;
DeprecatedString movetext;
for (size_t j = i; j < lines.size(); j++)
movetext = String::formatted("{}{}", movetext, lines.at(i).to_string());
movetext = DeprecatedString::formatted("{}{}", movetext, lines.at(i).to_string());
for (auto token : movetext.split(' ')) {
token = token.trim_whitespace();
@ -626,16 +626,16 @@ void ChessWidget::export_pgn(Core::File& file) const
// Tag Pair Section
file.write("[Event \"Casual Game\"]\n"sv);
file.write("[Site \"SerenityOS Chess\"]\n"sv);
file.write(String::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_string("%Y.%m.%d"sv)));
file.write(DeprecatedString::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_string("%Y.%m.%d"sv)));
file.write("[Round \"1\"]\n"sv);
String username(getlogin());
const String player1 = (!username.is_empty() ? username.view() : "?"sv);
const String player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv : "?"sv);
file.write(String::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2));
file.write(String::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2));
DeprecatedString username(getlogin());
const DeprecatedString player1 = (!username.is_empty() ? username.view() : "?"sv);
const DeprecatedString player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv : "?"sv);
file.write(DeprecatedString::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2));
file.write(DeprecatedString::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2));
file.write(String::formatted("[Result \"{}\"]\n", Chess::Board::result_to_points(m_board.game_result(), m_board.turn())));
file.write(DeprecatedString::formatted("[Result \"{}\"]\n", Chess::Board::result_to_points(m_board.game_result(), m_board.turn())));
file.write("[WhiteElo \"?\"]\n"sv);
file.write("[BlackElo \"?\"]\n"sv);
file.write("[Variant \"Standard\"]\n"sv);
@ -645,13 +645,13 @@ void ChessWidget::export_pgn(Core::File& file) const
// Movetext Section
for (size_t i = 0, move_no = 1; i < m_board.moves().size(); i += 2, move_no++) {
const String white = m_board.moves().at(i).to_algebraic();
const DeprecatedString white = m_board.moves().at(i).to_algebraic();
if (i + 1 < m_board.moves().size()) {
const String black = m_board.moves().at(i + 1).to_algebraic();
file.write(String::formatted("{}. {} {} ", move_no, white, black));
const DeprecatedString black = m_board.moves().at(i + 1).to_algebraic();
file.write(DeprecatedString::formatted("{}. {} {} ", move_no, white, black));
} else {
file.write(String::formatted("{}. {} ", move_no, white));
file.write(DeprecatedString::formatted("{}. {} ", move_no, white));
}
}
@ -688,7 +688,7 @@ int ChessWidget::resign()
set_drag_enabled(false);
update();
const String msg = Chess::Board::result_to_string(m_board.game_result(), m_board.turn());
const DeprecatedString msg = Chess::Board::result_to_string(m_board.game_result(), m_board.turn());
GUI::MessageBox::show(window(), msg, "Game Over"sv, GUI::MessageBox::Type::Information);
return 0;

View file

@ -36,7 +36,7 @@ public:
void set_side(Chess::Color side) { m_side = side; };
void set_piece_set(StringView set);
String const& piece_set() const { return m_piece_set; };
DeprecatedString const& piece_set() const { return m_piece_set; };
Chess::Square mouse_to_square(GUI::MouseEvent& event) const;
@ -47,7 +47,7 @@ public:
bool show_available_moves() const { return m_show_available_moves; }
void set_show_available_moves(bool e) { m_show_available_moves = e; }
String get_fen() const;
DeprecatedString get_fen() const;
void import_pgn(Core::File&);
void export_pgn(Core::File&) const;
@ -56,7 +56,7 @@ public:
void reset();
struct BoardTheme {
String name;
DeprecatedString name;
Color dark_square_color;
Color light_square_color;
};
@ -120,7 +120,7 @@ private:
Color m_marking_secondary_color { Color::from_argb(0x6655dd55) };
Chess::Color m_side { Chess::Color::White };
HashMap<Chess::Piece, RefPtr<Gfx::Bitmap>> m_pieces;
String m_piece_set;
DeprecatedString m_piece_set;
Chess::Square m_moving_square { 50, 50 };
Gfx::IntPoint m_drag_point;
bool m_dragging_piece { false };

View file

@ -36,7 +36,7 @@ Engine::Engine(StringView command)
posix_spawn_file_actions_adddup2(&file_actions, wpipefds[0], STDIN_FILENO);
posix_spawn_file_actions_adddup2(&file_actions, rpipefds[1], STDOUT_FILENO);
String cstr(command);
DeprecatedString cstr(command);
char const* argv[] = { cstr.characters(), nullptr };
if (posix_spawnp(&m_pid, cstr.characters(), &file_actions, nullptr, const_cast<char**>(argv), environ) < 0) {
perror("posix_spawnp");

View file

@ -169,7 +169,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
});
engines_action_group.add_action(*action);
if (engine == String("Human"))
if (engine == DeprecatedString("Human"))
action->set_checked(true);
TRY(engine_submenu->try_add_action(*action));