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

@ -18,8 +18,8 @@ class Block {
public:
virtual ~Block() = default;
virtual DeprecatedString render_to_html(bool tight = false) const = 0;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const = 0;
virtual ByteString render_to_html(bool tight = false) const = 0;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const = 0;
virtual RecursionDecision walk(Visitor&) const = 0;
};

View file

@ -11,21 +11,21 @@
namespace Markdown {
DeprecatedString BlockQuote::render_to_html(bool) const
ByteString BlockQuote::render_to_html(bool) const
{
StringBuilder builder;
builder.append("<blockquote>\n"sv);
builder.append(m_contents->render_to_html());
builder.append("</blockquote>\n"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<DeprecatedString> BlockQuote::render_lines_for_terminal(size_t view_width) const
Vector<ByteString> BlockQuote::render_lines_for_terminal(size_t view_width) const
{
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
size_t child_width = view_width < 4 ? 0 : view_width - 4;
for (auto& line : m_contents->render_lines_for_terminal(child_width))
lines.append(DeprecatedString::formatted(" {}", line));
lines.append(ByteString::formatted(" {}", line));
return lines;
}

View file

@ -21,8 +21,8 @@ public:
}
virtual ~BlockQuote() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<BlockQuote> parse(LineIterator& lines);

View file

@ -14,7 +14,7 @@
namespace Markdown {
DeprecatedString CodeBlock::render_to_html(bool) const
ByteString CodeBlock::render_to_html(bool) const
{
StringBuilder builder;
@ -51,12 +51,12 @@ DeprecatedString CodeBlock::render_to_html(bool) const
builder.append("</pre>\n"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<DeprecatedString> CodeBlock::render_lines_for_terminal(size_t) const
Vector<ByteString> CodeBlock::render_lines_for_terminal(size_t) const
{
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
// Do not indent too much if we are in the synopsis
auto indentation = " "sv;
@ -67,7 +67,7 @@ Vector<DeprecatedString> CodeBlock::render_lines_for_terminal(size_t) const
}
for (auto const& line : m_code.split('\n', SplitBehavior::KeepEmpty))
lines.append(DeprecatedString::formatted("{}{}", indentation, line));
lines.append(ByteString::formatted("{}{}", indentation, line));
return lines;
}
@ -173,7 +173,7 @@ OwnPtr<CodeBlock> CodeBlock::parse_backticks(LineIterator& lines, Heading* curre
builder.append('\n');
}
return make<CodeBlock>(language, style, builder.to_deprecated_string(), current_section);
return make<CodeBlock>(language, style, builder.to_byte_string(), current_section);
}
OwnPtr<CodeBlock> CodeBlock::parse_indent(LineIterator& lines)
@ -196,6 +196,6 @@ OwnPtr<CodeBlock> CodeBlock::parse_indent(LineIterator& lines)
builder.append('\n');
}
return make<CodeBlock>("", "", builder.to_deprecated_string(), nullptr);
return make<CodeBlock>("", "", builder.to_byte_string(), nullptr);
}
}

View file

