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

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -170,7 +170,7 @@ private:
painter.blit({}, audio_bitmap, audio_bitmap.rect());
if (show_percent()) {
auto volume_text = m_audio_muted ? "mute" : DeprecatedString::formatted("{}%", m_audio_volume);
auto volume_text = m_audio_muted ? "mute" : ByteString::formatted("{}%", m_audio_volume);
painter.draw_text(Gfx::IntRect { 16, 3, 24, 16 }, volume_text, Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::TopLeft, palette().window_text());
}
}

View file

@ -39,7 +39,7 @@ ErrorOr<String> ClipboardHistoryModel::column_name(int column) const
}
}
static StringView bpp_for_format_resilient(DeprecatedString format)
static StringView bpp_for_format_resilient(ByteString format)
{
unsigned format_uint = format.to_uint().value_or(static_cast<unsigned>(Gfx::BitmapFormat::Invalid));
// Cannot use Gfx::Bitmap::bpp_for_format here, as we have to accept invalid enum values.
@ -64,7 +64,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
switch (index.column()) {
case Column::Data:
if (data_and_type.mime_type.starts_with("text/"sv))
return DeprecatedString::copy(data_and_type.data);
return ByteString::copy(data_and_type.data);
if (data_and_type.mime_type == "image/x-serenityos") {
StringBuilder builder;
builder.append('[');
@ -75,7 +75,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
builder.append(bpp_for_format_resilient(data_and_type.metadata.get("format").value_or("0")));
builder.append(']');
builder.append(" bitmap"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
if (data_and_type.mime_type.starts_with("glyph/"sv)) {
StringBuilder builder;
@ -90,7 +90,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
builder.append_code_point(start);
builder.appendff(") [{}x{}]", width, height);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
return "<...>";
case Column::Type:
@ -98,13 +98,13 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode
case Column::Size:
return AK::human_readable_size(data_and_type.data.size());
case Column::Time:
return time.to_deprecated_string();
return time.to_byte_string();
default:
VERIFY_NOT_REACHED();
}
}
void ClipboardHistoryModel::clipboard_content_did_change(DeprecatedString const&)
void ClipboardHistoryModel::clipboard_content_did_change(ByteString const&)
{
auto data_and_type = GUI::Clipboard::the().fetch_data_and_type();
if (!(data_and_type.data.is_empty() && data_and_type.mime_type.is_empty() && data_and_type.metadata.is_empty()))
@ -184,7 +184,7 @@ ErrorOr<JsonObject> ClipboardHistoryModel::ClipboardItem::to_json() const
return object;
}
ErrorOr<void> ClipboardHistoryModel::read_from_file(DeprecatedString const& path)
ErrorOr<void> ClipboardHistoryModel::read_from_file(ByteString const& path)
{
m_path = path;
@ -219,7 +219,7 @@ ErrorOr<void> ClipboardHistoryModel::write_to_file(bool rewrite_all)
auto const write_element = [](Core::File& file, ClipboardItem const& item) -> ErrorOr<void> {
if (!item.data_and_type.mime_type.starts_with("text/"sv))
return {};
TRY(file.write_until_depleted(TRY(item.to_json()).to_deprecated_string().bytes()));
TRY(file.write_until_depleted(TRY(item.to_json()).to_byte_string().bytes()));
TRY(file.write_until_depleted("\n"sv.bytes()));
return {};
};

View file

@ -44,7 +44,7 @@ public:
void clear();
bool is_empty() { return m_history_items.is_empty(); }
ErrorOr<void> read_from_file(DeprecatedString const& path);
ErrorOr<void> read_from_file(ByteString const& path);
ErrorOr<void> write_to_file(bool rewrite_all);
ErrorOr<void> invalidate_model_and_file(bool rewrite_all);
@ -64,10 +64,10 @@ private:
virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; }
// ^GUI::Clipboard::ClipboardClient
virtual void clipboard_content_did_change(DeprecatedString const&) override;
virtual void clipboard_content_did_change(ByteString const&) override;
Vector<ClipboardItem> m_history_items;
size_t m_history_limit;
DeprecatedString m_path;
ByteString m_path;
};

View file

@ -23,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app = TRY(GUI::Application::create(arguments));
auto clipboard_config = TRY(Core::ConfigFile::open_for_app("ClipboardHistory"));
auto const default_path = DeprecatedString::formatted("{}/{}", Core::StandardPaths::data_directory(), "Clipboard/ClipboardHistory.json"sv);
auto const default_path = ByteString::formatted("{}/{}", Core::StandardPaths::data_directory(), "Clipboard/ClipboardHistory.json"sv);
auto const clipboard_file_path = clipboard_config->read_entry("Clipboard", "ClipboardFilePath", default_path);
auto const parent_path = LexicalPath(clipboard_file_path);
TRY(Core::Directory::create(parent_path.dirname(), Core::Directory::CreateDirectories::Yes));

View file

@ -63,10 +63,10 @@ ErrorOr<void> KeymapStatusWidget::refresh_menu()
return {};
}
void KeymapStatusWidget::set_current_keymap(DeprecatedString const& keymap)
void KeymapStatusWidget::set_current_keymap(ByteString const& keymap)
{
m_current_keymap = keymap;
set_tooltip(MUST(String::from_deprecated_string(keymap)));
set_tooltip(MUST(String::from_byte_string(keymap)));
update();
}

View file

@ -15,7 +15,7 @@ class KeymapStatusWidget final : public GUI::Widget {
public:
virtual ~KeymapStatusWidget() override;
void set_current_keymap(DeprecatedString const& keymap);
void set_current_keymap(ByteString const& keymap);
private:
KeymapStatusWidget();
@ -27,6 +27,6 @@ private:
RefPtr<GUI::Menu> m_context_menu;
DeprecatedString m_current_keymap;
ByteString m_current_keymap;
GUI::ActionGroup m_keymaps_group;
};

View file

@ -27,7 +27,7 @@ void KeymapStatusWindow::wm_event(GUI::WMEvent& event)
}
}
void KeymapStatusWindow::set_keymap_text(DeprecatedString const& keymap)
void KeymapStatusWindow::set_keymap_text(ByteString const& keymap)
{
m_status_widget->set_current_keymap(keymap);
}

View file

@ -23,5 +23,5 @@ private:
RefPtr<KeymapStatusWidget> m_status_widget;
void set_keymap_text(DeprecatedString const& keymap);
void set_keymap_text(ByteString const& keymap);
};

View file

@ -113,8 +113,8 @@ private:
int connected_adapters = 0;
json.as_array().for_each([&adapter_info, &connected_adapters](auto& value) {
auto& if_object = value.as_object();
auto ip_address = if_object.get_deprecated_string("ipv4_address"sv).value_or("no IP");
auto ifname = if_object.get_deprecated_string("name"sv).value();
auto ip_address = if_object.get_byte_string("ipv4_address"sv).value_or("no IP");
auto ifname = if_object.get_byte_string("name"sv).value();
auto link_up = if_object.get_bool("link_up"sv).value();
auto link_speed = if_object.get_i32("link_speed"sv).value();