1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:47:35 +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

@ -56,9 +56,9 @@ ResultOr<Value> BinaryOperatorExpression::evaluate(ExecutionContext& context) co
return Result { SQLCommand::Unknown, SQLErrorCode::BooleanOperatorTypeMismatch, BinaryOperator_name(type()) };
AK::StringBuilder builder;
builder.append(lhs_value.to_string());
builder.append(rhs_value.to_string());
return Value(builder.to_string());
builder.append(lhs_value.to_deprecated_string());
builder.append(rhs_value.to_deprecated_string());
return Value(builder.to_deprecated_string());
}
case BinaryOperator::Multiplication:
return lhs_value.multiply(rhs_value);
@ -181,7 +181,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
char escape_char = '\0';
if (escape()) {
auto escape_str = TRY(escape()->evaluate(context)).to_string();
auto escape_str = TRY(escape()->evaluate(context)).to_deprecated_string();
if (escape_str.length() != 1)
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, "ESCAPE should be a single character" };
escape_char = escape_str[0];
@ -192,7 +192,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
bool escaped = false;
AK::StringBuilder builder;
builder.append('^');
for (auto c : rhs_value.to_string()) {
for (auto c : rhs_value.to_deprecated_string()) {
if (escape() && c == escape_char && !escaped) {
escaped = true;
} else if (s_posix_basic_metacharacters.contains(c)) {
@ -212,14 +212,14 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
// FIXME: We should probably cache this regex.
auto regex = Regex<PosixBasic>(builder.build());
auto result = regex.match(lhs_value.to_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
auto result = regex.match(lhs_value.to_deprecated_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
return Value(invert_expression() ? !result.success : result.success);
}
case MatchOperator::Regexp: {
Value lhs_value = TRY(lhs()->evaluate(context));
Value rhs_value = TRY(rhs()->evaluate(context));
auto regex = Regex<PosixExtended>(rhs_value.to_string());
auto regex = Regex<PosixExtended>(rhs_value.to_deprecated_string());
auto err = regex.parser_result.error;
if (err != regex::Error::NoError) {
StringBuilder builder;
@ -229,7 +229,7 @@ ResultOr<Value> MatchExpression::evaluate(ExecutionContext& context) const
return Result { SQLCommand::Unknown, SQLErrorCode::SyntaxError, builder.build() };
}
auto result = regex.match(lhs_value.to_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
auto result = regex.match(lhs_value.to_deprecated_string(), PosixFlags::Insensitive | PosixFlags::Unicode);
return Value(invert_expression() ? !result.success : result.success);
}
case MatchOperator::Glob:

View file

@ -26,7 +26,7 @@ class Parser {
DeprecatedString message;
SourcePosition position;
DeprecatedString to_string() const
DeprecatedString to_deprecated_string() const
{
return DeprecatedString::formatted("{} (line: {}, column: {})", message, position.line, position.column);
}

View file

@ -102,7 +102,7 @@ void HashBucket::deserialize(Serializer& serializer)
dbgln_if(SQL_DEBUG, "Bucket has {} keys", size);
for (auto ix = 0u; ix < size; ix++) {
auto key = serializer.deserialize<Key>(m_hash_index.descriptor());
dbgln_if(SQL_DEBUG, "Key {}: {}", ix, key.to_string());
dbgln_if(SQL_DEBUG, "Key {}: {}", ix, key.to_deprecated_string());
m_entries.append(key);
}
m_inflated = true;
@ -136,7 +136,7 @@ bool HashBucket::insert(Key const& key)
return false;
}
if ((length() + key.length()) > BLOCKSIZE) {
dbgln_if(SQL_DEBUG, "Adding key {} would make length exceed block size", key.to_string());
dbgln_if(SQL_DEBUG, "Adding key {} would make length exceed block size", key.to_deprecated_string());
return false;
}
m_entries.append(key);
@ -202,7 +202,7 @@ void HashBucket::list_bucket()
warnln("Bucket #{} size {} local depth {} pointer {}{}",
index(), size(), local_depth(), pointer(), (pointer() ? "" : " (VIRTUAL)"));
for (auto& key : entries()) {
warnln(" {} hash {}", key.to_string(), key.hash());
warnln(" {} hash {}", key.to_deprecated_string(), key.hash());
}
}
@ -253,7 +253,7 @@ HashBucket* HashIndex::get_bucket_for_insert(Key const& key)
auto key_hash = key.hash();
do {
dbgln_if(SQL_DEBUG, "HashIndex::get_bucket_for_insert({}) bucket {} of {}", key.to_string(), key_hash % size(), size());
dbgln_if(SQL_DEBUG, "HashIndex::get_bucket_for_insert({}) bucket {} of {}", key.to_deprecated_string(), key_hash % size(), size());
auto bucket = get_bucket(key_hash % size());
if (bucket->length() + key.length() < BLOCKSIZE) {
return bucket;
@ -349,7 +349,7 @@ Optional<u32> HashIndex::get(Key& key)
{
auto hash = key.hash();
auto bucket_index = hash % size();
dbgln_if(SQL_DEBUG, "HashIndex::get({}) bucket_index {}", key.to_string(), bucket_index);
dbgln_if(SQL_DEBUG, "HashIndex::get({}) bucket_index {}", key.to_deprecated_string(), bucket_index);
auto bucket = get_bucket(bucket_index);
if constexpr (SQL_DEBUG)
bucket->list_bucket();
@ -358,7 +358,7 @@ Optional<u32> HashIndex::get(Key& key)
bool HashIndex::insert(Key const& key)
{
dbgln_if(SQL_DEBUG, "HashIndex::insert({})", key.to_string());
dbgln_if(SQL_DEBUG, "HashIndex::insert({})", key.to_deprecated_string());
auto bucket = get_bucket_for_insert(key);
bucket->insert(key);
if constexpr (SQL_DEBUG)

View file

@ -21,7 +21,7 @@ SchemaDef::SchemaDef(DeprecatedString name)
}
SchemaDef::SchemaDef(Key const& key)
: Relation(key["schema_name"].to_string())
: Relation(key["schema_name"].to_deprecated_string())
{
}
@ -186,7 +186,7 @@ void TableDef::append_column(Key const& column)
auto column_type = column["column_type"].to_int();
VERIFY(column_type.has_value());
append_column(column["column_name"].to_string(), static_cast<SQLType>(*column_type));
append_column(column["column_name"].to_deprecated_string(), static_cast<SQLType>(*column_type));
}
Key TableDef::make_key(SchemaDef const& schema_def)

View file

@ -164,8 +164,8 @@ private:
}
StringBuilder bytes_builder;
bytes_builder.join(' ', bytes);
builder.append(bytes_builder.to_string());
dbgln(builder.to_string());
builder.append(bytes_builder.to_deprecated_string());
dbgln(builder.to_deprecated_string());
}
ByteBuffer m_buffer {};

View file

@ -153,7 +153,7 @@ size_t TreeNode::length() const
bool TreeNode::insert(Key const& key)
{
dbgln_if(SQL_DEBUG, "[#{}] INSERT({})", pointer(), key.to_string());
dbgln_if(SQL_DEBUG, "[#{}] INSERT({})", pointer(), key.to_deprecated_string());
if (!is_leaf())
return node_for(key)->insert_in_leaf(key);
return insert_in_leaf(key);
@ -161,14 +161,14 @@ bool TreeNode::insert(Key const& key)
bool TreeNode::update_key_pointer(Key const& key)
{
dbgln_if(SQL_DEBUG, "[#{}] UPDATE({}, {})", pointer(), key.to_string(), key.pointer());
dbgln_if(SQL_DEBUG, "[#{}] UPDATE({}, {})", pointer(), key.to_deprecated_string(), key.pointer());
if (!is_leaf())
return node_for(key)->update_key_pointer(key);
for (auto ix = 0u; ix < size(); ix++) {
if (key == m_entries[ix]) {
dbgln_if(SQL_DEBUG, "[#{}] {} == {}",
pointer(), key.to_string(), m_entries[ix].to_string());
pointer(), key.to_deprecated_string(), m_entries[ix].to_deprecated_string());
if (m_entries[ix].pointer() != key.pointer()) {
m_entries[ix].set_pointer(key.pointer());
dump_if(SQL_DEBUG, "To WAL");
@ -186,13 +186,13 @@ bool TreeNode::insert_in_leaf(Key const& key)
if (!m_tree.duplicates_allowed()) {
for (auto& entry : m_entries) {
if (key == entry) {
dbgln_if(SQL_DEBUG, "[#{}] duplicate key {}", pointer(), key.to_string());
dbgln_if(SQL_DEBUG, "[#{}] duplicate key {}", pointer(), key.to_deprecated_string());
return false;
}
}
}
dbgln_if(SQL_DEBUG, "[#{}] insert_in_leaf({})", pointer(), key.to_string());
dbgln_if(SQL_DEBUG, "[#{}] insert_in_leaf({})", pointer(), key.to_deprecated_string());
just_insert(key, nullptr);
return true;
}
@ -209,7 +209,7 @@ TreeNode* TreeNode::down_node(size_t ix)
TreeNode* TreeNode::node_for(Key const& key)
{
dump_if(SQL_DEBUG, DeprecatedString::formatted("node_for(Key {})", key.to_string()));
dump_if(SQL_DEBUG, DeprecatedString::formatted("node_for(Key {})", key.to_deprecated_string()));
if (is_leaf())
return this;
for (size_t ix = 0; ix < size(); ix++) {
@ -220,45 +220,45 @@ TreeNode* TreeNode::node_for(Key const& key)
}
}
dbgln_if(SQL_DEBUG, "[#{}] {} >= {} v{}",
pointer(), key.to_string(), (DeprecatedString)m_entries[size() - 1], m_down[size()].pointer());
pointer(), key.to_deprecated_string(), (DeprecatedString)m_entries[size() - 1], m_down[size()].pointer());
return down_node(size())->node_for(key);
}
Optional<u32> TreeNode::get(Key& key)
{
dump_if(SQL_DEBUG, DeprecatedString::formatted("get({})", key.to_string()));
dump_if(SQL_DEBUG, DeprecatedString::formatted("get({})", key.to_deprecated_string()));
for (auto ix = 0u; ix < size(); ix++) {
if (key < m_entries[ix]) {
if (is_leaf()) {
dbgln_if(SQL_DEBUG, "[#{}] {} < {} -> 0",
pointer(), key.to_string(), (DeprecatedString)m_entries[ix]);
pointer(), key.to_deprecated_string(), (DeprecatedString)m_entries[ix]);
return {};
} else {
dbgln_if(SQL_DEBUG, "[{}] {} < {} ({} -> {})",
pointer(), key.to_string(), (DeprecatedString)m_entries[ix],
pointer(), key.to_deprecated_string(), (DeprecatedString)m_entries[ix],
ix, m_down[ix].pointer());
return down_node(ix)->get(key);
}
}
if (key == m_entries[ix]) {
dbgln_if(SQL_DEBUG, "[#{}] {} == {} -> {}",
pointer(), key.to_string(), (DeprecatedString)m_entries[ix],
pointer(), key.to_deprecated_string(), (DeprecatedString)m_entries[ix],
m_entries[ix].pointer());
key.set_pointer(m_entries[ix].pointer());
return m_entries[ix].pointer();
}
}
if (m_entries.is_empty()) {
dbgln_if(SQL_DEBUG, "[#{}] {} Empty node??", pointer(), key.to_string());
dbgln_if(SQL_DEBUG, "[#{}] {} Empty node??", pointer(), key.to_deprecated_string());
VERIFY_NOT_REACHED();
}
if (is_leaf()) {
dbgln_if(SQL_DEBUG, "[#{}] {} > {} -> 0",
pointer(), key.to_string(), (DeprecatedString)m_entries[size() - 1]);
pointer(), key.to_deprecated_string(), (DeprecatedString)m_entries[size() - 1]);
return {};
}
dbgln_if(SQL_DEBUG, "[#{}] {} > {} ({} -> {})",
pointer(), key.to_string(), (DeprecatedString)m_entries[size() - 1],
pointer(), key.to_deprecated_string(), (DeprecatedString)m_entries[size() - 1],
size(), m_down[size()].pointer());
return down_node(size())->get(key);
}
@ -381,7 +381,7 @@ void TreeNode::list_node(int indent)
down_node(ix)->list_node(indent + 2);
}
do_indent();
warnln("{}", m_entries[ix].to_string());
warnln("{}", m_entries[ix].to_deprecated_string());
}
if (!is_leaf()) {
down_node(size())->list_node(indent + 2);

View file

@ -161,14 +161,14 @@ size_t Tuple::length() const
return len;
}
DeprecatedString Tuple::to_string() const
DeprecatedString Tuple::to_deprecated_string() const
{
StringBuilder builder;
for (auto& part : m_data) {
if (!builder.is_empty()) {
builder.append('|');
}
builder.append(part.to_string());
builder.append(part.to_deprecated_string());
}
if (pointer() != 0) {
builder.appendff(":{}", pointer());
@ -176,11 +176,11 @@ DeprecatedString Tuple::to_string() const
return builder.build();
}
Vector<DeprecatedString> Tuple::to_string_vector() const
Vector<DeprecatedString> Tuple::to_deprecated_string_vector() const
{
Vector<DeprecatedString> ret;
for (auto& value : m_data) {
ret.append(value.to_string());
ret.append(value.to_deprecated_string());
}
return ret;
}

View file

@ -35,9 +35,9 @@ public:
Tuple& operator=(Tuple const&);
[[nodiscard]] DeprecatedString to_string() const;
explicit operator DeprecatedString() const { return to_string(); }
[[nodiscard]] Vector<DeprecatedString> to_string_vector() const;
[[nodiscard]] DeprecatedString to_deprecated_string() const;
explicit operator DeprecatedString() const { return to_deprecated_string(); }
[[nodiscard]] Vector<DeprecatedString> to_deprecated_string_vector() const;
bool operator<(Tuple const& other) const { return compare(other) < 0; }
bool operator<=(Tuple const& other) const { return compare(other) <= 0; }

View file

@ -39,7 +39,7 @@ struct TupleElementDescriptor {
return (sizeof(u32) + name.length()) + 2 * sizeof(u8);
}
DeprecatedString to_string() const
DeprecatedString to_deprecated_string() const
{
return DeprecatedString::formatted(" name: {} type: {} order: {}", name, SQLType_name(type), Order_name(order));
}
@ -91,11 +91,11 @@ public:
return len;
}
DeprecatedString to_string() const
DeprecatedString to_deprecated_string() const
{
Vector<DeprecatedString> elements;
for (auto& element : *this) {
elements.append(element.to_string());
elements.append(element.to_deprecated_string());
}
return DeprecatedString::formatted("[\n{}\n]", DeprecatedString::join('\n', elements));
}

View file

@ -105,7 +105,7 @@ bool Value::is_null() const
return !m_value.has_value();
}
DeprecatedString Value::to_string() const
DeprecatedString Value::to_deprecated_string() const
{
if (is_null())
return "(null)"sv;
@ -346,7 +346,7 @@ int Value::compare(Value const& other) const
return 1;
return m_value->visit(
[&](DeprecatedString const& value) -> int { return value.view().compare(other.to_string()); },
[&](DeprecatedString const& value) -> int { return value.view().compare(other.to_deprecated_string()); },
[&](int value) -> int {
auto casted = other.to_int();
if (!casted.has_value())
@ -407,7 +407,7 @@ bool Value::operator==(Value const& value) const
bool Value::operator==(StringView value) const
{
return to_string() == value;
return to_deprecated_string() == value;
}
bool Value::operator==(int value) const

View file

@ -49,7 +49,7 @@ public:
[[nodiscard]] StringView type_name() const;
[[nodiscard]] bool is_null() const;
[[nodiscard]] DeprecatedString to_string() const;
[[nodiscard]] DeprecatedString to_deprecated_string() const;
[[nodiscard]] Optional<int> to_int() const;
[[nodiscard]] Optional<u32> to_u32() const;
[[nodiscard]] Optional<double> to_double() const;
@ -125,6 +125,6 @@ template<>
struct AK::Formatter<SQL::Value> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, SQL::Value const& value)
{
return Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_deprecated_string());
}
};