@ -17,7 +17,7 @@ namespace Markdown {
class CodeBlock final : public Block {
public:
CodeBlock(DeprecatedString const& language, DeprecatedString const& style, DeprecatedString const& code, Heading* current_section)
CodeBlock(ByteString const& language, ByteString const& style, ByteString const& code, Heading* current_section)
: m_code(move(code))
, m_language(language)
, m_style(style)
@ -26,15 +26,15 @@ public:
}
virtual ~CodeBlock() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<CodeBlock> parse(LineIterator& lines, Heading* current_section);
private:
DeprecatedString m_code;
DeprecatedString m_language;
DeprecatedString m_style;
ByteString m_code;
ByteString m_language;
ByteString m_style;
Heading* m_current_section;
static OwnPtr<CodeBlock> parse_backticks(LineIterator& lines, Heading* current_section);

View file

@ -11,7 +11,7 @@
namespace Markdown {
DeprecatedString CommentBlock::render_to_html(bool) const
ByteString CommentBlock::render_to_html(bool) const
{
StringBuilder builder;
@ -20,12 +20,12 @@ DeprecatedString CommentBlock::render_to_html(bool) const
// TODO: This is probably incorrect, because we technically need to escape "--" in some form. However, Browser does not care about this.
builder.append("-->\n"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<DeprecatedString> CommentBlock::render_lines_for_terminal(size_t) const
Vector<ByteString> CommentBlock::render_lines_for_terminal(size_t) const
{
return Vector<DeprecatedString> {};
return Vector<ByteString> {};
}
RecursionDecision CommentBlock::walk(Visitor& visitor) const
@ -69,7 +69,7 @@ OwnPtr<CommentBlock> CommentBlock::parse(LineIterator& lines)
line = *lines;
}
return make<CommentBlock>(builder.to_deprecated_string());
return make<CommentBlock>(builder.to_byte_string());
}
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/OwnPtr.h>
#include <LibMarkdown/Block.h>
#include <LibMarkdown/LineIterator.h>
@ -16,19 +16,19 @@ namespace Markdown {
class CommentBlock final : public Block {
public:
CommentBlock(DeprecatedString const& comment)
CommentBlock(ByteString const& comment)
: m_comment(comment)
{
}
virtual ~CommentBlock() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<CommentBlock> parse(LineIterator& lines);
private:
DeprecatedString m_comment;
ByteString m_comment;
};
}

View file

@ -17,7 +17,7 @@
namespace Markdown {
DeprecatedString ContainerBlock::render_to_html(bool tight) const
ByteString ContainerBlock::render_to_html(bool tight) const
{
StringBuilder builder;
@ -37,12 +37,12 @@ DeprecatedString ContainerBlock::render_to_html(bool tight) const
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<DeprecatedString> ContainerBlock::render_lines_for_terminal(size_t view_width) const
Vector<ByteString> ContainerBlock::render_lines_for_terminal(size_t view_width) const
{
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
for (auto& block : m_blocks) {
for (auto& line : block->render_lines_for_terminal(view_width))
@ -97,7 +97,7 @@ OwnPtr<ContainerBlock> ContainerBlock::parse(LineIterator& lines)
auto flush_paragraph = [&] {
if (paragraph_text.is_empty())
return;
auto paragraph = make<Paragraph>(Text::parse(paragraph_text.to_deprecated_string()));
auto paragraph = make<Paragraph>(Text::parse(paragraph_text.to_byte_string()));
blocks.append(move(paragraph));
paragraph_text.clear();
};

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/OwnPtr.h>
#include <LibMarkdown/Block.h>
#include <LibMarkdown/LineIterator.h>
@ -25,8 +25,8 @@ public:
virtual ~ContainerBlock() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<ContainerBlock> parse(LineIterator& lines);

View file

@ -12,7 +12,7 @@
namespace Markdown {
DeprecatedString Document::render_to_html(StringView extra_head_contents) const
ByteString Document::render_to_html(StringView extra_head_contents) const
{
StringBuilder builder;
builder.append(R"~~~(<!DOCTYPE html>
@ -35,10 +35,10 @@ DeprecatedString Document::render_to_html(StringView extra_head_contents) const
</body>
</html>)~~~"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString Document::render_to_inline_html() const
ByteString Document::render_to_inline_html() const
{
return m_container->render_to_html();
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
#include <LibMarkdown/Block.h>
@ -20,8 +20,8 @@ public:
: m_container(move(container))
{
}
DeprecatedString render_to_html(StringView extra_head_contents = ""sv) const;
DeprecatedString render_to_inline_html() const;
ByteString render_to_html(StringView extra_head_contents = ""sv) const;
ByteString render_to_inline_html() const;
ErrorOr<String> render_for_terminal(size_t view_width = 0) const;
/*

View file

@ -12,14 +12,14 @@
namespace Markdown {
DeprecatedString Heading::render_to_html(bool) const
ByteString Heading::render_to_html(bool) const
{
auto input = Unicode::normalize(m_text.render_for_raw_print().view(), Unicode::NormalizationForm::NFD);
auto slugified = MUST(AK::slugify(input));
return DeprecatedString::formatted("<h{} id='{}'><a href='#{}'>#</a> {}</h{}>\n", m_level, slugified, slugified, m_text.render_to_html(), m_level);
return ByteString::formatted("<h{} id='{}'><a href='#{}'>#</a> {}</h{}>\n", m_level, slugified, slugified, m_text.render_to_html(), m_level);
}
Vector<DeprecatedString> Heading::render_lines_for_terminal(size_t) const
Vector<ByteString> Heading::render_lines_for_terminal(size_t) const
{
StringBuilder builder;
@ -36,7 +36,7 @@ Vector<DeprecatedString> Heading::render_lines_for_terminal(size_t) const
break;
}
return Vector<DeprecatedString> { builder.to_deprecated_string() };
return Vector<ByteString> { builder.to_byte_string() };
}
RecursionDecision Heading::walk(Visitor& visitor) const

View file

@ -26,8 +26,8 @@ public:
}
virtual ~Heading() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<Heading> parse(LineIterator& lines);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/StringBuilder.h>
#include <LibMarkdown/HorizontalRule.h>
#include <LibMarkdown/Visitor.h>
@ -12,18 +12,18 @@
namespace Markdown {
DeprecatedString HorizontalRule::render_to_html(bool) const
ByteString HorizontalRule::render_to_html(bool) const
{
return "<hr />\n";
}
Vector<DeprecatedString> HorizontalRule::render_lines_for_terminal(size_t view_width) const
Vector<ByteString> HorizontalRule::render_lines_for_terminal(size_t view_width) const
{
StringBuilder builder(view_width + 1);
for (size_t i = 0; i < view_width; ++i)
builder.append('-');
builder.append("\n\n"sv);
return Vector<DeprecatedString> { builder.to_deprecated_string() };
return Vector<ByteString> { builder.to_byte_string() };
}
RecursionDecision HorizontalRule::walk(Visitor& visitor) const

View file

@ -20,8 +20,8 @@ public:
HorizontalRule() = default;
virtual ~HorizontalRule() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<HorizontalRule> parse(LineIterator& lines);
};

View file

@ -13,7 +13,7 @@
namespace Markdown {
DeprecatedString List::render_to_html(bool) const
ByteString List::render_to_html(bool) const
{
StringBuilder builder;
@ -35,12 +35,12 @@ DeprecatedString List::render_to_html(bool) const
builder.appendff("</{}>\n", tag);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<DeprecatedString> List::render_lines_for_terminal(size_t view_width) const
Vector<ByteString> List::render_lines_for_terminal(size_t view_width) const
{
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
int i = 0;
for (auto& item : m_items) {
@ -57,13 +57,13 @@ Vector<DeprecatedString> List::render_lines_for_terminal(size_t view_width) cons
builder.append(first_line);
lines.append(builder.to_deprecated_string());
lines.append(builder.to_byte_string());
for (auto& line : item_lines) {
builder.clear();
builder.append(DeprecatedString::repeated(' ', item_indentation));
builder.append(ByteString::repeated(' ', item_indentation));
builder.append(line);
lines.append(builder.to_deprecated_string());
lines.append(builder.to_byte_string());
}
}

View file

@ -25,8 +25,8 @@ public:
}
virtual ~List() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<List> parse(LineIterator& lines);

View file

@ -11,7 +11,7 @@
namespace Markdown {
DeprecatedString Paragraph::render_to_html(bool tight) const
ByteString Paragraph::render_to_html(bool tight) const
{
StringBuilder builder;
@ -25,12 +25,12 @@ DeprecatedString Paragraph::render_to_html(bool tight) const
builder.append('\n');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<DeprecatedString> Paragraph::render_lines_for_terminal(size_t) const
Vector<ByteString> Paragraph::render_lines_for_terminal(size_t) const
{
return Vector<DeprecatedString> { DeprecatedString::formatted(" {}", m_text.render_for_terminal()), "" };
return Vector<ByteString> { ByteString::formatted(" {}", m_text.render_for_terminal()), "" };
}
RecursionDecision Paragraph::walk(Visitor& visitor) const

View file

@ -22,8 +22,8 @@ public:
virtual ~Paragraph() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
private:

View file

@ -12,11 +12,11 @@
namespace Markdown {
Vector<DeprecatedString> Table::render_lines_for_terminal(size_t view_width) const
Vector<ByteString> Table::render_lines_for_terminal(size_t view_width) const
{
auto unit_width_length = view_width == 0 ? 4 : ((float)(view_width - m_columns.size()) / (float)m_total_width);
StringBuilder builder;
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
auto write_aligned = [&](auto const& text, auto width, auto alignment) {
size_t original_length = text.terminal_length();
@ -44,12 +44,12 @@ Vector<DeprecatedString> Table::render_lines_for_terminal(size_t view_width) con
write_aligned(col.header, width, col.alignment);
}
lines.append(builder.to_deprecated_string());
lines.append(builder.to_byte_string());
builder.clear();
for (size_t i = 0; i < view_width; ++i)
builder.append('-');
lines.append(builder.to_deprecated_string());
lines.append(builder.to_byte_string());
builder.clear();
for (size_t i = 0; i < m_row_count; ++i) {
@ -65,7 +65,7 @@ Vector<DeprecatedString> Table::render_lines_for_terminal(size_t view_width) con
size_t width = col.relative_width * unit_width_length;
write_aligned(cell, width, col.alignment);
}
lines.append(builder.to_deprecated_string());
lines.append(builder.to_byte_string());
builder.clear();
}
@ -74,7 +74,7 @@ Vector<DeprecatedString> Table::render_lines_for_terminal(size_t view_width) con
return lines;
}
DeprecatedString Table::render_to_html(bool) const
ByteString Table::render_to_html(bool) const
{
auto alignment_string = [](Alignment alignment) {
switch (alignment) {
@ -114,7 +114,7 @@ DeprecatedString Table::render_to_html(bool) const
builder.append("</tbody>"sv);
builder.append("</table>"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
RecursionDecision Table::walk(Visitor& visitor) const

View file

@ -33,8 +33,8 @@ public:
Table() = default;
virtual ~Table() override = default;
virtual DeprecatedString render_to_html(bool tight = false) const override;
virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual ByteString render_to_html(bool tight = false) const override;
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
virtual RecursionDecision walk(Visitor&) const override;
static OwnPtr<Table> parse(LineIterator& lines);

View file

@ -298,25 +298,25 @@ size_t Text::terminal_length() const
return m_node->terminal_length();
}
DeprecatedString Text::render_to_html() const
ByteString Text::render_to_html() const
{
StringBuilder builder;
m_node->render_to_html(builder);
return builder.to_deprecated_string().trim(" \n\t"sv);
return builder.to_byte_string().trim(" \n\t"sv);
}
DeprecatedString Text::render_for_raw_print() const
ByteString Text::render_for_raw_print() const
{
StringBuilder builder;
m_node->render_for_raw_print(builder);
return builder.to_deprecated_string().trim(" \n\t"sv);
return builder.to_byte_string().trim(" \n\t"sv);
}
DeprecatedString Text::render_for_terminal() const
ByteString Text::render_for_terminal() const
{
StringBuilder builder;
m_node->render_for_terminal(builder);
return builder.to_deprecated_string().trim(" \n\t"sv);
return builder.to_byte_string().trim(" \n\t"sv);
}
RecursionDecision Text::walk(Visitor& visitor) const
@ -366,7 +366,7 @@ Vector<Text::Token> Text::tokenize(StringView str)
return;
tokens.append({
current_token.to_deprecated_string(),
current_token.to_byte_string(),
left_flanking,
right_flanking,
punct_before,
@ -671,11 +671,11 @@ NonnullOwnPtr<Text::Node> Text::parse_link(Vector<Token>::ConstIterator& tokens)
if (*iterator == ")"sv) {
tokens = iterator;
DeprecatedString href = address.to_deprecated_string().trim_whitespace();
ByteString href = address.to_byte_string().trim_whitespace();
// Add file:// if the link is an absolute path otherwise it will be assumed relative.
if (AK::StringUtils::starts_with(href, "/"sv, CaseSensitivity::CaseSensitive))
href = DeprecatedString::formatted("file://{}", href);
href = ByteString::formatted("file://{}", href);
return make<LinkNode>(is_image, move(link_text), move(href), image_width, image_height);
}

View file

@ -8,7 +8,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Noncopyable.h>
#include <AK/OwnPtr.h>
#include <AK/RecursionDecision.h>
@ -75,7 +75,7 @@ public:
class TextNode : public Node {
public:
DeprecatedString text;
ByteString text;
bool collapsible;
TextNode(StringView text)
@ -101,11 +101,11 @@ public:
public:
bool is_image;
NonnullOwnPtr<Node> text;
DeprecatedString href;
ByteString href;
Optional<int> image_width;
Optional<int> image_height;
LinkNode(bool is_image, NonnullOwnPtr<Node> text, DeprecatedString href, Optional<int> image_width, Optional<int> image_height)
LinkNode(bool is_image, NonnullOwnPtr<Node> text, ByteString href, Optional<int> image_width, Optional<int> image_height)
: is_image(is_image)
, text(move(text))
, href(move(href))
@ -154,16 +154,16 @@ public:
size_t terminal_length() const;
DeprecatedString render_to_html() const;
DeprecatedString render_for_terminal() const;
DeprecatedString render_for_raw_print() const;
ByteString render_to_html() const;
ByteString render_for_terminal() const;
ByteString render_for_raw_print() const;
RecursionDecision walk(Visitor&) const;
static Text parse(StringView);
private:
struct Token {
DeprecatedString data;
ByteString data;
// Flanking basically means that a delimiter run has a non-whitespace,
// non-punctuation character on the corresponding side. For a more exact
// definition, see the CommonMark spec.

View file

@ -47,7 +47,7 @@ public:
virtual RecursionDecision visit(Text::StrikeThroughNode const&) { return RecursionDecision::Recurse; }
virtual RecursionDecision visit(Text::TextNode const&) { return RecursionDecision::Recurse; }
virtual RecursionDecision visit(DeprecatedString const&) { return RecursionDecision::Recurse; }
virtual RecursionDecision visit(ByteString const&) { return RecursionDecision::Recurse; }
};
}