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

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/NonnullRefPtr.h>
#include <AK/StringBuilder.h>
@ -13,7 +13,7 @@
namespace Gemini {
DeprecatedString Document::render_to_html() const
ByteString Document::render_to_html() const
{
StringBuilder html_builder;
html_builder.append("<!DOCTYPE html>\n<html>\n"sv);
@ -26,7 +26,7 @@ DeprecatedString Document::render_to_html() const
}
html_builder.append("</body>"sv);
html_builder.append("</html>"sv);
return html_builder.to_deprecated_string();
return html_builder.to_byte_string();
}
NonnullRefPtr<Document> Document::parse(StringView lines, const URL& url)

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Forward.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/URL.h>
@ -15,22 +15,22 @@ namespace Gemini {
class Line {
public:
Line(DeprecatedString string)
Line(ByteString string)
: m_text(move(string))
{
}
virtual ~Line() = default;
virtual DeprecatedString render_to_html() const = 0;
virtual ByteString render_to_html() const = 0;
protected:
DeprecatedString m_text;
ByteString m_text;
};
class Document : public RefCounted<Document> {
public:
DeprecatedString render_to_html() const;
ByteString render_to_html() const;
static NonnullRefPtr<Document> parse(StringView source, const URL&);
@ -52,43 +52,43 @@ private:
class Text : public Line {
public:
Text(DeprecatedString line)
Text(ByteString line)
: Line(move(line))
{
}
virtual ~Text() override = default;
virtual DeprecatedString render_to_html() const override;
virtual ByteString render_to_html() const override;
};
class Link : public Line {
public:
Link(DeprecatedString line, Document const&);
Link(ByteString line, Document const&);
virtual ~Link() override = default;
virtual DeprecatedString render_to_html() const override;
virtual ByteString render_to_html() const override;
private:
URL m_url;
DeprecatedString m_name;
ByteString m_name;
};
class Preformatted : public Line {
public:
Preformatted(DeprecatedString line)
Preformatted(ByteString line)
: Line(move(line))
{
}
virtual ~Preformatted() override = default;
virtual DeprecatedString render_to_html() const override;
virtual ByteString render_to_html() const override;
};
class UnorderedList : public Line {
public:
UnorderedList(DeprecatedString line)
UnorderedList(ByteString line)
: Line(move(line))
{
}
virtual ~UnorderedList() override = default;
virtual DeprecatedString render_to_html() const override;
virtual ByteString render_to_html() const override;
};
class Control : public Line {
@ -105,7 +105,7 @@ public:
{
}
virtual ~Control() override = default;
virtual DeprecatedString render_to_html() const override;
virtual ByteString render_to_html() const override;
private:
Kind m_kind;
@ -113,13 +113,13 @@ private:
class Heading : public Line {
public:
Heading(DeprecatedString line, int level)
Heading(ByteString line, int level)
: Line(move(line))
, m_level(level)
{
}
virtual ~Heading() override = default;
virtual DeprecatedString render_to_html() const override;
virtual ByteString render_to_html() const override;
private:
int m_level { 1 };

View file

@ -13,7 +13,7 @@ namespace Gemini {
ErrorOr<ByteBuffer> GeminiRequest::to_raw_request() const
{
StringBuilder builder;
TRY(builder.try_append(m_url.to_deprecated_string()));
TRY(builder.try_append(m_url.to_byte_string()));
TRY(builder.try_append("\r\n"sv));
return builder.to_byte_buffer();
}

View file

@ -8,7 +8,7 @@
namespace Gemini {
GeminiResponse::GeminiResponse(int status, DeprecatedString meta)
GeminiResponse::GeminiResponse(int status, ByteString meta)
: m_status(status)
, m_meta(meta)
{

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/NetworkResponse.h>
namespace Gemini {
@ -14,19 +14,19 @@ namespace Gemini {
class GeminiResponse : public Core::NetworkResponse {
public:
virtual ~GeminiResponse() override = default;
static NonnullRefPtr<GeminiResponse> create(int status, DeprecatedString meta)
static NonnullRefPtr<GeminiResponse> create(int status, ByteString meta)
{
return adopt_ref(*new GeminiResponse(status, meta));
}
int status() const { return m_status; }
DeprecatedString meta() const { return m_meta; }
ByteString meta() const { return m_meta; }
private:
GeminiResponse(int status, DeprecatedString);
GeminiResponse(int status, ByteString);
int m_status { 0 };
DeprecatedString m_meta;
ByteString m_meta;
};
}

View file

@ -115,7 +115,7 @@ void Job::on_socket_connected()
if constexpr (JOB_DEBUG) {
dbgln("Job: raw_request:");
dbgln("{}", DeprecatedString::copy(raw_request));
dbgln("{}", ByteString::copy(raw_request));
}
bool success = write(raw_request);
if (!success)

View file

@ -53,7 +53,7 @@ protected:
GeminiRequest m_request;
State m_state { State::InStatus };
int m_status { -1 };
DeprecatedString m_meta;
ByteString m_meta;
Vector<ByteBuffer, 2> m_received_buffers;
size_t m_received_size { 0 };
size_t m_buffered_size { 0 };

View file

@ -9,20 +9,20 @@
namespace Gemini {
DeprecatedString Text::render_to_html() const
ByteString Text::render_to_html() const
{
StringBuilder builder;
builder.append(escape_html_entities(m_text));
builder.append("<br>\n"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString Heading::render_to_html() const
ByteString Heading::render_to_html() const
{
return DeprecatedString::formatted("<h{}>{}</h{}>", m_level, escape_html_entities(m_text.substring_view(m_level, m_text.length() - m_level)), m_level);
return ByteString::formatted("<h{}>{}</h{}>", m_level, escape_html_entities(m_text.substring_view(m_level, m_text.length() - m_level)), m_level);
}
DeprecatedString UnorderedList::render_to_html() const
ByteString UnorderedList::render_to_html() const
{
// 1.3.5.4.2 "Advanced clients can take the space of the bullet symbol into account"
// FIXME: The spec is unclear about what the space means, or where it goes
@ -31,10 +31,10 @@ DeprecatedString UnorderedList::render_to_html() const
builder.append("<li>"sv);
builder.append(escape_html_entities(m_text.substring_view(1, m_text.length() - 1)));
builder.append("</li>"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString Control::render_to_html() const
ByteString Control::render_to_html() const
{
switch (m_kind) {
case Kind::PreformattedEnd:
@ -52,7 +52,7 @@ DeprecatedString Control::render_to_html() const
}
}
Link::Link(DeprecatedString text, Document const& document)
Link::Link(ByteString text, Document const& document)
: Line(move(text))
{
size_t index = 2;
@ -60,7 +60,7 @@ Link::Link(DeprecatedString text, Document const& document)
++index;
auto url_string = m_text.substring_view(index, m_text.length() - index);
auto space_offset = url_string.find_any_of(" \t"sv);
DeprecatedString url = url_string;
ByteString url = url_string;
if (space_offset.has_value()) {
url = url_string.substring_view(0, space_offset.value());
auto offset = space_offset.value();
@ -70,27 +70,27 @@ Link::Link(DeprecatedString text, Document const& document)
}
m_url = document.url().complete_url(url);
if (m_name.is_empty())
m_name = m_url.to_deprecated_string();
m_name = m_url.to_byte_string();
}
DeprecatedString Link::render_to_html() const
ByteString Link::render_to_html() const
{
StringBuilder builder;
builder.append("<a href=\""sv);
builder.append(escape_html_entities(m_url.to_deprecated_string()));
builder.append(escape_html_entities(m_url.to_byte_string()));
builder.append("\">"sv);
builder.append(escape_html_entities(m_name));
builder.append("</a><br>\n"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString Preformatted::render_to_html() const
ByteString Preformatted::render_to_html() const
{
StringBuilder builder;
builder.append(escape_html_entities(m_text));
builder.append('\n');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}