1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:07:44 +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

@ -252,7 +252,7 @@ ErrorOr<DeprecatedString> Account::generate_passwd_file() const
if (errno)
return Error::from_errno(errno);
return builder.to_string();
return builder.to_deprecated_string();
}
#ifndef AK_OS_BSD_GENERIC
@ -293,7 +293,7 @@ ErrorOr<DeprecatedString> Account::generate_shadow_file() const
if (errno)
return Error::from_errno(errno);
return builder.to_string();
return builder.to_deprecated_string();
}
#endif

View file

@ -818,7 +818,7 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, Span<char con
object.set("invariant_offset", has_invariant ? option_to_complete.length() : 0u);
object.set("display_trivia", option.help_string);
object.set("trailing_trivia", option.argument_mode == OptionArgumentMode::Required ? " " : "");
outln(file, "{}", object.to_string());
outln(file, "{}", object.to_deprecated_string());
};
if (option_to_complete.starts_with("--"sv)) {

View file

@ -113,7 +113,7 @@ ErrorOr<void> ConfigFile::reparse()
builder.append(line[i]);
++i;
}
current_group = &m_groups.ensure(builder.to_string());
current_group = &m_groups.ensure(builder.to_deprecated_string());
break;
}
default: { // Start of key
@ -132,8 +132,8 @@ ErrorOr<void> ConfigFile::reparse()
// We're not in a group yet, create one with the name ""...
current_group = &m_groups.ensure("");
}
auto value_string = value_builder.to_string();
current_group->set(key_builder.to_string(), value_string.trim_whitespace(TrimMode::Right));
auto value_string = value_builder.to_deprecated_string();
current_group->set(key_builder.to_deprecated_string(), value_string.trim_whitespace(TrimMode::Right));
}
}
}

View file

