1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 19:57:36 +00:00

Everywhere: Rename to_{string => deprecated_string}() where applicable

This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
This commit is contained in:
Linus Groh 2022-12-06 01:12:49 +00:00 committed by Andreas Kling
parent 6e19ab2bbc
commit 57dc179b1f
597 changed files with 1973 additions and 1972 deletions

View file

@ -151,7 +151,7 @@ struct ParsedDHCPv4Options {
return values;
}
DeprecatedString to_string() const
DeprecatedString to_deprecated_string() const
{
StringBuilder builder;
builder.append("DHCP Options ("sv);

View file

@ -191,13 +191,13 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces()
json.value().as_array().for_each([&ifnames_to_immediately_discover, &ifnames_to_attempt_later](auto& value) {
auto if_object = value.as_object();
if (if_object.get("class_name"sv).to_string() == "LoopbackAdapter")
if (if_object.get("class_name"sv).to_deprecated_string() == "LoopbackAdapter")
return;
auto name = if_object.get("name"sv).to_string();
auto mac = if_object.get("mac_address"sv).to_string();
auto name = if_object.get("name"sv).to_deprecated_string();
auto mac = if_object.get("mac_address"sv).to_deprecated_string();
auto is_up = if_object.get("link_up"sv).to_bool();
auto ipv4_addr_maybe = IPv4Address::from_string(if_object.get("ipv4_address"sv).to_string());
auto ipv4_addr_maybe = IPv4Address::from_string(if_object.get("ipv4_address"sv).to_deprecated_string());
auto ipv4_addr = ipv4_addr_maybe.has_value() ? ipv4_addr_maybe.value() : IPv4Address { 0, 0, 0, 0 };
if (is_up) {
dbgln_if(DHCPV4_DEBUG, "Found adapter '{}' with mac {}, and it was up!", name, mac);
@ -216,7 +216,7 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces()
void DHCPv4Client::handle_offer(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
{
dbgln("We were offered {} for {}", packet.yiaddr().to_string(), options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(0));
dbgln("We were offered {} for {}", packet.yiaddr().to_deprecated_string(), options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(0));
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
if (!transaction) {
dbgln("we're not looking for {}", packet.xid());
@ -237,8 +237,8 @@ void DHCPv4Client::handle_offer(DHCPv4Packet const& packet, ParsedDHCPv4Options
void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
{
if constexpr (DHCPV4CLIENT_DEBUG) {
dbgln("The DHCP server handed us {}", packet.yiaddr().to_string());
dbgln("Here are the options: {}", options.to_string());
dbgln("The DHCP server handed us {}", packet.yiaddr().to_deprecated_string());
dbgln("Here are the options: {}", options.to_deprecated_string());
}
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
@ -270,8 +270,8 @@ void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options co
void DHCPv4Client::handle_nak(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
{
dbgln("The DHCP server told us to go chase our own tail about {}", packet.yiaddr().to_string());
dbgln("Here are the options: {}", options.to_string());
dbgln("The DHCP server told us to go chase our own tail about {}", packet.yiaddr().to_deprecated_string());
dbgln("Here are the options: {}", options.to_deprecated_string());
// make another request a bit later :shrug:
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
if (!transaction) {
@ -293,7 +293,7 @@ void DHCPv4Client::process_incoming(DHCPv4Packet const& packet)
{
auto options = packet.parse_options();
dbgln_if(DHCPV4CLIENT_DEBUG, "Here are the options: {}", options.to_string());
dbgln_if(DHCPV4CLIENT_DEBUG, "Here are the options: {}", options.to_deprecated_string());
auto value_or_error = options.get<DHCPMessageType>(DHCPOption::DHCPMessageType);
if (!value_or_error.has_value())
@ -332,7 +332,7 @@ void DHCPv4Client::dhcp_discover(InterfaceDescriptor const& iface)
if constexpr (DHCPV4CLIENT_DEBUG) {
dbgln("Trying to lease an IP for {} with ID {}", iface.ifname, transaction_id);
if (!iface.current_ip_address.is_zero())
dbgln("going to request the server to hand us {}", iface.current_ip_address.to_string());
dbgln("going to request the server to hand us {}", iface.current_ip_address.to_deprecated_string());
}
DHCPv4PacketBuilder builder;
@ -360,7 +360,7 @@ void DHCPv4Client::dhcp_discover(InterfaceDescriptor const& iface)
void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& offer)
{
auto& iface = transaction.interface;
dbgln("Leasing the IP {} for adapter {}", offer.yiaddr().to_string(), iface.ifname);
dbgln("Leasing the IP {} for adapter {}", offer.yiaddr().to_deprecated_string(), iface.ifname);
DHCPv4PacketBuilder builder;
DHCPv4Packet& packet = builder.peek();

View file

@ -359,5 +359,5 @@ DeprecatedString deduplicate_destination_file_name(DeprecatedString const& desti
basename.append(destination_path.extension());
}
return LexicalPath::join(destination_path.dirname(), basename.to_string()).string();
return LexicalPath::join(destination_path.dirname(), basename.to_deprecated_string()).string();
}

View file

@ -75,7 +75,7 @@ DeprecatedString InspectableProcess::wait_for_response()
void InspectableProcess::send_request(JsonObject const& request)
{
auto serialized = request.to_string();
auto serialized = request.to_deprecated_string();
u32 length = serialized.length();
// FIXME: Propagate errors

View file

@ -199,7 +199,7 @@ bool Launcher::open_url(const URL& url, DeprecatedString const& handler_name)
if (url.scheme() == "file")
return open_file_url(url);
return open_with_user_preferences(m_protocol_handlers, url.scheme(), { url.to_string() });
return open_with_user_preferences(m_protocol_handlers, url.scheme(), { url.to_deprecated_string() });
}
bool Launcher::open_with_handler_name(const URL& url, DeprecatedString const& handler_name)
@ -213,7 +213,7 @@ bool Launcher::open_with_handler_name(const URL& url, DeprecatedString const& ha
if (url.scheme() == "file")
argument = url.path();
else
argument = url.to_string();
argument = url.to_deprecated_string();
return spawn(handler.executable, { argument });
}

View file

@ -118,9 +118,9 @@ void LookupServer::load_etc_hosts()
add_answer(name, RecordType::A, DeprecatedString { (char const*)&raw_addr, sizeof(raw_addr) });
StringBuilder builder;
builder.append(maybe_address->to_string_reversed());
builder.append(maybe_address->to_deprecated_string_reversed());
builder.append(".in-addr.arpa"sv);
add_answer(builder.to_string(), RecordType::PTR, name.as_string());
add_answer(builder.to_deprecated_string(), RecordType::PTR, name.as_string());
}
}

View file

@ -127,7 +127,7 @@ Vector<IPv4Address> MulticastDNS::local_addresses() const
json.as_array().for_each([&addresses](auto& value) {
auto if_object = value.as_object();
auto address = if_object.get("ipv4_address"sv).to_string();
auto address = if_object.get("ipv4_address"sv).to_deprecated_string();
auto ipv4_address = IPv4Address::from_string(address);
// Skip unconfigured interfaces.
if (!ipv4_address.has_value())

View file

@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
Vector<DeprecatedString> interfaces_with_dhcp_enabled;
proc_net_adapters_json.as_array().for_each([&](auto& value) {
auto& if_object = value.as_object();
auto ifname = if_object.get("name"sv).to_string();
auto ifname = if_object.get("name"sv).to_deprecated_string();
if (ifname == "loop"sv)
return;

View file

@ -99,7 +99,7 @@ SQL::ResultOr<void> SQLStatement::parse()
m_statement = parser.next_statement();
if (parser.has_errors())
return SQL::Result { SQL::SQLCommand::Unknown, SQL::SQLErrorCode::SyntaxError, parser.errors()[0].to_string() };
return SQL::Result { SQL::SQLCommand::Unknown, SQL::SQLErrorCode::SyntaxError, parser.errors()[0].to_deprecated_string() };
return {};
}
@ -129,7 +129,7 @@ void SQLStatement::next()
}
if (m_index < m_result->size()) {
auto& tuple = m_result->at(m_index++).row;
client_connection->async_next_result(statement_id(), tuple.to_string_vector());
client_connection->async_next_result(statement_id(), tuple.to_deprecated_string_vector());
deferred_invoke([this]() {
next();
});

View file

@ -209,7 +209,7 @@ void Service::spawn(int socket_fd)
if (!m_sockets.is_empty()) {
// The new descriptor is !CLOEXEC here.
setenv("SOCKET_TAKEOVER", builder.to_string().characters(), true);
setenv("SOCKET_TAKEOVER", builder.to_deprecated_string().characters(), true);
}
if (m_account.has_value() && m_account.value().uid() != getuid()) {

View file

@ -32,7 +32,7 @@ ClockWidget::ClockWidget()
if (now != last_update_time) {
tick_clock();
last_update_time = now;
set_tooltip(Core::DateTime::now().to_string("%Y-%m-%d"sv));
set_tooltip(Core::DateTime::now().to_deprecated_string("%Y-%m-%d"sv));
}
});
@ -158,14 +158,14 @@ ClockWidget::ClockWidget()
void ClockWidget::update_format(DeprecatedString const& format)
{
m_time_format = format;
m_time_width = font().width(Core::DateTime::create(122, 2, 22, 22, 22, 22).to_string(format));
m_time_width = font().width(Core::DateTime::create(122, 2, 22, 22, 22, 22).to_deprecated_string(format));
set_fixed_size(m_time_width + 20, 21);
}
void ClockWidget::paint_event(GUI::PaintEvent& event)
{
GUI::Frame::paint_event(event);
auto time_text = Core::DateTime::now().to_string(m_time_format);
auto time_text = Core::DateTime::now().to_deprecated_string(m_time_format);
GUI::Painter painter(*this);
painter.add_clip_rect(frame_inner_rect());

View file

@ -21,7 +21,7 @@ struct Command {
u8 command;
u8 subcommand;
DeprecatedString to_string() const
DeprecatedString to_deprecated_string() const
{
StringBuilder builder;
@ -57,6 +57,6 @@ struct Command {
break;
}
return builder.to_string();
return builder.to_deprecated_string();
};
};

View file

@ -306,11 +306,11 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
properties.for_each_property([&](auto property_id, auto& value) {
MUST(serializer.add(Web::CSS::string_from_property_id(property_id), value.to_string()));
MUST(serializer.add(Web::CSS::string_from_property_id(property_id), value.to_deprecated_string()));
});
MUST(serializer.finish());
return builder.to_string();
return builder.to_deprecated_string();
};
auto serialize_custom_properties_json = [](Web::DOM::Element const& element) -> DeprecatedString {
@ -323,7 +323,7 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
for (auto const& property : element_to_check->custom_properties()) {
if (!seen_properties.contains(property.key)) {
seen_properties.set(property.key);
MUST(serializer.add(property.key, property.value.value->to_string()));
MUST(serializer.add(property.key, property.value.value->to_deprecated_string()));
}
}
@ -332,7 +332,7 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
MUST(serializer.finish());
return builder.to_string();
return builder.to_deprecated_string();
};
auto serialize_node_box_sizing_json = [](Web::Layout::Node const* layout_node) -> DeprecatedString {
if (!layout_node || !layout_node->is_box()) {
@ -363,7 +363,7 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
}
MUST(serializer.finish());
return builder.to_string();
return builder.to_deprecated_string();
};
if (pseudo_element.has_value()) {
@ -490,7 +490,7 @@ Messages::WebContentServer::DumpLayoutTreeResponse ConnectionFromClient::dump_la
return DeprecatedString { "(no layout tree)" };
StringBuilder builder;
Web::dump_tree(builder, *layout_root);
return builder.to_string();
return builder.to_deprecated_string();
}
void ConnectionFromClient::set_content_filters(Vector<DeprecatedString> const& filters)

View file

@ -369,7 +369,7 @@ Messages::WebDriverClient::GetCurrentUrlResponse WebDriverConnection::get_curren
TRY(handle_any_user_prompts());
// 3. Let url be the serialization of the current top-level browsing contexts active documents document URL.
auto url = m_page_client.page().top_level_browsing_context().active_document()->url().to_string();
auto url = m_page_client.page().top_level_browsing_context().active_document()->url().to_deprecated_string();
// 4. Return success with data url.
return url;
@ -1063,7 +1063,7 @@ Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_e
auto property = Web::CSS::property_id_from_string(name);
if (auto* computed_values = element->computed_css_values())
computed_value = computed_values->property(property)->to_string();
computed_value = computed_values->property(property)->to_deprecated_string();
}
// -> Otherwise
else {

View file

@ -127,7 +127,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
StringBuilder path_builder;
path_builder.append(Configuration::the().root_path());
path_builder.append(requested_path);
auto real_path = path_builder.to_string();
auto real_path = path_builder.to_deprecated_string();
if (Core::File::is_directory(real_path)) {
@ -137,14 +137,14 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
red.append(requested_path);
red.append("/"sv);
TRY(send_redirect(red.to_string(), request));
TRY(send_redirect(red.to_deprecated_string(), request));
return true;
}
StringBuilder index_html_path_builder;
index_html_path_builder.append(real_path);
index_html_path_builder.append("/index.html"sv);
auto index_html_path = index_html_path_builder.to_string();
auto index_html_path = index_html_path_builder.to_deprecated_string();
if (!Core::File::exists(index_html_path)) {
TRY(handle_directory_listing(requested_path, real_path, request));
return true;
@ -295,7 +295,7 @@ ErrorOr<void> Client::handle_directory_listing(DeprecatedString const& requested
struct stat st;
memset(&st, 0, sizeof(st));
int rc = stat(path_builder.to_string().characters(), &st);
int rc = stat(path_builder.to_deprecated_string().characters(), &st);
if (rc < 0) {
perror("stat");
}
@ -316,7 +316,7 @@ ErrorOr<void> Client::handle_directory_listing(DeprecatedString const& requested
builder.appendff("<td>{:10}</td><td>&nbsp;</td>", st.st_size);
builder.append("<td>"sv);
builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string());
builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_deprecated_string());
builder.append("</td>"sv);
builder.append("</tr>\n"sv);
}
@ -327,7 +327,7 @@ ErrorOr<void> Client::handle_directory_listing(DeprecatedString const& requested
builder.append("</body>\n"sv);
builder.append("</html>\n"sv);
auto response = builder.to_string();
auto response = builder.to_deprecated_string();
InputMemoryStream stream { response.bytes() };
return send_response(stream, request, { .type = "text/html", .length = response.length() });
}
@ -363,7 +363,7 @@ ErrorOr<void> Client::send_error_response(unsigned code, HTTP::HttpRequest const
void Client::log_response(unsigned code, HTTP::HttpRequest const& request)
{
outln("{} :: {:03d} :: {} {}", Core::DateTime::now().to_string(), code, request.method_name(), request.url().serialize().substring(1));
outln("{} :: {:03d} :: {} {}", Core::DateTime::now().to_deprecated_string(), code, request.method_name(), request.url().serialize().substring(1));
}
bool Client::verify_credentials(Vector<HTTP::HttpRequest::Header> const& headers)

View file

@ -97,7 +97,7 @@ DeprecatedString KeymapSwitcher::get_current_keymap() const
auto json = JsonValue::from_string(proc_keymap->read_all()).release_value_but_fixme_should_propagate_errors();
auto const& keymap_object = json.as_object();
VERIFY(keymap_object.has("keymap"sv));
return keymap_object.get("keymap"sv).to_string();
return keymap_object.get("keymap"sv).to_deprecated_string();
}
void KeymapSwitcher::set_keymap(const AK::DeprecatedString& keymap)

View file

@ -241,7 +241,7 @@ void WindowGeometryOverlay::update_rect()
int height_steps = (window->height() - window->base_size().height()) / window->size_increment().height();
m_label = DeprecatedString::formatted("{} ({}x{})", window->rect(), width_steps, height_steps);
} else {
m_label = window->rect().to_string();
m_label = window->rect().to_deprecated_string();
}
m_label_rect = Gfx::IntRect { 0, 0, wm.font().width(m_label) + 16, wm.font().glyph_height() + 10 };

View file

@ -2044,7 +2044,7 @@ void WindowManager::set_accepts_drag(bool accepts)
void WindowManager::invalidate_after_theme_or_font_change()
{
Compositor::the().set_background_color(m_config->read_entry("Background", "Color", palette().desktop_background().to_string()));
Compositor::the().set_background_color(m_config->read_entry("Background", "Color", palette().desktop_background().to_deprecated_string()));
WindowFrame::reload_config();
for_each_window_stack([&](auto& window_stack) {
window_stack.for_each_window([&](Window& window) {
@ -2281,7 +2281,7 @@ void WindowManager::set_cursor_highlight_color(Gfx::Color const& color)
{
m_cursor_highlight_color = color;
Compositor::the().invalidate_cursor();
m_config->write_entry("Mouse", "CursorHighlightColor", color.to_string());
m_config->write_entry("Mouse", "CursorHighlightColor", color.to_deprecated_string());
sync_config_to_disk();
}

View file

@ -203,7 +203,7 @@ void WindowSwitcher::draw()
painter.blit(icon_rect.location(), window.icon(), window.icon().rect());
painter.draw_text(item_rect.translated(thumbnail_width() + 12, 0).translated(1, 1), window.computed_title(), WindowManager::the().window_title_font(), Gfx::TextAlignment::CenterLeft, text_color.inverted());
painter.draw_text(item_rect.translated(thumbnail_width() + 12, 0), window.computed_title(), WindowManager::the().window_title_font(), Gfx::TextAlignment::CenterLeft, text_color);
auto window_details = m_windows_on_multiple_stacks ? DeprecatedString::formatted("{} on {}:{}", window.rect().to_string(), window.window_stack().row() + 1, window.window_stack().column() + 1) : window.rect().to_string();
auto window_details = m_windows_on_multiple_stacks ? DeprecatedString::formatted("{} on {}:{}", window.rect().to_deprecated_string(), window.window_stack().row() + 1, window.window_stack().column() + 1) : window.rect().to_deprecated_string();
painter.draw_text(item_rect, window_details, Gfx::TextAlignment::CenterRight, rect_text_color);
}
}