1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +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

@ -97,7 +97,7 @@ Value::Value(SQLType type)
{
}
Value::Value(DeprecatedString value)
Value::Value(ByteString value)
: m_type(SQLType::Text)
, m_value(move(value))
{
@ -214,24 +214,24 @@ bool Value::is_int() const
return m_value.has_value() && (m_value->has<i64>() || m_value->has<u64>());
}
DeprecatedString Value::to_deprecated_string() const
ByteString Value::to_byte_string() const
{
if (is_null())
return "(null)"sv;
return m_value->visit(
[](DeprecatedString const& value) -> DeprecatedString { return value; },
[](Integer auto value) -> DeprecatedString { return DeprecatedString::number(value); },
[](double value) -> DeprecatedString { return DeprecatedString::number(value); },
[](bool value) -> DeprecatedString { return value ? "true"sv : "false"sv; },
[](TupleValue const& value) -> DeprecatedString {
[](ByteString const& value) -> ByteString { return value; },
[](Integer auto value) -> ByteString { return ByteString::number(value); },
[](double value) -> ByteString { return ByteString::number(value); },
[](bool value) -> ByteString { return value ? "true"sv : "false"sv; },
[](TupleValue const& value) -> ByteString {
StringBuilder builder;
builder.append('(');
builder.join(',', value.values);
builder.append(')');
return builder.to_deprecated_string();
return builder.to_byte_string();
});
}
@ -241,7 +241,7 @@ Optional<double> Value::to_double() const
return {};
return m_value->visit(
[](DeprecatedString const& value) -> Optional<double> { return value.to_double(); },
[](ByteString const& value) -> Optional<double> { return value.to_double(); },
[](Integer auto value) -> Optional<double> { return static_cast<double>(value); },
[](double value) -> Optional<double> { return value; },
[](bool value) -> Optional<double> { return static_cast<double>(value); },
@ -254,7 +254,7 @@ Optional<bool> Value::to_bool() const
return {};
return m_value->visit(
[](DeprecatedString const& value) -> Optional<bool> {
[](ByteString const& value) -> Optional<bool> {
if (value.equals_ignoring_ascii_case("true"sv) || value.equals_ignoring_ascii_case("t"sv))
return true;
if (value.equals_ignoring_ascii_case("false"sv) || value.equals_ignoring_ascii_case("f"sv))
@ -293,7 +293,7 @@ Value& Value::operator=(Value value)
return *this;
}
Value& Value::operator=(DeprecatedString value)
Value& Value::operator=(ByteString value)
{
m_type = SQLType::Text;
m_value = move(value);
@ -361,7 +361,7 @@ size_t Value::length() const
// FIXME: This seems to be more of an encoded byte size rather than a length.
return m_value->visit(
[](DeprecatedString const& value) -> size_t { return sizeof(u32) + value.length(); },
[](ByteString const& value) -> size_t { return sizeof(u32) + value.length(); },
[](Integer auto value) -> size_t {
return downsize_integer(value, [](auto integer, auto) {
return sizeof(integer);
@ -385,7 +385,7 @@ u32 Value::hash() const
return 0;
return m_value->visit(
[](DeprecatedString const& value) -> u32 { return value.hash(); },
[](ByteString const& value) -> u32 { return value.hash(); },
[](Integer auto value) -> u32 {
return downsize_integer(value, [](auto integer, auto) {
if constexpr (sizeof(decltype(integer)) == 8)
@ -418,7 +418,7 @@ int Value::compare(Value const& other) const
return 1;
return m_value->visit(
[&](DeprecatedString const& value) -> int { return value.view().compare(other.to_deprecated_string()); },
[&](ByteString const& value) -> int { return value.view().compare(other.to_byte_string()); },
[&](Integer auto value) -> int {
auto casted = other.to_int<IntegerType<decltype(value)>>();
if (!casted.has_value())
@ -479,7 +479,7 @@ bool Value::operator==(Value const& value) const
bool Value::operator==(StringView value) const
{
return to_deprecated_string() == value;
return to_byte_string() == value;
}
bool Value::operator==(double value) const
@ -749,7 +749,7 @@ void Value::deserialize(Serializer& serializer)
case SQLType::Null:
VERIFY_NOT_REACHED();
case SQLType::Text:
m_value = serializer.deserialize<DeprecatedString>();
m_value = serializer.deserialize<ByteString>();
break;
case SQLType::Integer:
switch (type_data) {
@ -834,7 +834,7 @@ ErrorOr<void> IPC::encode(Encoder& encoder, SQL::Value const& value)
case SQL::SQLType::Null:
return {};
case SQL::SQLType::Text:
return encoder.encode(value.to_deprecated_string());
return encoder.encode(value.to_byte_string());
case SQL::SQLType::Integer:
return SQL::downsize_integer(value, [&](auto integer, auto) {
return encoder.encode(integer);
@ -865,7 +865,7 @@ ErrorOr<SQL::Value> IPC::decode(Decoder& decoder)
case SQL::SQLType::Null:
return SQL::Value {};
case SQL::SQLType::Text:
return SQL::Value { TRY(decoder.decode<DeprecatedString>()) };
return SQL::Value { TRY(decoder.decode<ByteString>()) };
case SQL::SQLType::Integer:
switch (type_data) {
case SQL::TypeData::Int8: