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

@ -10,14 +10,14 @@
namespace PDF {
DeprecatedString OutlineItem::to_string(int indent) const
DeprecatedString OutlineItem::to_deprecated_string(int indent) const
{
auto indent_str = DeprecatedString::repeated(" "sv, indent + 1);
StringBuilder child_builder;
child_builder.append('[');
for (auto& child : children)
child_builder.appendff("{}\n", child.to_string(indent + 1));
child_builder.appendff("{}\n", child.to_deprecated_string(indent + 1));
child_builder.appendff("{}]", indent_str);
StringBuilder builder;
@ -28,10 +28,10 @@ DeprecatedString OutlineItem::to_string(int indent) const
builder.appendff("{}color={}\n", indent_str, color);
builder.appendff("{}italic={}\n", indent_str, italic);
builder.appendff("{}bold={}\n", indent_str, bold);
builder.appendff("{}children={}\n", indent_str, child_builder.to_string());
builder.appendff("{}children={}\n", indent_str, child_builder.to_deprecated_string());
builder.appendff("{}}}", DeprecatedString::repeated(" "sv, indent));
return builder.to_string();
return builder.to_deprecated_string();
}
PDFErrorOr<NonnullRefPtr<Document>> Document::create(ReadonlyBytes bytes)

View file

@ -66,7 +66,7 @@ struct OutlineItem final : public RefCounted<OutlineItem> {
OutlineItem() = default;
DeprecatedString to_string(int indent) const;
DeprecatedString to_deprecated_string(int indent) const;
};
struct OutlineDict final : public RefCounted<OutlineDict> {
@ -185,8 +185,8 @@ struct Formatter<PDF::Page> : Formatter<FormatString> {
{
return Formatter<FormatString>::format(builder,
"Page {{\n resources={}\n contents={}\n media_box={}\n crop_box={}\n user_unit={}\n rotate={}\n}}"sv,
page.resources->to_string(1),
page.contents->to_string(1),
page.resources->to_deprecated_string(1),
page.contents->to_deprecated_string(1),
page.media_box,
page.crop_box,
page.user_unit,
@ -230,7 +230,7 @@ struct Formatter<PDF::Destination> : Formatter<FormatString> {
for (auto& param : destination.parameters)
param_builder.appendff("{} ", param);
return Formatter<FormatString>::format(builder, "{{ type={} page={} params={} }}"sv, type_str, destination.page, param_builder.to_string());
return Formatter<FormatString>::format(builder, "{{ type={} page={} params={} }}"sv, type_str, destination.page, param_builder.to_deprecated_string());
}
};
@ -238,7 +238,7 @@ template<>
struct Formatter<PDF::OutlineItem> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, PDF::OutlineItem const& item)
{
return builder.put_string(item.to_string(0));
return builder.put_string(item.to_deprecated_string(0));
}
};
@ -249,11 +249,11 @@ struct Formatter<PDF::OutlineDict> : Formatter<FormatString> {
StringBuilder child_builder;
child_builder.append('[');
for (auto& child : dict.children)
child_builder.appendff("{}\n", child.to_string(2));
child_builder.appendff("{}\n", child.to_deprecated_string(2));
child_builder.append(" ]"sv);
return Formatter<FormatString>::format(builder,
"OutlineDict {{\n count={}\n children={}\n}}"sv, dict.count, child_builder.to_string());
"OutlineDict {{\n count={}\n children={}\n}}"sv, dict.count, child_builder.to_deprecated_string());
}
};

View file

@ -741,7 +741,7 @@ struct Formatter<PDF::DocumentParser::LinearizationDictionary> : Formatter<Strin
builder.appendff(" offset_of_main_xref_table={}\n", dict.offset_of_main_xref_table);
builder.appendff(" first_page={}\n", dict.first_page);
builder.append('}');
return Formatter<StringView>::format(format_builder, builder.to_string());
return Formatter<StringView>::format(format_builder, builder.to_deprecated_string());
}
};
@ -765,7 +765,7 @@ struct Formatter<PDF::DocumentParser::PageOffsetHintTable> : Formatter<StringVie
builder.appendff(" bits_required_for_fraction_numerator={}\n", table.bits_required_for_fraction_numerator);
builder.appendff(" shared_object_reference_fraction_denominator={}\n", table.shared_object_reference_fraction_denominator);
builder.append('}');
return Formatter<StringView>::format(format_builder, builder.to_string());
return Formatter<StringView>::format(format_builder, builder.to_deprecated_string());
}
};
@ -789,7 +789,7 @@ struct Formatter<PDF::DocumentParser::PageOffsetHintTableEntry> : Formatter<Stri
builder.appendff(" page_content_stream_offset_number={}\n", entry.page_content_stream_offset_number);
builder.appendff(" page_content_stream_length_number={}\n", entry.page_content_stream_length_number);
builder.append('}');
return Formatter<StringView>::format(format_builder, builder.to_string());
return Formatter<StringView>::format(format_builder, builder.to_deprecated_string());
}
};

View file

@ -75,7 +75,7 @@ public:
}
virtual char const* type_name() const = 0;
virtual DeprecatedString to_string(int indent) const = 0;
virtual DeprecatedString to_deprecated_string(int indent) const = 0;
protected:
#define ENUMERATE_TYPE(_, name) \
@ -98,7 +98,7 @@ template<PDF::IsObject T>
struct Formatter<T> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, T const& object)
{
return Formatter<StringView>::format(builder, object.to_string(0));
return Formatter<StringView>::format(builder, object.to_deprecated_string(0));
}
};

View file

@ -36,21 +36,21 @@ static void append_indent(StringBuilder& builder, int indent)
builder.append(" "sv);
}
DeprecatedString StringObject::to_string(int) const
DeprecatedString StringObject::to_deprecated_string(int) const
{
if (is_binary())
return DeprecatedString::formatted("<{}>", encode_hex(string().bytes()).to_uppercase());
return DeprecatedString::formatted("({})", string());
}
DeprecatedString NameObject::to_string(int) const
DeprecatedString NameObject::to_deprecated_string(int) const
{
StringBuilder builder;
builder.appendff("/{}", this->name());
return builder.to_string();
return builder.to_deprecated_string();
}
DeprecatedString ArrayObject::to_string(int indent) const
DeprecatedString ArrayObject::to_deprecated_string(int indent) const
{
StringBuilder builder;
builder.append("[\n"sv);
@ -61,16 +61,16 @@ DeprecatedString ArrayObject::to_string(int indent) const
builder.append(",\n"sv);
first = false;
append_indent(builder, indent + 1);
builder.appendff("{}", element.to_string(indent));
builder.appendff("{}", element.to_deprecated_string(indent));
}
builder.append('\n');
append_indent(builder, indent);
builder.append(']');
return builder.to_string();
return builder.to_deprecated_string();
}
DeprecatedString DictObject::to_string(int indent) const
DeprecatedString DictObject::to_deprecated_string(int indent) const
{
StringBuilder builder;
builder.append("<<\n"sv);
@ -82,21 +82,21 @@ DeprecatedString DictObject::to_string(int indent) const
first = false;
append_indent(builder, indent + 1);
builder.appendff("/{} ", key);
builder.appendff("{}", value.to_string(indent + 1));
builder.appendff("{}", value.to_deprecated_string(indent + 1));
}
builder.append('\n');
append_indent(builder, indent);
builder.append(">>"sv);
return builder.to_string();
return builder.to_deprecated_string();
}
DeprecatedString StreamObject::to_string(int indent) const
DeprecatedString StreamObject::to_deprecated_string(int indent) const
{
StringBuilder builder;
builder.append("stream\n"sv);
append_indent(builder, indent);
builder.appendff("{}\n", dict()->to_string(indent + 1));
builder.appendff("{}\n", dict()->to_deprecated_string(indent + 1));
append_indent(builder, indent + 1);
auto string = encode_hex(bytes());
@ -114,19 +114,19 @@ DeprecatedString StreamObject::to_string(int indent) const
append_indent(builder, indent);
builder.append("endstream"sv);
return builder.to_string();
return builder.to_deprecated_string();
}
DeprecatedString IndirectValue::to_string(int indent) const
DeprecatedString IndirectValue::to_deprecated_string(int indent) const
{
StringBuilder builder;
builder.appendff("{} {} obj\n", index(), generation_index());
append_indent(builder, indent + 1);
builder.append(value().to_string(indent + 1));
builder.append(value().to_deprecated_string(indent + 1));
builder.append('\n');
append_indent(builder, indent);
builder.append("endobj"sv);
return builder.to_string();
return builder.to_deprecated_string();
}
}

View file

@ -32,7 +32,7 @@ public:
void set_string(DeprecatedString string) { m_string = move(string); }
char const* type_name() const override { return "string"; }
DeprecatedString to_string(int indent) const override;
DeprecatedString to_deprecated_string(int indent) const override;
protected:
bool is_string() const override { return true; }
@ -54,7 +54,7 @@ public:
[[nodiscard]] ALWAYS_INLINE FlyString const& name() const { return m_name; }
char const* type_name() const override { return "name"; }
DeprecatedString to_string(int indent) const override;
DeprecatedString to_deprecated_string(int indent) const override;
protected:
bool is_name() const override { return true; }
@ -90,7 +90,7 @@ public:
{
return "array";
}
DeprecatedString to_string(int indent) const override;
DeprecatedString to_deprecated_string(int indent) const override;
protected:
bool is_array() const override { return true; }
@ -136,7 +136,7 @@ public:
{
return "dict";
}
DeprecatedString to_string(int indent) const override;
DeprecatedString to_deprecated_string(int indent) const override;
protected:
bool is_dict() const override { return true; }
@ -160,7 +160,7 @@ public:
[[nodiscard]] ByteBuffer& buffer() { return m_buffer; };
char const* type_name() const override { return "stream"; }
DeprecatedString to_string(int indent) const override;
DeprecatedString to_deprecated_string(int indent) const override;
private:
bool is_stream() const override { return true; }
@ -184,7 +184,7 @@ public:
[[nodiscard]] ALWAYS_INLINE Value const& value() const { return m_value; }
char const* type_name() const override { return "indirect_object"; }
DeprecatedString to_string(int indent) const override;
DeprecatedString to_deprecated_string(int indent) const override;
protected:
bool is_indirect_value() const override { return true; }

View file

@ -180,7 +180,7 @@ struct Formatter<PDF::Operator> : Formatter<StringView> {
builder.append(" ]"sv);
}
return Formatter<StringView>::format(format_builder, builder.to_string());
return Formatter<StringView>::format(format_builder, builder.to_deprecated_string());
}
};

View file

@ -233,7 +233,7 @@ PDFErrorOr<NonnullRefPtr<NameObject>> Parser::parse_name()
m_reader.consume_whitespace();
return make_object<NameObject>(builder.to_string());
return make_object<NameObject>(builder.to_deprecated_string());
}
NonnullRefPtr<StringObject> Parser::parse_string()
@ -347,7 +347,7 @@ DeprecatedString Parser::parse_literal_string()
}
}
return builder.to_string();
return builder.to_deprecated_string();
}
DeprecatedString Parser::parse_hex_string()
@ -359,7 +359,7 @@ DeprecatedString Parser::parse_hex_string()
while (true) {
if (m_reader.matches('>')) {
m_reader.consume();
return builder.to_string();
return builder.to_deprecated_string();
} else {
int hex_value = 0;
@ -372,7 +372,7 @@ DeprecatedString Parser::parse_hex_string()
m_reader.consume();
hex_value *= 16;
builder.append(static_cast<char>(hex_value));
return builder.to_string();
return builder.to_deprecated_string();
}
VERIFY(isxdigit(ch));

View file

@ -193,7 +193,7 @@ struct Formatter<PDF::LineDashPattern> : Formatter<StringView> {
}
builder.appendff("] {}", pattern.phase);
return format_builder.put_string(builder.to_string());
return format_builder.put_string(builder.to_deprecated_string());
}
};
@ -237,7 +237,7 @@ struct Formatter<PDF::TextState> : Formatter<StringView> {
builder.appendff(" rise={}\n", state.rise);
builder.appendff(" knockout={}\n", state.knockout);
builder.append(" }"sv);
return format_builder.put_string(builder.to_string());
return format_builder.put_string(builder.to_deprecated_string());
}
};
@ -257,7 +257,7 @@ struct Formatter<PDF::GraphicsState> : Formatter<StringView> {
builder.appendff(" line_dash_pattern={}\n", state.line_dash_pattern);
builder.appendff(" text_state={}\n", state.text_state);
builder.append('}');
return format_builder.put_string(builder.to_string());
return format_builder.put_string(builder.to_deprecated_string());
}
};

View file

@ -9,7 +9,7 @@
namespace PDF {
DeprecatedString Value::to_string(int indent) const
DeprecatedString Value::to_deprecated_string(int indent) const
{
return visit(
[&](Empty const&) -> DeprecatedString {
@ -32,7 +32,7 @@ DeprecatedString Value::to_string(int indent) const
return DeprecatedString::formatted("{} {} R", ref.as_ref_index(), ref.as_ref_generation_index());
},
[&](NonnullRefPtr<Object> const& object) {
return object->to_string(indent);
return object->to_deprecated_string(indent);
});
}

View file

@ -36,7 +36,7 @@ public:
set<NonnullRefPtr<Object>>(*refptr);
}
[[nodiscard]] DeprecatedString to_string(int indent = 0) const;
[[nodiscard]] DeprecatedString to_deprecated_string(int indent = 0) const;
[[nodiscard]] ALWAYS_INLINE bool has_number() const { return has<int>() || has<float>(); }
@ -95,7 +95,7 @@ template<>
struct Formatter<PDF::Value> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, PDF::Value const& value)
{
return Formatter<StringView>::format(builder, value.to_string());
return Formatter<StringView>::format(builder, value.to_deprecated_string());
}
};

View file

@ -140,7 +140,7 @@ struct Formatter<PDF::XRefTable> : Formatter<StringView> {
for (auto& entry : table.m_entries)
builder.appendff("\n {}", entry);
builder.append("\n}"sv);
return Formatter<StringView>::format(format_builder, builder.to_string());
return Formatter<StringView>::format(format_builder, builder.to_deprecated_string());
}
};