@ -84,7 +84,7 @@ void DateTime::set_time(int year, int month, int day, int hour, int minute, int
m_second = tm.tm_sec;
}
DeprecatedString DateTime::to_string(StringView format) const
DeprecatedString DateTime::to_deprecated_string(StringView format) const
{
struct tm tm;
localtime_r(&m_timestamp, &tm);

View file

@ -31,7 +31,7 @@ public:
bool is_leap_year() const;
void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
DeprecatedString to_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
DeprecatedString to_deprecated_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
static DateTime create(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
static DateTime now();

View file

@ -92,7 +92,7 @@ DeprecatedString DirIterator::next_full_path()
if (!m_path.ends_with('/'))
builder.append('/');
builder.append(next_path());
return builder.to_string();
return builder.to_deprecated_string();
}
int DirIterator::fd() const

View file

@ -211,7 +211,7 @@ private:
public:
void send_response(JsonObject const& response)
{
auto serialized = response.to_string();
auto serialized = response.to_deprecated_string();
auto bytes_to_send = serialized.bytes();
u32 length = bytes_to_send.size();
// FIXME: Propagate errors
@ -280,7 +280,7 @@ public:
auto address = request.get("address"sv).to_number<FlatPtr>();
for (auto& object : Object::all_objects()) {
if ((FlatPtr)&object == address) {
bool success = object.set_property(request.get("name"sv).to_string(), request.get("value"sv));
bool success = object.set_property(request.get("name"sv).to_deprecated_string(), request.get("value"sv));
JsonObject response;
response.set("type", "SetProperty");
response.set("success", success);

View file

@ -45,7 +45,7 @@ ErrorOr<DeprecatedString> Group::generate_group_file() const
if (errno)
return Error::from_errno(errno);
return builder.to_string();
return builder.to_deprecated_string();
}
ErrorOr<void> Group::sync()

View file

@ -35,7 +35,7 @@ void MimeData::set_urls(Vector<URL> const& urls)
{
StringBuilder builder;
for (auto& url : urls) {
builder.append(url.to_string());
builder.append(url.to_deprecated_string());
builder.append('\n');
}
set_data("text/uri-list", builder.to_byte_buffer());

View file

@ -301,7 +301,7 @@ requires IsBaseOf<Object, T>
property_name, \
[this] { return this->getter(); }, \
[this](auto& value) { \
this->setter(value.to_string()); \
this->setter(value.to_deprecated_string()); \
return true; \
});

View file

@ -53,11 +53,11 @@ Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::F
process.ppid = process_object.get("ppid"sv).to_u32();
process.nfds = process_object.get("nfds"sv).to_u32();
process.kernel = process_object.get("kernel"sv).to_bool();
process.name = process_object.get("name"sv).to_string();
process.executable = process_object.get("executable"sv).to_string();
process.tty = process_object.get("tty"sv).to_string();
process.pledge = process_object.get("pledge"sv).to_string();
process.veil = process_object.get("veil"sv).to_string();
process.name = process_object.get("name"sv).to_deprecated_string();
process.executable = process_object.get("executable"sv).to_deprecated_string();
process.tty = process_object.get("tty"sv).to_deprecated_string();
process.pledge = process_object.get("pledge"sv).to_deprecated_string();
process.veil = process_object.get("veil"sv).to_deprecated_string();
process.amount_virtual = process_object.get("amount_virtual"sv).to_u32();
process.amount_resident = process_object.get("amount_resident"sv).to_u32();
process.amount_shared = process_object.get("amount_shared"sv).to_u32();
@ -73,8 +73,8 @@ Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::F
Core::ThreadStatistics thread;
thread.tid = thread_object.get("tid"sv).to_u32();
thread.times_scheduled = thread_object.get("times_scheduled"sv).to_u32();
thread.name = thread_object.get("name"sv).to_string();
thread.state = thread_object.get("state"sv).to_string();
thread.name = thread_object.get("name"sv).to_deprecated_string();
thread.state = thread_object.get("state"sv).to_deprecated_string();
thread.time_user = thread_object.get("time_user"sv).to_u64();
thread.time_kernel = thread_object.get("time_kernel"sv).to_u64();
thread.cpu = thread_object.get("cpu"sv).to_u32();

View file

@ -51,7 +51,7 @@ public:
IPv4Address ipv4_address() const { return m_ipv4_address; }
u16 port() const { return m_port; }
DeprecatedString to_string() const
DeprecatedString to_deprecated_string() const
{
switch (m_type) {
case Type::IPv4:
@ -97,6 +97,6 @@ template<>
struct AK::Formatter<Core::SocketAddress> : Formatter<DeprecatedString> {
ErrorOr<void> format(FormatBuilder& builder, Core::SocketAddress const& value)
{
return Formatter<DeprecatedString>::format(builder, value.to_string());
return Formatter<DeprecatedString>::format(builder, value.to_deprecated_string());
}
};

View file

@ -30,7 +30,7 @@ DeprecatedString StandardPaths::desktop_directory()
StringBuilder builder;
builder.append(home_directory());
builder.append("/Desktop"sv);
return LexicalPath::canonicalized_path(builder.to_string());
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
}
DeprecatedString StandardPaths::documents_directory()
@ -38,7 +38,7 @@ DeprecatedString StandardPaths::documents_directory()
StringBuilder builder;
builder.append(home_directory());
builder.append("/Documents"sv);
return LexicalPath::canonicalized_path(builder.to_string());
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
}
DeprecatedString StandardPaths::downloads_directory()
@ -46,7 +46,7 @@ DeprecatedString StandardPaths::downloads_directory()
StringBuilder builder;
builder.append(home_directory());
builder.append("/Downloads"sv);
return LexicalPath::canonicalized_path(builder.to_string());
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
}
DeprecatedString StandardPaths::config_directory()
@ -54,7 +54,7 @@ DeprecatedString StandardPaths::config_directory()
StringBuilder builder;
builder.append(home_directory());
builder.append("/.config"sv);
return LexicalPath::canonicalized_path(builder.to_string());
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
}
DeprecatedString StandardPaths::tempfile_directory()

View file

@ -702,7 +702,7 @@ ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts)
static ALWAYS_INLINE ErrorOr<pid_t> posix_spawn_wrapper(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[], StringView function_name, decltype(::posix_spawn) spawn_function)
{
pid_t child_pid;
if ((errno = spawn_function(&child_pid, path.to_string().characters(), file_actions, attr, arguments, envp)))
if ((errno = spawn_function(&child_pid, path.to_deprecated_string().characters(), file_actions, attr, arguments, envp)))
return Error::from_syscall(function_name, -errno);
return child_pid;
}
@ -1082,7 +1082,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
exec_filename = maybe_executable.release_value();
} else {
exec_filename = filename.to_string();
exec_filename = filename.to_deprecated_string();
}
params.path = { exec_filename.characters(), exec_filename.length() };
@ -1094,7 +1094,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
auto argument_strings = TRY(FixedArray<DeprecatedString>::try_create(arguments.size()));
auto argv = TRY(FixedArray<char*>::try_create(arguments.size() + 1));
for (size_t i = 0; i < arguments.size(); ++i) {
argument_strings[i] = arguments[i].to_string();
argument_strings[i] = arguments[i].to_deprecated_string();
argv[i] = const_cast<char*>(argument_strings[i].characters());
}
argv[arguments.size()] = nullptr;
@ -1104,7 +1104,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
auto environment_strings = TRY(FixedArray<DeprecatedString>::try_create(environment->size()));
auto envp = TRY(FixedArray<char*>::try_create(environment->size() + 1));
for (size_t i = 0; i < environment->size(); ++i) {
environment_strings[i] = environment->at(i).to_string();
environment_strings[i] = environment->at(i).to_deprecated_string();
envp[i] = const_cast<char*>(environment_strings[i].characters());
}
envp[environment->size()] = nullptr;

View file

@ -25,7 +25,7 @@ static void parse_sockets_from_system_server()
for (auto& socket : StringView { sockets, strlen(sockets) }.split_view(' ')) {
auto params = socket.split_view(':');
s_overtaken_sockets.set(params[0].to_string(), strtol(params[1].to_string().characters(), nullptr, 10));
s_overtaken_sockets.set(params[0].to_deprecated_string(), strtol(params[1].to_deprecated_string().characters(), nullptr, 10));
}
s_overtaken_sockets_parsed = true;