1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 19:07:35 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -4,15 +4,15 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibGemini/Document.h>
namespace Gemini {
String Document::render_to_html() const
DeprecatedString Document::render_to_html() const
{
StringBuilder html_builder;
html_builder.append("<!DOCTYPE html>\n<html>\n"sv);

View file

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

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <LibCore/Forward.h>

View file

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

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.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, String meta)
static NonnullRefPtr<GeminiResponse> create(int status, DeprecatedString meta)
{
return adopt_ref(*new GeminiResponse(status, meta));
}
int status() const { return m_status; }
String meta() const { return m_meta; }
DeprecatedString meta() const { return m_meta; }
private:
GeminiResponse(int status, String);
GeminiResponse(int status, DeprecatedString);
int m_status { 0 };
String m_meta;
DeprecatedString m_meta;
};
}

View file

@ -53,11 +53,11 @@ bool Job::can_read_line() const
return MUST(m_socket->can_read_line());
}
String Job::read_line(size_t size)
DeprecatedString Job::read_line(size_t size)
{
ByteBuffer buffer = ByteBuffer::create_uninitialized(size).release_value_but_fixme_should_propagate_errors();
auto bytes_read = MUST(m_socket->read_until(buffer, "\r\n"sv));
return String::copy(bytes_read);
return DeprecatedString::copy(bytes_read);
}
ByteBuffer Job::receive(size_t size)
@ -114,7 +114,7 @@ void Job::on_socket_connected()
if constexpr (JOB_DEBUG) {
dbgln("Job: raw_request:");
dbgln("{}", String::copy(raw_request));
dbgln("{}", DeprecatedString::copy(raw_request));
}
bool success = write(raw_request);
if (!success)

View file

@ -35,7 +35,7 @@ protected:
void flush_received_buffers();
void register_on_ready_to_read(Function<void()>);
bool can_read_line() const;
String read_line(size_t);
DeprecatedString read_line(size_t);
bool can_read() const;
ByteBuffer receive(size_t);
bool write(ReadonlyBytes);
@ -49,7 +49,7 @@ protected:
GeminiRequest m_request;
State m_state { State::InStatus };
int m_status { -1 };
String m_meta;
DeprecatedString m_meta;
Vector<ByteBuffer, 2> m_received_buffers;
size_t m_received_size { 0 };
size_t m_buffered_size { 0 };

View file

@ -9,7 +9,7 @@
namespace Gemini {
String Text::render_to_html() const
DeprecatedString Text::render_to_html() const
{
StringBuilder builder;
builder.append(escape_html_entities(m_text));
@ -17,12 +17,12 @@ String Text::render_to_html() const
return builder.build();
}
String Heading::render_to_html() const
DeprecatedString Heading::render_to_html() const
{
return String::formatted("<h{}>{}</h{}>", m_level, escape_html_entities(m_text.substring_view(m_level, m_text.length() - m_level)), m_level);
return DeprecatedString::formatted("<h{}>{}</h{}>", m_level, escape_html_entities(m_text.substring_view(m_level, m_text.length() - m_level)), m_level);
}
String UnorderedList::render_to_html() const
DeprecatedString 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
@ -34,7 +34,7 @@ String UnorderedList::render_to_html() const
return builder.build();
}
String Control::render_to_html() const
DeprecatedString Control::render_to_html() const
{
switch (m_kind) {
case Kind::PreformattedEnd:
@ -52,7 +52,7 @@ String Control::render_to_html() const
}
}
Link::Link(String text, Document const& document)
Link::Link(DeprecatedString text, Document const& document)
: Line(move(text))
{
size_t index = 2;
@ -60,7 +60,7 @@ Link::Link(String 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);
String url = url_string;
DeprecatedString url = url_string;
if (space_offset.has_value()) {
url = url_string.substring_view(0, space_offset.value());
auto offset = space_offset.value();
@ -73,7 +73,7 @@ Link::Link(String text, Document const& document)
m_name = m_url.to_string();
}
String Link::render_to_html() const
DeprecatedString Link::render_to_html() const
{
StringBuilder builder;
builder.append("<a href=\""sv);
@ -84,7 +84,7 @@ String Link::render_to_html() const
return builder.build();
}
String Preformatted::render_to_html() const
DeprecatedString Preformatted::render_to_html() const
{
StringBuilder builder;
builder.append(escape_html_entities(m_text));