diff --git a/AK/DeprecatedString.cpp b/AK/ByteString.cpp similarity index 63% rename from AK/DeprecatedString.cpp rename to AK/ByteString.cpp index 408243d430b..a1211261768 100644 --- a/AK/DeprecatedString.cpp +++ b/AK/ByteString.cpp @@ -5,8 +5,8 @@ */ #include +#include #include -#include #include #include #include @@ -16,17 +16,17 @@ namespace AK { -bool DeprecatedString::operator==(DeprecatedFlyString const& fly_string) const +bool ByteString::operator==(DeprecatedFlyString const& fly_string) const { return m_impl == fly_string.impl() || view() == fly_string.view(); } -bool DeprecatedString::operator==(DeprecatedString const& other) const +bool ByteString::operator==(ByteString const& other) const { return m_impl == other.impl() || view() == other.view(); } -bool DeprecatedString::operator==(StringView other) const +bool ByteString::operator==(StringView other) const { if (other.is_null()) return is_empty(); @@ -34,17 +34,17 @@ bool DeprecatedString::operator==(StringView other) const return view() == other; } -bool DeprecatedString::operator<(DeprecatedString const& other) const +bool ByteString::operator<(ByteString const& other) const { return view() < other.view(); } -bool DeprecatedString::operator>(DeprecatedString const& other) const +bool ByteString::operator>(ByteString const& other) const { return view() > other.view(); } -bool DeprecatedString::copy_characters_to_buffer(char* buffer, size_t buffer_size) const +bool ByteString::copy_characters_to_buffer(char* buffer, size_t buffer_size) const { // We must fit at least the NUL-terminator. VERIFY(buffer_size > 0); @@ -56,55 +56,55 @@ bool DeprecatedString::copy_characters_to_buffer(char* buffer, size_t buffer_siz return characters_to_copy == length(); } -DeprecatedString DeprecatedString::isolated_copy() const +ByteString ByteString::isolated_copy() const { if (m_impl->length() == 0) return empty(); char* buffer; auto impl = StringImpl::create_uninitialized(length(), buffer); memcpy(buffer, m_impl->characters(), m_impl->length()); - return DeprecatedString(move(*impl)); + return ByteString(move(*impl)); } -DeprecatedString DeprecatedString::substring(size_t start, size_t length) const +ByteString ByteString::substring(size_t start, size_t length) const { if (!length) - return DeprecatedString::empty(); + return ByteString::empty(); VERIFY(!Checked::addition_would_overflow(start, length)); VERIFY(start + length <= m_impl->length()); return { characters() + start, length }; } -DeprecatedString DeprecatedString::substring(size_t start) const +ByteString ByteString::substring(size_t start) const { VERIFY(start <= length()); return { characters() + start, length() - start }; } -StringView DeprecatedString::substring_view(size_t start, size_t length) const +StringView ByteString::substring_view(size_t start, size_t length) const { VERIFY(!Checked::addition_would_overflow(start, length)); VERIFY(start + length <= m_impl->length()); return { characters() + start, length }; } -StringView DeprecatedString::substring_view(size_t start) const +StringView ByteString::substring_view(size_t start) const { VERIFY(start <= length()); return { characters() + start, length() - start }; } -Vector DeprecatedString::split(char separator, SplitBehavior split_behavior) const +Vector ByteString::split(char separator, SplitBehavior split_behavior) const { return split_limit(separator, 0, split_behavior); } -Vector DeprecatedString::split_limit(char separator, size_t limit, SplitBehavior split_behavior) const +Vector ByteString::split_limit(char separator, size_t limit, SplitBehavior split_behavior) const { if (is_empty()) return {}; - Vector v; + Vector v; size_t substart = 0; bool keep_empty = has_flag(split_behavior, SplitBehavior::KeepEmpty); bool keep_separator = has_flag(split_behavior, SplitBehavior::KeepTrailingSeparator); @@ -123,7 +123,7 @@ Vector DeprecatedString::split_limit(char separator, size_t li return v; } -Vector DeprecatedString::split_view(Function separator, SplitBehavior split_behavior) const +Vector ByteString::split_view(Function separator, SplitBehavior split_behavior) const { if (is_empty()) return {}; @@ -147,78 +147,78 @@ Vector DeprecatedString::split_view(Function separator, return v; } -Vector DeprecatedString::split_view(char const separator, SplitBehavior split_behavior) const +Vector ByteString::split_view(char const separator, SplitBehavior split_behavior) const { return split_view([separator](char ch) { return ch == separator; }, split_behavior); } -ByteBuffer DeprecatedString::to_byte_buffer() const +ByteBuffer ByteString::to_byte_buffer() const { // FIXME: Handle OOM failure. return ByteBuffer::copy(bytes()).release_value_but_fixme_should_propagate_errors(); } template -Optional DeprecatedString::to_int(TrimWhitespace trim_whitespace) const +Optional ByteString::to_int(TrimWhitespace trim_whitespace) const { return StringUtils::convert_to_int(view(), trim_whitespace); } -template Optional DeprecatedString::to_int(TrimWhitespace) const; -template Optional DeprecatedString::to_int(TrimWhitespace) const; -template Optional DeprecatedString::to_int(TrimWhitespace) const; -template Optional DeprecatedString::to_int(TrimWhitespace) const; -template Optional DeprecatedString::to_int(TrimWhitespace) const; +template Optional ByteString::to_int(TrimWhitespace) const; +template Optional ByteString::to_int(TrimWhitespace) const; +template Optional ByteString::to_int(TrimWhitespace) const; +template Optional ByteString::to_int(TrimWhitespace) const; +template Optional ByteString::to_int(TrimWhitespace) const; template -Optional DeprecatedString::to_uint(TrimWhitespace trim_whitespace) const +Optional ByteString::to_uint(TrimWhitespace trim_whitespace) const { return StringUtils::convert_to_uint(view(), trim_whitespace); } -template Optional DeprecatedString::to_uint(TrimWhitespace) const; -template Optional DeprecatedString::to_uint(TrimWhitespace) const; -template Optional DeprecatedString::to_uint(TrimWhitespace) const; -template Optional DeprecatedString::to_uint(TrimWhitespace) const; -template Optional DeprecatedString::to_uint(TrimWhitespace) const; +template Optional ByteString::to_uint(TrimWhitespace) const; +template Optional ByteString::to_uint(TrimWhitespace) const; +template Optional ByteString::to_uint(TrimWhitespace) const; +template Optional ByteString::to_uint(TrimWhitespace) const; +template Optional ByteString::to_uint(TrimWhitespace) const; #ifndef KERNEL -Optional DeprecatedString::to_double(TrimWhitespace trim_whitespace) const +Optional ByteString::to_double(TrimWhitespace trim_whitespace) const { return StringUtils::convert_to_floating_point(*this, trim_whitespace); } -Optional DeprecatedString::to_float(TrimWhitespace trim_whitespace) const +Optional ByteString::to_float(TrimWhitespace trim_whitespace) const { return StringUtils::convert_to_floating_point(*this, trim_whitespace); } #endif -bool DeprecatedString::starts_with(StringView str, CaseSensitivity case_sensitivity) const +bool ByteString::starts_with(StringView str, CaseSensitivity case_sensitivity) const { return StringUtils::starts_with(*this, str, case_sensitivity); } -bool DeprecatedString::starts_with(char ch) const +bool ByteString::starts_with(char ch) const { if (is_empty()) return false; return characters()[0] == ch; } -bool DeprecatedString::ends_with(StringView str, CaseSensitivity case_sensitivity) const +bool ByteString::ends_with(StringView str, CaseSensitivity case_sensitivity) const { return StringUtils::ends_with(*this, str, case_sensitivity); } -bool DeprecatedString::ends_with(char ch) const +bool ByteString::ends_with(char ch) const { if (is_empty()) return false; return characters()[length() - 1] == ch; } -DeprecatedString DeprecatedString::repeated(char ch, size_t count) +ByteString ByteString::repeated(char ch, size_t count) { if (!count) return empty(); @@ -228,7 +228,7 @@ DeprecatedString DeprecatedString::repeated(char ch, size_t count) return *impl; } -DeprecatedString DeprecatedString::repeated(StringView string, size_t count) +ByteString ByteString::repeated(StringView string, size_t count) { if (!count || string.is_empty()) return empty(); @@ -239,7 +239,7 @@ DeprecatedString DeprecatedString::repeated(StringView string, size_t count) return *impl; } -DeprecatedString DeprecatedString::bijective_base_from(size_t value, unsigned base, StringView map) +ByteString ByteString::bijective_base_from(size_t value, unsigned base, StringView map) { value++; if (map.is_null()) @@ -265,13 +265,13 @@ DeprecatedString DeprecatedString::bijective_base_from(size_t value, unsigned ba for (size_t j = 0; j < i / 2; ++j) swap(buffer[j], buffer[i - j - 1]); - return DeprecatedString { ReadonlyBytes(buffer.data(), i) }; + return ByteString { ReadonlyBytes(buffer.data(), i) }; } -DeprecatedString DeprecatedString::roman_number_from(size_t value) +ByteString ByteString::roman_number_from(size_t value) { if (value > 3999) - return DeprecatedString::number(value); + return ByteString::number(value); StringBuilder builder; @@ -318,44 +318,44 @@ DeprecatedString DeprecatedString::roman_number_from(size_t value) } } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -bool DeprecatedString::matches(StringView mask, Vector& mask_spans, CaseSensitivity case_sensitivity) const +bool ByteString::matches(StringView mask, Vector& mask_spans, CaseSensitivity case_sensitivity) const { return StringUtils::matches(*this, mask, case_sensitivity, &mask_spans); } -bool DeprecatedString::matches(StringView mask, CaseSensitivity case_sensitivity) const +bool ByteString::matches(StringView mask, CaseSensitivity case_sensitivity) const { return StringUtils::matches(*this, mask, case_sensitivity); } -bool DeprecatedString::contains(StringView needle, CaseSensitivity case_sensitivity) const +bool ByteString::contains(StringView needle, CaseSensitivity case_sensitivity) const { return StringUtils::contains(*this, needle, case_sensitivity); } -bool DeprecatedString::contains(char needle, CaseSensitivity case_sensitivity) const +bool ByteString::contains(char needle, CaseSensitivity case_sensitivity) const { return StringUtils::contains(*this, StringView(&needle, 1), case_sensitivity); } -bool DeprecatedString::equals_ignoring_ascii_case(StringView other) const +bool ByteString::equals_ignoring_ascii_case(StringView other) const { return StringUtils::equals_ignoring_ascii_case(view(), other); } -DeprecatedString DeprecatedString::reverse() const +ByteString ByteString::reverse() const { StringBuilder reversed_string(length()); for (size_t i = length(); i-- > 0;) { reversed_string.append(characters()[i]); } - return reversed_string.to_deprecated_string(); + return reversed_string.to_byte_string(); } -DeprecatedString escape_html_entities(StringView html) +ByteString escape_html_entities(StringView html) { StringBuilder builder; for (size_t i = 0; i < html.length(); ++i) { @@ -370,40 +370,40 @@ DeprecatedString escape_html_entities(StringView html) else builder.append(html[i]); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString::DeprecatedString(DeprecatedFlyString const& string) +ByteString::ByteString(DeprecatedFlyString const& string) : m_impl(*(string.impl() ?: &StringImpl::the_empty_stringimpl())) { } -DeprecatedString DeprecatedString::to_lowercase() const +ByteString ByteString::to_lowercase() const { return m_impl->to_lowercase(); } -DeprecatedString DeprecatedString::to_uppercase() const +ByteString ByteString::to_uppercase() const { return m_impl->to_uppercase(); } -DeprecatedString DeprecatedString::to_snakecase() const +ByteString ByteString::to_snakecase() const { return StringUtils::to_snakecase(*this); } -DeprecatedString DeprecatedString::to_titlecase() const +ByteString ByteString::to_titlecase() const { return StringUtils::to_titlecase(*this); } -DeprecatedString DeprecatedString::invert_case() const +ByteString ByteString::invert_case() const { return StringUtils::invert_case(*this); } -bool DeprecatedString::operator==(char const* cstring) const +bool ByteString::operator==(char const* cstring) const { if (!cstring) return is_empty(); @@ -411,28 +411,28 @@ bool DeprecatedString::operator==(char const* cstring) const return view() == cstring; } -DeprecatedString DeprecatedString::vformatted(StringView fmtstr, TypeErasedFormatParams& params) +ByteString ByteString::vformatted(StringView fmtstr, TypeErasedFormatParams& params) { StringBuilder builder; MUST(vformat(builder, fmtstr, params)); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -Vector DeprecatedString::find_all(StringView needle) const +Vector ByteString::find_all(StringView needle) const { return StringUtils::find_all(*this, needle); } -DeprecatedStringCodePointIterator DeprecatedString::code_points() const +DeprecatedStringCodePointIterator ByteString::code_points() const { return DeprecatedStringCodePointIterator(*this); } -ErrorOr DeprecatedString::from_utf8(ReadonlyBytes bytes) +ErrorOr ByteString::from_utf8(ReadonlyBytes bytes) { if (!Utf8View(bytes).validate()) - return Error::from_string_literal("DeprecatedString::from_utf8: Input was not valid UTF-8"); - return DeprecatedString { *StringImpl::create(bytes) }; + return Error::from_string_literal("ByteString::from_utf8: Input was not valid UTF-8"); + return ByteString { *StringImpl::create(bytes) }; } } diff --git a/AK/DeprecatedString.h b/AK/ByteString.h similarity index 63% rename from AK/DeprecatedString.h rename to AK/ByteString.h index 4813342bded..dc48d63c48b 100644 --- a/AK/DeprecatedString.h +++ b/AK/ByteString.h @@ -16,93 +16,93 @@ namespace AK { -// DeprecatedString is a convenience wrapper around StringImpl, suitable for passing +// ByteString is a convenience wrapper around StringImpl, suitable for passing // around as a value type. It's basically the same as passing around a // RefPtr, with a bit of syntactic sugar. // // Note that StringImpl is an immutable object that cannot shrink or grow. // Its allocation size is snugly tailored to the specific string it contains. -// Copying a DeprecatedString is very efficient, since the internal StringImpl is +// Copying a ByteString is very efficient, since the internal StringImpl is // retainable and so copying only requires modifying the ref count. // -// There are three main ways to construct a new DeprecatedString: +// There are three main ways to construct a new ByteString: // -// s = DeprecatedString("some literal"); +// s = ByteString("some literal"); // -// s = DeprecatedString::formatted("{} little piggies", m_piggies); +// s = ByteString::formatted("{} little piggies", m_piggies); // // StringBuilder builder; // builder.append("abc"); // builder.append("123"); -// s = builder.to_deprecated_string(); +// s = builder.to_byte_string(); -class DeprecatedString { +class ByteString { public: - ~DeprecatedString() = default; + ~ByteString() = default; - DeprecatedString() + ByteString() : m_impl(StringImpl::the_empty_stringimpl()) { } - DeprecatedString(StringView view) + ByteString(StringView view) : m_impl(*StringImpl::create(view.characters_without_null_termination(), view.length())) { } - DeprecatedString(DeprecatedString const& other) + ByteString(ByteString const& other) : m_impl(other.m_impl) { } - DeprecatedString(DeprecatedString&& other) + ByteString(ByteString&& other) : m_impl(move(other.m_impl)) { other.m_impl = StringImpl::the_empty_stringimpl(); } - DeprecatedString(char const* cstring, ShouldChomp shouldChomp = NoChomp) + ByteString(char const* cstring, ShouldChomp shouldChomp = NoChomp) : m_impl(*StringImpl::create(cstring, shouldChomp)) { } - DeprecatedString(char const* cstring, size_t length, ShouldChomp shouldChomp = NoChomp) + ByteString(char const* cstring, size_t length, ShouldChomp shouldChomp = NoChomp) : m_impl(*StringImpl::create(cstring, length, shouldChomp)) { } - explicit DeprecatedString(ReadonlyBytes bytes, ShouldChomp shouldChomp = NoChomp) + explicit ByteString(ReadonlyBytes bytes, ShouldChomp shouldChomp = NoChomp) : m_impl(*StringImpl::create(bytes, shouldChomp)) { } - DeprecatedString(StringImpl const& impl) + ByteString(StringImpl const& impl) : m_impl(impl) { } - DeprecatedString(NonnullRefPtr&& impl) + ByteString(NonnullRefPtr&& impl) : m_impl(*move(impl)) { } - DeprecatedString(DeprecatedFlyString const&); + ByteString(DeprecatedFlyString const&); - static ErrorOr from_utf8(ReadonlyBytes); - static ErrorOr from_utf8(StringView string) { return from_utf8(string.bytes()); } + static ErrorOr from_utf8(ReadonlyBytes); + static ErrorOr from_utf8(StringView string) { return from_utf8(string.bytes()); } - [[nodiscard]] static DeprecatedString repeated(char, size_t count); - [[nodiscard]] static DeprecatedString repeated(StringView, size_t count); + [[nodiscard]] static ByteString repeated(char, size_t count); + [[nodiscard]] static ByteString repeated(StringView, size_t count); - [[nodiscard]] static DeprecatedString bijective_base_from(size_t value, unsigned base = 26, StringView map = {}); - [[nodiscard]] static DeprecatedString roman_number_from(size_t value); + [[nodiscard]] static ByteString bijective_base_from(size_t value, unsigned base = 26, StringView map = {}); + [[nodiscard]] static ByteString roman_number_from(size_t value); template - [[nodiscard]] static DeprecatedString join(SeparatorType const& separator, CollectionType const& collection, StringView fmtstr = "{}"sv) + [[nodiscard]] static ByteString join(SeparatorType const& separator, CollectionType const& collection, StringView fmtstr = "{}"sv) { StringBuilder builder; builder.join(separator, collection, fmtstr); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } [[nodiscard]] bool matches(StringView mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const; @@ -117,17 +117,17 @@ public: [[nodiscard]] Optional to_float(TrimWhitespace = TrimWhitespace::Yes) const; #endif - [[nodiscard]] DeprecatedString to_lowercase() const; - [[nodiscard]] DeprecatedString to_uppercase() const; - [[nodiscard]] DeprecatedString to_snakecase() const; - [[nodiscard]] DeprecatedString to_titlecase() const; - [[nodiscard]] DeprecatedString invert_case() const; + [[nodiscard]] ByteString to_lowercase() const; + [[nodiscard]] ByteString to_uppercase() const; + [[nodiscard]] ByteString to_snakecase() const; + [[nodiscard]] ByteString to_titlecase() const; + [[nodiscard]] ByteString invert_case() const; [[nodiscard]] bool is_whitespace() const { return StringUtils::is_whitespace(*this); } [[nodiscard]] DeprecatedStringCodePointIterator code_points() const; - [[nodiscard]] DeprecatedString trim(StringView characters, TrimMode mode = TrimMode::Both) const + [[nodiscard]] ByteString trim(StringView characters, TrimMode mode = TrimMode::Both) const { auto trimmed_view = StringUtils::trim(view(), characters, mode); if (view() == trimmed_view) @@ -135,7 +135,7 @@ public: return trimmed_view; } - [[nodiscard]] DeprecatedString trim_whitespace(TrimMode mode = TrimMode::Both) const + [[nodiscard]] ByteString trim_whitespace(TrimMode mode = TrimMode::Both) const { auto trimmed_view = StringUtils::trim_whitespace(view(), mode); if (view() == trimmed_view) @@ -148,8 +148,8 @@ public: [[nodiscard]] bool contains(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const; [[nodiscard]] bool contains(char, CaseSensitivity = CaseSensitivity::CaseSensitive) const; - [[nodiscard]] Vector split_limit(char separator, size_t limit, SplitBehavior = SplitBehavior::Nothing) const; - [[nodiscard]] Vector split(char separator, SplitBehavior = SplitBehavior::Nothing) const; + [[nodiscard]] Vector split_limit(char separator, size_t limit, SplitBehavior = SplitBehavior::Nothing) const; + [[nodiscard]] Vector split(char separator, SplitBehavior = SplitBehavior::Nothing) const; [[nodiscard]] Vector split_view(char separator, SplitBehavior = SplitBehavior::Nothing) const; [[nodiscard]] Vector split_view(Function separator, SplitBehavior = SplitBehavior::Nothing) const; @@ -163,8 +163,8 @@ public: [[nodiscard]] StringView find_last_split_view(char separator) const { return view().find_last_split_view(separator); } - [[nodiscard]] DeprecatedString substring(size_t start, size_t length) const; - [[nodiscard]] DeprecatedString substring(size_t start) const; + [[nodiscard]] ByteString substring(size_t start, size_t length) const; + [[nodiscard]] ByteString substring(size_t start) const; [[nodiscard]] StringView substring_view(size_t start, size_t length) const; [[nodiscard]] StringView substring_view(size_t start) const; @@ -190,7 +190,7 @@ public: return bit_cast((*m_impl)[i]); } - using ConstIterator = SimpleIterator; + using ConstIterator = SimpleIterator; [[nodiscard]] constexpr ConstIterator begin() const { return ConstIterator::begin(*this); } [[nodiscard]] constexpr ConstIterator end() const { return ConstIterator::end(*this); } @@ -200,47 +200,47 @@ public: [[nodiscard]] bool starts_with(char) const; [[nodiscard]] bool ends_with(char) const; - bool operator==(DeprecatedString const&) const; + bool operator==(ByteString const&) const; bool operator==(StringView) const; bool operator==(DeprecatedFlyString const&) const; - bool operator<(DeprecatedString const&) const; - bool operator>=(DeprecatedString const& other) const { return !(*this < other); } + bool operator<(ByteString const&) const; + bool operator>=(ByteString const& other) const { return !(*this < other); } bool operator>=(char const* other) const { return !(*this < other); } - bool operator>(DeprecatedString const&) const; - bool operator<=(DeprecatedString const& other) const { return !(*this > other); } + bool operator>(ByteString const&) const; + bool operator<=(ByteString const& other) const { return !(*this > other); } bool operator<=(char const* other) const { return !(*this > other); } bool operator==(char const* cstring) const; - [[nodiscard]] DeprecatedString isolated_copy() const; + [[nodiscard]] ByteString isolated_copy() const; - [[nodiscard]] static DeprecatedString empty() + [[nodiscard]] static ByteString empty() { return StringImpl::the_empty_stringimpl(); } [[nodiscard]] StringImpl const* impl() const { return m_impl.ptr(); } - DeprecatedString& operator=(DeprecatedString&& other) + ByteString& operator=(ByteString&& other) { if (this != &other) m_impl = move(other.m_impl); return *this; } - DeprecatedString& operator=(DeprecatedString const& other) + ByteString& operator=(ByteString const& other) { if (this != &other) - m_impl = const_cast(other).m_impl; + m_impl = const_cast(other).m_impl; return *this; } template T> - DeprecatedString& operator=(T bytes) + ByteString& operator=(T bytes) { m_impl = *StringImpl::create(bytes); return *this; @@ -254,24 +254,24 @@ public: [[nodiscard]] ByteBuffer to_byte_buffer() const; template - [[nodiscard]] static DeprecatedString copy(BufferType const& buffer, ShouldChomp should_chomp = NoChomp) + [[nodiscard]] static ByteString copy(BufferType const& buffer, ShouldChomp should_chomp = NoChomp) { if (buffer.is_empty()) return empty(); - return DeprecatedString(reinterpret_cast(buffer.data()), buffer.size(), should_chomp); + return ByteString(reinterpret_cast(buffer.data()), buffer.size(), should_chomp); } - [[nodiscard]] static DeprecatedString vformatted(StringView fmtstr, TypeErasedFormatParams&); + [[nodiscard]] static ByteString vformatted(StringView fmtstr, TypeErasedFormatParams&); template - [[nodiscard]] static DeprecatedString formatted(CheckedFormatString&& fmtstr, Parameters const&... parameters) + [[nodiscard]] static ByteString formatted(CheckedFormatString&& fmtstr, Parameters const&... parameters) { VariadicFormatParams variadic_format_parameters { parameters... }; return vformatted(fmtstr.view(), variadic_format_parameters); } template - [[nodiscard]] static DeprecatedString number(T value) + [[nodiscard]] static ByteString number(T value) { return formatted("{}", value); } @@ -281,9 +281,9 @@ public: return { characters(), length() }; } - [[nodiscard]] DeprecatedString replace(StringView needle, StringView replacement, ReplaceMode replace_mode = ReplaceMode::All) const { return StringUtils::replace(*this, needle, replacement, replace_mode); } + [[nodiscard]] ByteString replace(StringView needle, StringView replacement, ReplaceMode replace_mode = ReplaceMode::All) const { return StringUtils::replace(*this, needle, replacement, replace_mode); } [[nodiscard]] size_t count(StringView needle) const { return StringUtils::count(*this, needle); } - [[nodiscard]] DeprecatedString reverse() const; + [[nodiscard]] ByteString reverse() const; template [[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts&&... strings) const @@ -308,17 +308,17 @@ private: }; template<> -struct Traits : public DefaultTraits { - static unsigned hash(DeprecatedString const& s) { return s.impl() ? s.impl()->hash() : 0; } +struct Traits : public DefaultTraits { + static unsigned hash(ByteString const& s) { return s.impl() ? s.impl()->hash() : 0; } }; // FIXME: Rename this to indicate that it's about ASCII-only case insensitivity. -struct CaseInsensitiveStringTraits : public Traits { - static unsigned hash(DeprecatedString const& s) { return s.impl() ? s.impl()->case_insensitive_hash() : 0; } - static bool equals(DeprecatedString const& a, DeprecatedString const& b) { return a.equals_ignoring_ascii_case(b); } +struct CaseInsensitiveStringTraits : public Traits { + static unsigned hash(ByteString const& s) { return s.impl() ? s.impl()->case_insensitive_hash() : 0; } + static bool equals(ByteString const& a, ByteString const& b) { return a.equals_ignoring_ascii_case(b); } }; -DeprecatedString escape_html_entities(StringView html); +ByteString escape_html_entities(StringView html); } diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index 366b1d271fb..15ebea36de2 100644 --- a/AK/CMakeLists.txt +++ b/AK/CMakeLists.txt @@ -6,7 +6,7 @@ set(AK_SOURCES CountingStream.cpp DOSPackedTime.cpp DeprecatedFlyString.cpp - DeprecatedString.cpp + ByteString.cpp Error.cpp FloatingPointStringConversions.cpp FlyString.cpp diff --git a/AK/Demangle.h b/AK/Demangle.h index 0d6484298ba..3321256f451 100644 --- a/AK/Demangle.h +++ b/AK/Demangle.h @@ -8,17 +8,17 @@ #ifndef KERNEL -# include +# include # include # include namespace AK { -inline DeprecatedString demangle(StringView name) +inline ByteString demangle(StringView name) { int status = 0; - auto* demangled_name = abi::__cxa_demangle(name.to_deprecated_string().characters(), nullptr, nullptr, &status); - auto string = DeprecatedString(status == 0 ? StringView { demangled_name, strlen(demangled_name) } : name); + auto* demangled_name = abi::__cxa_demangle(name.to_byte_string().characters(), nullptr, nullptr, &status); + auto string = ByteString(status == 0 ? StringView { demangled_name, strlen(demangled_name) } : name); if (status == 0) free(demangled_name); return string; diff --git a/AK/DeprecatedFlyString.cpp b/AK/DeprecatedFlyString.cpp index cc9f50de78a..0ac1f52f97f 100644 --- a/AK/DeprecatedFlyString.cpp +++ b/AK/DeprecatedFlyString.cpp @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include -#include #include #include #include @@ -36,7 +36,7 @@ void DeprecatedFlyString::did_destroy_impl(Badge, StringImpl& impl) fly_impls().remove(&impl); } -DeprecatedFlyString::DeprecatedFlyString(DeprecatedString const& string) +DeprecatedFlyString::DeprecatedFlyString(ByteString const& string) { if (string.impl()->is_fly()) { m_impl = string.impl(); @@ -61,7 +61,7 @@ DeprecatedFlyString::DeprecatedFlyString(StringView string) return string == *candidate; }); if (it == fly_impls().end()) { - auto new_string = string.to_deprecated_string(); + auto new_string = string.to_byte_string(); fly_impls().set(new_string.impl()); new_string.impl()->set_fly({}, true); m_impl = new_string.impl(); @@ -122,10 +122,10 @@ bool DeprecatedFlyString::ends_with(StringView str, CaseSensitivity case_sensiti DeprecatedFlyString DeprecatedFlyString::to_lowercase() const { - return DeprecatedString(*m_impl).to_lowercase(); + return ByteString(*m_impl).to_lowercase(); } -bool DeprecatedFlyString::operator==(DeprecatedString const& other) const +bool DeprecatedFlyString::operator==(ByteString const& other) const { return m_impl == other.impl() || view() == other.view(); } diff --git a/AK/DeprecatedFlyString.h b/AK/DeprecatedFlyString.h index b7b0ca03750..174b2d9d184 100644 --- a/AK/DeprecatedFlyString.h +++ b/AK/DeprecatedFlyString.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace AK { @@ -22,10 +22,10 @@ public: : m_impl(move(other.m_impl)) { } - DeprecatedFlyString(DeprecatedString const&); + DeprecatedFlyString(ByteString const&); DeprecatedFlyString(StringView); DeprecatedFlyString(char const* string) - : DeprecatedFlyString(static_cast(string)) + : DeprecatedFlyString(static_cast(string)) { } @@ -54,7 +54,7 @@ public: bool operator==(DeprecatedFlyString const& other) const { return m_impl == other.m_impl; } - bool operator==(DeprecatedString const&) const; + bool operator==(ByteString const&) const; bool operator==(StringView) const; diff --git a/AK/Error.h b/AK/Error.h index 351d2853498..9ed9a53124a 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -43,10 +43,10 @@ public: } static Error from_string_view(StringView string_literal) { return Error(string_literal); } - template T> + template T> static Error from_string_view(T) { - // `Error::from_string_view(DeprecatedString::formatted(...))` is a somewhat common mistake, which leads to a UAF situation. + // `Error::from_string_view(ByteString::formatted(...))` is a somewhat common mistake, which leads to a UAF situation. // If your string outlives this error and _isn't_ a temporary being passed to this function, explicitly call .view() on it to resolve to the StringView overload. static_assert(DependentFalse, "Error::from_string_view(String) is almost always a use-after-free"); VERIFY_NOT_REACHED(); diff --git a/AK/FlyString.h b/AK/FlyString.h index 7e939e62970..9fe8786a383 100644 --- a/AK/FlyString.h +++ b/AK/FlyString.h @@ -22,7 +22,7 @@ public: static ErrorOr from_utf8(StringView); template - requires(IsOneOf, DeprecatedString, DeprecatedFlyString, FlyString, String>) + requires(IsOneOf, ByteString, DeprecatedFlyString, FlyString, String>) static ErrorOr from_utf8(T&&) = delete; FlyString(String const&); diff --git a/AK/Format.cpp b/AK/Format.cpp index f8a4cfbd354..237c48621cc 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -274,7 +274,7 @@ ErrorOr FormatBuilder::put_u64( size_t used_by_prefix = 0; if (align == Align::Right && zero_pad) { - // We want DeprecatedString::formatted("{:#08x}", 32) to produce '0x00000020' instead of '0x000020'. This + // We want ByteString::formatted("{:#08x}", 32) to produce '0x00000020' instead of '0x000020'. This // behavior differs from both fmtlib and printf, but is more intuitive. used_by_prefix = 0; } else { @@ -1131,13 +1131,13 @@ void vout(LogLevel log_level, StringView fmtstr, TypeErasedFormatParams& params, #ifndef KERNEL // FIXME: Deduplicate with Core::Process:get_name() -[[gnu::used]] static DeprecatedString process_name_helper() +[[gnu::used]] static ByteString process_name_helper() { # if defined(AK_OS_SERENITY) char buffer[BUFSIZ] = {}; int rc = get_process_name(buffer, BUFSIZ); if (rc != 0) - return DeprecatedString {}; + return ByteString {}; return StringView { buffer, strlen(buffer) }; # elif defined(AK_LIBC_GLIBC) || (defined(AK_OS_LINUX) && !defined(AK_OS_ANDROID)) return StringView { program_invocation_name, strlen(program_invocation_name) }; diff --git a/AK/Format.h b/AK/Format.h index ef546593ad8..0212d419f64 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -501,7 +501,7 @@ struct Formatter : Formatter { } }; template<> -struct Formatter : Formatter { +struct Formatter : Formatter { }; template<> struct Formatter : Formatter { diff --git a/AK/Forward.h b/AK/Forward.h index 3fc2231aee8..24f18de69f9 100644 --- a/AK/Forward.h +++ b/AK/Forward.h @@ -27,7 +27,7 @@ class CircularBuffer; class ConstrainedStream; class CountingStream; class DeprecatedFlyString; -class DeprecatedString; +class ByteString; class DeprecatedStringCodePointIterator; class Duration; class Error; @@ -159,12 +159,12 @@ using AK::BigEndianOutputBitStream; using AK::Bitmap; using AK::ByteBuffer; using AK::Bytes; +using AK::ByteString; using AK::CircularBuffer; using AK::CircularQueue; using AK::ConstrainedStream; using AK::CountingStream; using AK::DeprecatedFlyString; -using AK::DeprecatedString; using AK::DeprecatedStringCodePointIterator; using AK::DoublyLinkedList; using AK::Duration; diff --git a/AK/GenericLexer.cpp b/AK/GenericLexer.cpp index 6a93edbad56..69039d81c8a 100644 --- a/AK/GenericLexer.cpp +++ b/AK/GenericLexer.cpp @@ -11,7 +11,7 @@ #include #ifndef KERNEL -# include +# include # include #endif @@ -186,7 +186,7 @@ template ErrorOr GenericLexer::consume_decimal_integer(); template ErrorOr GenericLexer::consume_decimal_integer(); #ifndef KERNEL -Optional GenericLexer::consume_and_unescape_string(char escape_char) +Optional GenericLexer::consume_and_unescape_string(char escape_char) { auto view = consume_quoted_string(escape_char); if (view.is_null()) @@ -195,7 +195,7 @@ Optional GenericLexer::consume_and_unescape_string(char escape StringBuilder builder; for (size_t i = 0; i < view.length(); ++i) builder.append(consume_escaped_character(escape_char)); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } auto GenericLexer::consume_escaped_code_point(bool combine_surrogate_pairs) -> Result diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index 4f2f2bb11e0..ab1756be248 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -92,7 +92,7 @@ public: } #ifndef KERNEL - bool consume_specific(DeprecatedString const& next) + bool consume_specific(ByteString const& next) { return consume_specific(StringView { next }); } @@ -126,7 +126,7 @@ public: StringView consume_until(StringView); StringView consume_quoted_string(char escape_char = 0); #ifndef KERNEL - Optional consume_and_unescape_string(char escape_char = '\\'); + Optional consume_and_unescape_string(char escape_char = '\\'); #endif template ErrorOr consume_decimal_integer(); diff --git a/AK/Hex.cpp b/AK/Hex.cpp index 8e09729fbbb..37aeb571396 100644 --- a/AK/Hex.cpp +++ b/AK/Hex.cpp @@ -45,14 +45,14 @@ ErrorOr> encode_hex(const ReadonlyBytes input) return Kernel::KString::try_create(output.string_view()); } #else -DeprecatedString encode_hex(const ReadonlyBytes input) +ByteString encode_hex(const ReadonlyBytes input) { StringBuilder output(input.size() * 2); for (auto ch : input) output.appendff("{:02x}", ch); - return output.to_deprecated_string(); + return output.to_byte_string(); } #endif diff --git a/AK/Hex.h b/AK/Hex.h index b65f46757bc..6c56480166c 100644 --- a/AK/Hex.h +++ b/AK/Hex.h @@ -13,7 +13,7 @@ #ifdef KERNEL # include #else -# include +# include #endif namespace AK { @@ -34,7 +34,7 @@ ErrorOr decode_hex(StringView); #ifdef KERNEL ErrorOr> encode_hex(ReadonlyBytes); #else -DeprecatedString encode_hex(ReadonlyBytes); +ByteString encode_hex(ReadonlyBytes); #endif } diff --git a/AK/IPv4Address.h b/AK/IPv4Address.h index f927777508c..7e88968acea 100644 --- a/AK/IPv4Address.h +++ b/AK/IPv4Address.h @@ -17,7 +17,7 @@ # include # include #else -# include +# include # include #endif @@ -67,18 +67,18 @@ public: octet(SubnetClass::D)); } #else - DeprecatedString to_deprecated_string() const + ByteString to_byte_string() const { - return DeprecatedString::formatted("{}.{}.{}.{}", + return ByteString::formatted("{}.{}.{}.{}", octet(SubnetClass::A), octet(SubnetClass::B), octet(SubnetClass::C), octet(SubnetClass::D)); } - DeprecatedString to_deprecated_string_reversed() const + ByteString to_byte_string_reversed() const { - return DeprecatedString::formatted("{}.{}.{}.{}", + return ByteString::formatted("{}.{}.{}.{}", octet(SubnetClass::D), octet(SubnetClass::C), octet(SubnetClass::B), @@ -179,7 +179,7 @@ template<> struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, IPv4Address value) { - return Formatter::format(builder, value.to_deprecated_string()); + return Formatter::format(builder, value.to_byte_string()); } }; #endif diff --git a/AK/Iterator.h b/AK/Iterator.h index 594c2141bdb..d09cbeaf261 100644 --- a/AK/Iterator.h +++ b/AK/Iterator.h @@ -71,7 +71,7 @@ private: { using RawContainerType = RemoveCV; - if constexpr (IsSame || IsSame) + if constexpr (IsSame || IsSame) return { container, container.length() }; else return { container, container.size() }; diff --git a/AK/JsonArray.h b/AK/JsonArray.h index 9b732036bba..cc0a7b74437 100644 --- a/AK/JsonArray.h +++ b/AK/JsonArray.h @@ -73,7 +73,7 @@ public: template void serialize(Builder&) const; - [[nodiscard]] DeprecatedString to_deprecated_string() const { return serialized(); } + [[nodiscard]] ByteString to_byte_string() const { return serialized(); } template void for_each(Callback callback) const @@ -111,7 +111,7 @@ inline typename Builder::OutputType JsonArray::serialized() const { Builder builder; serialize(builder); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } diff --git a/AK/JsonArraySerializer.h b/AK/JsonArraySerializer.h index ef45da294d3..383d420a9ec 100644 --- a/AK/JsonArraySerializer.h +++ b/AK/JsonArraySerializer.h @@ -68,7 +68,7 @@ public: } #ifndef KERNEL - ErrorOr add(DeprecatedString const& value) + ErrorOr add(ByteString const& value) { TRY(begin_item()); if constexpr (IsLegacyBuilder) { diff --git a/AK/JsonObject.cpp b/AK/JsonObject.cpp index 5d280143559..261b97dd0be 100644 --- a/AK/JsonObject.cpp +++ b/AK/JsonObject.cpp @@ -109,7 +109,7 @@ Optional JsonObject::get_bool(StringView key) const } #if !defined(KERNEL) -Optional JsonObject::get_deprecated_string(StringView key) const +Optional JsonObject::get_byte_string(StringView key) const { auto maybe_value = get(key); if (maybe_value.has_value() && maybe_value->is_string()) @@ -249,7 +249,7 @@ bool JsonObject::has_double(StringView key) const } #endif -void JsonObject::set(DeprecatedString const& key, JsonValue value) +void JsonObject::set(ByteString const& key, JsonValue value) { m_members.set(key, move(value)); } @@ -259,7 +259,7 @@ bool JsonObject::remove(StringView key) return m_members.remove(key); } -DeprecatedString JsonObject::to_deprecated_string() const +ByteString JsonObject::to_byte_string() const { return serialized(); } diff --git a/AK/JsonObject.h b/AK/JsonObject.h index a6d14a4b1c9..ff09afb4644 100644 --- a/AK/JsonObject.h +++ b/AK/JsonObject.h @@ -8,8 +8,8 @@ #pragma once +#include #include -#include #include #include #include @@ -20,7 +20,7 @@ namespace AK { class JsonObject { template - using CallbackErrorType = decltype(declval()(declval(), declval()).release_error()); + using CallbackErrorType = decltype(declval()(declval(), declval()).release_error()); public: JsonObject(); @@ -78,7 +78,7 @@ public: Optional get_bool(StringView key) const; #if !defined(KERNEL) - Optional get_deprecated_string(StringView key) const; + Optional get_byte_string(StringView key) const; #endif Optional get_object(StringView key) const; @@ -89,7 +89,7 @@ public: Optional get_float_with_precision_loss(StringView key) const; #endif - void set(DeprecatedString const& key, JsonValue value); + void set(ByteString const& key, JsonValue value); template void for_each_member(Callback callback) const @@ -98,7 +98,7 @@ public: callback(member.key, member.value); } - template Callback> + template Callback> ErrorOr> try_for_each_member(Callback&& callback) const { for (auto const& member : m_members) @@ -114,10 +114,10 @@ public: template void serialize(Builder&) const; - [[nodiscard]] DeprecatedString to_deprecated_string() const; + [[nodiscard]] ByteString to_byte_string() const; private: - OrderedHashMap m_members; + OrderedHashMap m_members; }; template @@ -135,7 +135,7 @@ inline typename Builder::OutputType JsonObject::serialized() const { Builder builder; serialize(builder); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } template @@ -186,7 +186,7 @@ inline typename Builder::OutputType JsonValue::serialized() const { Builder builder; serialize(builder); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } diff --git a/AK/JsonObjectSerializer.h b/AK/JsonObjectSerializer.h index 518856e66aa..d5f858830a3 100644 --- a/AK/JsonObjectSerializer.h +++ b/AK/JsonObjectSerializer.h @@ -63,7 +63,7 @@ public: } #ifndef KERNEL - ErrorOr add(StringView key, DeprecatedString const& value) + ErrorOr add(StringView key, ByteString const& value) { TRY(begin_item(key)); if constexpr (IsLegacyBuilder) { diff --git a/AK/JsonParser.cpp b/AK/JsonParser.cpp index 07159371eb6..e26e1fff08b 100644 --- a/AK/JsonParser.cpp +++ b/AK/JsonParser.cpp @@ -31,7 +31,7 @@ constexpr bool is_space(int ch) // │ │ // ╰─── u[0-9A-Za-z]{4} ──╯ // -ErrorOr JsonParser::consume_and_unescape_string() +ErrorOr JsonParser::consume_and_unescape_string() { if (!consume_specific('"')) return Error::from_string_literal("JsonParser: Expected '\"'"); @@ -128,7 +128,7 @@ ErrorOr JsonParser::consume_and_unescape_string() } } - return final_sb.to_deprecated_string(); + return final_sb.to_byte_string(); } ErrorOr JsonParser::parse_object() diff --git a/AK/JsonParser.h b/AK/JsonParser.h index 38e9a65c9a4..88b373bfaf9 100644 --- a/AK/JsonParser.h +++ b/AK/JsonParser.h @@ -23,7 +23,7 @@ public: private: ErrorOr parse_helper(); - ErrorOr consume_and_unescape_string(); + ErrorOr consume_and_unescape_string(); ErrorOr parse_array(); ErrorOr parse_object(); ErrorOr parse_number(); diff --git a/AK/JsonPath.cpp b/AK/JsonPath.cpp index 3a66e7643fe..b761757a277 100644 --- a/AK/JsonPath.cpp +++ b/AK/JsonPath.cpp @@ -31,16 +31,16 @@ JsonValue JsonPath::resolve(JsonValue const& top_root) const return root; } -DeprecatedString JsonPath::to_deprecated_string() const +ByteString JsonPath::to_byte_string() const { StringBuilder builder; builder.append("{ ."sv); for (auto const& el : *this) { builder.append("sv > "sv); - builder.append(el.to_deprecated_string()); + builder.append(el.to_byte_string()); } builder.append("sv }"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } diff --git a/AK/JsonPath.h b/AK/JsonPath.h index 9b8364cdb03..f24f91684b3 100644 --- a/AK/JsonPath.h +++ b/AK/JsonPath.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -34,7 +34,7 @@ public: } Kind kind() const { return m_kind; } - DeprecatedString const& key() const + ByteString const& key() const { VERIFY(m_kind == Kind::Key); return m_key; @@ -46,13 +46,13 @@ public: return m_index; } - DeprecatedString to_deprecated_string() const + ByteString to_byte_string() const { switch (m_kind) { case Kind::Key: return key(); case Kind::Index: - return DeprecatedString::number(index()); + return ByteString::number(index()); default: return "*"; } @@ -78,7 +78,7 @@ public: private: Kind m_kind; - DeprecatedString m_key; + ByteString m_key; size_t m_index { 0 }; JsonPathElement(Kind kind) @@ -90,7 +90,7 @@ private: class JsonPath : public Vector { public: JsonValue resolve(JsonValue const&) const; - DeprecatedString to_deprecated_string() const; + ByteString to_byte_string() const; }; } diff --git a/AK/JsonValue.cpp b/AK/JsonValue.cpp index 87619dd119d..b6c20341f77 100644 --- a/AK/JsonValue.cpp +++ b/AK/JsonValue.cpp @@ -155,7 +155,7 @@ JsonValue::JsonValue(long long unsigned value) } JsonValue::JsonValue(char const* cstring) - : JsonValue(DeprecatedString(cstring)) + : JsonValue(ByteString(cstring)) { } @@ -167,7 +167,7 @@ JsonValue::JsonValue(double value) } #endif -JsonValue::JsonValue(DeprecatedString const& value) +JsonValue::JsonValue(ByteString const& value) { m_type = Type::String; m_value.as_string = const_cast(value.impl()); @@ -175,7 +175,7 @@ JsonValue::JsonValue(DeprecatedString const& value) } JsonValue::JsonValue(StringView value) - : JsonValue(value.to_deprecated_string()) + : JsonValue(value.to_byte_string()) { } diff --git a/AK/JsonValue.h b/AK/JsonValue.h index 85b6b9f73dd..9750392c11c 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -10,7 +10,7 @@ # error "JsonValue does not propagate allocation failures, so it is not safe to use in the kernel." #endif -#include +#include #include #include #include @@ -52,7 +52,7 @@ public: JsonValue(double); JsonValue(char const*); - JsonValue(DeprecatedString const&); + JsonValue(ByteString const&); JsonValue(StringView); template @@ -78,14 +78,14 @@ public: template void serialize(Builder&) const; - DeprecatedString as_string_or(DeprecatedString const& alternative) const + ByteString as_string_or(ByteString const& alternative) const { if (is_string()) return as_string(); return alternative; } - DeprecatedString to_deprecated_string() const + ByteString to_byte_string() const { if (is_string()) return as_string(); @@ -148,7 +148,7 @@ public: return m_value.as_bool; } - DeprecatedString as_string() const + ByteString as_string() const { VERIFY(is_string()); return *m_value.as_string; @@ -290,7 +290,7 @@ template<> struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, JsonValue const& value) { - return Formatter::format(builder, value.to_deprecated_string()); + return Formatter::format(builder, value.to_byte_string()); } }; diff --git a/AK/LexicalPath.cpp b/AK/LexicalPath.cpp index b6c2181c296..b2f573b6ae5 100644 --- a/AK/LexicalPath.cpp +++ b/AK/LexicalPath.cpp @@ -14,7 +14,7 @@ namespace AK { char s_single_dot = '.'; -LexicalPath::LexicalPath(DeprecatedString path) +LexicalPath::LexicalPath(ByteString path) : m_string(canonicalized_path(move(path))) { if (m_string.is_empty()) { @@ -58,9 +58,9 @@ LexicalPath::LexicalPath(DeprecatedString path) } } -Vector LexicalPath::parts() const +Vector LexicalPath::parts() const { - Vector vector; + Vector vector; vector.ensure_capacity(m_parts.size()); for (auto& part : m_parts) vector.unchecked_append(part); @@ -88,7 +88,7 @@ bool LexicalPath::is_child_of(LexicalPath const& possible_parent) const return common_parts_with_parent == possible_parent.parts_view().span(); } -DeprecatedString LexicalPath::canonicalized_path(DeprecatedString path) +ByteString LexicalPath::canonicalized_path(ByteString path) { // NOTE: We never allow an empty m_string, if it's empty, we just set it to '.'. if (path.is_empty()) @@ -101,7 +101,7 @@ DeprecatedString LexicalPath::canonicalized_path(DeprecatedString path) auto is_absolute = path[0] == '/'; auto parts = path.split_view('/'); size_t approximate_canonical_length = 0; - Vector canonical_parts; + Vector canonical_parts; for (auto& part : parts) { if (part == ".") @@ -131,10 +131,10 @@ DeprecatedString LexicalPath::canonicalized_path(DeprecatedString path) if (is_absolute) builder.append('/'); builder.join('/', canonical_parts); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString LexicalPath::absolute_path(DeprecatedString dir_path, DeprecatedString target) +ByteString LexicalPath::absolute_path(ByteString dir_path, ByteString target) { if (LexicalPath(target).is_absolute()) { return LexicalPath::canonicalized_path(target); @@ -142,10 +142,10 @@ DeprecatedString LexicalPath::absolute_path(DeprecatedString dir_path, Deprecate return LexicalPath::canonicalized_path(join(dir_path, target).string()); } -DeprecatedString LexicalPath::relative_path(StringView a_path, StringView a_prefix) +ByteString LexicalPath::relative_path(StringView a_path, StringView a_prefix) { if (!a_path.starts_with('/') || !a_prefix.starts_with('/')) { - // FIXME: This should probably VERIFY or return an Optional. + // FIXME: This should probably VERIFY or return an Optional. return ""sv; } @@ -186,7 +186,7 @@ DeprecatedString LexicalPath::relative_path(StringView a_path, StringView a_pref builder.append('/'); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } LexicalPath LexicalPath::append(StringView value) const diff --git a/AK/LexicalPath.h b/AK/LexicalPath.h index 35793aea753..44640309b43 100644 --- a/AK/LexicalPath.h +++ b/AK/LexicalPath.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include // On Linux distros that use mlibc `basename` is defined as a macro that expands to `__mlibc_gnu_basename` or `__mlibc_gnu_basename_c`, so we undefine it. @@ -24,10 +24,10 @@ public: Yes }; - explicit LexicalPath(DeprecatedString); + explicit LexicalPath(ByteString); bool is_absolute() const { return !m_string.is_empty() && m_string[0] == '/'; } - DeprecatedString const& string() const { return m_string; } + ByteString const& string() const { return m_string; } StringView dirname() const { return m_dirname; } StringView basename(StripExtension s = StripExtension::No) const { return s == StripExtension::No ? m_basename : m_basename.substring_view(0, m_basename.length() - m_extension.length() - 1); } @@ -35,7 +35,7 @@ public: StringView extension() const { return m_extension; } Vector const& parts_view() const { return m_parts; } - [[nodiscard]] Vector parts() const; + [[nodiscard]] Vector parts() const; bool has_extension(StringView) const; bool is_child_of(LexicalPath const& possible_parent) const; @@ -44,9 +44,9 @@ public: [[nodiscard]] LexicalPath prepend(StringView) const; [[nodiscard]] LexicalPath parent() const; - [[nodiscard]] static DeprecatedString canonicalized_path(DeprecatedString); - [[nodiscard]] static DeprecatedString absolute_path(DeprecatedString dir_path, DeprecatedString target); - [[nodiscard]] static DeprecatedString relative_path(StringView absolute_path, StringView prefix); + [[nodiscard]] static ByteString canonicalized_path(ByteString); + [[nodiscard]] static ByteString absolute_path(ByteString dir_path, ByteString target); + [[nodiscard]] static ByteString relative_path(StringView absolute_path, StringView prefix); template [[nodiscard]] static LexicalPath join(StringView first, S&&... rest) @@ -55,28 +55,28 @@ public: builder.append(first); ((builder.append('/'), builder.append(forward(rest))), ...); - return LexicalPath { builder.to_deprecated_string() }; + return LexicalPath { builder.to_byte_string() }; } - [[nodiscard]] static DeprecatedString dirname(DeprecatedString path) + [[nodiscard]] static ByteString dirname(ByteString path) { auto lexical_path = LexicalPath(move(path)); return lexical_path.dirname(); } - [[nodiscard]] static DeprecatedString basename(DeprecatedString path, StripExtension s = StripExtension::No) + [[nodiscard]] static ByteString basename(ByteString path, StripExtension s = StripExtension::No) { auto lexical_path = LexicalPath(move(path)); return lexical_path.basename(s); } - [[nodiscard]] static DeprecatedString title(DeprecatedString path) + [[nodiscard]] static ByteString title(ByteString path) { auto lexical_path = LexicalPath(move(path)); return lexical_path.title(); } - [[nodiscard]] static DeprecatedString extension(DeprecatedString path) + [[nodiscard]] static ByteString extension(ByteString path) { auto lexical_path = LexicalPath(move(path)); return lexical_path.extension(); @@ -84,7 +84,7 @@ public: private: Vector m_parts; - DeprecatedString m_string; + ByteString m_string; StringView m_dirname; StringView m_basename; StringView m_title; diff --git a/AK/MACAddress.h b/AK/MACAddress.h index cd90c83fe34..b948575e5ad 100644 --- a/AK/MACAddress.h +++ b/AK/MACAddress.h @@ -15,7 +15,7 @@ #ifdef KERNEL # include #else -# include +# include #endif class [[gnu::packed]] MACAddress { @@ -64,9 +64,9 @@ public: return Kernel::KString::formatted("{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", m_data[0], m_data[1], m_data[2], m_data[3], m_data[4], m_data[5]); } #else - DeprecatedString to_deprecated_string() const + ByteString to_byte_string() const { - return DeprecatedString::formatted("{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", m_data[0], m_data[1], m_data[2], m_data[3], m_data[4], m_data[5]); + return ByteString::formatted("{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", m_data[0], m_data[1], m_data[2], m_data[3], m_data[4], m_data[5]); } #endif diff --git a/AK/NumberFormat.cpp b/AK/NumberFormat.cpp index bb60ca4c74c..3841f5ce339 100644 --- a/AK/NumberFormat.cpp +++ b/AK/NumberFormat.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -13,7 +13,7 @@ namespace AK { // FIXME: Remove this hackery once printf() supports floats. -static DeprecatedString number_string_with_one_decimal(u64 number, u64 unit, StringView suffix, UseThousandsSeparator use_thousands_separator) +static ByteString number_string_with_one_decimal(u64 number, u64 unit, StringView suffix, UseThousandsSeparator use_thousands_separator) { constexpr auto max_unit_size = NumericLimits::max() / 10; VERIFY(unit < max_unit_size); @@ -21,25 +21,25 @@ static DeprecatedString number_string_with_one_decimal(u64 number, u64 unit, Str auto integer_part = number / unit; auto decimal_part = (number % unit) * 10 / unit; if (use_thousands_separator == UseThousandsSeparator::Yes) - return DeprecatedString::formatted("{:'d}.{} {}", integer_part, decimal_part, suffix); + return ByteString::formatted("{:'d}.{} {}", integer_part, decimal_part, suffix); - return DeprecatedString::formatted("{}.{} {}", integer_part, decimal_part, suffix); + return ByteString::formatted("{}.{} {}", integer_part, decimal_part, suffix); } -DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on, StringView unit, UseThousandsSeparator use_thousands_separator) +ByteString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on, StringView unit, UseThousandsSeparator use_thousands_separator) { u64 size_of_unit = based_on == HumanReadableBasedOn::Base2 ? 1024 : 1000; constexpr auto unit_prefixes = AK::Array { "", "K", "M", "G", "T", "P", "E" }; auto full_unit_suffix = [&](int index) { auto binary_infix = (based_on == HumanReadableBasedOn::Base2 && index != 0) ? "i"sv : ""sv; - return DeprecatedString::formatted("{}{}{}", + return ByteString::formatted("{}{}{}", unit_prefixes[index], binary_infix, unit); }; auto size_of_current_unit = size_of_unit; if (quantity < size_of_unit) - return DeprecatedString::formatted("{} {}", quantity, full_unit_suffix(0)); + return ByteString::formatted("{} {}", quantity, full_unit_suffix(0)); for (size_t i = 1; i < unit_prefixes.size() - 1; i++) { auto suffix = full_unit_suffix(i); @@ -54,28 +54,28 @@ DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn base size_of_current_unit, full_unit_suffix(unit_prefixes.size() - 1), use_thousands_separator); } -DeprecatedString human_readable_size(u64 size, HumanReadableBasedOn based_on, UseThousandsSeparator use_thousands_separator) +ByteString human_readable_size(u64 size, HumanReadableBasedOn based_on, UseThousandsSeparator use_thousands_separator) { return human_readable_quantity(size, based_on, "B"sv, use_thousands_separator); } -DeprecatedString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator) +ByteString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator) { if (size < 1 * KiB) { if (use_thousands_separator == UseThousandsSeparator::Yes) - return DeprecatedString::formatted("{:'d} bytes", size); + return ByteString::formatted("{:'d} bytes", size); - return DeprecatedString::formatted("{} bytes", size); + return ByteString::formatted("{} bytes", size); } auto human_readable_size_string = human_readable_size(size, HumanReadableBasedOn::Base2, use_thousands_separator); if (use_thousands_separator == UseThousandsSeparator::Yes) - return DeprecatedString::formatted("{} ({:'d} bytes)", human_readable_size_string, size); + return ByteString::formatted("{} ({:'d} bytes)", human_readable_size_string, size); - return DeprecatedString::formatted("{} ({} bytes)", human_readable_size_string, size); + return ByteString::formatted("{} ({} bytes)", human_readable_size_string, size); } -DeprecatedString human_readable_time(i64 time_in_seconds) +ByteString human_readable_time(i64 time_in_seconds) { auto days = time_in_seconds / 86400; time_in_seconds = time_in_seconds % 86400; @@ -99,10 +99,10 @@ DeprecatedString human_readable_time(i64 time_in_seconds) builder.appendff("{} second{}", time_in_seconds, time_in_seconds == 1 ? "" : "s"); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString human_readable_digital_time(i64 time_in_seconds) +ByteString human_readable_digital_time(i64 time_in_seconds) { auto hours = time_in_seconds / 3600; time_in_seconds = time_in_seconds % 3600; @@ -117,7 +117,7 @@ DeprecatedString human_readable_digital_time(i64 time_in_seconds) builder.appendff("{:02}:", minutes); builder.appendff("{:02}", time_in_seconds); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } diff --git a/AK/NumberFormat.h b/AK/NumberFormat.h index 72b4f6a17a4..fdb16d3a113 100644 --- a/AK/NumberFormat.h +++ b/AK/NumberFormat.h @@ -6,7 +6,7 @@ #pragma once -#include +#include namespace AK { @@ -20,12 +20,12 @@ enum class UseThousandsSeparator { No }; -DeprecatedString human_readable_size(u64 size, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No); -DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, StringView unit = "B"sv, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No); +ByteString human_readable_size(u64 size, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No); +ByteString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, StringView unit = "B"sv, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No); -DeprecatedString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No); -DeprecatedString human_readable_time(i64 time_in_seconds); -DeprecatedString human_readable_digital_time(i64 time_in_seconds); +ByteString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No); +ByteString human_readable_time(i64 time_in_seconds); +ByteString human_readable_digital_time(i64 time_in_seconds); } diff --git a/AK/ReverseIterator.h b/AK/ReverseIterator.h index 5aa0e714c39..c3553758ac1 100644 --- a/AK/ReverseIterator.h +++ b/AK/ReverseIterator.h @@ -66,7 +66,7 @@ private: static constexpr SimpleReverseIterator rbegin(Container& container) { using RawContainerType = RemoveCV; - if constexpr (IsSame || IsSame) + if constexpr (IsSame || IsSame) return { container, static_cast(container.length()) - 1 }; else return { container, static_cast(container.size()) - 1 }; diff --git a/AK/ScopeLogger.h b/AK/ScopeLogger.h index 92b3699d5dc..5b6390aebc1 100644 --- a/AK/ScopeLogger.h +++ b/AK/ScopeLogger.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -24,9 +24,9 @@ public: for (auto indent = m_depth++; indent > 0; indent--) sb.append(' '); if (m_extra.is_empty()) - dbgln("\033[1;{}m{}entering {}\033[0m", m_depth % 8 + 30, sb.to_deprecated_string(), m_location); + dbgln("\033[1;{}m{}entering {}\033[0m", m_depth % 8 + 30, sb.to_byte_string(), m_location); else - dbgln("\033[1;{}m{}entering {}\033[0m ({})", m_depth % 8 + 30, sb.to_deprecated_string(), m_location, m_extra); + dbgln("\033[1;{}m{}entering {}\033[0m ({})", m_depth % 8 + 30, sb.to_byte_string(), m_location, m_extra); } ScopeLogger(SourceLocation location = SourceLocation::current()) @@ -42,15 +42,15 @@ public: for (auto indent = --m_depth; indent > 0; indent--) sb.append(' '); if (m_extra.is_empty()) - dbgln("\033[1;{}m{}leaving {}\033[0m", depth % 8 + 30, sb.to_deprecated_string(), m_location); + dbgln("\033[1;{}m{}leaving {}\033[0m", depth % 8 + 30, sb.to_byte_string(), m_location); else - dbgln("\033[1;{}m{}leaving {}\033[0m ({})", depth % 8 + 30, sb.to_deprecated_string(), m_location, m_extra); + dbgln("\033[1;{}m{}leaving {}\033[0m ({})", depth % 8 + 30, sb.to_byte_string(), m_location, m_extra); } private: static inline size_t m_depth = 0; SourceLocation m_location; - DeprecatedString m_extra; + ByteString m_extra; }; template<> diff --git a/AK/SourceGenerator.h b/AK/SourceGenerator.h index 000410ac7a6..7a2c0e444ae 100644 --- a/AK/SourceGenerator.h +++ b/AK/SourceGenerator.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -116,12 +116,12 @@ public: } // FIXME: These are deprecated. - void set(StringView key, DeprecatedString value) + void set(StringView key, ByteString value) { - set(key, MUST(String::from_deprecated_string(value))); + set(key, MUST(String::from_byte_string(value))); } template - void set(char const (&key)[N], DeprecatedString value) + void set(char const (&key)[N], ByteString value) { set(StringView { key, N - 1 }, value); } diff --git a/AK/String.cpp b/AK/String.cpp index f6d7f2dc1f9..3fe5e088679 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -621,14 +621,14 @@ void String::did_create_fly_string(Badge) const m_data->set_fly_string(true); } -DeprecatedString String::to_deprecated_string() const +ByteString String::to_byte_string() const { - return DeprecatedString(bytes_as_string_view()); + return ByteString(bytes_as_string_view()); } -ErrorOr String::from_deprecated_string(DeprecatedString const& deprecated_string) +ErrorOr String::from_byte_string(ByteString const& byte_string) { - return String::from_utf8(deprecated_string.view()); + return String::from_utf8(byte_string.view()); } bool String::equals_ignoring_ascii_case(StringView other) const diff --git a/AK/String.h b/AK/String.h index e54b7fb4f2c..f122160fb69 100644 --- a/AK/String.h +++ b/AK/String.h @@ -67,7 +67,7 @@ public: // Creates a new String from a sequence of UTF-8 encoded code points. static ErrorOr from_utf8(StringView); template - requires(IsOneOf, DeprecatedString, DeprecatedFlyString, FlyString, String>) + requires(IsOneOf, ByteString, DeprecatedFlyString, FlyString, String>) static ErrorOr from_utf8(T&&) = delete; // Creates a new String by reading byte_count bytes from a UTF-8 encoded Stream. @@ -221,11 +221,11 @@ public: void did_create_fly_string(Badge) const; // FIXME: Remove these once all code has been ported to String - [[nodiscard]] DeprecatedString to_deprecated_string() const; - static ErrorOr from_deprecated_string(DeprecatedString const&); + [[nodiscard]] ByteString to_byte_string() const; + static ErrorOr from_byte_string(ByteString const&); template requires(IsSame, StringView>) - static ErrorOr from_deprecated_string(T&&) = delete; + static ErrorOr from_byte_string(T&&) = delete; private: // NOTE: If the least significant bit of the pointer is set, this is a short string. diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp index 88b3f7fdb19..1db8dea923c 100644 --- a/AK/StringBuilder.cpp +++ b/AK/StringBuilder.cpp @@ -15,7 +15,7 @@ #include #ifndef KERNEL -# include +# include # include # include #endif @@ -144,11 +144,11 @@ ErrorOr StringBuilder::to_byte_buffer() const } #ifndef KERNEL -DeprecatedString StringBuilder::to_deprecated_string() const +ByteString StringBuilder::to_byte_string() const { if (is_empty()) - return DeprecatedString::empty(); - return DeprecatedString((char const*)data(), length()); + return ByteString::empty(); + return ByteString((char const*)data(), length()); } ErrorOr StringBuilder::to_string() const diff --git a/AK/StringBuilder.h b/AK/StringBuilder.h index 8632d838a7a..8d2e09a48fa 100644 --- a/AK/StringBuilder.h +++ b/AK/StringBuilder.h @@ -18,7 +18,7 @@ class StringBuilder { public: static constexpr size_t inline_capacity = 256; - using OutputType = DeprecatedString; + using OutputType = ByteString; static ErrorOr create(size_t initial_capacity = inline_capacity); @@ -70,7 +70,7 @@ public: } #ifndef KERNEL - [[nodiscard]] DeprecatedString to_deprecated_string() const; + [[nodiscard]] ByteString to_byte_string() const; #endif ErrorOr to_string() const; diff --git a/AK/StringUtils.cpp b/AK/StringUtils.cpp index ab087a43580..814db99776c 100644 --- a/AK/StringUtils.cpp +++ b/AK/StringUtils.cpp @@ -17,7 +17,7 @@ #ifdef KERNEL # include #else -# include +# include # include # include #endif @@ -465,7 +465,7 @@ Optional find_any_of(StringView haystack, StringView needles, SearchDire } #ifndef KERNEL -DeprecatedString to_snakecase(StringView str) +ByteString to_snakecase(StringView str) { auto should_insert_underscore = [&](auto i, auto current_char) { if (i == 0) @@ -488,10 +488,10 @@ DeprecatedString to_snakecase(StringView str) builder.append('_'); builder.append_as_lowercase(ch); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString to_titlecase(StringView str) +ByteString to_titlecase(StringView str) { StringBuilder builder; bool next_is_upper = true; @@ -504,10 +504,10 @@ DeprecatedString to_titlecase(StringView str) next_is_upper = ch == ' '; } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString invert_case(StringView str) +ByteString invert_case(StringView str) { StringBuilder builder(str.length()); @@ -518,10 +518,10 @@ DeprecatedString invert_case(StringView str) builder.append(to_ascii_lowercase(ch)); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString replace(StringView str, StringView needle, StringView replacement, ReplaceMode replace_mode) +ByteString replace(StringView str, StringView needle, StringView replacement, ReplaceMode replace_mode) { if (str.is_empty()) return str; @@ -546,7 +546,7 @@ DeprecatedString replace(StringView str, StringView needle, StringView replaceme last_position = position + needle.length(); } replaced_string.append(str.substring_view(last_position, str.length() - last_position)); - return replaced_string.to_deprecated_string(); + return replaced_string.to_byte_string(); } ErrorOr replace(String const& haystack, StringView needle, StringView replacement, ReplaceMode replace_mode) diff --git a/AK/StringUtils.h b/AK/StringUtils.h index 1bc4b865bdb..1f29fdff748 100644 --- a/AK/StringUtils.h +++ b/AK/StringUtils.h @@ -106,11 +106,11 @@ enum class SearchDirection { }; Optional find_any_of(StringView haystack, StringView needles, SearchDirection); -DeprecatedString to_snakecase(StringView); -DeprecatedString to_titlecase(StringView); -DeprecatedString invert_case(StringView); +ByteString to_snakecase(StringView); +ByteString to_titlecase(StringView); +ByteString invert_case(StringView); -DeprecatedString replace(StringView, StringView needle, StringView replacement, ReplaceMode); +ByteString replace(StringView, StringView needle, StringView replacement, ReplaceMode); ErrorOr replace(String const&, StringView needle, StringView replacement, ReplaceMode); size_t count(StringView, StringView needle); diff --git a/AK/StringView.cpp b/AK/StringView.cpp index 92ffe4fe94c..f5440c716dd 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -13,8 +13,8 @@ #include #ifndef KERNEL +# include # include -# include # include # include #endif @@ -34,7 +34,7 @@ StringView::StringView(FlyString const& string) { } -StringView::StringView(DeprecatedString const& string) +StringView::StringView(ByteString const& string) : m_characters(string.characters()) , m_length(string.length()) { @@ -176,17 +176,17 @@ bool StringView::equals_ignoring_ascii_case(StringView other) const } #ifndef KERNEL -DeprecatedString StringView::to_lowercase_string() const +ByteString StringView::to_lowercase_string() const { return StringImpl::create_lowercased(characters_without_null_termination(), length()).release_nonnull(); } -DeprecatedString StringView::to_uppercase_string() const +ByteString StringView::to_uppercase_string() const { return StringImpl::create_uppercased(characters_without_null_termination(), length()).release_nonnull(); } -DeprecatedString StringView::to_titlecase_string() const +ByteString StringView::to_titlecase_string() const { return StringUtils::to_titlecase(*this); } @@ -257,14 +257,14 @@ Optional StringView::to_float(TrimWhitespace trim_whitespace) const return StringUtils::convert_to_floating_point(*this, trim_whitespace); } -bool StringView::operator==(DeprecatedString const& string) const +bool StringView::operator==(ByteString const& string) const { return *this == string.view(); } -DeprecatedString StringView::to_deprecated_string() const { return DeprecatedString { *this }; } +ByteString StringView::to_byte_string() const { return ByteString { *this }; } -DeprecatedString StringView::replace(StringView needle, StringView replacement, ReplaceMode replace_mode) const +ByteString StringView::replace(StringView needle, StringView replacement, ReplaceMode replace_mode) const { return StringUtils::replace(*this, needle, replacement, replace_mode); } diff --git a/AK/StringView.h b/AK/StringView.h index 94ac28c36a2..ff9cc8068d8 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -50,7 +50,7 @@ public: #ifndef KERNEL StringView(String const&); StringView(FlyString const&); - StringView(DeprecatedString const&); + StringView(ByteString const&); StringView(DeprecatedFlyString const&); #endif @@ -58,11 +58,11 @@ public: #ifndef KERNEL explicit StringView(String&&) = delete; explicit StringView(FlyString&&) = delete; - explicit StringView(DeprecatedString&&) = delete; + explicit StringView(ByteString&&) = delete; explicit StringView(DeprecatedFlyString&&) = delete; #endif - template StringType> + template StringType> StringView& operator=(StringType&&) = delete; [[nodiscard]] constexpr bool is_null() const @@ -110,9 +110,9 @@ public: [[nodiscard]] StringView trim_whitespace(TrimMode mode = TrimMode::Both) const { return StringUtils::trim_whitespace(*this, mode); } #ifndef KERNEL - [[nodiscard]] DeprecatedString to_lowercase_string() const; - [[nodiscard]] DeprecatedString to_uppercase_string() const; - [[nodiscard]] DeprecatedString to_titlecase_string() const; + [[nodiscard]] ByteString to_lowercase_string() const; + [[nodiscard]] ByteString to_uppercase_string() const; + [[nodiscard]] ByteString to_titlecase_string() const; #endif [[nodiscard]] Optional find(char needle, size_t start = 0) const @@ -272,7 +272,7 @@ public: } #ifndef KERNEL - bool operator==(DeprecatedString const&) const; + bool operator==(ByteString const&) const; #endif [[nodiscard]] constexpr int compare(StringView other) const @@ -314,7 +314,7 @@ public: constexpr bool operator>=(StringView other) const { return compare(other) >= 0; } #ifndef KERNEL - [[nodiscard]] DeprecatedString to_deprecated_string() const; + [[nodiscard]] ByteString to_byte_string() const; #endif [[nodiscard]] bool is_whitespace() const @@ -323,7 +323,7 @@ public: } #ifndef KERNEL - [[nodiscard]] DeprecatedString replace(StringView needle, StringView replacement, ReplaceMode) const; + [[nodiscard]] ByteString replace(StringView needle, StringView replacement, ReplaceMode) const; #endif [[nodiscard]] size_t count(StringView needle) const { @@ -354,7 +354,7 @@ public: } private: - friend class DeprecatedString; + friend class ByteString; char const* m_characters { nullptr }; size_t m_length { 0 }; }; diff --git a/AK/URL.cpp b/AK/URL.cpp index 6f1019973e2..ec40ca2cd98 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -38,21 +38,21 @@ URL URL::complete_url(StringView relative_url) const ErrorOr URL::username() const { - return String::from_deprecated_string(percent_decode(m_username)); + return String::from_byte_string(percent_decode(m_username)); } ErrorOr URL::password() const { - return String::from_deprecated_string(percent_decode(m_password)); + return String::from_byte_string(percent_decode(m_password)); } -DeprecatedString URL::path_segment_at_index(size_t index) const +ByteString URL::path_segment_at_index(size_t index) const { VERIFY(index < path_segment_count()); return percent_decode(m_paths[index]); } -DeprecatedString URL::basename() const +ByteString URL::basename() const { if (!m_valid) return {}; @@ -72,7 +72,7 @@ void URL::set_scheme(String scheme) ErrorOr URL::set_username(StringView username) { // To set the username given a url and username, set url’s username to the result of running UTF-8 percent-encode on username using the userinfo percent-encode set. - m_username = TRY(String::from_deprecated_string(percent_encode(username, PercentEncodeSet::Userinfo))); + m_username = TRY(String::from_byte_string(percent_encode(username, PercentEncodeSet::Userinfo))); m_valid = compute_validity(); return {}; } @@ -81,7 +81,7 @@ ErrorOr URL::set_username(StringView username) ErrorOr URL::set_password(StringView password) { // To set the password given a url and password, set url’s password to the result of running UTF-8 percent-encode on password using the userinfo percent-encode set. - m_password = TRY(String::from_deprecated_string(percent_encode(password, PercentEncodeSet::Userinfo))); + m_password = TRY(String::from_byte_string(percent_encode(password, PercentEncodeSet::Userinfo))); m_valid = compute_validity(); return {}; } @@ -108,18 +108,18 @@ void URL::set_port(Optional port) m_valid = compute_validity(); } -void URL::set_paths(Vector const& paths) +void URL::set_paths(Vector const& paths) { m_paths.clear_with_capacity(); m_paths.ensure_capacity(paths.size()); for (auto const& segment : paths) - m_paths.unchecked_append(String::from_deprecated_string(percent_encode(segment, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors()); + m_paths.unchecked_append(String::from_byte_string(percent_encode(segment, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors()); m_valid = compute_validity(); } void URL::append_path(StringView path) { - m_paths.append(String::from_deprecated_string(percent_encode(path, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors()); + m_paths.append(String::from_byte_string(percent_encode(path, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors()); } // https://url.spec.whatwg.org/#cannot-have-a-username-password-port @@ -182,7 +182,7 @@ Optional URL::default_port_for_scheme(StringView scheme) return {}; } -URL URL::create_with_file_scheme(DeprecatedString const& path, DeprecatedString const& fragment, DeprecatedString const& hostname) +URL URL::create_with_file_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname) { LexicalPath lexical_path(path); if (!lexical_path.is_absolute()) @@ -190,38 +190,38 @@ URL URL::create_with_file_scheme(DeprecatedString const& path, DeprecatedString URL url; url.set_scheme("file"_string); - url.set_host(hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors()); + url.set_host(hostname == "localhost" ? String {} : String::from_byte_string(hostname).release_value_but_fixme_should_propagate_errors()); url.set_paths(lexical_path.parts()); if (path.ends_with('/')) url.append_slash(); if (!fragment.is_empty()) - url.set_fragment(String::from_deprecated_string(fragment).release_value_but_fixme_should_propagate_errors()); + url.set_fragment(String::from_byte_string(fragment).release_value_but_fixme_should_propagate_errors()); return url; } -URL URL::create_with_help_scheme(DeprecatedString const& path, DeprecatedString const& fragment, DeprecatedString const& hostname) +URL URL::create_with_help_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname) { LexicalPath lexical_path(path); URL url; url.set_scheme("help"_string); - url.set_host(hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors()); + url.set_host(hostname == "localhost" ? String {} : String::from_byte_string(hostname).release_value_but_fixme_should_propagate_errors()); url.set_paths(lexical_path.parts()); if (path.ends_with('/')) url.append_slash(); if (!fragment.is_empty()) - url.set_fragment(String::from_deprecated_string(fragment).release_value_but_fixme_should_propagate_errors()); + url.set_fragment(String::from_byte_string(fragment).release_value_but_fixme_should_propagate_errors()); return url; } -URL URL::create_with_url_or_path(DeprecatedString const& url_or_path) +URL URL::create_with_url_or_path(ByteString const& url_or_path) { URL url = url_or_path; if (url.is_valid()) return url; - DeprecatedString path = LexicalPath::canonicalized_path(url_or_path); + ByteString path = LexicalPath::canonicalized_path(url_or_path); return URL::create_with_file_scheme(path); } @@ -237,7 +237,7 @@ URL URL::create_with_data(StringView mime_type, StringView payload, bool is_base builder.append(";base64"sv); builder.append(','); builder.append(payload); - url.set_paths({ builder.to_deprecated_string() }); + url.set_paths({ builder.to_byte_string() }); return url; } @@ -248,12 +248,12 @@ bool URL::is_special_scheme(StringView scheme) } // https://url.spec.whatwg.org/#url-path-serializer -DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding) const +ByteString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding) const { // 1. If url has an opaque path, then return url’s path. // FIXME: Reimplement this step once we modernize the URL implementation to meet the spec. if (cannot_be_a_base_url()) - return m_paths[0].to_deprecated_string(); + return m_paths[0].to_byte_string(); // 2. Let output be the empty string. StringBuilder output; @@ -261,15 +261,15 @@ DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding // 3. For each segment of url’s path: append U+002F (/) followed by segment to output. for (auto const& segment : m_paths) { output.append('/'); - output.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(segment) : segment.to_deprecated_string()); + output.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(segment) : segment.to_byte_string()); } // 4. Return output. - return output.to_deprecated_string(); + return output.to_byte_string(); } // https://url.spec.whatwg.org/#concept-url-serializer -DeprecatedString URL::serialize(ExcludeFragment exclude_fragment) const +ByteString URL::serialize(ExcludeFragment exclude_fragment) const { // 1. Let output be url’s scheme and U+003A (:) concatenated. StringBuilder output; @@ -331,14 +331,14 @@ DeprecatedString URL::serialize(ExcludeFragment exclude_fragment) const } // 7. Return output. - return output.to_deprecated_string(); + return output.to_byte_string(); } // https://url.spec.whatwg.org/#url-rendering // NOTE: This does e.g. not display credentials. // FIXME: Parts of the URL other than the host should have their sequences of percent-encoded bytes replaced with code points // resulting from percent-decoding those sequences converted to bytes, unless that renders those sequences invisible. -DeprecatedString URL::serialize_for_display() const +ByteString URL::serialize_for_display() const { VERIFY(m_valid); @@ -374,17 +374,17 @@ DeprecatedString URL::serialize_for_display() const builder.append(*m_fragment); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } ErrorOr URL::to_string() const { - return String::from_deprecated_string(serialize()); + return String::from_byte_string(serialize()); } // https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin // https://url.spec.whatwg.org/#concept-url-origin -DeprecatedString URL::serialize_origin() const +ByteString URL::serialize_origin() const { VERIFY(m_valid); @@ -407,7 +407,7 @@ DeprecatedString URL::serialize_origin() const builder.append(serialized_host().release_value_but_fixme_should_propagate_errors()); if (m_port.has_value()) builder.appendff(":{}", *m_port); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } bool URL::equals(URL const& other, ExcludeFragment exclude_fragments) const @@ -544,7 +544,7 @@ void URL::append_percent_encoded_if_necessary(StringBuilder& builder, u32 code_p builder.append_code_point(code_point); } -DeprecatedString URL::percent_encode(StringView input, URL::PercentEncodeSet set, SpaceAsPlus space_as_plus) +ByteString URL::percent_encode(StringView input, URL::PercentEncodeSet set, SpaceAsPlus space_as_plus) { StringBuilder builder; for (auto code_point : Utf8View(input)) { @@ -553,10 +553,10 @@ DeprecatedString URL::percent_encode(StringView input, URL::PercentEncodeSet set else append_percent_encoded_if_necessary(builder, code_point, set); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString URL::percent_decode(StringView input) +ByteString URL::percent_decode(StringView input) { if (!input.contains('%')) return input; @@ -575,7 +575,7 @@ DeprecatedString URL::percent_decode(StringView input) builder.append(byte); } } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } diff --git a/AK/URL.h b/AK/URL.h index 951297a738c..2aeee6365ff 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -45,7 +45,7 @@ public: URL() = default; URL(StringView); - URL(DeprecatedString const& string) + URL(ByteString const& string) : URL(string.view()) { } @@ -77,11 +77,11 @@ public: ErrorOr password() const; Host const& host() const { return m_host; } ErrorOr serialized_host() const; - DeprecatedString basename() const; + ByteString basename() const; Optional const& query() const { return m_query; } Optional const& fragment() const { return m_fragment; } Optional port() const { return m_port; } - DeprecatedString path_segment_at_index(size_t index) const; + ByteString path_segment_at_index(size_t index) const; size_t path_segment_count() const { return m_paths.size(); } u16 port_or_default() const { return m_port.value_or(default_port_for_scheme(m_scheme).value_or(0)); } @@ -96,7 +96,7 @@ public: ErrorOr set_password(StringView); void set_host(Host); void set_port(Optional); - void set_paths(Vector const&); + void set_paths(Vector const&); void set_query(Optional query) { m_query = move(query); } void set_fragment(Optional fragment) { m_fragment = move(fragment); } void set_cannot_be_a_base_url(bool value) { m_cannot_be_a_base_url = value; } @@ -111,14 +111,14 @@ public: Yes, No }; - DeprecatedString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; - DeprecatedString serialize(ExcludeFragment = ExcludeFragment::No) const; - DeprecatedString serialize_for_display() const; - DeprecatedString to_deprecated_string() const { return serialize(); } + ByteString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; + ByteString serialize(ExcludeFragment = ExcludeFragment::No) const; + ByteString serialize_for_display() const; + ByteString to_byte_string() const { return serialize(); } ErrorOr to_string() const; // HTML origin - DeprecatedString serialize_origin() const; + ByteString serialize_origin() const; bool equals(URL const& other, ExcludeFragment = ExcludeFragment::No) const; @@ -130,9 +130,9 @@ public: }; ErrorOr process_data_url() const; - static URL create_with_url_or_path(DeprecatedString const&); - static URL create_with_file_scheme(DeprecatedString const& path, DeprecatedString const& fragment = {}, DeprecatedString const& hostname = {}); - static URL create_with_help_scheme(DeprecatedString const& path, DeprecatedString const& fragment = {}, DeprecatedString const& hostname = {}); + static URL create_with_url_or_path(ByteString const&); + static URL create_with_file_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {}); + static URL create_with_help_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {}); static URL create_with_data(StringView mime_type, StringView payload, bool is_base64 = false); static Optional default_port_for_scheme(StringView); @@ -142,8 +142,8 @@ public: No, Yes, }; - static DeprecatedString percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No); - static DeprecatedString percent_decode(StringView input); + static ByteString percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No); + static ByteString percent_decode(StringView input); bool operator==(URL const& other) const { return equals(other, ExcludeFragment::No); } @@ -198,7 +198,7 @@ struct Formatter : Formatter { template<> struct Traits : public DefaultTraits { - static unsigned hash(URL const& url) { return url.to_deprecated_string().hash(); } + static unsigned hash(URL const& url) { return url.to_byte_string().hash(); } }; } diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index 8ab4e841ce1..700eb117ec7 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -5,9 +5,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include -#include #include #include #include @@ -57,7 +57,7 @@ static Optional parse_opaque_host(StringView input) // currently report validation errors, they are only useful for debugging efforts in the URL parsing code. // 4. Return the result of running UTF-8 percent-encode on input using the C0 control percent-encode set. - return String::from_deprecated_string(URL::percent_encode(input, URL::PercentEncodeSet::C0Control)).release_value_but_fixme_should_propagate_errors(); + return String::from_byte_string(URL::percent_encode(input, URL::PercentEncodeSet::C0Control)).release_value_but_fixme_should_propagate_errors(); } struct ParsedIPv4Number { @@ -606,7 +606,7 @@ static Optional parse_host(StringView input, bool is_opaque = false) // NOTE: This is handled in Unicode::create_unicode_url, to work around the fact that we can't call into LibUnicode here // FIXME: 5. Let asciiDomain be the result of running domain to ASCII with domain and false. // FIXME: 6. If asciiDomain is failure, then return failure. - auto ascii_domain_or_error = String::from_deprecated_string(domain); + auto ascii_domain_or_error = String::from_byte_string(domain); if (ascii_domain_or_error.is_error()) return {}; @@ -792,7 +792,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, if (start_index >= end_index) return {}; - DeprecatedString processed_input = raw_input.substring_view(start_index, end_index - start_index); + ByteString processed_input = raw_input.substring_view(start_index, end_index - start_index); // 2. If input contains any ASCII tab or newline, invalid-URL-unit validation error. // 3. Remove all ASCII tab or newline from input. @@ -1116,7 +1116,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional const& base_url, // 2. If atSignSeen is true, then prepend "%40" to buffer. if (at_sign_seen) { - auto content = buffer.to_deprecated_string(); + auto content = buffer.to_byte_string(); buffer.clear(); buffer.append("%40"sv); buffer.append(content); diff --git a/AK/Utf16View.cpp b/AK/Utf16View.cpp index b3eb615c035..5c0b4c76005 100644 --- a/AK/Utf16View.cpp +++ b/AK/Utf16View.cpp @@ -81,9 +81,9 @@ u32 Utf16View::decode_surrogate_pair(u16 high_surrogate, u16 low_surrogate) return ((high_surrogate - high_surrogate_min) << 10) + (low_surrogate - low_surrogate_min) + first_supplementary_plane_code_point; } -ErrorOr Utf16View::to_deprecated_string(AllowInvalidCodeUnits allow_invalid_code_units) const +ErrorOr Utf16View::to_byte_string(AllowInvalidCodeUnits allow_invalid_code_units) const { - return TRY(to_utf8(allow_invalid_code_units)).to_deprecated_string(); + return TRY(to_utf8(allow_invalid_code_units)).to_byte_string(); } ErrorOr Utf16View::to_utf8(AllowInvalidCodeUnits allow_invalid_code_units) const diff --git a/AK/Utf16View.h b/AK/Utf16View.h index ed40af75637..c1323be9421 100644 --- a/AK/Utf16View.h +++ b/AK/Utf16View.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -78,7 +78,7 @@ public: No, }; - ErrorOr to_deprecated_string(AllowInvalidCodeUnits = AllowInvalidCodeUnits::No) const; + ErrorOr to_byte_string(AllowInvalidCodeUnits = AllowInvalidCodeUnits::No) const; ErrorOr to_utf8(AllowInvalidCodeUnits = AllowInvalidCodeUnits::No) const; bool is_null() const { return m_code_units.is_null(); } diff --git a/AK/Utf8View.h b/AK/Utf8View.h index d7ae838dc71..0e1184401fb 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -12,7 +12,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace AK { @@ -72,12 +72,12 @@ public: } #ifndef KERNEL - explicit Utf8View(DeprecatedString& string) + explicit Utf8View(ByteString& string) : m_string(string.view()) { } - explicit Utf8View(DeprecatedString&&) = delete; + explicit Utf8View(ByteString&&) = delete; #endif ~Utf8View() = default; @@ -255,14 +255,14 @@ public: return Utf8View(m_string).byte_offset_of(m_it); } - DeprecatedStringCodePointIterator(DeprecatedString string) + DeprecatedStringCodePointIterator(ByteString string) : m_string(move(string)) , m_it(Utf8View(m_string).begin()) { } private: - DeprecatedString m_string; + ByteString m_string; Utf8CodePointIterator m_it; }; #endif diff --git a/Base/usr/share/man/man5/clipboard.md b/Base/usr/share/man/man5/clipboard.md index 90d3ba0162e..d062274f472 100644 --- a/Base/usr/share/man/man5/clipboard.md +++ b/Base/usr/share/man/man5/clipboard.md @@ -5,17 +5,17 @@ clipboard - Data formats specific to Clipboard and drag & drop ## Clipboard The clipboard feature works through the Clipboard server, which generally acts as a global storage or three things: -- a `DeprecatedString` mime type, +- a `ByteString` mime type, - a (potentially large) block of data, shared as an anonymous file, -- a `HashMap` of arbitrary metadata, depending on the mime type. +- a `HashMap` of arbitrary metadata, depending on the mime type. See also [`Userland/Libraries/LibGUI/Clipboard.h`](../../../../../Userland/Libraries/LibGUI/Clipboard.h). ## Drag & drop In contrast to the clipboard, the drag & drop feature works through WindowServer, and a bouquet of data is transmitted: -- a `[UTF8] DeprecatedString` to be displayed while dragging, -- a `HashMap` map that contains arbitrary data for a variety of possible mime types, +- a `[UTF8] ByteString` to be displayed while dragging, +- a `HashMap` map that contains arbitrary data for a variety of possible mime types, - a `Gfx::ShareableBitmap` to be displayed while dragging Drag & drop is most prominently supported by File Manager, Spreadsheet, and Terminal. diff --git a/Base/usr/share/man/man5/ipc.md b/Base/usr/share/man/man5/ipc.md index 12bea5d6fd2..eb61349becc 100644 --- a/Base/usr/share/man/man5/ipc.md +++ b/Base/usr/share/man/man5/ipc.md @@ -91,7 +91,7 @@ Start from defining an endpoint in the IPC file in `MyServer.ipc`. ```ipc endpoint MyServer { - SyncAPI(DeprecatedString text) => (i32 status) + SyncAPI(ByteString text) => (i32 status) AsyncAPI(i32 mode) =| } ``` @@ -102,7 +102,7 @@ Part of the generated C++ messages: class SyncAPI final : public IPC::Message { public: using ResponseType = SyncAPIResponse; - SyncAPI(const DeprecatedString& text) : m_text(text) {} + SyncAPI(const ByteString& text) : m_text(text) {} virtual ~SyncAPI() override {} static OwnPtr decode(...); virtual IPC::MessageBuffer encode(...) const override; diff --git a/Documentation/StringFormatting.md b/Documentation/StringFormatting.md index 33f6265f50f..ba494ce5660 100644 --- a/Documentation/StringFormatting.md +++ b/Documentation/StringFormatting.md @@ -1,6 +1,6 @@ # String Formatting -Many places in Serenity allow you to format strings, similar to `printf()`, for example `DeprecatedString::formatted()` +Many places in Serenity allow you to format strings, similar to `printf()`, for example `ByteString::formatted()` , `StringBuilder::appendff()`, or `dbgln()`. These are checked at compile time to ensure the format string matches the number of parameters. The syntax is largely based on the [C++ `std::formatter` syntax](https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification) @@ -10,27 +10,27 @@ For basic usage, any occurrences of `{}` in the format string are replaced with form, in order: ```c++ -DeprecatedString::formatted("Well, {} my {} friends!", "hello", 42) == "Well, hello my 42 friends!"; +ByteString::formatted("Well, {} my {} friends!", "hello", 42) == "Well, hello my 42 friends!"; ``` If you want to include a literal `{` in the output, use `{{`: ```c++ -DeprecatedString::formatted("{{ {}", "hello") == "{ hello"; +ByteString::formatted("{{ {}", "hello") == "{ hello"; ``` You can refer to the arguments by index, if you want to repeat one or change the order: ```c++ -DeprecatedString::formatted("{2}{0}{1}", "a", "b", "c") == "cab"; +ByteString::formatted("{2}{0}{1}", "a", "b", "c") == "cab"; ``` To control how the arguments are formatted, add colon after the optional index, and then add format specifier characters: ```c++ -DeprecatedString::formatted("{:.4}", "cool dude") == "cool"; -DeprecatedString::formatted("{0:.4}", "cool dude") == "cool"; +ByteString::formatted("{:.4}", "cool dude") == "cool"; +ByteString::formatted("{0:.4}", "cool dude") == "cool"; ``` ## Format specifiers @@ -135,6 +135,6 @@ type cannot be formatted. For example: ```c++ // B has a Formatter defined, but A does not. -DeprecatedString::formatted("{}", FormatIfSupported { A {} }) == "?"; -DeprecatedString::formatted("{}", FormatIfSupported { B {} }) == "B"; +ByteString::formatted("{}", FormatIfSupported { A {} }) == "?"; +ByteString::formatted("{}", FormatIfSupported { B {} }) == "B"; ``` diff --git a/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp b/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp index ff2a27ef1d8..8a64051ca1b 100644 --- a/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp +++ b/Ladybird/Android/src/main/cpp/LadybirdActivity.cpp @@ -6,7 +6,7 @@ #include "ALooperEventLoopImplementation.h" #include "JNIHelpers.h" -#include +#include #include #include #include @@ -21,7 +21,7 @@ #include #include -static ErrorOr extract_tar_archive(String archive_file, DeprecatedString output_directory); +static ErrorOr extract_tar_archive(String archive_file, ByteString output_directory); JavaVM* global_vm; static OwnPtr s_main_event_loop; @@ -89,29 +89,29 @@ Java_org_serenityos_ladybird_LadybirdActivity_disposeNativeCode(JNIEnv* env, job delete &Core::EventLoopManager::the(); } -ErrorOr extract_tar_archive(String archive_file, DeprecatedString output_directory) +ErrorOr extract_tar_archive(String archive_file, ByteString output_directory) { constexpr size_t buffer_size = 4096; auto file = TRY(Core::InputBufferedFile::create(TRY(Core::File::open(archive_file, Core::File::OpenMode::Read)))); - DeprecatedString old_pwd = TRY(Core::System::getcwd()); + ByteString old_pwd = TRY(Core::System::getcwd()); TRY(Core::System::chdir(output_directory)); ScopeGuard go_back = [&old_pwd] { MUST(Core::System::chdir(old_pwd)); }; auto tar_stream = TRY(Archive::TarInputStream::construct(move(file))); - HashMap global_overrides; - HashMap local_overrides; + HashMap global_overrides; + HashMap local_overrides; - auto get_override = [&](StringView key) -> Optional { - Optional maybe_local = local_overrides.get(key); + auto get_override = [&](StringView key) -> Optional { + Optional maybe_local = local_overrides.get(key); if (maybe_local.has_value()) return maybe_local; - Optional maybe_global = global_overrides.get(key); + Optional maybe_global = global_overrides.get(key); if (maybe_global.has_value()) return maybe_global; @@ -163,7 +163,7 @@ ErrorOr extract_tar_archive(String archive_file, DeprecatedString output_d long_name.append(reinterpret_cast(slice.data()), slice.size()); } - local_overrides.set("path", long_name.to_deprecated_string()); + local_overrides.set("path", long_name.to_byte_string()); TRY(tar_stream->advance()); continue; } @@ -175,9 +175,9 @@ ErrorOr extract_tar_archive(String archive_file, DeprecatedString output_d LexicalPath path = LexicalPath(header.filename()); if (!header.prefix().is_empty()) path = path.prepend(header.prefix()); - DeprecatedString filename = get_override("path"sv).value_or(path.string()); + ByteString filename = get_override("path"sv).value_or(path.string()); - DeprecatedString absolute_path = TRY(FileSystem::absolute_path(filename)).to_deprecated_string(); + ByteString absolute_path = TRY(FileSystem::absolute_path(filename)).to_byte_string(); auto parent_path = LexicalPath(absolute_path).parent(); auto header_mode = TRY(header.mode()); diff --git a/Ladybird/Android/src/main/cpp/WebContentService.cpp b/Ladybird/Android/src/main/cpp/WebContentService.cpp index f0924bfbbca..a9e6b64b905 100644 --- a/Ladybird/Android/src/main/cpp/WebContentService.cpp +++ b/Ladybird/Android/src/main/cpp/WebContentService.cpp @@ -122,9 +122,9 @@ ErrorOr> bind_service(void (*bind_method)(int, int)) static ErrorOr load_content_filters() { - auto file_or_error = Core::File::open(DeprecatedString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); + auto file_or_error = Core::File::open(ByteString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); if (file_or_error.is_error()) - file_or_error = Core::File::open(DeprecatedString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); + file_or_error = Core::File::open(ByteString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); if (file_or_error.is_error()) return file_or_error.release_error(); diff --git a/Ladybird/AppKit/Application/ApplicationDelegate.mm b/Ladybird/AppKit/Application/ApplicationDelegate.mm index 98f3edd2bbc..aeec1252acc 100644 --- a/Ladybird/AppKit/Application/ApplicationDelegate.mm +++ b/Ladybird/AppKit/Application/ApplicationDelegate.mm @@ -474,7 +474,7 @@ [submenu addItem:[NSMenuItem separatorItem]]; auto* spoof_user_agent_menu = [[NSMenu alloc] init]; - auto add_user_agent = [spoof_user_agent_menu](DeprecatedString name) { + auto add_user_agent = [spoof_user_agent_menu](ByteString name) { [spoof_user_agent_menu addItem:[[NSMenuItem alloc] initWithTitle:Ladybird::string_to_ns_string(name) action:@selector(setUserAgentSpoof:) keyEquivalent:@""]]; diff --git a/Ladybird/AppKit/UI/LadybirdWebView.h b/Ladybird/AppKit/UI/LadybirdWebView.h index 6ec20458bb5..67150c7d8c0 100644 --- a/Ladybird/AppKit/UI/LadybirdWebView.h +++ b/Ladybird/AppKit/UI/LadybirdWebView.h @@ -27,7 +27,7 @@ - (void)onLoadStart:(URL const&)url isRedirect:(BOOL)is_redirect; - (void)onLoadFinish:(URL const&)url; -- (void)onTitleChange:(DeprecatedString const&)title; +- (void)onTitleChange:(ByteString const&)title; - (void)onFaviconChange:(Gfx::Bitmap const&)bitmap; - (void)onNavigateBack; @@ -58,7 +58,7 @@ - (void)resetZoom; - (float)zoomLevel; -- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument; +- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument; - (void)viewSource; diff --git a/Ladybird/AppKit/UI/LadybirdWebView.mm b/Ladybird/AppKit/UI/LadybirdWebView.mm index 646a93f08c3..3ada6c05fbf 100644 --- a/Ladybird/AppKit/UI/LadybirdWebView.mm +++ b/Ladybird/AppKit/UI/LadybirdWebView.mm @@ -180,7 +180,7 @@ struct HideCursor { m_web_view_bridge->set_preferred_color_scheme(color_scheme); } -- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument +- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument { m_web_view_bridge->debug_request(request, argument); } @@ -634,7 +634,7 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_ return [delegate cookieJar].get_named_cookie(url, name); }; - m_web_view_bridge->on_get_cookie = [](auto const& url, auto source) -> DeprecatedString { + m_web_view_bridge->on_get_cookie = [](auto const& url, auto source) -> ByteString { auto* delegate = (ApplicationDelegate*)[NSApp delegate]; return [delegate cookieJar].get_cookie(url, source); }; diff --git a/Ladybird/AppKit/UI/Palette.mm b/Ladybird/AppKit/UI/Palette.mm index 149656d976a..94602b78595 100644 --- a/Ladybird/AppKit/UI/Palette.mm +++ b/Ladybird/AppKit/UI/Palette.mm @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -33,7 +33,7 @@ Core::AnonymousBuffer create_system_palette() auto theme_file = is_dark ? "Dark"sv : "Default"sv; auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file)))); - auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_deprecated_string()).release_value_but_fixme_should_propagate_errors(); + auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_byte_string()).release_value_but_fixme_should_propagate_errors(); auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme); auto palette = Gfx::Palette(move(palette_impl)); diff --git a/Ladybird/AppKit/UI/Tab.mm b/Ladybird/AppKit/UI/Tab.mm index ccf8810170b..0d8a2263a45 100644 --- a/Ladybird/AppKit/UI/Tab.mm +++ b/Ladybird/AppKit/UI/Tab.mm @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -247,7 +247,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800; } } -- (void)onTitleChange:(DeprecatedString const&)title +- (void)onTitleChange:(ByteString const&)title { [[self tabController] onTitleChange:title]; diff --git a/Ladybird/AppKit/UI/TabController.h b/Ladybird/AppKit/UI/TabController.h index 6e47e8264fd..f18fb187913 100644 --- a/Ladybird/AppKit/UI/TabController.h +++ b/Ladybird/AppKit/UI/TabController.h @@ -16,7 +16,7 @@ struct TabSettings { BOOL scripting_enabled { YES }; BOOL block_popups { YES }; BOOL same_origin_policy_enabled { NO }; - DeprecatedString user_agent_name { "Disabled"sv }; + ByteString user_agent_name { "Disabled"sv }; }; @interface TabController : NSWindowController @@ -27,14 +27,14 @@ struct TabSettings { - (void)loadHTML:(StringView)html url:(URL const&)url; - (void)onLoadStart:(URL const&)url isRedirect:(BOOL)isRedirect; -- (void)onTitleChange:(DeprecatedString const&)title; +- (void)onTitleChange:(ByteString const&)title; - (void)navigateBack:(id)sender; - (void)navigateForward:(id)sender; - (void)reload:(id)sender; - (void)clearHistory; -- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument; +- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument; - (void)focusLocationToolbarItem; diff --git a/Ladybird/AppKit/UI/TabController.mm b/Ladybird/AppKit/UI/TabController.mm index 286dfa5c0fc..ba8afb9e738 100644 --- a/Ladybird/AppKit/UI/TabController.mm +++ b/Ladybird/AppKit/UI/TabController.mm @@ -54,7 +54,7 @@ enum class IsHistoryNavigation { @interface TabController () { - DeprecatedString m_title; + ByteString m_title; WebView::History m_history; IsHistoryNavigation m_is_history_navigation; @@ -133,7 +133,7 @@ enum class IsHistoryNavigation { [self updateNavigationButtonStates]; } -- (void)onTitleChange:(DeprecatedString const&)title +- (void)onTitleChange:(ByteString const&)title { m_title = title; m_history.update_title(m_title); @@ -201,7 +201,7 @@ enum class IsHistoryNavigation { [self updateNavigationButtonStates]; } -- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument +- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument { if (request == "dump-history") { m_history.dump(); @@ -390,8 +390,8 @@ enum class IsHistoryNavigation { - (void)setUserAgentSpoof:(NSMenuItem*)sender { - DeprecatedString const user_agent_name = [[sender title] UTF8String]; - DeprecatedString user_agent = ""; + ByteString const user_agent_name = [[sender title] UTF8String]; + ByteString user_agent = ""; if (user_agent_name == "Disabled"sv) { user_agent = Web::default_user_agent; } else { diff --git a/Ladybird/FontPlugin.cpp b/Ladybird/FontPlugin.cpp index 2e8dac841b4..fda4fa06715 100644 --- a/Ladybird/FontPlugin.cpp +++ b/Ladybird/FontPlugin.cpp @@ -6,13 +6,13 @@ */ #include "FontPlugin.h" -#include +#include #include #include #include #include -extern DeprecatedString s_serenity_resource_root; +extern ByteString s_serenity_resource_root; namespace Ladybird { diff --git a/Ladybird/Qt/AutoComplete.cpp b/Ladybird/Qt/AutoComplete.cpp index 4afd9299b04..d743f93dd33 100644 --- a/Ladybird/Qt/AutoComplete.cpp +++ b/Ladybird/Qt/AutoComplete.cpp @@ -45,7 +45,7 @@ ErrorOr AutoComplete::parse_google_autocomplete(Vector const& j if (!json[0].is_string()) return Error::from_string_view("Invalid JSON, expected first element to be a string"sv); - auto query = TRY(String::from_deprecated_string(json[0].as_string())); + auto query = TRY(String::from_byte_string(json[0].as_string())); if (!json[1].is_array()) return Error::from_string_view("Invalid JSON, expected second element to be an array"sv); @@ -55,7 +55,7 @@ ErrorOr AutoComplete::parse_google_autocomplete(Vector const& j return Error::from_string_view("Invalid JSON, query does not match"sv); for (auto& suggestion : suggestions_array) { - m_auto_complete_model->add(TRY(String::from_deprecated_string(suggestion.as_string()))); + m_auto_complete_model->add(TRY(String::from_byte_string(suggestion.as_string()))); } return {}; @@ -67,7 +67,7 @@ ErrorOr AutoComplete::parse_duckduckgo_autocomplete(Vector cons auto maybe_value = suggestion.as_object().get("phrase"sv); if (!maybe_value.has_value()) continue; - m_auto_complete_model->add(TRY(String::from_deprecated_string(maybe_value->as_string()))); + m_auto_complete_model->add(TRY(String::from_byte_string(maybe_value->as_string()))); } return {}; @@ -77,7 +77,7 @@ ErrorOr AutoComplete::parse_yahoo_autocomplete(JsonObject const& json) { if (!json.get("q"sv).has_value() || !json.get("q"sv)->is_string()) return Error::from_string_view("Invalid JSON, expected \"q\" to be a string"sv); - auto query = TRY(String::from_deprecated_string(json.get("q"sv)->as_string())); + auto query = TRY(String::from_byte_string(json.get("q"sv)->as_string())); if (!json.get("r"sv).has_value() || !json.get("r"sv)->is_array()) return Error::from_string_view("Invalid JSON, expected \"r\" to be an object"sv); @@ -94,7 +94,7 @@ ErrorOr AutoComplete::parse_yahoo_autocomplete(JsonObject const& json) if (!suggestion.get("k"sv).has_value() || !suggestion.get("k"sv)->is_string()) return Error::from_string_view("Invalid JSON, expected \"k\" to be a string"sv); - m_auto_complete_model->add(TRY(String::from_deprecated_string(suggestion.get("k"sv)->as_string()))); + m_auto_complete_model->add(TRY(String::from_byte_string(suggestion.get("k"sv)->as_string()))); }; return {}; @@ -105,7 +105,7 @@ ErrorOr AutoComplete::got_network_response(QNetworkReply* reply) if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError) return {}; - AK::JsonParser parser(ak_deprecated_string_from_qstring(reply->readAll())); + AK::JsonParser parser(ak_byte_string_from_qstring(reply->readAll())); auto json = TRY(parser.parse()); auto engine_name = Settings::the()->autocomplete_engine().name; diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index da39f64d508..804d380db71 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -331,7 +331,7 @@ BrowserWindow::BrowserWindow(Vector const& initial_urls, WebView::CookieJar auto* disable_spoofing = add_user_agent("Disabled"sv, Web::default_user_agent); disable_spoofing->setChecked(true); for (auto const& user_agent : WebView::user_agents) - add_user_agent(user_agent.key, user_agent.value.to_deprecated_string()); + add_user_agent(user_agent.key, user_agent.value.to_byte_string()); auto* custom_user_agent_action = new QAction("Custom...", this); custom_user_agent_action->setCheckable(true); @@ -340,7 +340,7 @@ BrowserWindow::BrowserWindow(Vector const& initial_urls, WebView::CookieJar QObject::connect(custom_user_agent_action, &QAction::triggered, this, [this, disable_spoofing] { auto user_agent = QInputDialog::getText(this, "Custom User Agent", "Enter User Agent:"); if (!user_agent.isEmpty()) { - debug_request("spoof-user-agent", ak_deprecated_string_from_qstring(user_agent)); + debug_request("spoof-user-agent", ak_byte_string_from_qstring(user_agent)); debug_request("clear-cache"); // clear the cache to ensure requests are re-done with the new user agent } else { disable_spoofing->activate(QAction::Trigger); @@ -455,7 +455,7 @@ void BrowserWindow::set_current_tab(Tab* tab) update_displayed_zoom_level(); } -void BrowserWindow::debug_request(DeprecatedString const& request, DeprecatedString const& argument) +void BrowserWindow::debug_request(ByteString const& request, ByteString const& argument) { if (!m_current_tab) return; @@ -505,7 +505,7 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab) }; tab->view().on_tab_open_request = [this](auto url, auto activate_tab) { - auto& tab = new_tab(qstring_from_ak_string(url.to_deprecated_string()), activate_tab); + auto& tab = new_tab(qstring_from_ak_string(url.to_byte_string()), activate_tab); return tab.view().handle(); }; @@ -533,7 +533,7 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab) return m_cookie_jar.get_named_cookie(url, name); }; - tab->view().on_get_cookie = [this](auto& url, auto source) -> DeprecatedString { + tab->view().on_get_cookie = [this](auto& url, auto source) -> ByteString { return m_cookie_jar.get_cookie(url, source); }; diff --git a/Ladybird/Qt/BrowserWindow.h b/Ladybird/Qt/BrowserWindow.h index 3cf612a7279..0315e9f57e3 100644 --- a/Ladybird/Qt/BrowserWindow.h +++ b/Ladybird/Qt/BrowserWindow.h @@ -102,7 +102,7 @@ private: Tab& create_new_tab(Web::HTML::ActivateTab activate_tab); - void debug_request(DeprecatedString const& request, DeprecatedString const& argument = ""); + void debug_request(ByteString const& request, ByteString const& argument = ""); void set_current_tab(Tab* tab); void update_displayed_zoom_level(); diff --git a/Ladybird/Qt/RequestManagerQt.cpp b/Ladybird/Qt/RequestManagerQt.cpp index e05fc95f8c9..7ff68da45a5 100644 --- a/Ladybird/Qt/RequestManagerQt.cpp +++ b/Ladybird/Qt/RequestManagerQt.cpp @@ -24,7 +24,7 @@ void RequestManagerQt::reply_finished(QNetworkReply* reply) request->did_finish(); } -RefPtr RequestManagerQt::start_request(DeprecatedString const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy) +RefPtr RequestManagerQt::start_request(ByteString const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy) { if (!url.scheme().bytes_as_string_view().is_one_of_ignoring_ascii_case("http"sv, "https"sv)) { return nullptr; @@ -38,9 +38,9 @@ RefPtr RequestManagerQt::start_request(Depr return request; } -ErrorOr> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, DeprecatedString const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) +ErrorOr> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, ByteString const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) { - QNetworkRequest request { QString(url.to_deprecated_string().characters()) }; + QNetworkRequest request { QString(url.to_byte_string().characters()) }; request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy); request.setAttribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Manual); request.setAttribute(QNetworkRequest::CookieSaveControlAttribute, QNetworkRequest::Manual); @@ -87,11 +87,11 @@ void RequestManagerQt::Request::did_finish() { auto buffer = m_reply.readAll(); auto http_status_code = m_reply.attribute(QNetworkRequest::Attribute::HttpStatusCodeAttribute).toInt(); - HashMap response_headers; - Vector set_cookie_headers; + HashMap response_headers; + Vector set_cookie_headers; for (auto& it : m_reply.rawHeaderPairs()) { - auto name = DeprecatedString(it.first.data(), it.first.length()); - auto value = DeprecatedString(it.second.data(), it.second.length()); + auto name = ByteString(it.first.data(), it.first.length()); + auto value = ByteString(it.second.data(), it.second.length()); if (name.equals_ignoring_ascii_case("set-cookie"sv)) { // NOTE: Qt may have bundled multiple Set-Cookie headers into a single one. // We have to extract the full list of cookies via QNetworkReply::header(). @@ -104,7 +104,7 @@ void RequestManagerQt::Request::did_finish() } } if (!set_cookie_headers.is_empty()) { - response_headers.set("set-cookie"sv, JsonArray { set_cookie_headers }.to_deprecated_string()); + response_headers.set("set-cookie"sv, JsonArray { set_cookie_headers }.to_byte_string()); } bool success = http_status_code != 0; on_buffered_request_finish(success, buffer.length(), response_headers, http_status_code, ReadonlyBytes { buffer.data(), (size_t)buffer.size() }); diff --git a/Ladybird/Qt/RequestManagerQt.h b/Ladybird/Qt/RequestManagerQt.h index 9728db76e31..3b6a8faa97d 100644 --- a/Ladybird/Qt/RequestManagerQt.h +++ b/Ladybird/Qt/RequestManagerQt.h @@ -27,7 +27,7 @@ public: virtual void prefetch_dns(AK::URL const&) override { } virtual void preconnect(AK::URL const&) override { } - virtual RefPtr start_request(DeprecatedString const& method, AK::URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override; + virtual RefPtr start_request(ByteString const& method, AK::URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override; private slots: void reply_finished(QNetworkReply*); @@ -38,7 +38,7 @@ private: class Request : public Web::ResourceLoaderConnectorRequest { public: - static ErrorOr> create(QNetworkAccessManager& qnam, DeprecatedString const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); + static ErrorOr> create(QNetworkAccessManager& qnam, ByteString const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); virtual ~Request() override; diff --git a/Ladybird/Qt/Settings.h b/Ladybird/Qt/Settings.h index 076d4f14525..e061f8d0a30 100644 --- a/Ladybird/Qt/Settings.h +++ b/Ladybird/Qt/Settings.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include diff --git a/Ladybird/Qt/StringUtils.cpp b/Ladybird/Qt/StringUtils.cpp index 56f9725d4a5..ce26c6b7b7e 100644 --- a/Ladybird/Qt/StringUtils.cpp +++ b/Ladybird/Qt/StringUtils.cpp @@ -6,9 +6,9 @@ #include "StringUtils.h" -AK::DeprecatedString ak_deprecated_string_from_qstring(QString const& qstring) +AK::ByteString ak_byte_string_from_qstring(QString const& qstring) { - return AK::DeprecatedString(qstring.toUtf8().data()); + return AK::ByteString(qstring.toUtf8().data()); } String ak_string_from_qstring(QString const& qstring) diff --git a/Ladybird/Qt/StringUtils.h b/Ladybird/Qt/StringUtils.h index d04b1298c08..7c856f7b7d9 100644 --- a/Ladybird/Qt/StringUtils.h +++ b/Ladybird/Qt/StringUtils.h @@ -6,12 +6,12 @@ #pragma once -#include +#include #include #include #include #include -AK::DeprecatedString ak_deprecated_string_from_qstring(QString const&); +AK::ByteString ak_byte_string_from_qstring(QString const&); String ak_string_from_qstring(QString const&); QString qstring_from_ak_string(StringView); diff --git a/Ladybird/Qt/Tab.cpp b/Ladybird/Qt/Tab.cpp index 29c99faa2d3..5466ba9ad03 100644 --- a/Ladybird/Qt/Tab.cpp +++ b/Ladybird/Qt/Tab.cpp @@ -107,7 +107,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St }; view().on_link_hover = [this](auto const& url) { - m_hover_label->setText(qstring_from_ak_string(url.to_deprecated_string())); + m_hover_label->setText(qstring_from_ak_string(url.to_byte_string())); update_hover_label(); m_hover_label->show(); }; @@ -123,7 +123,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St m_history.replace_current(url, m_title.toUtf8().data()); } - m_location_edit->setText(url.to_deprecated_string().characters()); + m_location_edit->setText(url.to_byte_string().characters()); m_location_edit->setCursorPosition(0); // Don't add to history if back or forward is pressed @@ -648,7 +648,7 @@ void Tab::back() m_is_history_navigation = true; m_history.go_back(); - view().load(m_history.current().url.to_deprecated_string()); + view().load(m_history.current().url.to_byte_string()); } void Tab::forward() @@ -658,7 +658,7 @@ void Tab::forward() m_is_history_navigation = true; m_history.go_forward(); - view().load(m_history.current().url.to_deprecated_string()); + view().load(m_history.current().url.to_byte_string()); } void Tab::reload() @@ -667,7 +667,7 @@ void Tab::reload() return; m_is_history_navigation = true; - view().load(m_history.current().url.to_deprecated_string()); + view().load(m_history.current().url.to_byte_string()); } void Tab::open_link(URL const& url) @@ -703,7 +703,7 @@ int Tab::tab_index() return m_window->tab_index(this); } -void Tab::debug_request(DeprecatedString const& request, DeprecatedString const& argument) +void Tab::debug_request(ByteString const& request, ByteString const& argument) { if (request == "dump-history") m_history.dump(); diff --git a/Ladybird/Qt/Tab.h b/Ladybird/Qt/Tab.h index 50bbf11f27b..71d5b89aca8 100644 --- a/Ladybird/Qt/Tab.h +++ b/Ladybird/Qt/Tab.h @@ -40,7 +40,7 @@ public: void forward(); void reload(); - void debug_request(DeprecatedString const& request, DeprecatedString const& argument); + void debug_request(ByteString const& request, ByteString const& argument); void open_file(); void update_reset_zoom_button(); diff --git a/Ladybird/Qt/WebContentView.cpp b/Ladybird/Qt/WebContentView.cpp index 61b465632a9..46c0e6d9ee9 100644 --- a/Ladybird/Qt/WebContentView.cpp +++ b/Ladybird/Qt/WebContentView.cpp @@ -576,7 +576,7 @@ static Core::AnonymousBuffer make_system_theme_from_qt_palette(QWidget& widget, auto theme_file = mode == WebContentView::PaletteMode::Default ? "Default"sv : "Dark"sv; auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file)))); - auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_deprecated_string()).release_value_but_fixme_should_propagate_errors(); + auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_byte_string()).release_value_but_fixme_should_propagate_errors(); auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme); auto palette = Gfx::Palette(move(palette_impl)); @@ -752,7 +752,7 @@ bool WebContentView::event(QEvent* event) ErrorOr WebContentView::dump_layout_tree() { - return String::from_deprecated_string(client().dump_layout_tree()); + return String::from_byte_string(client().dump_layout_tree()); } } diff --git a/Ladybird/Qt/WebContentView.h b/Ladybird/Qt/WebContentView.h index f72155f7747..d3af87da715 100644 --- a/Ladybird/Qt/WebContentView.h +++ b/Ladybird/Qt/WebContentView.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include diff --git a/Ladybird/Qt/WebSocketClientManagerQt.cpp b/Ladybird/Qt/WebSocketClientManagerQt.cpp index da02babcfc2..e8087579ab9 100644 --- a/Ladybird/Qt/WebSocketClientManagerQt.cpp +++ b/Ladybird/Qt/WebSocketClientManagerQt.cpp @@ -19,7 +19,7 @@ NonnullRefPtr WebSocketClientManagerQt::create() WebSocketClientManagerQt::WebSocketClientManagerQt() = default; WebSocketClientManagerQt::~WebSocketClientManagerQt() = default; -RefPtr WebSocketClientManagerQt::connect(AK::URL const& url, DeprecatedString const& origin, Vector const& protocols) +RefPtr WebSocketClientManagerQt::connect(AK::URL const& url, ByteString const& origin, Vector const& protocols) { WebSocket::ConnectionInfo connection_info(url); connection_info.set_origin(origin); diff --git a/Ladybird/Qt/WebSocketClientManagerQt.h b/Ladybird/Qt/WebSocketClientManagerQt.h index 54014036be1..85930ef7cd9 100644 --- a/Ladybird/Qt/WebSocketClientManagerQt.h +++ b/Ladybird/Qt/WebSocketClientManagerQt.h @@ -19,7 +19,7 @@ public: static NonnullRefPtr create(); virtual ~WebSocketClientManagerQt() override; - virtual RefPtr connect(AK::URL const&, DeprecatedString const& origin, Vector const& protocols) override; + virtual RefPtr connect(AK::URL const&, ByteString const& origin, Vector const& protocols) override; private: WebSocketClientManagerQt(); diff --git a/Ladybird/Qt/WebSocketImplQt.cpp b/Ladybird/Qt/WebSocketImplQt.cpp index e73ea7473c3..ff6a01e0e9d 100644 --- a/Ladybird/Qt/WebSocketImplQt.cpp +++ b/Ladybird/Qt/WebSocketImplQt.cpp @@ -85,13 +85,13 @@ ErrorOr WebSocketImplQt::read(int max_size) return buffer.slice(0, bytes_read); } -ErrorOr WebSocketImplQt::read_line(size_t size) +ErrorOr WebSocketImplQt::read_line(size_t size) { auto buffer = TRY(ByteBuffer::create_uninitialized(size)); auto bytes_read = m_socket->readLine(reinterpret_cast(buffer.data()), buffer.size()); if (bytes_read == -1) return Error::from_string_literal("WebSocketImplQt::read_line(): Error reading from socket"); - return DeprecatedString::copy(buffer.span().slice(0, bytes_read)); + return ByteString::copy(buffer.span().slice(0, bytes_read)); } } diff --git a/Ladybird/Qt/WebSocketImplQt.h b/Ladybird/Qt/WebSocketImplQt.h index 6285d53f46c..e9810d52db6 100644 --- a/Ladybird/Qt/WebSocketImplQt.h +++ b/Ladybird/Qt/WebSocketImplQt.h @@ -22,7 +22,7 @@ public: virtual void connect(WebSocket::ConnectionInfo const&) override; virtual bool can_read_line() override; - virtual ErrorOr read_line(size_t) override; + virtual ErrorOr read_line(size_t) override; virtual ErrorOr read(int max_size) override; virtual bool send(ReadonlyBytes) override; virtual bool eof() override; diff --git a/Ladybird/Qt/WebSocketQt.cpp b/Ladybird/Qt/WebSocketQt.cpp index 751a52ae7ea..86b4043ea9d 100644 --- a/Ladybird/Qt/WebSocketQt.cpp +++ b/Ladybird/Qt/WebSocketQt.cpp @@ -50,7 +50,7 @@ WebSocketQt::WebSocketQt(NonnullRefPtr underlying_socket) } } }; - m_websocket->on_close = [weak_this = make_weak_ptr()](u16 code, DeprecatedString reason, bool was_clean) { + m_websocket->on_close = [weak_this = make_weak_ptr()](u16 code, ByteString reason, bool was_clean) { if (auto strong_this = weak_this.strong_ref()) if (strong_this->on_close) strong_this->on_close(code, move(reason), was_clean); @@ -74,7 +74,7 @@ Web::WebSockets::WebSocket::ReadyState WebSocketQt::ready_state() VERIFY_NOT_REACHED(); } -DeprecatedString WebSocketQt::subprotocol_in_use() +ByteString WebSocketQt::subprotocol_in_use() { return m_websocket->subprotocol_in_use(); } @@ -89,7 +89,7 @@ void WebSocketQt::send(StringView message) m_websocket->send(WebSocket::Message(message)); } -void WebSocketQt::close(u16 code, DeprecatedString reason) +void WebSocketQt::close(u16 code, ByteString reason) { m_websocket->close(code, reason); } diff --git a/Ladybird/Qt/WebSocketQt.h b/Ladybird/Qt/WebSocketQt.h index 34cff6c070a..be792e9aded 100644 --- a/Ladybird/Qt/WebSocketQt.h +++ b/Ladybird/Qt/WebSocketQt.h @@ -21,10 +21,10 @@ public: virtual ~WebSocketQt() override; virtual Web::WebSockets::WebSocket::ReadyState ready_state() override; - virtual DeprecatedString subprotocol_in_use() override; + virtual ByteString subprotocol_in_use() override; virtual void send(ByteBuffer binary_or_text_message, bool is_text) override; virtual void send(StringView message) override; - virtual void close(u16 code, DeprecatedString reason) override; + virtual void close(u16 code, ByteString reason) override; private: explicit WebSocketQt(NonnullRefPtr); diff --git a/Ladybird/SQLServer/main.cpp b/Ladybird/SQLServer/main.cpp index 5bed2cba5be..6c04eb38933 100644 --- a/Ladybird/SQLServer/main.cpp +++ b/Ladybird/SQLServer/main.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -17,7 +17,7 @@ ErrorOr serenity_main(Main::Arguments arguments) { AK::set_rich_debug_enabled(true); - DeprecatedString pid_file; + ByteString pid_file; Core::ArgsParser args_parser; args_parser.add_option(pid_file, "Path to the PID file for the SQLServer singleton process", "pid-file", 'p', "pid_file"); @@ -25,7 +25,7 @@ ErrorOr serenity_main(Main::Arguments arguments) VERIFY(!pid_file.is_empty()); - auto database_path = DeprecatedString::formatted("{}/Ladybird", Core::StandardPaths::data_directory()); + auto database_path = ByteString::formatted("{}/Ladybird", Core::StandardPaths::data_directory()); TRY(Core::Directory::create(database_path, Core::Directory::CreateDirectories::Yes)); Core::EventLoop loop; diff --git a/Ladybird/Utilities.cpp b/Ladybird/Utilities.cpp index 5897abe7a34..0e2e0be0766 100644 --- a/Ladybird/Utilities.cpp +++ b/Ladybird/Utilities.cpp @@ -12,13 +12,13 @@ #include #include -DeprecatedString s_serenity_resource_root; +ByteString s_serenity_resource_root; ErrorOr application_directory() { auto current_executable_path = TRY(Core::System::current_executable_path()); auto dirname = LexicalPath::dirname(current_executable_path); - return String::from_deprecated_string(dirname); + return String::from_byte_string(dirname); } void platform_init() @@ -26,14 +26,14 @@ void platform_init() s_serenity_resource_root = [] { auto const* source_dir = getenv("SERENITY_SOURCE_DIR"); if (source_dir) { - return DeprecatedString::formatted("{}/Base", source_dir); + return ByteString::formatted("{}/Base", source_dir); } auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME"); VERIFY(home); - auto home_lagom = DeprecatedString::formatted("{}/.lagom", home); + auto home_lagom = ByteString::formatted("{}/.lagom", home); if (FileSystem::is_directory(home_lagom)) return home_lagom; - auto app_dir = application_directory().release_value_but_fixme_should_propagate_errors().to_deprecated_string(); + auto app_dir = application_directory().release_value_but_fixme_should_propagate_errors().to_byte_string(); #ifdef AK_OS_MACOS return LexicalPath(app_dir).parent().append("Resources"sv).string(); #else diff --git a/Ladybird/Utilities.h b/Ladybird/Utilities.h index 8194d2339a7..f754fbee5a0 100644 --- a/Ladybird/Utilities.h +++ b/Ladybird/Utilities.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -16,4 +16,4 @@ void platform_init(); ErrorOr application_directory(); ErrorOr> get_paths_for_helper_process(StringView process_name); -extern DeprecatedString s_serenity_resource_root; +extern ByteString s_serenity_resource_root; diff --git a/Ladybird/WebContent/main.cpp b/Ladybird/WebContent/main.cpp index 50c05fbfb48..c10e12baf44 100644 --- a/Ladybird/WebContent/main.cpp +++ b/Ladybird/WebContent/main.cpp @@ -131,9 +131,9 @@ ErrorOr serenity_main(Main::Arguments arguments) static ErrorOr load_content_filters() { - auto file_or_error = Core::File::open(DeprecatedString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); + auto file_or_error = Core::File::open(ByteString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); if (file_or_error.is_error()) - file_or_error = Core::File::open(DeprecatedString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); + file_or_error = Core::File::open(ByteString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); if (file_or_error.is_error()) return file_or_error.release_error(); diff --git a/Ladybird/WebDriver/main.cpp b/Ladybird/WebDriver/main.cpp index b688d8db7b6..ba29a44a540 100644 --- a/Ladybird/WebDriver/main.cpp +++ b/Ladybird/WebDriver/main.cpp @@ -30,7 +30,7 @@ static ErrorOr launch_process(StringView application, ReadonlySpan launch_browser(DeprecatedString const& socket_path) +static ErrorOr launch_browser(ByteString const& socket_path) { return launch_process("Ladybird"sv, Array { @@ -40,9 +40,9 @@ static ErrorOr launch_browser(DeprecatedString const& socket_path) }); } -static ErrorOr launch_headless_browser(DeprecatedString const& socket_path) +static ErrorOr launch_headless_browser(ByteString const& socket_path) { - auto resources = DeprecatedString::formatted("{}/res", s_serenity_resource_root); + auto resources = ByteString::formatted("{}/res", s_serenity_resource_root); return launch_process("headless-browser"sv, Array { "--resources", @@ -78,7 +78,7 @@ ErrorOr serenity_main(Main::Arguments arguments) platform_init(); - auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory())); + auto webdriver_socket_path = ByteString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory())); TRY(Core::Directory::create(webdriver_socket_path, Core::Directory::CreateDirectories::Yes)); Core::EventLoop loop; diff --git a/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm b/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm index c0af16b6fd1..5e65b5fdd02 100644 --- a/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm +++ b/Meta/Lagom/Contrib/MacPDF/AppDelegate.mm @@ -22,7 +22,7 @@ NSString* source_root = [[NSBundle mainBundle] executablePath]; for (int i = 0; i < 7; ++i) source_root = [source_root stringByDeletingLastPathComponent]; - auto source_root_string = DeprecatedString([source_root UTF8String]); + auto source_root_string = ByteString([source_root UTF8String]); Core::ResourceImplementation::install(make(MUST(String::formatted("{}/Base/res", source_root_string)))); } diff --git a/Meta/Lagom/Tools/CodeGenerators/GMLCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/GMLCompiler/main.cpp index 02812376f35..bc6a6b66d0b 100644 --- a/Meta/Lagom/Tools/CodeGenerators/GMLCompiler/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/GMLCompiler/main.cpp @@ -68,16 +68,16 @@ static bool is_ui_dimension_property(StringView property) } // FIXME: Since normal string-based properties take either String or StringView (and the latter can be implicitly constructed from the former), -// we need to special-case DeprecatedString property setters while those still exist. +// we need to special-case ByteString property setters while those still exist. // Please remove a setter from this list once it uses StringView or String. -static bool takes_deprecated_string(StringView property) +static bool takes_byte_string(StringView property) { - static HashTable deprecated_string_properties; - if (deprecated_string_properties.is_empty()) { - deprecated_string_properties.set("icon_from_path"sv); - deprecated_string_properties.set("name"sv); + static HashTable byte_string_properties; + if (byte_string_properties.is_empty()) { + byte_string_properties.set("icon_from_path"sv); + byte_string_properties.set("name"sv); } - return deprecated_string_properties.contains(property); + return byte_string_properties.contains(property); } static ErrorOr include_path_for(StringView class_name, LexicalPath const& gml_file_name) @@ -141,7 +141,7 @@ static char const footer[] = R"~~~( static ErrorOr escape_string(JsonValue to_escape) { - auto string = TRY(String::from_deprecated_string(to_escape.as_string())); + auto string = TRY(String::from_byte_string(to_escape.as_string())); // All C++ simple escape sequences; see https://en.cppreference.com/w/cpp/language/escape // Other commonly-escaped characters are hard-to-type Unicode and therefore fine to include verbatim in UTF-8 coded strings. @@ -194,7 +194,7 @@ static ErrorOr generate_initializer_for(Optional property_na { if (value.is_string()) { if (property_name.has_value()) { - if (takes_deprecated_string(*property_name)) + if (takes_byte_string(*property_name)) return String::formatted(R"~~~("{}"sv)~~~", TRY(escape_string(value))); if (auto const enum_value = TRY(generate_enum_initializer_for(*property_name, value)); enum_value.has_value()) @@ -252,7 +252,7 @@ static ErrorOr generate_initializer_for(Optional property_na // All loading happens in a separate block. static ErrorOr generate_loader_for_object(GUI::GML::Object const& gml_object, SourceGenerator generator, String object_name, size_t indentation, UseObjectConstructor use_object_constructor) { - generator.set("object_name", object_name.to_deprecated_string()); + generator.set("object_name", object_name.to_byte_string()); generator.set("class_name", gml_object.name()); auto append = [&](auto& generator, char const(&text)[N]) -> ErrorOr { diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp index 38ecd49d14d..f7b03c3ba0a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp @@ -17,12 +17,12 @@ #include struct Parameter { - Vector attributes; - DeprecatedString type; - DeprecatedString name; + Vector attributes; + ByteString type; + ByteString name; }; -static DeprecatedString pascal_case(DeprecatedString const& identifier) +static ByteString pascal_case(ByteString const& identifier) { StringBuilder builder; bool was_new_word = true; @@ -37,48 +37,48 @@ static DeprecatedString pascal_case(DeprecatedString const& identifier) } else builder.append(ch); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } struct Message { - DeprecatedString name; + ByteString name; bool is_synchronous { false }; Vector inputs; Vector outputs; - DeprecatedString response_name() const + ByteString response_name() const { StringBuilder builder; builder.append(pascal_case(name)); builder.append("Response"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } }; struct Endpoint { - Vector includes; - DeprecatedString name; + Vector includes; + ByteString name; u32 magic; Vector messages; }; -static bool is_primitive_type(DeprecatedString const& type) +static bool is_primitive_type(ByteString const& type) { return type.is_one_of("u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "size_t", "bool", "double", "float", "int", "unsigned", "unsigned int"); } -static bool is_simple_type(DeprecatedString const& type) +static bool is_simple_type(ByteString const& type) { // Small types that it makes sense just to pass by value. return type.is_one_of("Gfx::Color", "Web::DevicePixels", "Gfx::IntPoint", "Gfx::FloatPoint", "Web::DevicePixelPoint", "Gfx::IntSize", "Gfx::FloatSize", "Web::DevicePixelSize", "Core::File::OpenMode"); } -static bool is_primitive_or_simple_type(DeprecatedString const& type) +static bool is_primitive_or_simple_type(ByteString const& type) { return is_primitive_type(type) || is_simple_type(type); } -static DeprecatedString message_name(DeprecatedString const& endpoint, DeprecatedString const& message, bool is_response) +static ByteString message_name(ByteString const& endpoint, ByteString const& message, bool is_response) { StringBuilder builder; builder.append("Messages::"sv); @@ -87,7 +87,7 @@ static DeprecatedString message_name(DeprecatedString const& endpoint, Deprecate builder.append(pascal_case(message)); if (is_response) builder.append("Response"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } Vector parse(ByteBuffer const& file_contents) @@ -133,7 +133,7 @@ Vector parse(ByteBuffer const& file_contents) consume_whitespace(); } } - // FIXME: This is not entirely correct. Types can have spaces, for example `HashMap`. + // FIXME: This is not entirely correct. Types can have spaces, for example `HashMap`. // Maybe we should use LibCpp::Parser for parsing types. parameter.type = lexer.consume_until([](char ch) { return isspace(ch); }); if (parameter.type.ends_with(',')) { @@ -208,7 +208,7 @@ Vector parse(ByteBuffer const& file_contents) }; auto parse_include = [&] { - DeprecatedString include; + ByteString include; consume_whitespace(); include = lexer.consume_while([](char ch) { return ch != '\n'; }); consume_whitespace(); @@ -234,7 +234,7 @@ Vector parse(ByteBuffer const& file_contents) lexer.consume_specific("endpoint"); consume_whitespace(); endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); }); - endpoints.last().magic = Traits::hash(endpoints.last().name); + endpoints.last().magic = Traits::hash(endpoints.last().name); consume_whitespace(); assert_specific('{'); parse_messages(); @@ -248,22 +248,22 @@ Vector parse(ByteBuffer const& file_contents) return endpoints; } -HashMap build_message_ids_for_endpoint(SourceGenerator generator, Endpoint const& endpoint) +HashMap build_message_ids_for_endpoint(SourceGenerator generator, Endpoint const& endpoint) { - HashMap message_ids; + HashMap message_ids; generator.appendln("\nenum class MessageID : i32 {"); for (auto const& message : endpoint.messages) { message_ids.set(message.name, message_ids.size() + 1); generator.set("message.pascal_name", pascal_case(message.name)); - generator.set("message.id", DeprecatedString::number(message_ids.size())); + generator.set("message.id", ByteString::number(message_ids.size())); generator.appendln(" @message.pascal_name@ = @message.id@,"); if (message.is_synchronous) { message_ids.set(message.response_name(), message_ids.size() + 1); generator.set("message.pascal_name", pascal_case(message.response_name())); - generator.set("message.id", DeprecatedString::number(message_ids.size())); + generator.set("message.id", ByteString::number(message_ids.size())); generator.appendln(" @message.pascal_name@ = @message.id@,"); } @@ -272,14 +272,14 @@ HashMap build_message_ids_for_endpoint(SourceGenerator ge return message_ids; } -DeprecatedString constructor_for_message(DeprecatedString const& name, Vector const& parameters) +ByteString constructor_for_message(ByteString const& name, Vector const& parameters) { StringBuilder builder; builder.append(name); if (parameters.is_empty()) { builder.append("() {}"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } builder.append('('); for (size_t i = 0; i < parameters.size(); ++i) { @@ -296,10 +296,10 @@ DeprecatedString constructor_for_message(DeprecatedString const& name, Vector const& parameters, DeprecatedString const& response_type = {}) +void do_message(SourceGenerator message_generator, ByteString const& name, Vector const& parameters, ByteString const& response_type = {}) { auto pascal_name = pascal_case(name); message_generator.set("message.name", name); @@ -377,7 +377,7 @@ public:)~~~"); builder.append(", "sv); } - message_generator.set("message.constructor_call_parameters", builder.to_deprecated_string()); + message_generator.set("message.constructor_call_parameters", builder.to_byte_string()); message_generator.appendln(R"~~~( return make<@message.pascal_name@>(@message.constructor_call_parameters@); })~~~"); @@ -432,17 +432,17 @@ private: void do_message_for_proxy(SourceGenerator message_generator, Endpoint const& endpoint, Message const& message) { - auto do_implement_proxy = [&](DeprecatedString const& name, Vector const& parameters, bool is_synchronous, bool is_try) { - DeprecatedString return_type = "void"; + auto do_implement_proxy = [&](ByteString const& name, Vector const& parameters, bool is_synchronous, bool is_try) { + ByteString return_type = "void"; if (is_synchronous) { if (message.outputs.size() == 1) return_type = message.outputs[0].type; else if (!message.outputs.is_empty()) return_type = message_name(endpoint.name, message.name, true); } - DeprecatedString inner_return_type = return_type; + ByteString inner_return_type = return_type; if (is_try) - return_type = DeprecatedString::formatted("IPC::IPCErrorOr<{}>", return_type); + return_type = ByteString::formatted("IPC::IPCErrorOr<{}>", return_type); message_generator.set("message.name", message.name); message_generator.set("message.pascal_name", pascal_case(message.name)); @@ -541,14 +541,14 @@ void do_message_for_proxy(SourceGenerator message_generator, Endpoint const& end void build_endpoint(SourceGenerator generator, Endpoint const& endpoint) { generator.set("endpoint.name", endpoint.name); - generator.set("endpoint.magic", DeprecatedString::number(endpoint.magic)); + generator.set("endpoint.magic", ByteString::number(endpoint.magic)); generator.appendln("\nnamespace Messages::@endpoint.name@ {"); - HashMap message_ids = build_message_ids_for_endpoint(generator.fork(), endpoint); + HashMap message_ids = build_message_ids_for_endpoint(generator.fork(), endpoint); for (auto const& message : endpoint.messages) { - DeprecatedString response_name; + ByteString response_name; if (message.is_synchronous) { response_name = message.response_name(); do_message(generator.fork(), response_name, message.outputs); @@ -611,7 +611,7 @@ public: switch (message_id) {)~~~"); for (auto const& message : endpoint.messages) { - auto do_decode_message = [&](DeprecatedString const& name) { + auto do_decode_message = [&](ByteString const& name) { auto message_generator = generator.fork(); message_generator.set("message.name", name); @@ -649,13 +649,13 @@ public: virtual ~@endpoint.name@Stub() override { } virtual u32 magic() const override { return @endpoint.magic@; } - virtual DeprecatedString name() const override { return "@endpoint.name@"; } + virtual ByteString name() const override { return "@endpoint.name@"; } virtual ErrorOr> handle(const IPC::Message& message) override { switch (message.message_id()) {)~~~"); for (auto const& message : endpoint.messages) { - auto do_handle_message = [&](DeprecatedString const& name, Vector const& parameters, bool returns_something) { + auto do_handle_message = [&](ByteString const& name, Vector const& parameters, bool returns_something) { auto message_generator = generator.fork(); StringBuilder argument_generator; @@ -671,7 +671,7 @@ public: message_generator.set("message.pascal_name", pascal_case(name)); message_generator.set("message.response_type", pascal_case(message.response_name())); message_generator.set("handler_name", name); - message_generator.set("arguments", argument_generator.to_deprecated_string()); + message_generator.set("arguments", argument_generator.to_byte_string()); message_generator.appendln(R"~~~( case (int)Messages::@endpoint.name@::MessageID::@message.pascal_name@: {)~~~"); if (returns_something) { @@ -709,8 +709,8 @@ public: for (auto const& message : endpoint.messages) { auto message_generator = generator.fork(); - auto do_handle_message_decl = [&](DeprecatedString const& name, Vector const& parameters, bool is_response) { - DeprecatedString return_type = "void"; + auto do_handle_message_decl = [&](ByteString const& name, Vector const& parameters, bool is_response) { + ByteString return_type = "void"; if (message.is_synchronous && !message.outputs.is_empty() && !is_response) return_type = message_name(endpoint.name, message.name, true); message_generator.set("message.complex_return_type", return_type); @@ -719,7 +719,7 @@ public: message_generator.appendln(R"~~~( virtual @message.complex_return_type@ @handler_name@()~~~"); - auto make_argument_type = [](DeprecatedString const& type) { + auto make_argument_type = [](ByteString const& type) { StringBuilder builder; bool const_ref = !is_primitive_or_simple_type(type); @@ -728,7 +728,7 @@ public: if (const_ref) builder.append(" const&"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; for (size_t i = 0; i < parameters.size(); ++i) { diff --git a/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp index 3ece80aa631..1357cb0f780 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include @@ -18,40 +18,40 @@ #include struct ArgumentDefinition { - Optional name; - Optional cpp_type; - DeprecatedString expression; - Optional cast_to; + Optional name; + Optional cpp_type; + ByteString expression; + Optional cast_to; }; struct FunctionDefinition { - DeprecatedString name; - DeprecatedString return_type; + ByteString name; + ByteString return_type; Vector arguments; - DeprecatedString implementation; + ByteString implementation; bool unimplemented; - DeprecatedString variant_gl_type; + ByteString variant_gl_type; }; struct VariantType { - DeprecatedString encoded_type; - Optional implementation; + ByteString encoded_type; + Optional implementation; bool unimplemented; }; struct Variants { - Vector api_suffixes { "" }; + Vector api_suffixes { "" }; Vector argument_counts { NumericLimits::max() }; - Vector argument_defaults { "" }; + Vector argument_defaults { "" }; bool convert_range { false }; Vector types { { .encoded_type = "", - .implementation = Optional {}, + .implementation = Optional {}, .unimplemented = false, } }; - DeprecatedString pointer_argument { "" }; + ByteString pointer_argument { "" }; }; struct EncodedTypeEntry { @@ -76,18 +76,18 @@ constexpr static Array type_definitions = { struct EncodedType { EncodedTypeEntry type_entry; - DeprecatedString cpp_type; - DeprecatedString function_name_suffix; + ByteString cpp_type; + ByteString function_name_suffix; bool is_pointer; bool is_const_pointer; }; -Vector get_name_list(Optional name_definition) +Vector get_name_list(Optional name_definition) { if (!name_definition.has_value() || name_definition->is_null()) return {}; - Vector names; + Vector names; if (name_definition->is_string()) { names.append(name_definition->as_string()); } else if (name_definition->is_array()) { @@ -101,12 +101,12 @@ Vector get_name_list(Optional name_definitio return names; } -Optional get_encoded_type(DeprecatedString encoded_type) +Optional get_encoded_type(ByteString encoded_type) { bool is_const_pointer = !encoded_type.ends_with('!'); if (!is_const_pointer) encoded_type = encoded_type.substring_view(0, encoded_type.length() - 1); - DeprecatedString function_name_suffix = encoded_type; + ByteString function_name_suffix = encoded_type; bool is_pointer = encoded_type.ends_with('v'); if (is_pointer) @@ -127,7 +127,7 @@ Optional get_encoded_type(DeprecatedString encoded_type) return EncodedType { .type_entry = type_definition.value(), - .cpp_type = DeprecatedString::formatted( + .cpp_type = ByteString::formatted( "{}{}{}", type_definition->cpp_type, is_pointer && is_const_pointer ? " const" : "", @@ -138,7 +138,7 @@ Optional get_encoded_type(DeprecatedString encoded_type) }; } -DeprecatedString wrap_expression_in_range_conversion(DeprecatedString source_type, DeprecatedString target_type, DeprecatedString expression) +ByteString wrap_expression_in_range_conversion(ByteString source_type, ByteString target_type, ByteString expression) { VERIFY(target_type == "GLfloat" || target_type == "GLdouble"); @@ -147,19 +147,19 @@ DeprecatedString wrap_expression_in_range_conversion(DeprecatedString source_typ return expression; if (source_type == "GLbyte") - return DeprecatedString::formatted("({} + 128.) / 127.5 - 1.", expression); + return ByteString::formatted("({} + 128.) / 127.5 - 1.", expression); else if (source_type == "GLfloat") - return DeprecatedString::formatted("static_cast({})", expression); + return ByteString::formatted("static_cast({})", expression); else if (source_type == "GLint") - return DeprecatedString::formatted("({} + 2147483648.) / 2147483647.5 - 1.", expression); + return ByteString::formatted("({} + 2147483648.) / 2147483647.5 - 1.", expression); else if (source_type == "GLshort") - return DeprecatedString::formatted("({} + 32768.) / 32767.5 - 1.", expression); + return ByteString::formatted("({} + 32768.) / 32767.5 - 1.", expression); else if (source_type == "GLubyte") - return DeprecatedString::formatted("{} / 255.", expression); + return ByteString::formatted("{} / 255.", expression); else if (source_type == "GLuint") - return DeprecatedString::formatted("{} / 4294967296.", expression); + return ByteString::formatted("{} / 4294967296.", expression); else if (source_type == "GLushort") - return DeprecatedString::formatted("{} / 65536.", expression); + return ByteString::formatted("{} / 65536.", expression); VERIFY_NOT_REACHED(); } @@ -189,7 +189,7 @@ Variants read_variants_settings(JsonObject const& variants_obj) }); } if (variants_obj.has_string("pointer_argument"sv)) { - variants.pointer_argument = variants_obj.get_deprecated_string("pointer_argument"sv).value(); + variants.pointer_argument = variants_obj.get_byte_string("pointer_argument"sv).value(); } if (variants_obj.has_object("types"sv)) { variants.types.clear_with_capacity(); @@ -197,7 +197,7 @@ Variants read_variants_settings(JsonObject const& variants_obj) auto const& type = type_value.as_object(); variants.types.append(VariantType { .encoded_type = key, - .implementation = type.get_deprecated_string("implementation"sv), + .implementation = type.get_byte_string("implementation"sv), .unimplemented = type.get_bool("unimplemented"sv).value_or(false), }); }); @@ -223,20 +223,20 @@ Vector copy_arguments_for_variant(Vector // Pointer argument if (encoded_type.is_pointer) { - variant_arguments[i].name = (variadic_index == 0) ? variants.pointer_argument : Optional {}; + variant_arguments[i].name = (variadic_index == 0) ? variants.pointer_argument : Optional {}; if (variadic_index >= argument_count) { // If this variable argument is past the argument count, fall back to the defaults variant_arguments[i].expression = variants.argument_defaults[variadic_index]; - variant_arguments[i].cast_to = Optional {}; + variant_arguments[i].cast_to = Optional {}; } else if (argument_count == 1 && variants.argument_counts.size() == 1) { // Otherwise, if the pointer is the only variadic argument, pass it through unchanged - variant_arguments[i].cast_to = Optional {}; + variant_arguments[i].cast_to = Optional {}; } else { // Otherwise, index into the pointer argument - auto indexed_expression = DeprecatedString::formatted("{}[{}]", variants.pointer_argument, variadic_index); + auto indexed_expression = ByteString::formatted("{}[{}]", variants.pointer_argument, variadic_index); if (variants.convert_range && cast_to.has_value()) indexed_expression = wrap_expression_in_range_conversion(base_cpp_type, cast_to.value(), indexed_expression); variant_arguments[i].expression = indexed_expression; @@ -246,9 +246,9 @@ Vector copy_arguments_for_variant(Vector // Regular argument if (variadic_index >= argument_count) { // If the variable argument is past the argument count, fall back to the defaults - variant_arguments[i].name = Optional {}; + variant_arguments[i].name = Optional {}; variant_arguments[i].expression = variants.argument_defaults[variadic_index]; - variant_arguments[i].cast_to = Optional {}; + variant_arguments[i].cast_to = Optional {}; } else if (variants.convert_range && cast_to.has_value()) { // Otherwise, if we need to convert the input values, wrap the expression in a range conversion @@ -261,7 +261,7 @@ Vector copy_arguments_for_variant(Vector // Determine if we can skip casting to the target type if (cast_to == base_cpp_type || (variants.convert_range && cast_to == "GLdouble")) - variant_arguments[i].cast_to = Optional {}; + variant_arguments[i].cast_to = Optional {}; variadic_index++; } @@ -269,7 +269,7 @@ Vector copy_arguments_for_variant(Vector return variant_arguments; } -Vector create_function_definitions(DeprecatedString function_name, JsonObject const& function_definition) +Vector create_function_definitions(ByteString function_name, JsonObject const& function_definition) { // A single function definition can expand to multiple generated functions by way of: // - differing API suffices (ARB, EXT, etc.); @@ -284,17 +284,17 @@ Vector create_function_definitions(DeprecatedString function VERIFY(argument_value.is_object()); auto const& argument = argument_value.as_object(); - auto type = argument.get_deprecated_string("type"sv); + auto type = argument.get_byte_string("type"sv); auto argument_names = get_name_list(argument.get("name"sv)); - auto expression = argument.get_deprecated_string("expression"sv).value_or("@argument_name@"); - auto cast_to = argument.get_deprecated_string("cast_to"sv); + auto expression = argument.get_byte_string("expression"sv).value_or("@argument_name@"); + auto cast_to = argument.get_byte_string("cast_to"sv); // Add an empty dummy name when all we have is an expression if (argument_names.is_empty() && !expression.is_empty()) argument_names.append(""); for (auto const& argument_name : argument_names) { - argument_definitions.append({ .name = argument_name.is_empty() ? Optional {} : argument_name, + argument_definitions.append({ .name = argument_name.is_empty() ? Optional {} : argument_name, .cpp_type = type, .expression = expression, .cast_to = cast_to }); @@ -304,8 +304,8 @@ Vector create_function_definitions(DeprecatedString function // Create functions for each name and/or variant Vector functions; - auto return_type = function_definition.get_deprecated_string("return_type"sv).value_or("void"); - auto function_implementation = function_definition.get_deprecated_string("implementation"sv).value_or(function_name.to_snakecase()); + auto return_type = function_definition.get_byte_string("return_type"sv).value_or("void"); + auto function_implementation = function_definition.get_byte_string("implementation"sv).value_or(function_name.to_snakecase()); auto function_unimplemented = function_definition.get_bool("unimplemented"sv).value_or(false); if (!function_definition.has("variants"sv)) { @@ -336,10 +336,10 @@ Vector create_function_definitions(DeprecatedString function for (auto const& api_suffix : variants.api_suffixes) { functions.append({ - .name = DeprecatedString::formatted( + .name = ByteString::formatted( "{}{}{}{}", function_name, - variants.argument_counts.size() > 1 ? DeprecatedString::formatted("{}", argument_count) : "", + variants.argument_counts.size() > 1 ? ByteString::formatted("{}", argument_count) : "", encoded_type.has_value() && variants.types.size() > 1 ? encoded_type->function_name_suffix : "", api_suffix), .return_type = return_type, diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp index 44789917ff1..1d8e05ae509 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp @@ -6,8 +6,8 @@ #include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common. #include +#include #include -#include #include #include #include @@ -487,7 +487,7 @@ struct AK::Formatter : Formatter { }; struct LocaleData { - HashMap calendars; + HashMap calendars; size_t time_zones { 0 }; size_t time_zone_formats { 0 }; @@ -513,27 +513,27 @@ struct CLDR { UniqueStorage unique_day_period_lists; UniqueStorage unique_hour_cycle_lists; - HashMap locales; + HashMap locales; - HashMap hour_cycles; - Vector hour_cycle_regions; + HashMap hour_cycles; + Vector hour_cycle_regions; - HashMap minimum_days; - Vector minimum_days_regions; + HashMap minimum_days; + Vector minimum_days_regions; - HashMap first_day; - Vector first_day_regions; + HashMap first_day; + Vector first_day_regions; - HashMap weekend_start; - Vector weekend_start_regions; + HashMap weekend_start; + Vector weekend_start_regions; - HashMap weekend_end; - Vector weekend_end_regions; + HashMap weekend_end; + Vector weekend_end_regions; - HashMap> meta_zones; - Vector time_zones { "UTC"sv }; + HashMap> meta_zones; + Vector time_zones { "UTC"sv }; - Vector calendars; + Vector calendars; }; static Optional day_period_from_string(StringView day_period) @@ -563,7 +563,7 @@ static Optional day_period_from_string(StringView day_period) return {}; } -static ErrorOr parse_hour_cycles(DeprecatedString core_path, CLDR& cldr) +static ErrorOr parse_hour_cycles(ByteString core_path, CLDR& cldr) { // https://unicode.org/reports/tr35/tr35-dates.html#Time_Data LexicalPath time_data_path(move(core_path)); @@ -587,7 +587,7 @@ static ErrorOr parse_hour_cycles(DeprecatedString core_path, CLDR& cldr) }; time_data_object.for_each_member([&](auto const& key, JsonValue const& value) { - auto allowed_hour_cycles_string = value.as_object().get_deprecated_string("_allowed"sv).value(); + auto allowed_hour_cycles_string = value.as_object().get_byte_string("_allowed"sv).value(); auto allowed_hour_cycles = allowed_hour_cycles_string.split_view(' '); Vector hour_cycles; @@ -607,7 +607,7 @@ static ErrorOr parse_hour_cycles(DeprecatedString core_path, CLDR& cldr) return {}; } -static ErrorOr parse_week_data(DeprecatedString core_path, CLDR& cldr) +static ErrorOr parse_week_data(ByteString core_path, CLDR& cldr) { // https://unicode.org/reports/tr35/tr35-dates.html#Week_Data LexicalPath week_data_path(move(core_path)); @@ -672,7 +672,7 @@ static ErrorOr parse_week_data(DeprecatedString core_path, CLDR& cldr) return {}; } -static ErrorOr parse_meta_zones(DeprecatedString core_path, CLDR& cldr) +static ErrorOr parse_meta_zones(ByteString core_path, CLDR& cldr) { // https://unicode.org/reports/tr35/tr35-dates.html#Metazones LexicalPath meta_zone_path(move(core_path)); @@ -686,8 +686,8 @@ static ErrorOr parse_meta_zones(DeprecatedString core_path, CLDR& cldr) meta_zone_array.for_each([&](JsonValue const& value) { auto const& mapping = value.as_object().get_object("mapZone"sv).value(); - auto const& meta_zone = mapping.get_deprecated_string("_other"sv).value(); - auto const& golden_zone = mapping.get_deprecated_string("_type"sv).value(); + auto const& meta_zone = mapping.get_byte_string("_other"sv).value(); + auto const& golden_zone = mapping.get_byte_string("_type"sv).value(); if (auto time_zone = TimeZone::time_zone_from_string(golden_zone); time_zone.has_value()) { auto& golden_zones = cldr.meta_zones.ensure(meta_zone); @@ -770,7 +770,7 @@ static ErrorOr remove_period_from_pattern(String pattern) return pattern; } -static ErrorOr> parse_date_time_pattern_raw(DeprecatedString pattern, DeprecatedString skeleton, CLDR& cldr) +static ErrorOr> parse_date_time_pattern_raw(ByteString pattern, ByteString skeleton, CLDR& cldr) { // https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table using Locale::CalendarPatternStyle; @@ -989,16 +989,16 @@ static ErrorOr> parse_date_time_pattern_raw(Deprecated return format; } -static ErrorOr> parse_date_time_pattern(DeprecatedString pattern, DeprecatedString skeleton, CLDR& cldr) +static ErrorOr> parse_date_time_pattern(ByteString pattern, ByteString skeleton, CLDR& cldr) { auto format = TRY(parse_date_time_pattern_raw(move(pattern), move(skeleton), cldr)); if (!format.has_value()) return OptionalNone {}; - format->pattern_index = cldr.unique_strings.ensure(format->pattern.to_deprecated_string()); + format->pattern_index = cldr.unique_strings.ensure(format->pattern.to_byte_string()); if (format->pattern12.has_value()) - format->pattern12_index = cldr.unique_strings.ensure(format->pattern12->to_deprecated_string()); + format->pattern12_index = cldr.unique_strings.ensure(format->pattern12->to_byte_string()); return Optional { cldr.unique_patterns.ensure(format.release_value()) }; } @@ -1388,7 +1388,7 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda calendar.symbols = cldr.unique_calendar_symbols_lists.ensure(move(symbols_list)); } -static ErrorOr parse_calendars(DeprecatedString locale_calendars_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_calendars(ByteString locale_calendars_path, CLDR& cldr, LocaleData& locale) { LexicalPath calendars_path(move(locale_calendars_path)); if (!calendars_path.basename().starts_with("ca-"sv)) @@ -1402,10 +1402,10 @@ static ErrorOr parse_calendars(DeprecatedString locale_calendars_path, CLD auto parse_patterns = [&](auto const& patterns_object, auto const& skeletons_object, Vector* patterns) -> ErrorOr { auto parse_pattern = [&](auto name) -> ErrorOr { - auto format = patterns_object.get_deprecated_string(name); - auto skeleton = skeletons_object.get_deprecated_string(name); + auto format = patterns_object.get_byte_string(name); + auto skeleton = skeletons_object.get_byte_string(name); - auto format_index = TRY(parse_date_time_pattern(format.value(), skeleton.value_or(DeprecatedString::empty()), cldr)).value(); + auto format_index = TRY(parse_date_time_pattern(format.value(), skeleton.value_or(ByteString::empty()), cldr)).value(); if (patterns) patterns->append(cldr.unique_patterns.get(format_index)); @@ -1483,7 +1483,7 @@ static ErrorOr parse_calendars(DeprecatedString locale_calendars_path, CLD return {}; } -static ErrorOr parse_time_zone_names(DeprecatedString locale_time_zone_names_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_time_zone_names(ByteString locale_time_zone_names_path, CLDR& cldr, LocaleData& locale) { LexicalPath time_zone_names_path(move(locale_time_zone_names_path)); time_zone_names_path = time_zone_names_path.append("timeZoneNames.json"sv); @@ -1494,9 +1494,9 @@ static ErrorOr parse_time_zone_names(DeprecatedString locale_time_zone_nam auto const& dates_object = locale_object.get_object("dates"sv).value(); auto const& time_zone_names_object = dates_object.get_object("timeZoneNames"sv).value(); auto const& meta_zone_object = time_zone_names_object.get_object("metazone"sv); - auto const& hour_format_string = time_zone_names_object.get_deprecated_string("hourFormat"sv).value(); - auto const& gmt_format_string = time_zone_names_object.get_deprecated_string("gmtFormat"sv).value(); - auto const& gmt_zero_format_string = time_zone_names_object.get_deprecated_string("gmtZeroFormat"sv).value(); + auto const& hour_format_string = time_zone_names_object.get_byte_string("hourFormat"sv).value(); + auto const& gmt_format_string = time_zone_names_object.get_byte_string("gmtFormat"sv).value(); + auto const& gmt_zero_format_string = time_zone_names_object.get_byte_string("gmtZeroFormat"sv).value(); if (!meta_zone_object.has_value()) return {}; @@ -1506,7 +1506,7 @@ static ErrorOr parse_time_zone_names(DeprecatedString locale_time_zone_nam if (!names.has_value()) return {}; - auto const& name = names->get_deprecated_string(key); + auto const& name = names->get_byte_string(key); if (name.has_value()) return cldr.unique_strings.ensure(name.value()); @@ -1592,7 +1592,7 @@ static ErrorOr parse_time_zone_names(DeprecatedString locale_time_zone_nam return {}; } -static ErrorOr parse_day_periods(DeprecatedString core_path, CLDR& cldr) +static ErrorOr parse_day_periods(ByteString core_path, CLDR& cldr) { // https://unicode.org/reports/tr35/tr35-dates.html#Day_Period_Rule_Sets LexicalPath day_periods_path(move(core_path)); @@ -1622,8 +1622,8 @@ static ErrorOr parse_day_periods(DeprecatedString core_path, CLDR& cldr) if (!day_period.has_value()) return {}; - auto begin = parse_hour(ranges.get_deprecated_string("_from"sv).value()); - auto end = parse_hour(ranges.get_deprecated_string("_before"sv).value()); + auto begin = parse_hour(ranges.get_byte_string("_from"sv).value()); + auto end = parse_hour(ranges.get_byte_string("_before"sv).value()); return DayPeriod { *day_period, begin, end }; }; @@ -1648,13 +1648,13 @@ static ErrorOr parse_day_periods(DeprecatedString core_path, CLDR& cldr) return {}; } -static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedString dates_path, CLDR& cldr) +static ErrorOr parse_all_locales(ByteString core_path, ByteString dates_path, CLDR& cldr) { TRY(parse_hour_cycles(core_path, cldr)); TRY(parse_week_data(core_path, cldr)); TRY(parse_meta_zones(core_path, cldr)); - auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr { + auto remove_variants_from_path = [&](ByteString path) -> ErrorOr { auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path))); StringBuilder builder; @@ -1664,7 +1664,7 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty()) builder.appendff("-{}", region); - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", dates_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr { @@ -1687,15 +1687,15 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr return {}; } -static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier) +static ByteString format_identifier(StringView owner, ByteString identifier) { identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All); identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All); if (all_of(identifier, is_ascii_digit)) - return DeprecatedString::formatted("{}_{}", owner[0], identifier); + return ByteString::formatted("{}_{}", owner[0], identifier); if (is_ascii_lower_alpha(identifier[0])) - return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); + return ByteString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); return identifier; } @@ -1953,9 +1953,9 @@ struct DayPeriodData { cldr.unique_day_period_lists.generate(generator, cldr.unique_day_periods.type_that_fits(), "s_day_period_lists"sv); cldr.unique_hour_cycle_lists.generate(generator, cldr.unique_hour_cycle_lists.type_that_fits(), "s_hour_cycle_lists"sv); - auto append_calendars = [&](DeprecatedString name, auto const& calendars) { + auto append_calendars = [&](ByteString name, auto const& calendars) { generator.set("name", name); - generator.set("size", DeprecatedString::number(calendars.size())); + generator.set("size", ByteString::number(calendars.size())); generator.append(R"~~~( static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~"); @@ -1965,7 +1965,7 @@ static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~"); auto calendar = calendars.find(calendar_key)->value; generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::number(calendar)); + generator.append(ByteString::number(calendar)); first = false; } @@ -1975,7 +1975,7 @@ static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~"); auto append_mapping = [&](auto const& keys, auto const& map, auto type, auto name, auto mapping_getter) { generator.set("type", type); generator.set("name", name); - generator.set("size", DeprecatedString::number(keys.size())); + generator.set("size", ByteString::number(keys.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@> @name@ { {)~~~"); @@ -1986,7 +1986,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); auto mapping = mapping_getter(value); generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::number(mapping)); + generator.append(ByteString::number(mapping)); first = false; } @@ -2008,7 +2008,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); generator.append("\n"); auto append_from_string = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector const& aliases = {}) -> ErrorOr { - HashValueMap hashes; + HashValueMap hashes; TRY(hashes.try_ensure_capacity(values.size())); for (auto const& value : values) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp index 383d068b79a..426816e8440 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp @@ -6,8 +6,8 @@ #include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common. #include +#include #include -#include #include #include #include @@ -22,14 +22,14 @@ #include #include -static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier) +static ByteString format_identifier(StringView owner, ByteString identifier) { identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All); if (all_of(identifier, is_ascii_digit)) - return DeprecatedString::formatted("{}_{}", owner[0], identifier); + return ByteString::formatted("{}_{}", owner[0], identifier); if (is_ascii_lower_alpha(identifier[0])) - return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); + return ByteString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); return identifier; } @@ -153,9 +153,9 @@ using KeywordList = Vector; using ListPatternList = Vector; struct LocaleData { - DeprecatedString language; - Optional territory; - Optional variant; + ByteString language; + Optional territory; + Optional variant; size_t display_patterns { 0 }; size_t languages { 0 }; size_t territories { 0 }; @@ -195,25 +195,25 @@ struct CLDR { UniqueStorage unique_list_pattern_lists; UniqueStorage unique_text_layouts; - HashMap locales; + HashMap locales; Vector locale_aliases; - Vector languages; + Vector languages; HashMap language_indices; - Vector territories; + Vector territories; HashMap territory_indices; - Vector scripts; + Vector scripts; HashMap script_indices; - Vector variants; + Vector variants; HashMap variant_indices; - Vector currencies; + Vector currencies; HashMap currency_indices; - Vector date_fields; + Vector date_fields; HashMap date_fields_indices; Vector date_field_aliases { @@ -224,17 +224,17 @@ struct CLDR { { "zone"sv, "timeZoneName"sv }, }; - HashMap> keywords; - HashMap> keyword_aliases; - HashMap keyword_names; + HashMap> keywords; + HashMap> keyword_aliases; + HashMap keyword_names; - Vector list_pattern_types; - Vector character_orders; - HashMap language_aliases; - HashMap territory_aliases; - HashMap script_aliases; - HashMap variant_aliases; - HashMap subdivision_aliases; + Vector list_pattern_types; + Vector character_orders; + HashMap language_aliases; + HashMap territory_aliases; + HashMap script_aliases; + HashMap variant_aliases; + HashMap subdivision_aliases; Vector complex_mappings; Vector likely_subtags; size_t max_variant_size { 0 }; @@ -253,9 +253,9 @@ struct CLDR { }) // NOTE: We return a pointer only because ErrorOr cannot store references. You may safely assume the pointer is non-null. -ErrorOr read_json_file_with_cache(DeprecatedString const& path) +ErrorOr read_json_file_with_cache(ByteString const& path) { - static HashMap parsed_json_cache; + static HashMap parsed_json_cache; if (auto parsed_json = parsed_json_cache.get(path); parsed_json.has_value()) return &parsed_json.value(); @@ -273,7 +273,7 @@ static ErrorOr parse_language_mapping(CLDR& cldr, StringView ke return LanguageMapping { move(parsed_key), move(parsed_alias) }; } -static ErrorOr parse_core_aliases(DeprecatedString core_supplemental_path, CLDR& cldr) +static ErrorOr parse_core_aliases(ByteString core_supplemental_path, CLDR& cldr) { LexicalPath core_aliases_path(move(core_supplemental_path)); core_aliases_path = core_aliases_path.append("aliases.json"sv); @@ -285,7 +285,7 @@ static ErrorOr parse_core_aliases(DeprecatedString core_supplemental_path, auto append_aliases = [&](auto& alias_object, auto& alias_map) { alias_object.for_each_member([&](auto const& key, JsonValue const& value) { - auto alias = value.as_object().get_deprecated_string("_replacement"sv).value(); + auto alias = value.as_object().get_byte_string("_replacement"sv).value(); if (key.contains('-')) { auto mapping = TRY_OR_DISCARD(parse_language_mapping(cldr, key, alias)); @@ -307,7 +307,7 @@ static ErrorOr parse_core_aliases(DeprecatedString core_supplemental_path, return {}; } -static ErrorOr parse_likely_subtags(DeprecatedString core_supplemental_path, CLDR& cldr) +static ErrorOr parse_likely_subtags(ByteString core_supplemental_path, CLDR& cldr) { LexicalPath likely_subtags_path(move(core_supplemental_path)); likely_subtags_path = likely_subtags_path.append("likelySubtags.json"sv); @@ -326,7 +326,7 @@ static ErrorOr parse_likely_subtags(DeprecatedString core_supplemental_pat return {}; } -static ErrorOr parse_identity(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_identity(ByteString locale_path, CLDR& cldr, LocaleData& locale) { LexicalPath locale_display_names_path(move(locale_path)); // Note: Every JSON file defines identity data, so we can use any of them. locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv); @@ -335,10 +335,10 @@ static ErrorOr parse_identity(DeprecatedString locale_path, CLDR& cldr, Lo auto const& main_object = locale_display_names.as_object().get_object("main"sv).value(); auto const& locale_object = main_object.get_object(locale_display_names_path.parent().basename()).value(); auto const& identity_object = locale_object.get_object("identity"sv).value(); - auto const& language_string = identity_object.get_deprecated_string("language"sv).value(); - auto const& territory_string = identity_object.get_deprecated_string("territory"sv); - auto const& script_string = identity_object.get_deprecated_string("script"sv); - auto const& variant_string = identity_object.get_deprecated_string("variant"sv); + auto const& language_string = identity_object.get_byte_string("language"sv).value(); + auto const& territory_string = identity_object.get_byte_string("territory"sv); + auto const& script_string = identity_object.get_byte_string("script"sv); + auto const& variant_string = identity_object.get_byte_string("variant"sv); locale.language = language_string; @@ -372,7 +372,7 @@ static ErrorOr parse_identity(DeprecatedString locale_path, CLDR& cldr, Lo return {}; } -static ErrorOr parse_locale_display_patterns(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_display_patterns(ByteString locale_path, CLDR& cldr, LocaleData& locale) { LexicalPath locale_display_names_path(move(locale_path)); locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv); @@ -382,8 +382,8 @@ static ErrorOr parse_locale_display_patterns(DeprecatedString locale_path, auto const& locale_object = main_object.get_object(locale_display_names_path.parent().basename()).value(); auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value(); auto const& locale_display_patterns_object = locale_display_names_object.get_object("localeDisplayPattern"sv).value(); - auto const& locale_pattern = locale_display_patterns_object.get_deprecated_string("localePattern"sv).value(); - auto const& locale_separator = locale_display_patterns_object.get_deprecated_string("localeSeparator"sv).value(); + auto const& locale_pattern = locale_display_patterns_object.get_byte_string("localePattern"sv).value(); + auto const& locale_separator = locale_display_patterns_object.get_byte_string("localeSeparator"sv).value(); DisplayPattern patterns {}; patterns.locale_pattern = cldr.unique_strings.ensure(locale_pattern); @@ -393,7 +393,7 @@ static ErrorOr parse_locale_display_patterns(DeprecatedString locale_path, return {}; } -static ErrorOr preprocess_languages(DeprecatedString locale_path, CLDR& cldr) +static ErrorOr preprocess_languages(ByteString locale_path, CLDR& cldr) { LexicalPath languages_path(move(locale_path)); languages_path = languages_path.append("languages.json"sv); @@ -417,7 +417,7 @@ static ErrorOr preprocess_languages(DeprecatedString locale_path, CLDR& cl return {}; } -static ErrorOr preprocess_currencies(DeprecatedString numbers_path, CLDR& cldr) +static ErrorOr preprocess_currencies(ByteString numbers_path, CLDR& cldr) { LexicalPath currencies_path(move(numbers_path)); currencies_path = currencies_path.append("currencies.json"sv); @@ -445,7 +445,7 @@ static bool is_sanctioned_date_field(StringView field) return field.is_one_of("era"sv, "year"sv, "quarter"sv, "month"sv, "week"sv, "weekday"sv, "day"sv, "dayperiod"sv, "hour"sv, "minute"sv, "second"sv, "zone"sv); } -static ErrorOr preprocess_date_fields(DeprecatedString dates_path, CLDR& cldr) +static ErrorOr preprocess_date_fields(ByteString dates_path, CLDR& cldr) { LexicalPath date_fields_path(move(dates_path)); date_fields_path = date_fields_path.append("dateFields.json"sv); @@ -469,7 +469,7 @@ static ErrorOr preprocess_date_fields(DeprecatedString dates_path, CLDR& c return {}; } -static ErrorOr parse_unicode_extension_keywords(DeprecatedString bcp47_path, CLDR& cldr) +static ErrorOr parse_unicode_extension_keywords(ByteString bcp47_path, CLDR& cldr) { constexpr auto desired_keywords = Array { "ca"sv, "co"sv, "hc"sv, "kf"sv, "kn"sv, "nu"sv }; auto keywords = TRY(read_json_file(bcp47_path)); @@ -483,7 +483,7 @@ static ErrorOr parse_unicode_extension_keywords(DeprecatedString bcp47_pat if (!desired_keywords.span().contains_slow(key)) return; - auto const& name = value.as_object().get_deprecated_string("_alias"sv).value(); + auto const& name = value.as_object().get_byte_string("_alias"sv).value(); cldr.keyword_names.set(key, name); auto& keywords = cldr.keywords.ensure(key); @@ -505,12 +505,12 @@ static ErrorOr parse_unicode_extension_keywords(DeprecatedString bcp47_pat if (key == "nu"sv && keyword.is_one_of("finance"sv, "native"sv, "traditio"sv)) return; - if (auto const& preferred = properties.as_object().get_deprecated_string("_preferred"sv); preferred.has_value()) { + if (auto const& preferred = properties.as_object().get_byte_string("_preferred"sv); preferred.has_value()) { cldr.keyword_aliases.ensure(key).append({ preferred.value(), keyword }); return; } - if (auto const& alias = properties.as_object().get_deprecated_string("_alias"sv); alias.has_value()) + if (auto const& alias = properties.as_object().get_byte_string("_alias"sv); alias.has_value()) cldr.keyword_aliases.ensure(key).append({ keyword, alias.value() }); keywords.append(keyword); @@ -520,7 +520,7 @@ static ErrorOr parse_unicode_extension_keywords(DeprecatedString bcp47_pat return {}; } -static Optional find_keyword_alias(StringView key, StringView calendar, CLDR& cldr) +static Optional find_keyword_alias(StringView key, StringView calendar, CLDR& cldr) { auto it = cldr.keyword_aliases.find(key); if (it == cldr.keyword_aliases.end()) @@ -533,7 +533,7 @@ static Optional find_keyword_alias(StringView key, StringView return alias->name; } -static ErrorOr parse_locale_languages(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_languages(ByteString locale_path, CLDR& cldr, LocaleData& locale) { LexicalPath languages_path(move(locale_path)); languages_path = languages_path.append("languages.json"sv); @@ -567,7 +567,7 @@ static ErrorOr parse_locale_languages(DeprecatedString locale_path, CLDR& return {}; } -static ErrorOr parse_locale_territories(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_territories(ByteString locale_path, CLDR& cldr, LocaleData& locale) { LexicalPath territories_path(move(locale_path)); territories_path = territories_path.append("territories.json"sv); @@ -598,7 +598,7 @@ static ErrorOr parse_locale_territories(DeprecatedString locale_path, CLDR return {}; } -static ErrorOr parse_locale_scripts(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_scripts(ByteString locale_path, CLDR& cldr, LocaleData& locale) { LexicalPath scripts_path(move(locale_path)); scripts_path = scripts_path.append("scripts.json"sv); @@ -629,7 +629,7 @@ static ErrorOr parse_locale_scripts(DeprecatedString locale_path, CLDR& cl return {}; } -static ErrorOr parse_locale_list_patterns(DeprecatedString misc_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_list_patterns(ByteString misc_path, CLDR& cldr, LocaleData& locale) { LexicalPath list_patterns_path(move(misc_path)); list_patterns_path = list_patterns_path.append("listPatterns.json"sv); @@ -664,10 +664,10 @@ static ErrorOr parse_locale_list_patterns(DeprecatedString misc_path, CLDR auto type = list_pattern_type(key); auto style = list_pattern_style(key); - auto start = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("start"sv).value()); - auto middle = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("middle"sv).value()); - auto end = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("end"sv).value()); - auto pair = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("2"sv).value()); + auto start = cldr.unique_strings.ensure(value.as_object().get_byte_string("start"sv).value()); + auto middle = cldr.unique_strings.ensure(value.as_object().get_byte_string("middle"sv).value()); + auto end = cldr.unique_strings.ensure(value.as_object().get_byte_string("end"sv).value()); + auto pair = cldr.unique_strings.ensure(value.as_object().get_byte_string("2"sv).value()); if (!cldr.list_pattern_types.contains_slow(type)) cldr.list_pattern_types.append(type); @@ -680,7 +680,7 @@ static ErrorOr parse_locale_list_patterns(DeprecatedString misc_path, CLDR return {}; } -static ErrorOr parse_locale_layout(DeprecatedString misc_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_layout(ByteString misc_path, CLDR& cldr, LocaleData& locale) { LexicalPath layout_path(move(misc_path)); layout_path = layout_path.append("layout.json"sv); @@ -699,7 +699,7 @@ static ErrorOr parse_locale_layout(DeprecatedString misc_path, CLDR& cldr, VERIFY_NOT_REACHED(); }; - auto character_order = orientation_object.get_deprecated_string("characterOrder"sv).value(); + auto character_order = orientation_object.get_byte_string("characterOrder"sv).value(); TextLayout layout {}; layout.character_order = text_layout_character_order(character_order); @@ -711,7 +711,7 @@ static ErrorOr parse_locale_layout(DeprecatedString misc_path, CLDR& cldr, return {}; } -static ErrorOr parse_locale_currencies(DeprecatedString numbers_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_currencies(ByteString numbers_path, CLDR& cldr, LocaleData& locale) { LexicalPath currencies_path(move(numbers_path)); currencies_path = currencies_path.append("currencies.json"sv); @@ -735,10 +735,10 @@ static ErrorOr parse_locale_currencies(DeprecatedString numbers_path, CLDR numeric_currencies.resize(cldr.currencies.size()); currencies_object.for_each_member([&](auto const& key, JsonValue const& value) { - auto long_name = value.as_object().get_deprecated_string("displayName"sv).value_or(key); - auto short_name = value.as_object().get_deprecated_string("symbol"sv).value_or(key); - auto narrow_name = value.as_object().get_deprecated_string("symbol-alt-narrow"sv); - auto numeric_name = value.as_object().get_deprecated_string("displayName-count-other"sv); + auto long_name = value.as_object().get_byte_string("displayName"sv).value_or(key); + auto short_name = value.as_object().get_byte_string("symbol"sv).value_or(key); + auto narrow_name = value.as_object().get_byte_string("symbol-alt-narrow"sv); + auto numeric_name = value.as_object().get_byte_string("displayName-count-other"sv); auto index = cldr.currency_indices.get(key).value(); long_currencies[index] = cldr.unique_strings.ensure(move(long_name)); @@ -754,7 +754,7 @@ static ErrorOr parse_locale_currencies(DeprecatedString numbers_path, CLDR return {}; } -static ErrorOr parse_locale_calendars(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_calendars(ByteString locale_path, CLDR& cldr, LocaleData& locale) { LexicalPath locale_display_names_path(move(locale_path)); locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv); @@ -789,7 +789,7 @@ static ErrorOr parse_locale_calendars(DeprecatedString locale_path, CLDR& return {}; } -static ErrorOr parse_locale_date_fields(DeprecatedString dates_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_locale_date_fields(ByteString dates_path, CLDR& cldr, LocaleData& locale) { LexicalPath date_fields_path(move(dates_path)); date_fields_path = date_fields_path.append("dateFields.json"sv); @@ -813,9 +813,9 @@ static ErrorOr parse_locale_date_fields(DeprecatedString dates_path, CLDR& if (!is_sanctioned_date_field(key)) return; - auto const& long_name = value.as_object().get_deprecated_string("displayName"sv).value(); - auto const& short_name = fields_object.get_object(DeprecatedString::formatted("{}-short", key))->get_deprecated_string("displayName"sv).value(); - auto const& narrow_name = fields_object.get_object(DeprecatedString::formatted("{}-narrow", key))->get_deprecated_string("displayName"sv).value(); + auto const& long_name = value.as_object().get_byte_string("displayName"sv).value(); + auto const& short_name = fields_object.get_object(ByteString::formatted("{}-short", key))->get_byte_string("displayName"sv).value(); + auto const& narrow_name = fields_object.get_object(ByteString::formatted("{}-narrow", key))->get_byte_string("displayName"sv).value(); auto index = cldr.date_fields_indices.get(key).value(); long_date_fields[index] = cldr.unique_strings.ensure(long_name); @@ -829,7 +829,7 @@ static ErrorOr parse_locale_date_fields(DeprecatedString dates_path, CLDR& return {}; } -static ErrorOr parse_number_system_keywords(DeprecatedString locale_numbers_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_number_system_keywords(ByteString locale_numbers_path, CLDR& cldr, LocaleData& locale) { LexicalPath numbers_path(move(locale_numbers_path)); numbers_path = numbers_path.append("numbers.json"sv); @@ -838,12 +838,12 @@ static ErrorOr parse_number_system_keywords(DeprecatedString locale_number auto const& main_object = numbers.as_object().get_object("main"sv).value(); auto const& locale_object = main_object.get_object(numbers_path.parent().basename()).value(); auto const& locale_numbers_object = locale_object.get_object("numbers"sv).value(); - auto const& default_numbering_system_object = locale_numbers_object.get_deprecated_string("defaultNumberingSystem"sv).value(); + auto const& default_numbering_system_object = locale_numbers_object.get_byte_string("defaultNumberingSystem"sv).value(); auto const& other_numbering_systems_object = locale_numbers_object.get_object("otherNumberingSystems"sv).value(); KeywordList keywords {}; - auto append_numbering_system = [&](DeprecatedString system_name) { + auto append_numbering_system = [&](ByteString system_name) { if (auto system_alias = find_keyword_alias("nu"sv, system_name, cldr); system_alias.has_value()) system_name = system_alias.release_value(); @@ -868,7 +868,7 @@ static ErrorOr parse_number_system_keywords(DeprecatedString locale_number return {}; } -static ErrorOr parse_calendar_keywords(DeprecatedString locale_dates_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_calendar_keywords(ByteString locale_dates_path, CLDR& cldr, LocaleData& locale) { KeywordList keywords {}; @@ -934,7 +934,7 @@ static void fill_in_collation_keywords(CLDR& cldr, LocaleData& locale) locale.collation_numeric_keywords = kn_index; } -static ErrorOr parse_default_content_locales(DeprecatedString core_path, CLDR& cldr) +static ErrorOr parse_default_content_locales(ByteString core_path, CLDR& cldr) { LexicalPath default_content_path(move(core_path)); default_content_path = default_content_path.append("defaultContent.json"sv); @@ -983,7 +983,7 @@ static ErrorOr define_aliases_without_scripts(CLDR& cldr) if ((parsed_locale.language == 0) || (parsed_locale.script == 0) || (parsed_locale.region == 0)) return {}; - auto locale_without_script = DeprecatedString::formatted("{}-{}", + auto locale_without_script = ByteString::formatted("{}-{}", cldr.unique_strings.get(parsed_locale.language), cldr.unique_strings.get(parsed_locale.region)); @@ -1008,7 +1008,7 @@ static ErrorOr define_aliases_without_scripts(CLDR& cldr) return {}; } -static ErrorOr parse_all_locales(DeprecatedString bcp47_path, DeprecatedString core_path, DeprecatedString locale_names_path, DeprecatedString misc_path, DeprecatedString numbers_path, DeprecatedString dates_path, CLDR& cldr) +static ErrorOr parse_all_locales(ByteString bcp47_path, ByteString core_path, ByteString locale_names_path, ByteString misc_path, ByteString numbers_path, ByteString dates_path, CLDR& cldr) { LexicalPath core_supplemental_path(core_path); core_supplemental_path = core_supplemental_path.append("supplemental"sv); @@ -1017,7 +1017,7 @@ static ErrorOr parse_all_locales(DeprecatedString bcp47_path, DeprecatedSt TRY(parse_core_aliases(core_supplemental_path.string(), cldr)); TRY(parse_likely_subtags(core_supplemental_path.string(), cldr)); - auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr { + auto remove_variants_from_path = [&](ByteString path) -> ErrorOr { auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path))); StringBuilder builder; @@ -1027,7 +1027,7 @@ static ErrorOr parse_all_locales(DeprecatedString bcp47_path, DeprecatedSt if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty()) builder.appendff("-{}", region); - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", locale_names_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr { @@ -1156,7 +1156,7 @@ namespace Locale { for (auto& keyword : cldr.keywords) { auto const& keyword_name = cldr.keyword_names.find(keyword.key)->value; - auto enum_name = DeprecatedString::formatted("Keyword{}", format_identifier({}, keyword_name)); + auto enum_name = ByteString::formatted("Keyword{}", format_identifier({}, keyword_name)); if (auto aliases = cldr.keyword_aliases.find(keyword.key); aliases != cldr.keyword_aliases.end()) generate_enum(generator, format_identifier, enum_name, {}, keyword.value, aliases->value); @@ -1179,9 +1179,9 @@ static ErrorOr generate_unicode_locale_implementation(Core::InputBufferedF StringBuilder builder; SourceGenerator generator { builder }; generator.set("string_index_type"sv, string_index_type); - generator.set("locales_size"sv, DeprecatedString::number(cldr.locales.size())); - generator.set("territories_size", DeprecatedString::number(cldr.territories.size())); - generator.set("variants_size", DeprecatedString::number(cldr.max_variant_size)); + generator.set("locales_size"sv, ByteString::number(cldr.locales.size())); + generator.set("territories_size", ByteString::number(cldr.territories.size())); + generator.set("variants_size", ByteString::number(cldr.max_variant_size)); generator.append(R"~~~( #include @@ -1285,7 +1285,7 @@ ReadonlySpan get_available_keyword_values(StringView key) cldr.unique_text_layouts.generate(generator, "TextLayout"sv, "s_text_layouts"sv, 30); auto append_index = [&](auto index) { - generator.append(DeprecatedString::formatted(", {}", index)); + generator.append(ByteString::formatted(", {}", index)); }; auto append_list_and_size = [&](auto const& list) { @@ -1298,16 +1298,16 @@ ReadonlySpan get_available_keyword_values(StringView key) generator.append(", {"); for (auto const& item : list) { generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::number(item)); + generator.append(ByteString::number(item)); first = false; } - generator.append(DeprecatedString::formatted(" }}, {}", list.size())); + generator.append(ByteString::formatted(" }}, {}", list.size())); }; auto append_mapping = [&](auto const& keys, auto const& map, auto type, auto name, auto mapping_getter) { generator.set("type", type); generator.set("name", name); - generator.set("size", DeprecatedString::number(keys.size())); + generator.set("size", ByteString::number(keys.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@> @name@ { {)~~~"); @@ -1318,7 +1318,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); auto mapping = mapping_getter(value); generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::number(mapping)); + generator.append(ByteString::number(mapping)); first = false; } @@ -1396,7 +1396,7 @@ struct LanguageMapping { )~~~"); auto append_complex_mapping = [&](StringView name, auto& mappings) { - generator.set("size", DeprecatedString::number(mappings.size())); + generator.set("size", ByteString::number(mappings.size())); generator.set("name"sv, name); generator.append(R"~~~( @@ -1416,14 +1416,14 @@ static constexpr Array s_@name@ { { }); for (auto const& mapping : mappings) { - generator.set("language"sv, DeprecatedString::number(mapping.key.language)); + generator.set("language"sv, ByteString::number(mapping.key.language)); generator.append(" { { @language@"); append_index(mapping.key.script); append_index(mapping.key.region); append_list_and_size(mapping.key.variants); - generator.set("language"sv, DeprecatedString::number(mapping.alias.language)); + generator.set("language"sv, ByteString::number(mapping.alias.language)); generator.append(" }, { @language@"); append_index(mapping.alias.script); @@ -1563,7 +1563,7 @@ Optional get_locale_@enum_snake@_mapping(StringView locale, StringVi }; auto append_from_string = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector const& aliases = {}) -> ErrorOr { - HashValueMap hashes; + HashValueMap hashes; TRY(hashes.try_ensure_capacity(values.size())); for (auto const& value : values) @@ -1621,8 +1621,8 @@ Optional get_locale_@enum_snake@_mapping(StringView locale, StringVi for (auto const& keyword : cldr.keywords) { auto const& keyword_name = cldr.keyword_names.find(keyword.key)->value; - auto enum_name = DeprecatedString::formatted("Keyword{}", format_identifier({}, keyword_name)); - auto enum_snake = DeprecatedString::formatted("keyword_{}", keyword.key); + auto enum_name = ByteString::formatted("Keyword{}", format_identifier({}, keyword_name)); + auto enum_snake = ByteString::formatted("keyword_{}", keyword.key); if (auto aliases = cldr.keyword_aliases.find(keyword.key); aliases != cldr.keyword_aliases.end()) TRY(append_from_string(enum_name, enum_snake, keyword.value, aliases->value)); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp index 1059270ad93..646bff5926c 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp @@ -7,8 +7,8 @@ #include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common. #include #include +#include #include -#include #include #include #include @@ -85,7 +85,7 @@ struct AK::Formatter : Formatter { format.zero_format_index, format.positive_format_index, format.negative_format_index, - identifier_indices.to_deprecated_string()); + identifier_indices.to_byte_string()); } }; @@ -215,7 +215,7 @@ struct AK::Traits : public DefaultTraits { struct LocaleData { Vector number_systems; - HashMap units {}; + HashMap units {}; u8 minimum_grouping_digits { 0 }; }; @@ -227,14 +227,14 @@ struct CLDR { UniqueStorage unique_systems; UniqueStorage unique_units; - HashMap> number_system_digits; - Vector number_systems; + HashMap> number_system_digits; + Vector number_systems; - HashMap locales; + HashMap locales; size_t max_identifier_count { 0 }; }; -static ErrorOr parse_number_system_digits(DeprecatedString core_supplemental_path, CLDR& cldr) +static ErrorOr parse_number_system_digits(ByteString core_supplemental_path, CLDR& cldr) { LexicalPath number_systems_path(move(core_supplemental_path)); number_systems_path = number_systems_path.append("numberingSystems.json"sv); @@ -244,11 +244,11 @@ static ErrorOr parse_number_system_digits(DeprecatedString core_supplement auto const& number_systems_object = supplemental_object.get_object("numberingSystems"sv).value(); number_systems_object.for_each_member([&](auto const& number_system, auto const& digits_object) { - auto type = digits_object.as_object().get_deprecated_string("_type"sv).value(); + auto type = digits_object.as_object().get_byte_string("_type"sv).value(); if (type != "numeric"sv) return; - auto digits = digits_object.as_object().get_deprecated_string("_digits"sv).value(); + auto digits = digits_object.as_object().get_byte_string("_digits"sv).value(); Utf8View utf8_digits { digits }; VERIFY(utf8_digits.length() == 10); @@ -266,7 +266,7 @@ static ErrorOr parse_number_system_digits(DeprecatedString core_supplement return {}; } -static DeprecatedString parse_identifiers(DeprecatedString pattern, StringView replacement, CLDR& cldr, NumberFormat& format) +static ByteString parse_identifiers(ByteString pattern, StringView replacement, CLDR& cldr, NumberFormat& format) { static constexpr Utf8View whitespace { "\u0020\u00a0\u200f"sv }; @@ -312,7 +312,7 @@ static DeprecatedString parse_identifiers(DeprecatedString pattern, StringView r cldr.max_identifier_count = max(cldr.max_identifier_count, format.identifier_indices.size()); } - pattern = DeprecatedString::formatted("{}{{{}:{}}}{}", + pattern = ByteString::formatted("{}{{{}:{}}}{}", *start_index > 0 ? pattern.substring_view(0, *start_index) : ""sv, replacement, replacement_index, @@ -320,13 +320,13 @@ static DeprecatedString parse_identifiers(DeprecatedString pattern, StringView r } } -static void parse_number_pattern(Vector patterns, CLDR& cldr, NumberFormatType type, NumberFormat& format, NumberSystem* number_system_for_groupings = nullptr) +static void parse_number_pattern(Vector patterns, CLDR& cldr, NumberFormatType type, NumberFormat& format, NumberSystem* number_system_for_groupings = nullptr) { // https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns // https://cldr.unicode.org/translation/number-currency-formats/number-and-currency-patterns VERIFY((patterns.size() == 1) || (patterns.size() == 2)); - auto replace_patterns = [&](DeprecatedString pattern) { + auto replace_patterns = [&](ByteString pattern) { static HashMap replacements = { { "{0}"sv, "{number}"sv }, { "{1}"sv, "{currency}"sv }, @@ -340,7 +340,7 @@ static void parse_number_pattern(Vector patterns, CLDR& cldr, for (auto const& replacement : replacements) pattern = pattern.replace(replacement.key, replacement.value, ReplaceMode::All); - if (auto start_number_index = pattern.find_any_of("#0"sv, DeprecatedString::SearchDirection::Forward); start_number_index.has_value()) { + if (auto start_number_index = pattern.find_any_of("#0"sv, ByteString::SearchDirection::Forward); start_number_index.has_value()) { auto end_number_index = *start_number_index + 1; for (; end_number_index < pattern.length(); ++end_number_index) { @@ -367,7 +367,7 @@ static void parse_number_pattern(Vector patterns, CLDR& cldr, } } - pattern = DeprecatedString::formatted("{}{{number}}{}", + pattern = ByteString::formatted("{}{{number}}{}", *start_number_index > 0 ? pattern.substring_view(0, *start_number_index) : ""sv, pattern.substring_view(end_number_index)); @@ -384,19 +384,19 @@ static void parse_number_pattern(Vector patterns, CLDR& cldr, }; auto zero_format = replace_patterns(move(patterns[0])); - format.positive_format_index = cldr.unique_strings.ensure(DeprecatedString::formatted("{{plusSign}}{}", zero_format)); + format.positive_format_index = cldr.unique_strings.ensure(ByteString::formatted("{{plusSign}}{}", zero_format)); if (patterns.size() == 2) { auto negative_format = replace_patterns(move(patterns[1])); format.negative_format_index = cldr.unique_strings.ensure(move(negative_format)); } else { - format.negative_format_index = cldr.unique_strings.ensure(DeprecatedString::formatted("{{minusSign}}{}", zero_format)); + format.negative_format_index = cldr.unique_strings.ensure(ByteString::formatted("{{minusSign}}{}", zero_format)); } format.zero_format_index = cldr.unique_strings.ensure(move(zero_format)); } -static void parse_number_pattern(Vector patterns, CLDR& cldr, NumberFormatType type, size_t& format_index, NumberSystem* number_system_for_groupings = nullptr) +static void parse_number_pattern(Vector patterns, CLDR& cldr, NumberFormatType type, size_t& format_index, NumberSystem* number_system_for_groupings = nullptr) { NumberFormat format {}; parse_number_pattern(move(patterns), cldr, type, format, number_system_for_groupings); @@ -404,7 +404,7 @@ static void parse_number_pattern(Vector patterns, CLDR& cldr, format_index = cldr.unique_formats.ensure(move(format)); } -static ErrorOr parse_number_systems(DeprecatedString locale_numbers_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_number_systems(ByteString locale_numbers_path, CLDR& cldr, LocaleData& locale) { LexicalPath numbers_path(move(locale_numbers_path)); numbers_path = numbers_path.append("numbers.json"sv); @@ -413,7 +413,7 @@ static ErrorOr parse_number_systems(DeprecatedString locale_numbers_path, auto const& main_object = numbers.as_object().get_object("main"sv).value(); auto const& locale_object = main_object.get_object(numbers_path.parent().basename()).value(); auto const& locale_numbers_object = locale_object.get_object("numbers"sv).value(); - auto const& minimum_grouping_digits = locale_numbers_object.get_deprecated_string("minimumGroupingDigits"sv).value(); + auto const& minimum_grouping_digits = locale_numbers_object.get_byte_string("minimumGroupingDigits"sv).value(); Vector> number_systems; number_systems.resize(cldr.number_systems.size()); @@ -517,9 +517,9 @@ static ErrorOr parse_number_systems(DeprecatedString locale_numbers_path, // The range separator does not appear in the symbols list, we have to extract it from // the range pattern. - auto misc_patterns_key = DeprecatedString::formatted("{}{}", misc_patterns_prefix, system); + auto misc_patterns_key = ByteString::formatted("{}{}", misc_patterns_prefix, system); auto misc_patterns = locale_numbers_object.get_object(misc_patterns_key).value(); - auto range_separator = misc_patterns.get_deprecated_string("range"sv).value(); + auto range_separator = misc_patterns.get_byte_string("range"sv).value(); auto begin_index = range_separator.find("{0}"sv).value() + "{0}"sv.length(); auto end_index = range_separator.find("{1}"sv).value(); @@ -536,7 +536,7 @@ static ErrorOr parse_number_systems(DeprecatedString locale_numbers_path, auto system = key.substring(decimal_formats_prefix.length()); auto& number_system = ensure_number_system(system); - auto format_object = value.as_object().get_deprecated_string("standard"sv).value(); + auto format_object = value.as_object().get_byte_string("standard"sv).value(); parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.decimal_format, &number_system); auto const& long_format = value.as_object().get_object("long"sv)->get_object("decimalFormat"sv).value(); @@ -548,10 +548,10 @@ static ErrorOr parse_number_systems(DeprecatedString locale_numbers_path, auto system = key.substring(currency_formats_prefix.length()); auto& number_system = ensure_number_system(system); - auto format_object = value.as_object().get_deprecated_string("standard"sv).value(); + auto format_object = value.as_object().get_byte_string("standard"sv).value(); parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.currency_format); - format_object = value.as_object().get_deprecated_string("accounting"sv).value(); + format_object = value.as_object().get_byte_string("accounting"sv).value(); parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.accounting_format); number_system.currency_unit_formats = parse_number_format(value.as_object()); @@ -559,13 +559,13 @@ static ErrorOr parse_number_systems(DeprecatedString locale_numbers_path, auto system = key.substring(percent_formats_prefix.length()); auto& number_system = ensure_number_system(system); - auto format_object = value.as_object().get_deprecated_string("standard"sv).value(); + auto format_object = value.as_object().get_byte_string("standard"sv).value(); parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.percent_format); } else if (key.starts_with(scientific_formats_prefix)) { auto system = key.substring(scientific_formats_prefix.length()); auto& number_system = ensure_number_system(system); - auto format_object = value.as_object().get_deprecated_string("standard"sv).value(); + auto format_object = value.as_object().get_byte_string("standard"sv).value(); parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.scientific_format); } }); @@ -584,7 +584,7 @@ static ErrorOr parse_number_systems(DeprecatedString locale_numbers_path, return {}; } -static ErrorOr parse_units(DeprecatedString locale_units_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_units(ByteString locale_units_path, CLDR& cldr, LocaleData& locale) { LexicalPath units_path(move(locale_units_path)); units_path = units_path.append("units.json"sv); @@ -597,7 +597,7 @@ static ErrorOr parse_units(DeprecatedString locale_units_path, CLDR& cldr, auto const& short_object = locale_units_object.get_object("short"sv).value(); auto const& narrow_object = locale_units_object.get_object("narrow"sv).value(); - HashMap units; + HashMap units; auto ensure_unit = [&](auto const& unit) -> Unit& { return units.ensure(unit, [&]() { @@ -687,7 +687,7 @@ static ErrorOr parse_units(DeprecatedString locale_units_path, CLDR& cldr, return {}; } -static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedString numbers_path, DeprecatedString units_path, CLDR& cldr) +static ErrorOr parse_all_locales(ByteString core_path, ByteString numbers_path, ByteString units_path, CLDR& cldr) { LexicalPath core_supplemental_path(move(core_path)); core_supplemental_path = core_supplemental_path.append("supplemental"sv); @@ -695,7 +695,7 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr TRY(parse_number_system_digits(core_supplemental_path.string(), cldr)); - auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr { + auto remove_variants_from_path = [&](ByteString path) -> ErrorOr { auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path))); StringBuilder builder; @@ -705,7 +705,7 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty()) builder.appendff("-{}", region); - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", numbers_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr { @@ -729,7 +729,7 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr return {}; } -static DeprecatedString format_identifier(StringView, DeprecatedString identifier) +static ByteString format_identifier(StringView, ByteString identifier) { return identifier.to_titlecase(); } @@ -765,7 +765,7 @@ static ErrorOr generate_unicode_locale_implementation(Core::InputBufferedF generator.set("number_format_index_type"sv, cldr.unique_formats.type_that_fits()); generator.set("number_format_list_index_type"sv, cldr.unique_format_lists.type_that_fits()); generator.set("numeric_symbol_list_index_type"sv, cldr.unique_symbols.type_that_fits()); - generator.set("identifier_count", DeprecatedString::number(cldr.max_identifier_count)); + generator.set("identifier_count", ByteString::number(cldr.max_identifier_count)); generator.append(R"~~~( #include @@ -848,22 +848,22 @@ struct Unit { auto locales = cldr.locales.keys(); quick_sort(locales); - generator.set("size", DeprecatedString::number(locales.size())); + generator.set("size", ByteString::number(locales.size())); generator.append(R"~~~( static constexpr Array s_minimum_grouping_digits { { )~~~"); bool first = true; for (auto const& locale : locales) { generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::number(cldr.locales.find(locale)->value.minimum_grouping_digits)); + generator.append(ByteString::number(cldr.locales.find(locale)->value.minimum_grouping_digits)); first = false; } generator.append(" } };\n"); - auto append_map = [&](DeprecatedString name, auto type, auto const& map) { + auto append_map = [&](ByteString name, auto type, auto const& map) { generator.set("name", name); generator.set("type", type); - generator.set("size", DeprecatedString::number(map.size())); + generator.set("size", ByteString::number(map.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@> @name@ { {)~~~"); @@ -872,9 +872,9 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); for (auto const& item : map) { generator.append(first ? " "sv : ", "sv); if constexpr (requires { item.value; }) - generator.append(DeprecatedString::number(item.value)); + generator.append(ByteString::number(item.value)); else - generator.append(DeprecatedString::number(item)); + generator.append(ByteString::number(item)); first = false; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp index 42ae2f990a3..8cf12eb887c 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp @@ -5,7 +5,7 @@ */ #include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common. -#include +#include #include #include #include @@ -18,14 +18,14 @@ #include #include -static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier) +static ByteString format_identifier(StringView owner, ByteString identifier) { identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All); if (all_of(identifier, is_ascii_digit)) - return DeprecatedString::formatted("{}_{}", owner[0], identifier); + return ByteString::formatted("{}_{}", owner[0], identifier); if (is_ascii_lower_alpha(identifier[0])) - return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); + return ByteString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); return identifier; } @@ -38,20 +38,20 @@ struct Relation { Inequality, }; - DeprecatedString const& modulus_variable_name() const + ByteString const& modulus_variable_name() const { VERIFY(modulus.has_value()); if (!cached_modulus_variable_name.has_value()) - cached_modulus_variable_name = DeprecatedString::formatted("mod_{}_{}", symbol, *modulus); + cached_modulus_variable_name = ByteString::formatted("mod_{}_{}", symbol, *modulus); return *cached_modulus_variable_name; } - DeprecatedString const& exponential_variable_name() const + ByteString const& exponential_variable_name() const { if (!cached_exponential_variable_name.has_value()) - cached_exponential_variable_name = DeprecatedString::formatted("exp_{}", symbol); + cached_exponential_variable_name = ByteString::formatted("exp_{}", symbol); return *cached_exponential_variable_name; } @@ -64,25 +64,25 @@ struct Relation { else if (symbol == 'e' || symbol == 'c') generator.append(exponential_variable_name()); else - generator.append(DeprecatedString::formatted("ops.{}", Locale::PluralOperands::symbol_to_variable_name(symbol))); + generator.append(ByteString::formatted("ops.{}", Locale::PluralOperands::symbol_to_variable_name(symbol))); }; auto append_value = [&](u32 value) { append_variable_name(); generator.append(" == "sv); - generator.append(DeprecatedString::number(value)); + generator.append(ByteString::number(value)); }; auto append_range = [&](auto const& range) { // This check avoids generating "0 <= unsigned_value", which is always true. if (range[0] != 0 || Locale::PluralOperands::symbol_requires_floating_point_modulus(symbol)) { - generator.append(DeprecatedString::formatted("{} <= ", range[0])); + generator.append(ByteString::formatted("{} <= ", range[0])); append_variable_name(); generator.append(" && "sv); } append_variable_name(); - generator.append(DeprecatedString::formatted(" <= {}", range[1])); + generator.append(ByteString::formatted(" <= {}", range[1])); }; if (type == Type::Inequality) @@ -105,7 +105,7 @@ struct Relation { generator.append(")"sv); } - void generate_precomputed_variables(SourceGenerator& generator, HashTable& generated_variables) const + void generate_precomputed_variables(SourceGenerator& generator, HashTable& generated_variables) const { // FIXME: How do we handle the exponential symbols? They seem unused by ECMA-402. if (symbol == 'e' || symbol == 'c') { @@ -127,7 +127,7 @@ struct Relation { generated_variables.set(variable); generator.set("variable"sv, move(variable)); generator.set("operand"sv, Locale::PluralOperands::symbol_to_variable_name(symbol)); - generator.set("modulus"sv, DeprecatedString::number(*modulus)); + generator.set("modulus"sv, ByteString::number(*modulus)); if (Locale::PluralOperands::symbol_requires_floating_point_modulus(symbol)) { generator.append(R"~~~( @@ -144,8 +144,8 @@ struct Relation { Vector comparators; private: - mutable Optional cached_modulus_variable_name; - mutable Optional cached_exponential_variable_name; + mutable Optional cached_modulus_variable_name; + mutable Optional cached_exponential_variable_name; }; struct Condition { @@ -170,7 +170,7 @@ struct Condition { } } - void generate_precomputed_variables(SourceGenerator& generator, HashTable& generated_variables) const + void generate_precomputed_variables(SourceGenerator& generator, HashTable& generated_variables) const { for (auto const& conjunctions : relations) { for (auto const& relation : conjunctions) @@ -182,18 +182,18 @@ struct Condition { }; struct Range { - DeprecatedString start; - DeprecatedString end; - DeprecatedString category; + ByteString start; + ByteString end; + ByteString category; }; -using Conditions = HashMap; +using Conditions = HashMap; using Ranges = Vector; struct LocaleData { - static DeprecatedString generated_method_name(StringView form, StringView locale) + static ByteString generated_method_name(StringView form, StringView locale) { - return DeprecatedString::formatted("{}_plurality_{}", form, format_identifier({}, locale)); + return ByteString::formatted("{}_plurality_{}", form, format_identifier({}, locale)); } Conditions& rules_for_form(StringView form) @@ -213,7 +213,7 @@ struct LocaleData { struct CLDR { UniqueStringStorage unique_strings; - HashMap locales; + HashMap locales; }; static Relation parse_relation(StringView relation) @@ -321,7 +321,7 @@ static void parse_condition(StringView category, StringView rule, Conditions& ru }); } -static ErrorOr parse_plural_rules(DeprecatedString core_supplemental_path, StringView file_name, CLDR& cldr) +static ErrorOr parse_plural_rules(ByteString core_supplemental_path, StringView file_name, CLDR& cldr) { static constexpr auto form_prefix = "plurals-type-"sv; static constexpr auto rule_prefix = "pluralRule-count-"sv; @@ -356,7 +356,7 @@ static ErrorOr parse_plural_rules(DeprecatedString core_supplemental_path, } // https://unicode.org/reports/tr35/tr35-numbers.html#Plural_Ranges -static ErrorOr parse_plural_ranges(DeprecatedString core_supplemental_path, CLDR& cldr) +static ErrorOr parse_plural_ranges(ByteString core_supplemental_path, CLDR& cldr) { static constexpr auto start_segment = "-start-"sv; static constexpr auto end_segment = "-end-"sv; @@ -392,13 +392,13 @@ static ErrorOr parse_plural_ranges(DeprecatedString core_supplemental_path return {}; } -static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedString locale_names_path, CLDR& cldr) +static ErrorOr parse_all_locales(ByteString core_path, ByteString locale_names_path, CLDR& cldr) { LexicalPath core_supplemental_path(move(core_path)); core_supplemental_path = core_supplemental_path.append("supplemental"sv); VERIFY(FileSystem::is_directory(core_supplemental_path.string())); - auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr { + auto remove_variants_from_path = [&](ByteString path) -> ErrorOr { auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path))); StringBuilder builder; @@ -408,7 +408,7 @@ static ErrorOr parse_all_locales(DeprecatedString core_path, DeprecatedStr if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty()) builder.appendff("-{}", region); - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", locale_names_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr { @@ -484,7 +484,7 @@ static PluralCategory default_range(PluralCategory, PluralCategory end) return; generator.set("method"sv, LocaleData::generated_method_name(form, locale)); - HashTable generated_variables; + HashTable generated_variables; generator.append(R"~~~( static PluralCategory @method@([[maybe_unused]] PluralOperands ops) @@ -539,7 +539,7 @@ static PluralCategory @method@(PluralCategory start, PluralCategory end) generator.set("type"sv, type); generator.set("form"sv, form); generator.set("default"sv, default_); - generator.set("size"sv, DeprecatedString::number(locales.size())); + generator.set("size"sv, ByteString::number(locales.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@> s_@form@_functions { {)~~~"); @@ -564,7 +564,7 @@ static constexpr Array<@type@, @size@> s_@form@_functions { {)~~~"); auto append_categories = [&](auto const& name, auto const& rules) { generator.set("name", name); - generator.set("size", DeprecatedString::number(rules.size() + 1)); + generator.set("size", ByteString::number(rules.size() + 1)); generator.append(R"~~~( static constexpr Array @name@ { { PluralCategory::Other)~~~"); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp index f68e69efc76..2fe54a6d201 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp @@ -5,7 +5,7 @@ */ #include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common. -#include +#include #include #include #include @@ -39,9 +39,9 @@ struct RelativeTimeFormat { && (pattern == other.pattern); } - DeprecatedString time_unit; - DeprecatedString style; - DeprecatedString plurality; + ByteString time_unit; + ByteString style; + ByteString plurality; size_t tense_or_number { 0 }; size_t pattern { 0 }; }; @@ -73,10 +73,10 @@ struct CLDR { UniqueStringStorage unique_strings; UniqueStorage unique_formats; - HashMap locales; + HashMap locales; }; -static ErrorOr parse_date_fields(DeprecatedString locale_dates_path, CLDR& cldr, LocaleData& locale) +static ErrorOr parse_date_fields(ByteString locale_dates_path, CLDR& cldr, LocaleData& locale) { LexicalPath date_fields_path(move(locale_dates_path)); date_fields_path = date_fields_path.append("dateFields.json"sv); @@ -135,9 +135,9 @@ static ErrorOr parse_date_fields(DeprecatedString locale_dates_path, CLDR& return {}; } -static ErrorOr parse_all_locales(DeprecatedString dates_path, CLDR& cldr) +static ErrorOr parse_all_locales(ByteString dates_path, CLDR& cldr) { - auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr { + auto remove_variants_from_path = [&](ByteString path) -> ErrorOr { auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path))); StringBuilder builder; @@ -147,7 +147,7 @@ static ErrorOr parse_all_locales(DeprecatedString dates_path, CLDR& cldr) if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty()) builder.appendff("-{}", region); - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", dates_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr { @@ -225,9 +225,9 @@ struct RelativeTimeFormatImpl { cldr.unique_formats.generate(generator, "RelativeTimeFormatImpl"sv, "s_relative_time_formats"sv, 10); - auto append_list = [&](DeprecatedString name, auto const& list) { + auto append_list = [&](ByteString name, auto const& list) { generator.set("name", name); - generator.set("size", DeprecatedString::number(list.size())); + generator.set("size", ByteString::number(list.size())); generator.append(R"~~~( static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~"); @@ -235,7 +235,7 @@ static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~ bool first = true; for (auto index : list) { generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::number(index)); + generator.append(ByteString::number(index)); first = false; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp index 091c029547e..d27d60628a8 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp @@ -5,8 +5,8 @@ */ #include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common. +#include #include -#include #include #include #include @@ -36,7 +36,7 @@ struct TimeZoneOffset { i64 offset { 0 }; Optional until; - Optional dst_rule; + Optional dst_rule; Optional dst_rule_index; i64 dst_offset { 0 }; @@ -56,17 +56,17 @@ struct DaylightSavingsOffset { struct TimeZoneData { UniqueStringStorage unique_strings; - HashMap> time_zones; - Vector time_zone_names; + HashMap> time_zones; + Vector time_zone_names; Vector time_zone_aliases; - HashMap> dst_offsets; - Vector dst_offset_names; + HashMap> dst_offsets; + Vector dst_offset_names; - HashMap time_zone_coordinates; + HashMap time_zone_coordinates; - HashMap> time_zone_regions; - Vector time_zone_region_names; + HashMap> time_zone_regions; + Vector time_zone_region_names; Vector time_zones_and_links; }; @@ -112,10 +112,10 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, DaylightSavingsOffset const& dst_offset) { auto format_time = [&](auto year) { - return DeprecatedString::formatted("AK::UnixDateTime::from_unix_time_parts({}, 1, 1, 0, 0, 0, 0)", year); + return ByteString::formatted("AK::UnixDateTime::from_unix_time_parts({}, 1, 1, 0, 0, 0, 0)", year); }; - static DeprecatedString max_year_as_time("max_year_as_time"sv); + static ByteString max_year_as_time("max_year_as_time"sv); return Formatter::format(builder, "{{ {}, {}, {}, {}, {} }}"sv, @@ -439,7 +439,7 @@ static void set_dst_rule_indices(TimeZoneData& time_zone_data) } } -static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier) +static ByteString format_identifier(StringView owner, ByteString identifier) { constexpr auto gmt_time_zones = Array { "Etc/GMT"sv, "GMT"sv }; @@ -448,9 +448,9 @@ static DeprecatedString format_identifier(StringView owner, DeprecatedString ide auto offset = identifier.substring_view(gmt_time_zone.length()); if (offset.starts_with('+')) - identifier = DeprecatedString::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1)); + identifier = ByteString::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1)); else if (offset.starts_with('-')) - identifier = DeprecatedString::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1)); + identifier = ByteString::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1)); } } @@ -458,9 +458,9 @@ static DeprecatedString format_identifier(StringView owner, DeprecatedString ide identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All); if (all_of(identifier, is_ascii_digit)) - return DeprecatedString::formatted("{}_{}", owner[0], identifier); + return ByteString::formatted("{}_{}", owner[0], identifier); if (is_ascii_lower_alpha(identifier[0])) - return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); + return ByteString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1)); return identifier; } @@ -568,14 +568,14 @@ struct DaylightSavingsOffset { auto append_offsets = [&](auto const& name, auto type, auto const& offsets) { generator.set("name", name); generator.set("type", type); - generator.set("size", DeprecatedString::number(offsets.size())); + generator.set("size", ByteString::number(offsets.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@> @name@ { { )~~~"); for (auto const& offset : offsets) - generator.append(DeprecatedString::formatted(" {},\n", offset)); + generator.append(ByteString::formatted(" {},\n", offset)); generator.append("} };\n"); }; @@ -597,7 +597,7 @@ static constexpr Array<@type@, @size@> @name@ { { auto const& time_zones = time_zone_data.time_zone_regions.find(value)->value; generator.set("name", name); - generator.set("size", DeprecatedString::number(time_zones.size())); + generator.set("size", ByteString::number(time_zones.size())); generator.append(R"~~~( static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~"); @@ -605,14 +605,14 @@ static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~"); bool first = true; for (auto const& time_zone : time_zones) { generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::number(time_zone)); + generator.append(ByteString::number(time_zone)); first = false; } generator.append(" } };"); }); - generator.set("size", DeprecatedString::number(time_zone_data.time_zone_names.size())); + generator.set("size", ByteString::number(time_zone_data.time_zone_names.size())); generator.append(R"~~~( static constexpr Array s_time_zone_locations { { )~~~"); @@ -620,12 +620,12 @@ static constexpr Array s_time_zone_locations { { for (auto const& time_zone : time_zone_data.time_zone_names) { auto location = time_zone_data.time_zone_coordinates.get(time_zone).value_or({}); - generator.append(DeprecatedString::formatted(" {},\n", location)); + generator.append(ByteString::formatted(" {},\n", location)); } generator.append("} };\n"); auto append_string_conversions = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector const& aliases = {}) -> ErrorOr { - HashValueMap hashes; + HashValueMap hashes; TRY(hashes.try_ensure_capacity(values.size())); auto hash = [](auto const& value) { @@ -750,10 +750,10 @@ Optional> get_named_time_zone_offsets(TimeZone time_zone, auto const& time_zone_offset = find_time_zone_offset(time_zone, time); Array named_offsets; - auto format_name = [](auto format, auto offset) -> DeprecatedString { + auto format_name = [](auto format, auto offset) -> ByteString { if (offset == 0) return decode_string(format).replace("{}"sv, ""sv, ReplaceMode::FirstOnly); - return DeprecatedString::formatted(decode_string(format), decode_string(offset)); + return ByteString::formatted(decode_string(format), decode_string(offset)); }; auto set_named_offset = [&](auto& named_offset, auto dst_offset, auto in_dst, auto format, auto offset) { diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp index b3870744ce2..65f7ffb007e 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp @@ -6,7 +6,7 @@ #include "GeneratorUtil.h" #include -#include +#include #include #include #include @@ -20,11 +20,11 @@ struct Emoji { size_t name { 0 }; Optional image_path; Unicode::EmojiGroup group; - DeprecatedString subgroup; + ByteString subgroup; u32 display_order { 0 }; Vector code_points; - DeprecatedString encoded_code_points; - DeprecatedString status; + ByteString encoded_code_points; + ByteString status; size_t code_point_array_index { 0 }; }; @@ -45,8 +45,8 @@ static void set_image_path_for_emoji(StringView emoji_resource_path, EmojiData& builder.appendff("U+{:X}", code_point); } - auto file = DeprecatedString::formatted("{}.png", builder.to_deprecated_string()); - auto path = DeprecatedString::formatted("{}/{}", emoji_resource_path, file); + auto file = ByteString::formatted("{}.png", builder.to_byte_string()); + auto path = ByteString::formatted("{}/{}", emoji_resource_path, file); if (!FileSystem::exists(path)) return; @@ -61,7 +61,7 @@ static ErrorOr parse_emoji_test_data(Core::InputBufferedFile& file, EmojiD Array buffer; Unicode::EmojiGroup group; - DeprecatedString subgroup; + ByteString subgroup; u32 display_order { 0 }; while (TRY(file.can_read_line())) { @@ -157,7 +157,7 @@ static ErrorOr parse_emoji_serenity_data(Core::InputBufferedFile& file, Em return {}; })); - auto name = builder.to_deprecated_string(); + auto name = builder.to_byte_string(); if (!any_of(name, is_ascii_lower_alpha)) name = name.to_titlecase(); @@ -218,7 +218,7 @@ static ErrorOr generate_emoji_data_implementation(Core::InputBufferedFile& SourceGenerator generator { builder }; generator.set("string_index_type"sv, emoji_data.unique_strings.type_that_fits()); - generator.set("emojis_size"sv, DeprecatedString::number(emoji_data.emojis.size())); + generator.set("emojis_size"sv, ByteString::number(emoji_data.emojis.size())); generator.append(R"~~~( #include @@ -238,7 +238,7 @@ namespace Unicode { for (auto const& emoji : emoji_data.emojis) { total_code_point_count += emoji.code_points.size(); } - generator.set("total_code_point_count", DeprecatedString::number(total_code_point_count)); + generator.set("total_code_point_count", ByteString::number(total_code_point_count)); generator.append(R"~~~( static constexpr Array s_emoji_code_points { {)~~~"); @@ -247,7 +247,7 @@ static constexpr Array s_emoji_code_points { {)~~ for (auto const& emoji : emoji_data.emojis) { for (auto code_point : emoji.code_points) { generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::formatted("{:#x}", code_point)); + generator.append(ByteString::formatted("{:#x}", code_point)); first = false; } } @@ -288,12 +288,12 @@ struct EmojiData { static constexpr Array s_emojis { {)~~~"); for (auto const& emoji : emoji_data.emojis) { - generator.set("name"sv, DeprecatedString::number(emoji.name)); - generator.set("image_path"sv, DeprecatedString::number(emoji.image_path.value_or(0))); - generator.set("group"sv, DeprecatedString::number(to_underlying(emoji.group))); - generator.set("display_order"sv, DeprecatedString::number(emoji.display_order)); - generator.set("code_point_start"sv, DeprecatedString::number(emoji.code_point_array_index)); - generator.set("code_point_count"sv, DeprecatedString::number(emoji.code_points.size())); + generator.set("name"sv, ByteString::number(emoji.name)); + generator.set("image_path"sv, ByteString::number(emoji.image_path.value_or(0))); + generator.set("group"sv, ByteString::number(to_underlying(emoji.group))); + generator.set("display_order"sv, ByteString::number(emoji.display_order)); + generator.set("code_point_start"sv, ByteString::number(emoji.code_point_array_index)); + generator.set("code_point_count"sv, ByteString::number(emoji.code_points.size())); generator.append(R"~~~( { @name@, @image_path@, @group@, @display_order@, @code_point_start@, @code_point_count@ },)~~~"); @@ -370,7 +370,7 @@ static ErrorOr generate_emoji_installation(Core::InputBufferedFile& file, generator.append("@emoji@"sv); generator.append(" - "sv); - generator.append(DeprecatedString::join(" "sv, emoji.code_points, "U+{:X}"sv)); + generator.append(ByteString::join(" "sv, emoji.code_points, "U+{:X}"sv)); generator.append(" @name@ (@status@)\n"sv); } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp index 95f8f33725d..31fc19dfd9c 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp @@ -7,8 +7,8 @@ #include "GeneratorUtil.h" #include #include +#include #include -#include #include #include #include @@ -28,8 +28,8 @@ struct SpecialCasing { Vector lowercase_mapping; Vector uppercase_mapping; Vector titlecase_mapping; - DeprecatedString locale; - DeprecatedString condition; + ByteString locale; + ByteString condition; }; // https://www.unicode.org/reports/tr44/#CaseFolding.txt @@ -42,13 +42,13 @@ struct CaseFolding { // https://www.unicode.org/reports/tr44/#Character_Decomposition_Mappings struct CodePointDecomposition { // `tag` is a string since it's used for codegen as an enum value. - DeprecatedString tag { "Canonical"sv }; + ByteString tag { "Canonical"sv }; size_t decomposition_index { 0 }; size_t decomposition_size { 0 }; }; // https://www.unicode.org/reports/tr44/#PropList.txt -using PropList = HashMap>; +using PropList = HashMap>; // https://www.unicode.org/reports/tr44/#DerivedNormalizationProps.txt enum class QuickCheck { @@ -63,7 +63,7 @@ struct Normalization { QuickCheck quick_check { QuickCheck::Yes }; }; -using NormalizationProps = HashMap>; +using NormalizationProps = HashMap>; struct CodePointName { Unicode::CodePointRange code_point_range; @@ -92,16 +92,16 @@ struct CasingTable { // https://www.unicode.org/reports/tr44/#UnicodeData.txt struct CodePointData { u32 code_point { 0 }; - DeprecatedString name; + ByteString name; Optional abbreviation; - DeprecatedString bidi_class; + ByteString bidi_class; Optional decomposition_mapping; Optional numeric_value_decimal; Optional numeric_value_digit; Optional numeric_value_numeric; bool bidi_mirrored { false }; - DeprecatedString unicode_1_name; - DeprecatedString iso_comment; + ByteString unicode_1_name; + ByteString iso_comment; CasingTable casing; }; @@ -127,7 +127,7 @@ struct CodePointTables { struct CodePointBidiClass { Unicode::CodePointRange code_point_range; - DeprecatedString bidi_class; + ByteString bidi_class; }; struct UnicodeData { @@ -135,12 +135,12 @@ struct UnicodeData { u32 code_points_with_decomposition_mapping { 0 }; Vector decomposition_mappings; - Vector compatibility_tags; + Vector compatibility_tags; Vector special_casing; u32 largest_special_casing_mapping_size { 0 }; - Vector conditions; - Vector locales; + Vector conditions; + Vector locales; Vector case_folding; u32 largest_case_folding_mapping_size { 0 }; @@ -190,11 +190,11 @@ struct UnicodeData { CodePointTables word_break_tables; CodePointTables sentence_break_tables; - HashTable bidirectional_classes; + HashTable bidirectional_classes; Vector code_point_bidirectional_classes; }; -static DeprecatedString sanitize_entry(DeprecatedString const& entry) +static ByteString sanitize_entry(ByteString const& entry) { auto sanitized = entry.replace("-"sv, "_"sv, ReplaceMode::All); sanitized = sanitized.replace(" "sv, "_"sv, ReplaceMode::All); @@ -209,7 +209,7 @@ static DeprecatedString sanitize_entry(DeprecatedString const& entry) next_is_upper = ch == '_'; } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } static ErrorOr parse_special_casing(Core::InputBufferedFile& file, UnicodeData& unicode_data) @@ -248,7 +248,7 @@ static ErrorOr parse_special_casing(Core::InputBufferedFile& file, Unicode } if (!casing.locale.is_empty()) { - casing.locale = DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(casing.locale[0]), casing.locale.substring_view(1)); + casing.locale = ByteString::formatted("{:c}{}", to_ascii_uppercase(casing.locale[0]), casing.locale.substring_view(1)); if (!unicode_data.locales.contains_slow(casing.locale)) unicode_data.locales.append(casing.locale); @@ -380,7 +380,7 @@ static ErrorOr parse_prop_list(Core::InputBufferedFile& file, PropList& pr static ErrorOr parse_alias_list(Core::InputBufferedFile& file, PropList const& prop_list, Vector& prop_aliases) { - DeprecatedString current_property; + ByteString current_property; Array buffer; auto append_alias = [&](auto alias, auto property) { @@ -455,7 +455,7 @@ static ErrorOr parse_name_aliases(Core::InputBufferedFile& file, UnicodeDa return {}; } -static ErrorOr parse_value_alias_list(Core::InputBufferedFile& file, StringView desired_category, Vector const& value_list, Vector& prop_aliases, bool primary_value_is_first = true, bool sanitize_alias = false) +static ErrorOr parse_value_alias_list(Core::InputBufferedFile& file, StringView desired_category, Vector const& value_list, Vector& prop_aliases, bool primary_value_is_first = true, bool sanitize_alias = false) { TRY(file.seek(0, SeekMode::SetPosition)); Array buffer; @@ -518,7 +518,7 @@ static ErrorOr parse_normalization_props(Core::InputBufferedFile& file, Un VERIFY((segments.size() == 2) || (segments.size() == 3)); auto code_point_range = parse_code_point_range(segments[0].trim_whitespace()); - auto property = segments[1].trim_whitespace().to_deprecated_string(); + auto property = segments[1].trim_whitespace().to_byte_string(); Vector value; QuickCheck quick_check = QuickCheck::Yes; @@ -620,7 +620,7 @@ static Optional parse_decomposition_mapping(StringView s if (parts.first().starts_with('<')) { auto const tag = parts.take_first().trim("<>"sv); - mapping.tag = DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(tag[0]), tag.substring_view(1)); + mapping.tag = ByteString::formatted("{:c}{}", to_ascii_uppercase(tag[0]), tag.substring_view(1)); if (!unicode_data.compatibility_tags.contains_slow(mapping.tag)) unicode_data.compatibility_tags.append(mapping.tag); @@ -755,15 +755,15 @@ static ErrorOr generate_unicode_data_header(Core::InputBufferedFile& file, { StringBuilder builder; SourceGenerator generator { builder }; - generator.set("special_casing_mapping_size", DeprecatedString::number(unicode_data.largest_special_casing_mapping_size)); - generator.set("case_folding_mapping_size", DeprecatedString::number(unicode_data.largest_case_folding_mapping_size)); + generator.set("special_casing_mapping_size", ByteString::number(unicode_data.largest_special_casing_mapping_size)); + generator.set("case_folding_mapping_size", ByteString::number(unicode_data.largest_case_folding_mapping_size)); auto generate_enum = [&](StringView name, StringView default_, auto values, Vector aliases = {}) { quick_sort(values); quick_sort(aliases, [](auto& alias1, auto& alias2) { return alias1.alias < alias2.alias; }); generator.set("name", name); - generator.set("underlying", DeprecatedString::formatted("{}UnderlyingType", name)); + generator.set("underlying", ByteString::formatted("{}UnderlyingType", name)); generator.set("type", ((values.size() + !default_.is_empty()) < 256) ? "u8"sv : "u16"sv); generator.append(R"~~~( @@ -872,8 +872,8 @@ static ErrorOr generate_unicode_data_implementation(Core::InputBufferedFil SourceGenerator generator { builder }; generator.set("string_index_type"sv, unicode_data.unique_strings.type_that_fits()); - generator.set("special_casing_size", DeprecatedString::number(unicode_data.special_casing.size())); - generator.set("case_folding_size", DeprecatedString::number(unicode_data.case_folding.size())); + generator.set("special_casing_size", ByteString::number(unicode_data.special_casing.size())); + generator.set("case_folding_size", ByteString::number(unicode_data.case_folding.size())); generator.set("CODE_POINT_TABLES_LSB_COUNT", TRY(String::number(CODE_POINT_TABLES_LSB_COUNT))); generator.set("CODE_POINT_TABLES_LSB_MASK", TRY(String::formatted("{:#x}", CODE_POINT_TABLES_LSB_MASK))); @@ -884,7 +884,7 @@ static ErrorOr generate_unicode_data_implementation(Core::InputBufferedFil #include #include #include -#include +#include #include #include #include @@ -905,17 +905,17 @@ namespace Unicode { generator.append(", {"); for (auto const& item : list) { generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::formatted(format, item)); + generator.append(ByteString::formatted(format, item)); first = false; } - generator.append(DeprecatedString::formatted(" }}, {}", list.size())); + generator.append(ByteString::formatted(" }}, {}", list.size())); }; generator.append(R"~~~( static constexpr Array s_special_case { {)~~~"); for (auto const& casing : unicode_data.special_casing) { - generator.set("code_point", DeprecatedString::formatted("{:#x}", casing.code_point)); + generator.set("code_point", ByteString::formatted("{:#x}", casing.code_point)); generator.append(R"~~~( { @code_point@)~~~"); @@ -939,7 +939,7 @@ static constexpr Array s_special_case { {) static constexpr Array s_case_folding { {)~~~"); for (auto const& folding : unicode_data.case_folding) { - generator.set("code_point", DeprecatedString::formatted("{:#x}", folding.code_point)); + generator.set("code_point", ByteString::formatted("{:#x}", folding.code_point)); generator.set("status", folding.status); generator.append(R"~~~( { @code_point@, CaseFoldingStatus::@status@)~~~"); @@ -1015,15 +1015,15 @@ struct CodePointBidiClassComparator : public CodePointRangeComparator { )~~~"); - generator.set("decomposition_mappings_size", DeprecatedString::number(unicode_data.decomposition_mappings.size())); + generator.set("decomposition_mappings_size", ByteString::number(unicode_data.decomposition_mappings.size())); generator.append("\nstatic constexpr Array s_decomposition_mappings_data { "); - generator.append(DeprecatedString::join(", "sv, unicode_data.decomposition_mappings, "{:#x}"sv)); + generator.append(ByteString::join(", "sv, unicode_data.decomposition_mappings, "{:#x}"sv)); generator.append(" };\n"); auto append_code_point_mappings = [&](StringView name, StringView mapping_type, u32 size, auto mapping_getter) { generator.set("name", name); generator.set("mapping_type", mapping_type); - generator.set("size", DeprecatedString::number(size)); + generator.set("size", ByteString::number(size)); generator.append(R"~~~( static constexpr Array<@mapping_type@, @size@> s_@name@_mappings { { @@ -1046,16 +1046,16 @@ static constexpr Array<@mapping_type@, @size@> s_@name@_mappings { { if (mappings_in_current_row++ > 0) generator.append(" "); - generator.set("code_point", DeprecatedString::formatted("{:#x}", data.code_point)); + generator.set("code_point", ByteString::formatted("{:#x}", data.code_point)); generator.append("{ @code_point@"); if constexpr (IsSame> || IsSame>) { - generator.set("mapping", DeprecatedString::formatted("{:#x}", *mapping)); + generator.set("mapping", ByteString::formatted("{:#x}", *mapping)); generator.append(", @mapping@ },"); } else if constexpr (IsSame>) { generator.set("tag", mapping->tag); - generator.set("start", DeprecatedString::number(mapping->decomposition_index)); - generator.set("size", DeprecatedString::number(mapping->decomposition_size)); + generator.set("start", ByteString::number(mapping->decomposition_index)); + generator.set("size", ByteString::number(mapping->decomposition_size)); generator.append(", CompatibilityFormattingTag::@tag@, @start@, @size@ },"); } else { append_list_and_size(mapping, "&s_@name@[{}]"sv); @@ -1195,7 +1195,7 @@ static constexpr Array<@type@, @size@> @name@ { { generator.set("type", type); generator.set("name", name); - generator.set("size", DeprecatedString::number(display_names.size())); + generator.set("size", ByteString::number(display_names.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@> @name@ { { @@ -1204,9 +1204,9 @@ static constexpr Array<@type@, @size@> @name@ { { if (values_in_current_row++ > 0) generator.append(", "); - generator.set("first", DeprecatedString::formatted("{:#x}", display_name.code_point_range.first)); - generator.set("last", DeprecatedString::formatted("{:#x}", display_name.code_point_range.last)); - generator.set("name", DeprecatedString::number(display_name.name)); + generator.set("first", ByteString::formatted("{:#x}", display_name.code_point_range.first)); + generator.set("last", ByteString::formatted("{:#x}", display_name.code_point_range.last)); + generator.set("name", ByteString::number(display_name.name)); generator.append("{ { @first@, @last@ }, @name@ }"); if (values_in_current_row == max_values_per_row) { @@ -1226,7 +1226,7 @@ static constexpr Array<@type@, @size@> @name@ { { constexpr size_t max_bidi_classes_per_row = 20; size_t bidi_classes_in_current_row = 0; - generator.set("size"sv, DeprecatedString::number(unicode_data.code_point_bidirectional_classes.size())); + generator.set("size"sv, ByteString::number(unicode_data.code_point_bidirectional_classes.size())); generator.append(R"~~~( static constexpr Array s_bidirectional_classes { { )~~~"); @@ -1234,8 +1234,8 @@ static constexpr Array s_bidirectional_classes { { if (bidi_classes_in_current_row++ > 0) generator.append(", "); - generator.set("first", DeprecatedString::formatted("{:#x}", data.code_point_range.first)); - generator.set("last", DeprecatedString::formatted("{:#x}", data.code_point_range.last)); + generator.set("first", ByteString::formatted("{:#x}", data.code_point_range.first)); + generator.set("last", ByteString::formatted("{:#x}", data.code_point_range.last)); generator.set("bidi_class", data.bidi_class); generator.append("{ { @first@, @last@ }, BidirectionalClass::@bidi_class@ }"); @@ -1274,13 +1274,13 @@ ReadonlySpan block_display_names() return display_names.span(); } -Optional code_point_display_name(u32 code_point) +Optional code_point_display_name(u32 code_point) { if (auto const* entry = binary_search(s_code_point_display_names, code_point, nullptr, CodePointNameComparator {})) { auto display_name = decode_string(entry->display_name); if (display_name.ends_with("{:X}"sv)) - return DeprecatedString::formatted(display_name, code_point); + return ByteString::formatted(display_name, code_point); return display_name; } @@ -1409,7 +1409,7 @@ bool code_point_has_@enum_snake@(u32 code_point, @enum_title@ @enum_snake@) ValueFromStringOptions options {}; for (auto const& prop : prop_list) { - if constexpr (IsSame, DeprecatedString>) { + if constexpr (IsSame, ByteString>) { hashes.set(CaseInsensitiveASCIIStringViewTraits::hash(prop), prop); options.sensitivity = CaseSensitivity::CaseInsensitive; } else { diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h index 03501c5b9c1..e2940c5ebcd 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -101,7 +101,7 @@ public: { generator.set("type"sv, type); generator.set("name"sv, name); - generator.set("size"sv, DeprecatedString::number(m_storage.size())); + generator.set("size"sv, ByteString::number(m_storage.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@ + 1> @name@ { { @@ -113,10 +113,10 @@ static constexpr Array<@type@, @size@ + 1> @name@ { { if (values_in_current_row++ > 0) generator.append(", "); - if constexpr (IsSame) - generator.append(DeprecatedString::formatted("\"{}\"sv", value)); + if constexpr (IsSame) + generator.append(ByteString::formatted("\"{}\"sv", value)); else - generator.append(DeprecatedString::formatted("{}", value)); + generator.append(ByteString::formatted("{}", value)); if (values_in_current_row == max_values_per_row) { values_in_current_row = 0; @@ -138,8 +138,8 @@ static constexpr Array<@type@, @size@ + 1> @name@ { { for (size_t i = 0; i < m_storage.size(); ++i) { auto const& list = m_storage[i]; - generator.set("index"sv, DeprecatedString::number(i)); - generator.set("size"sv, DeprecatedString::number(list.size())); + generator.set("index"sv, ByteString::number(i)); + generator.set("size"sv, ByteString::number(list.size())); generator.append(R"~~~( static constexpr Array<@type@, @size@> @name@@index@ { {)~~~"); @@ -147,14 +147,14 @@ static constexpr Array<@type@, @size@> @name@@index@ { {)~~~"); bool first = true; for (auto const& value : list) { generator.append(first ? " "sv : ", "sv); - generator.append(DeprecatedString::formatted("{}", value)); + generator.append(ByteString::formatted("{}", value)); first = false; } generator.append(" } };"); } - generator.set("size"sv, DeprecatedString::number(m_storage.size())); + generator.set("size"sv, ByteString::number(m_storage.size())); generator.append(R"~~~( @@ -168,7 +168,7 @@ static constexpr Array, @size@ + 1> @name@ { { if (values_in_current_row++ > 0) generator.append(", "); - generator.set("index"sv, DeprecatedString::number(i)); + generator.set("index"sv, ByteString::number(i)); generator.append("@name@@index@.span()"); if (values_in_current_row == max_values_per_row) { @@ -187,8 +187,8 @@ protected: HashMap m_storage_indices; }; -class UniqueStringStorage : public UniqueStorage { - using Base = UniqueStorage; +class UniqueStringStorage : public UniqueStorage { + using Base = UniqueStorage; public: // The goal of the string table generator is to ensure the table is located within the read-only @@ -204,7 +204,7 @@ public: if (values_in_current_row++ > 0) generator.append(", "); - generator.append(DeprecatedString::formatted("{:#x}", value)); + generator.append(ByteString::formatted("{:#x}", value)); if (values_in_current_row == max_values_per_row) { values_in_current_row = 0; @@ -224,7 +224,7 @@ public: next_index += string.length() + 2; } - generator.set("size", DeprecatedString::number(next_index)); + generator.set("size", ByteString::number(next_index)); generator.append(R"~~~( static constexpr Array s_encoded_strings { { )~~~"); @@ -242,7 +242,7 @@ static constexpr Array s_encoded_strings { { } }; )~~~"); - generator.set("size", DeprecatedString::number(string_indices.size())); + generator.set("size", ByteString::number(string_indices.size())); generator.append(R"~~~( static constexpr Array s_encoded_string_indices { { )~~~"); @@ -276,8 +276,8 @@ static constexpr StringView decode_string(size_t index) }; struct Alias { - DeprecatedString name; - DeprecatedString alias; + ByteString name; + ByteString alias; }; struct CanonicalLanguageID { @@ -385,11 +385,11 @@ void generate_value_from_string(SourceGenerator& generator, StringView method_na { ensure_from_string_types_are_generated(generator); - generator.set("method_name", DeprecatedString::formatted(method_name_format, value_name)); + generator.set("method_name", ByteString::formatted(method_name_format, value_name)); generator.set("value_type", value_type); generator.set("value_name", value_name); generator.set("return_type", options.return_type.has_value() ? *options.return_type : value_type); - generator.set("size", DeprecatedString::number(hashes.size())); + generator.set("size", ByteString::number(hashes.size())); generator.append(R"~~~( Optional<@return_type@> @method_name@(StringView key) @@ -408,11 +408,11 @@ Optional<@return_type@> @method_name@(StringView key) generator.append(" "); if constexpr (IsIntegral) - generator.set("value"sv, DeprecatedString::number(hashes.get(hash_key).value())); + generator.set("value"sv, ByteString::number(hashes.get(hash_key).value())); else - generator.set("value"sv, DeprecatedString::formatted("{}::{}", value_type, hashes.get(hash_key).value())); + generator.set("value"sv, ByteString::formatted("{}::{}", value_type, hashes.get(hash_key).value())); - generator.set("hash"sv, DeprecatedString::number(hash_key)); + generator.set("hash"sv, ByteString::number(hash_key)); generator.append("{ @hash@U, @value@ },"sv); if (values_in_current_row == max_values_per_row) { @@ -421,7 +421,7 @@ Optional<@return_type@> @method_name@(StringView key) } } - generator.set("return_statement", DeprecatedString::formatted(options.return_format, "value->value"sv)); + generator.set("return_statement", ByteString::formatted(options.return_format, "value->value"sv)); generator.append(R"~~~( } }; )~~~"); @@ -445,9 +445,9 @@ Optional<@return_type@> @method_name@(StringView key) } template -void generate_value_to_string(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, IdentifierFormatter&& format_identifier, ReadonlySpan values) +void generate_value_to_string(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, IdentifierFormatter&& format_identifier, ReadonlySpan values) { - generator.set("method_name", DeprecatedString::formatted(method_name_format, value_name)); + generator.set("method_name", ByteString::formatted(method_name_format, value_name)); generator.set("value_type", value_type); generator.set("value_name", value_name); @@ -475,7 +475,7 @@ StringView @method_name@(@value_type@ @value_name@) } template -void generate_enum(SourceGenerator& generator, IdentifierFormatter&& format_identifier, StringView name, StringView default_, Vector& values, Vector aliases = {}) +void generate_enum(SourceGenerator& generator, IdentifierFormatter&& format_identifier, StringView name, StringView default_, Vector& values, Vector aliases = {}) { quick_sort(values, [](auto const& value1, auto const& value2) { return value1.to_lowercase() < value2.to_lowercase(); }); quick_sort(aliases, [](auto const& alias1, auto const& alias2) { return alias1.alias.to_lowercase() < alias2.alias.to_lowercase(); }); @@ -514,20 +514,20 @@ template) mapping_name = name.replace("-"sv, "_"sv, ReplaceMode::All); else mapping_name = format_identifier(type, name); - return DeprecatedString::formatted(format, mapping_name.to_lowercase()); + return ByteString::formatted(format, mapping_name.to_lowercase()); }; - Vector mapping_names; + Vector mapping_names; for (auto const& locale : locales) { - DeprecatedString mapping_name; + ByteString mapping_name; if constexpr (requires { locale.key; }) { mapping_name = format_mapping_name(format, locale.key); @@ -544,7 +544,7 @@ void generate_mapping(SourceGenerator& generator, LocalesType const& locales, St generator.set("type", type); generator.set("name", name); - generator.set("size", DeprecatedString::number(locales.size())); + generator.set("size", ByteString::number(locales.size())); generator.append(R"~~~( static constexpr Array, @size@> @name@ { { )~~~"); @@ -589,9 +589,9 @@ ReadonlySpan @name@() first = false; if (auto it = aliases.find_if([&](auto const& alias) { return alias.alias == value; }); it != aliases.end()) - generator.append(DeprecatedString::formatted("\"{}\"sv", it->name)); + generator.append(ByteString::formatted("\"{}\"sv", it->name)); else - generator.append(DeprecatedString::formatted("\"{}\"sv", value)); + generator.append(ByteString::formatted("\"{}\"sv", value)); } generator.append(R"~~~( }; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index f3fdc897dee..f9716649547 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -112,7 +112,7 @@ static StringView sequence_storage_type_to_cpp_storage_type_name(SequenceStorage CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface); -static DeprecatedString union_type_to_variant(UnionType const& union_type, Interface const& interface) +static ByteString union_type_to_variant(UnionType const& union_type, Interface const& interface) { StringBuilder builder; builder.append("Variant<"sv); @@ -132,16 +132,16 @@ static DeprecatedString union_type_to_variant(UnionType const& union_type, Inter builder.append(", Empty"sv); builder.append('>'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface) { if (is_platform_object(type) || type.name() == "WindowProxy"sv) - return { .name = DeprecatedString::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector }; + return { .name = ByteString::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector }; if (is_javascript_builtin(type)) - return { .name = DeprecatedString::formatted("JS::Handle", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector }; + return { .name = ByteString::formatted("JS::Handle", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector }; if (interface.callback_functions.contains(type.name())) return { .name = "JS::Handle", .sequence_storage_type = SequenceStorageType::MarkedVector }; @@ -200,7 +200,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface) if (sequence_cpp_type.sequence_storage_type == SequenceStorageType::MarkedVector) return { .name = storage_type_name, .sequence_storage_type = SequenceStorageType::Vector }; - return { .name = DeprecatedString::formatted("{}<{}>", storage_type_name, sequence_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector }; + return { .name = ByteString::formatted("{}<{}>", storage_type_name, sequence_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector }; } if (type.name() == "record") { @@ -210,7 +210,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface) auto record_key_cpp_type = idl_type_name_to_cpp_type(record_key_type, interface); auto record_value_cpp_type = idl_type_name_to_cpp_type(record_value_type, interface); - return { .name = DeprecatedString::formatted("OrderedHashMap<{}, {}>", record_key_cpp_type.name, record_value_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector }; + return { .name = ByteString::formatted("OrderedHashMap<{}, {}>", record_key_cpp_type.name, record_value_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector }; } if (is(type)) { @@ -229,13 +229,13 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface) TODO(); } -static DeprecatedString make_input_acceptable_cpp(DeprecatedString const& input) +static ByteString make_input_acceptable_cpp(ByteString const& input) { if (input.is_one_of("class", "template", "for", "default", "char", "namespace", "delete", "inline")) { StringBuilder builder; builder.append(input); builder.append('_'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } return input.replace("-"sv, "_"sv, ReplaceMode::All); @@ -266,7 +266,7 @@ static void generate_include_for(auto& generator, auto& path) } LexicalPath include_path { path_string }; - forked_generator.set("include.path", DeprecatedString::formatted("{}/{}.h", include_path.dirname(), include_path.title())); + forked_generator.set("include.path", ByteString::formatted("{}/{}.h", include_path.dirname(), include_path.title())); forked_generator.append(R"~~~( #include <@include.path@> )~~~"); @@ -275,7 +275,7 @@ static void generate_include_for(auto& generator, auto& path) static void emit_includes_for_all_imports(auto& interface, auto& generator, bool is_iterator = false) { Queue const*> interfaces; - HashTable paths_imported; + HashTable paths_imported; interfaces.enqueue(&interface); @@ -297,13 +297,13 @@ static void emit_includes_for_all_imports(auto& interface, auto& generator, bool } if (is_iterator) { - auto iterator_path = DeprecatedString::formatted("{}Iterator", interface.fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All)); + auto iterator_path = ByteString::formatted("{}Iterator", interface.fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All)); generate_include_for_iterator(generator, iterator_path); } } template -static void generate_to_string(SourceGenerator& scoped_generator, ParameterType const& parameter, bool variadic, bool optional, Optional const& optional_default_value) +static void generate_to_string(SourceGenerator& scoped_generator, ParameterType const& parameter, bool variadic, bool optional, Optional const& optional_default_value) { if (variadic) { scoped_generator.append(R"~~~( @@ -363,7 +363,7 @@ static void generate_to_string(SourceGenerator& scoped_generator, ParameterType } template -static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter, DeprecatedString const& js_name, DeprecatedString const& js_suffix, DeprecatedString const& cpp_name, IDL::Interface const& interface, bool legacy_null_to_empty_string = false, bool optional = false, Optional optional_default_value = {}, bool variadic = false, size_t recursion_depth = 0) +static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter, ByteString const& js_name, ByteString const& js_suffix, ByteString const& cpp_name, IDL::Interface const& interface, bool legacy_null_to_empty_string = false, bool optional = false, Optional optional_default_value = {}, bool variadic = false, size_t recursion_depth = 0) { auto scoped_generator = generator.fork(); auto acceptable_cpp_name = make_input_acceptable_cpp(cpp_name); @@ -698,7 +698,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter auto default_value_cpp_name = enumeration.translated_cpp_names.get(enum_member_name); VERIFY(default_value_cpp_name.has_value()); enum_generator.set("enum.default.cpp_value", *default_value_cpp_name); - enum_generator.set("js_name.as_string", DeprecatedString::formatted("{}{}_string", enum_generator.get("js_name"sv), enum_generator.get("js_suffix"sv))); + enum_generator.set("js_name.as_string", ByteString::formatted("{}{}_string", enum_generator.get("js_name"sv), enum_generator.get("js_suffix"sv))); enum_generator.append(R"~~~( @parameter.type.name@ @cpp_name@ { @parameter.type.name@::@enum.default.cpp_value@ }; )~~~"); @@ -761,8 +761,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter for (auto& member : current_dictionary->members) { dictionary_generator.set("member_key", member.name); auto member_js_name = make_input_acceptable_cpp(member.name.to_snakecase()); - auto member_value_name = DeprecatedString::formatted("{}_value_{}", member_js_name, i); - auto member_property_value_name = DeprecatedString::formatted("{}_property_value_{}", member_js_name, i); + auto member_value_name = ByteString::formatted("{}_value_{}", member_js_name, i); + auto member_property_value_name = ByteString::formatted("{}_property_value_{}", member_js_name, i); dictionary_generator.set("member_name", member_js_name); dictionary_generator.set("member_value_name", member_value_name); dictionary_generator.set("member_property_value_name", member_property_value_name); @@ -848,7 +848,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter auto sequence_generator = scoped_generator.fork(); auto& parameterized_type = verify_cast(*parameter.type); - sequence_generator.set("recursion_depth", DeprecatedString::number(recursion_depth)); + sequence_generator.set("recursion_depth", ByteString::number(recursion_depth)); // An ECMAScript value V is converted to an IDL sequence value as follows: // 1. If Type(V) is not Object, throw a TypeError. @@ -900,7 +900,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter return vm.throw_completion(JS::ErrorType::NotIterable, @js_name@@js_suffix@.to_string_without_side_effects()); )~~~"); - parameterized_type.generate_sequence_from_iterable(sequence_generator, DeprecatedString::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), DeprecatedString::formatted("{}{}", js_name, js_suffix), DeprecatedString::formatted("iterator_method{}", recursion_depth), interface, recursion_depth + 1); + parameterized_type.generate_sequence_from_iterable(sequence_generator, ByteString::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), ByteString::formatted("{}{}", js_name, js_suffix), ByteString::formatted("iterator_method{}", recursion_depth), interface, recursion_depth + 1); if (optional) { sequence_generator.append(R"~~~( @@ -913,7 +913,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter auto record_generator = scoped_generator.fork(); auto& parameterized_type = verify_cast(*parameter.type); - record_generator.set("recursion_depth", DeprecatedString::number(recursion_depth)); + record_generator.set("recursion_depth", ByteString::number(recursion_depth)); // A record can only have two types: key type and value type. VERIFY(parameterized_type.parameters().size() == 2); @@ -963,7 +963,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter )~~~"); IDL::Parameter key_parameter { .type = parameterized_type.parameters()[0], .name = acceptable_cpp_name, .optional_default_value = {}, .extended_attributes = {} }; - generate_to_cpp(record_generator, key_parameter, "key", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("typed_key{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1); + generate_to_cpp(record_generator, key_parameter, "key", ByteString::number(recursion_depth), ByteString::formatted("typed_key{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1); record_generator.append(R"~~~( auto value@recursion_depth@ = TRY(@js_name@@js_suffix@_object.get(property_key@recursion_depth@)); @@ -971,7 +971,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // FIXME: Record value types should be TypeWithExtendedAttributes, which would allow us to get [LegacyNullToEmptyString] here. IDL::Parameter value_parameter { .type = parameterized_type.parameters()[1], .name = acceptable_cpp_name, .optional_default_value = {}, .extended_attributes = {} }; - generate_to_cpp(record_generator, value_parameter, "value", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("typed_value{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1); + generate_to_cpp(record_generator, value_parameter, "value", ByteString::number(recursion_depth), ByteString::formatted("typed_value{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1); record_generator.append(R"~~~( @cpp_name@.set(typed_key@recursion_depth@, typed_value@recursion_depth@); @@ -984,7 +984,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter auto& union_type = verify_cast(*parameter.type); union_generator.set("union_type", union_type_to_variant(union_type, interface)); - union_generator.set("recursion_depth", DeprecatedString::number(recursion_depth)); + union_generator.set("recursion_depth", ByteString::number(recursion_depth)); // NOTE: This is handled out here as we need the dictionary conversion code for the {} optional default value. // 3. Let types be the flattened member types of the union type. @@ -1036,9 +1036,9 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter to_variant_captures.append("&vm, &realm"sv); if (dictionary_type) - to_variant_captures.append(DeprecatedString::formatted(", &{}{}_to_dictionary", js_name, js_suffix)); + to_variant_captures.append(ByteString::formatted(", &{}{}_to_dictionary", js_name, js_suffix)); - union_generator.set("to_variant_captures", to_variant_captures.to_deprecated_string()); + union_generator.set("to_variant_captures", to_variant_captures.to_byte_string()); union_generator.append(R"~~~( auto @js_name@@js_suffix@_to_variant = [@to_variant_captures@](JS::Value @js_name@@js_suffix@) -> JS::ThrowCompletionOr<@union_type@> { @@ -1211,7 +1211,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter if (method) { )~~~"); - sequence_type->generate_sequence_from_iterable(union_generator, acceptable_cpp_name, DeprecatedString::formatted("{}{}", js_name, js_suffix), "method", interface, recursion_depth + 1); + sequence_type->generate_sequence_from_iterable(union_generator, acceptable_cpp_name, ByteString::formatted("{}{}", js_name, js_suffix), "method", interface, recursion_depth + 1); union_generator.append(R"~~~( @@ -1296,8 +1296,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter )~~~"); // NOTE: generate_to_cpp doesn't use the parameter name. // NOTE: generate_to_cpp will use to_{u32,etc.} which uses to_number internally and will thus use TRY, but it cannot throw as we know we are dealing with a number. - IDL::Parameter parameter { .type = *numeric_type, .name = DeprecatedString::empty(), .optional_default_value = {}, .extended_attributes = {} }; - generate_to_cpp(union_generator, parameter, js_name, js_suffix, DeprecatedString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1); + IDL::Parameter parameter { .type = *numeric_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} }; + generate_to_cpp(union_generator, parameter, js_name, js_suffix, ByteString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1); union_generator.append(R"~~~( return { @js_name@@js_suffix@_number }; @@ -1361,8 +1361,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // NOTE: generate_to_cpp doesn't use the parameter name. // NOTE: generate_to_cpp will use to_{u32,etc.} which uses to_number internally and will thus use TRY, but it cannot throw as we know we are dealing with a number. - IDL::Parameter parameter { .type = *numeric_type, .name = DeprecatedString::empty(), .optional_default_value = {}, .extended_attributes = {} }; - generate_to_cpp(union_numeric_type_generator, parameter, "x", DeprecatedString::empty(), "x_number", interface, false, false, {}, false, recursion_depth + 1); + IDL::Parameter parameter { .type = *numeric_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} }; + generate_to_cpp(union_numeric_type_generator, parameter, "x", ByteString::empty(), "x_number", interface, false, false, {}, false, recursion_depth + 1); union_numeric_type_generator.append(R"~~~( return x_number; @@ -1372,8 +1372,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter // NOTE: generate_to_cpp doesn't use the parameter name. // NOTE: generate_to_cpp will use to_{u32,etc.} which uses to_number internally and will thus use TRY, but it cannot throw as we know we are dealing with a number. - IDL::Parameter parameter { .type = *numeric_type, .name = DeprecatedString::empty(), .optional_default_value = {}, .extended_attributes = {} }; - generate_to_cpp(union_generator, parameter, js_name, js_suffix, DeprecatedString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1); + IDL::Parameter parameter { .type = *numeric_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} }; + generate_to_cpp(union_generator, parameter, js_name, js_suffix, ByteString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1); union_generator.append(R"~~~( return { @js_name@@js_suffix@_number }; @@ -1457,21 +1457,21 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter } } -static void generate_argument_count_check(SourceGenerator& generator, DeprecatedString const& function_name, size_t argument_count) +static void generate_argument_count_check(SourceGenerator& generator, ByteString const& function_name, size_t argument_count) { if (argument_count == 0) return; auto argument_count_check_generator = generator.fork(); argument_count_check_generator.set("function.name", function_name); - argument_count_check_generator.set("function.nargs", DeprecatedString::number(argument_count)); + argument_count_check_generator.set("function.nargs", ByteString::number(argument_count)); if (argument_count == 1) { argument_count_check_generator.set(".bad_arg_count", "JS::ErrorType::BadArgCountOne"); argument_count_check_generator.set(".arg_count_suffix", ""); } else { argument_count_check_generator.set(".bad_arg_count", "JS::ErrorType::BadArgCountMany"); - argument_count_check_generator.set(".arg_count_suffix", DeprecatedString::formatted(", \"{}\"", argument_count)); + argument_count_check_generator.set(".arg_count_suffix", ByteString::formatted(", \"{}\"", argument_count)); } argument_count_check_generator.append(R"~~~( @@ -1484,7 +1484,7 @@ static void generate_arguments(SourceGenerator& generator, Vector parameter_names; + Vector parameter_names; size_t argument_index = 0; for (auto& parameter : parameters) { auto parameter_name = make_input_acceptable_cpp(parameter.name.to_snakecase()); @@ -1492,18 +1492,18 @@ static void generate_arguments(SourceGenerator& generator, Vectormembers) { dictionary_generator.set("member_key", member.name); - auto member_key_js_name = DeprecatedString::formatted("{}{}", make_input_acceptable_cpp(member.name.to_snakecase()), recursion_depth); + auto member_key_js_name = ByteString::formatted("{}{}", make_input_acceptable_cpp(member.name.to_snakecase()), recursion_depth); dictionary_generator.set("member_name", member_key_js_name); - auto member_value_js_name = DeprecatedString::formatted("{}_value", member_key_js_name); + auto member_value_js_name = ByteString::formatted("{}_value", member_key_js_name); dictionary_generator.set("member_value", member_value_js_name); - auto wrapped_value_name = DeprecatedString::formatted("wrapped_{}", member_value_js_name); + auto wrapped_value_name = ByteString::formatted("wrapped_{}", member_value_js_name); dictionary_generator.set("wrapped_value_name", wrapped_value_name); dictionary_generator.append(R"~~~( JS::Value @wrapped_value_name@; )~~~"); - generate_wrap_statement(dictionary_generator, DeprecatedString::formatted("{}.{}", value, member.name.to_snakecase()), member.type, interface, DeprecatedString::formatted("{} =", wrapped_value_name), WrappingReference::No, recursion_depth + 1); + generate_wrap_statement(dictionary_generator, ByteString::formatted("{}.{}", value, member.name.to_snakecase()), member.type, interface, ByteString::formatted("{} =", wrapped_value_name), WrappingReference::No, recursion_depth + 1); dictionary_generator.append(R"~~~( MUST(dictionary_object@recursion_depth@->create_data_property("@member_key@", @wrapped_value_name@)); @@ -1856,23 +1856,23 @@ static void generate_return_statement(SourceGenerator& generator, IDL::Type cons return generate_wrap_statement(generator, "retval", return_type, interface, "return"sv); } -static void generate_variable_statement(SourceGenerator& generator, DeprecatedString const& variable_name, IDL::Type const& value_type, DeprecatedString const& value_name, IDL::Interface const& interface) +static void generate_variable_statement(SourceGenerator& generator, ByteString const& variable_name, IDL::Type const& value_type, ByteString const& value_name, IDL::Interface const& interface) { auto variable_generator = generator.fork(); variable_generator.set("variable_name", variable_name); variable_generator.append(R"~~~( JS::Value @variable_name@; )~~~"); - return generate_wrap_statement(generator, value_name, value_type, interface, DeprecatedString::formatted("{} = ", variable_name)); + return generate_wrap_statement(generator, value_name, value_type, interface, ByteString::formatted("{} = ", variable_name)); } -static void generate_function(SourceGenerator& generator, IDL::Function const& function, StaticFunction is_static_function, DeprecatedString const& class_name, DeprecatedString const& interface_fully_qualified_name, IDL::Interface const& interface) +static void generate_function(SourceGenerator& generator, IDL::Function const& function, StaticFunction is_static_function, ByteString const& class_name, ByteString const& interface_fully_qualified_name, IDL::Interface const& interface) { auto function_generator = generator.fork(); function_generator.set("class_name", class_name); function_generator.set("interface_fully_qualified_name", interface_fully_qualified_name); function_generator.set("function.name:snakecase", make_input_acceptable_cpp(function.name.to_snakecase())); - function_generator.set("overload_suffix", function.is_overloaded ? DeprecatedString::number(function.overload_index) : DeprecatedString::empty()); + function_generator.set("overload_suffix", function.is_overloaded ? ByteString::number(function.overload_index) : ByteString::empty()); if (function.extended_attributes.contains("ImplementedAs")) { auto implemented_as = function.extended_attributes.get("ImplementedAs").value(); @@ -1941,7 +1941,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@@overload_suffi if (arguments_builder.is_empty()) function_generator.set(".arguments", "vm"); else - function_generator.set(".arguments", DeprecatedString::formatted("vm, {}", arguments_builder.string_view())); + function_generator.set(".arguments", ByteString::formatted("vm, {}", arguments_builder.string_view())); function_generator.append(R"~~~( [[maybe_unused]] auto retval = TRY(throw_dom_exception_if_needed(vm, [&] { return @interface_fully_qualified_name@::@function.cpp_name@(@.arguments@); })); @@ -2082,7 +2082,7 @@ static Vector compute_the_effective_overload_set(aut return overloads; } -static DeprecatedString generate_constructor_for_idl_type(Type const& type) +static ByteString generate_constructor_for_idl_type(Type const& type) { auto append_type_list = [](auto& builder, auto const& type_list) { bool first = true; @@ -2099,14 +2099,14 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type) switch (type.kind()) { case Type::Kind::Plain: - return DeprecatedString::formatted("make_ref_counted(\"{}\", {})", type.name(), type.is_nullable()); + return ByteString::formatted("make_ref_counted(\"{}\", {})", type.name(), type.is_nullable()); case Type::Kind::Parameterized: { auto const& parameterized_type = type.as_parameterized(); StringBuilder builder; builder.appendff("make_ref_counted(\"{}\", {}, Vector> {{", type.name(), type.is_nullable()); append_type_list(builder, parameterized_type.parameters()); builder.append("})"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } case Type::Kind::Union: { auto const& union_type = type.as_union(); @@ -2114,7 +2114,7 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type) builder.appendff("make_ref_counted(\"{}\", {}, Vector> {{", type.name(), type.is_nullable()); append_type_list(builder, union_type.member_types()); builder.append("})"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } @@ -2145,7 +2145,7 @@ static size_t resolve_distinguishing_argument_index(Interface const& interface, VERIFY_NOT_REACHED(); } -static void generate_overload_arbiter(SourceGenerator& generator, auto const& overload_set, IDL::Interface const& interface, DeprecatedString const& class_name) +static void generate_overload_arbiter(SourceGenerator& generator, auto const& overload_set, IDL::Interface const& interface, ByteString const& class_name) { auto function_generator = generator.fork(); function_generator.set("class_name", class_name); @@ -2161,7 +2161,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@) auto maximum_argument_count = 0u; for (auto const& overload : overloads_set) maximum_argument_count = max(maximum_argument_count, overload.types.size()); - function_generator.set("max_argument_count", DeprecatedString::number(maximum_argument_count)); + function_generator.set("max_argument_count", ByteString::number(maximum_argument_count)); function_generator.appendln(" switch (min(@max_argument_count@, vm.argument_count())) {"); // Generate the effective overload set for each argument count. @@ -2182,8 +2182,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@) if (effective_overload_set.size() > 1) distinguishing_argument_index = resolve_distinguishing_argument_index(interface, effective_overload_set, argument_count); - function_generator.set("current_argument_count", DeprecatedString::number(argument_count)); - function_generator.set("overload_count", DeprecatedString::number(effective_overload_set.size())); + function_generator.set("current_argument_count", ByteString::number(argument_count)); + function_generator.set("overload_count", ByteString::number(effective_overload_set.size())); function_generator.appendln(R"~~~( case @current_argument_count@: { Vector overloads; @@ -2221,14 +2221,14 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@) types_builder.append("}"sv); optionality_builder.append("}"sv); - function_generator.set("overload.callable_id", DeprecatedString::number(overload.callable_id)); - function_generator.set("overload.types", types_builder.to_deprecated_string()); - function_generator.set("overload.optionality_values", optionality_builder.to_deprecated_string()); + function_generator.set("overload.callable_id", ByteString::number(overload.callable_id)); + function_generator.set("overload.types", types_builder.to_byte_string()); + function_generator.set("overload.optionality_values", optionality_builder.to_byte_string()); function_generator.appendln(" overloads.empend(@overload.callable_id@, @overload.types@, @overload.optionality_values@);"); } - function_generator.set("overload_set.distinguishing_argument_index", DeprecatedString::number(distinguishing_argument_index)); + function_generator.set("overload_set.distinguishing_argument_index", ByteString::number(distinguishing_argument_index)); function_generator.append(R"~~~( effective_overload_set.emplace(move(overloads), @overload_set.distinguishing_argument_index@); break; @@ -2247,7 +2247,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@) )~~~"); for (auto i = 0u; i < overload_set.value.size(); ++i) { - function_generator.set("overload_id", DeprecatedString::number(i)); + function_generator.set("overload_id", ByteString::number(i)); function_generator.append(R"~~~( case @overload_id@: return @function.name:snakecase@@overload_id@(vm); @@ -2274,7 +2274,7 @@ static void generate_prototype_or_global_mixin_declarations(IDL::Interface const )~~~"); if (overload_set.value.size() > 1) { for (auto i = 0u; i < overload_set.value.size(); ++i) { - function_generator.set("overload_suffix", DeprecatedString::number(i)); + function_generator.set("overload_suffix", ByteString::number(i)); function_generator.append(R"~~~( JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@); )~~~"); @@ -2420,7 +2420,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu continue; auto attribute_generator = function_generator.fork(); - auto return_value_name = DeprecatedString::formatted("{}_retval", attribute.name.to_snakecase()); + auto return_value_name = ByteString::formatted("{}_retval", attribute.name.to_snakecase()); attribute_generator.set("attribute.name", attribute.name); attribute_generator.set("attribute.return_value_name", return_value_name); @@ -2466,7 +2466,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu )~~~"); } - generate_wrap_statement(attribute_generator, return_value_name, attribute.type, interface_in_chain, DeprecatedString::formatted("auto {}_wrapped =", return_value_name)); + generate_wrap_statement(attribute_generator, return_value_name, attribute.type, interface_in_chain, ByteString::formatted("auto {}_wrapped =", return_value_name)); attribute_generator.append(R"~~~( MUST(result->create_data_property("@attribute.name@", @attribute.return_value_name@_wrapped)); @@ -2477,7 +2477,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu auto constant_generator = function_generator.fork(); constant_generator.set("constant.name", constant.name); - generate_wrap_statement(constant_generator, constant.value, constant.type, interface_in_chain, DeprecatedString::formatted("auto constant_{}_value =", constant.name)); + generate_wrap_statement(constant_generator, constant.value, constant.type, interface_in_chain, ByteString::formatted("auto constant_{}_value =", constant.name)); constant_generator.append(R"~~~( MUST(result->create_data_property("@constant.name@", constant_@constant.name@_value)); @@ -2487,7 +2487,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu } // https://webidl.spec.whatwg.org/#default-tojson-steps -static void generate_default_to_json_function(SourceGenerator& generator, DeprecatedString const& class_name, IDL::Interface const& start_interface) +static void generate_default_to_json_function(SourceGenerator& generator, ByteString const& class_name, IDL::Interface const& start_interface) { // NOTE: This is done heavily out of order since the spec mixes parse time and run time type information together. @@ -2526,7 +2526,7 @@ static void generate_named_properties_object_declarations(IDL::Interface const& { SourceGenerator generator { builder }; - generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name)); + generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name)); generator.append(R"~~~( class @named_properties_class@ : public JS::Object { @@ -2557,7 +2557,7 @@ static void generate_named_properties_object_definitions(IDL::Interface const& i generator.set("name", interface.name); generator.set("parent_name", interface.parent_name); generator.set("prototype_base_class", interface.prototype_base_class); - generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name)); + generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name)); // https://webidl.spec.whatwg.org/#create-a-named-properties-object generator.append(R"~~~( @@ -2701,11 +2701,11 @@ static void generate_prototype_or_global_mixin_definitions(IDL::Interface const& generator.set("prototype_name", interface.prototype_class); // Used for Global Mixin if (interface.pair_iterator_types.has_value()) { - generator.set("iterator_name", DeprecatedString::formatted("{}Iterator", interface.name)); + generator.set("iterator_name", ByteString::formatted("{}Iterator", interface.name)); } if (is_global_interface) { - generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name)); + generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name)); // Doing this with macros is not super nice, but simplifies codegen a lot. generator.append(R"~~~( #define define_direct_property (object.define_direct_property) @@ -2785,7 +2785,7 @@ void @class_name@::initialize(JS::Realm& realm) auto constant_generator = generator.fork(); constant_generator.set("constant.name", constant.name); - generate_wrap_statement(constant_generator, constant.value, constant.type, interface, DeprecatedString::formatted("auto constant_{}_value =", constant.name)); + generate_wrap_statement(constant_generator, constant.value, constant.type, interface, ByteString::formatted("auto constant_{}_value =", constant.name)); constant_generator.append(R"~~~( define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable); @@ -2797,7 +2797,7 @@ void @class_name@::initialize(JS::Realm& realm) auto function_generator = generator.fork(); function_generator.set("function.name", overload_set.key); function_generator.set("function.name:snakecase", make_input_acceptable_cpp(overload_set.key.to_snakecase())); - function_generator.set("function.length", DeprecatedString::number(get_shortest_function_length(overload_set.value))); + function_generator.set("function.length", ByteString::number(get_shortest_function_length(overload_set.value))); // FIXME: What if only some of the overloads are Unscopable? if (any_of(overload_set.value, [](auto const& function) { return function.extended_attributes.contains("Unscopable"); })) { @@ -3351,7 +3351,7 @@ private: )~~~"); if (overload_set.value.size() > 1) { for (auto i = 0u; i < overload_set.value.size(); ++i) { - function_generator.set("overload_suffix", DeprecatedString::number(i)); + function_generator.set("overload_suffix", ByteString::number(i)); function_generator.append(R"~~~( JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@); )~~~"); @@ -3451,7 +3451,7 @@ void @namespace_class@::initialize(JS::Realm& realm) auto function_generator = generator.fork(); function_generator.set("function.name", overload_set.key); function_generator.set("function.name:snakecase", make_input_acceptable_cpp(overload_set.key.to_snakecase())); - function_generator.set("function.length", DeprecatedString::number(get_shortest_function_length(overload_set.value))); + function_generator.set("function.length", ByteString::number(get_shortest_function_length(overload_set.value))); function_generator.append(R"~~~( define_native_function(realm, "@function.name@", @function.name:snakecase@, @function.length@, default_attributes); @@ -3521,7 +3521,7 @@ private: )~~~"); if (overload_set.value.size() > 1) { for (auto i = 0u; i < overload_set.value.size(); ++i) { - function_generator.set("overload_suffix", DeprecatedString::number(i)); + function_generator.set("overload_suffix", ByteString::number(i)); function_generator.append(R"~~~( JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@); )~~~"); @@ -3694,7 +3694,7 @@ JS::ThrowCompletionOr> @constructor_class@::constru } } - generator.set("constructor.length", DeprecatedString::number(shortest_length)); + generator.set("constructor.length", ByteString::number(shortest_length)); generator.append(R"~~~( auto& vm = this->vm(); @@ -3778,7 +3778,7 @@ JS::ThrowCompletionOr> @constructor_class@::constru generator.set(".arg_count_suffix", ""); } else { generator.set(".bad_arg_count", "JS::ErrorType::BadArgCountMany"); - generator.set(".arg_count_suffix", DeprecatedString::formatted(", \"{}\"", shortest_length)); + generator.set(".arg_count_suffix", ByteString::formatted(", \"{}\"", shortest_length)); } generator.append(R"~~~( @@ -3943,7 +3943,7 @@ void @constructor_class@::initialize(JS::Realm& realm) auto constant_generator = generator.fork(); constant_generator.set("constant.name", constant.name); - generate_wrap_statement(constant_generator, constant.value, constant.type, interface, DeprecatedString::formatted("auto constant_{}_value =", constant.name)); + generate_wrap_statement(constant_generator, constant.value, constant.type, interface, ByteString::formatted("auto constant_{}_value =", constant.name)); constant_generator.append(R"~~~( define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable); @@ -3955,7 +3955,7 @@ void @constructor_class@::initialize(JS::Realm& realm) auto function_generator = generator.fork(); function_generator.set("function.name", overload_set.key); function_generator.set("function.name:snakecase", make_input_acceptable_cpp(overload_set.key.to_snakecase())); - function_generator.set("function.length", DeprecatedString::number(get_shortest_function_length(overload_set.value))); + function_generator.set("function.length", ByteString::number(get_shortest_function_length(overload_set.value))); function_generator.append(R"~~~( define_native_function(realm, "@function.name@", @function.name:snakecase@, @function.length@, default_attributes); @@ -4172,7 +4172,7 @@ void @prototype_class@::initialize(JS::Realm& realm) Base::initialize(realm); )~~~"); if (interface.supports_named_properties()) { - generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name)); + generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name)); generator.set("namespaced_name", interface.namespaced_name); generator.append(R"~~~( define_direct_property(vm().well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm(), "@namespaced_name@"_string), JS::Attribute::Configurable); @@ -4198,7 +4198,7 @@ void generate_iterator_prototype_header(IDL::Interface const& interface, StringB VERIFY(interface.pair_iterator_types.has_value()); SourceGenerator generator { builder }; - generator.set("prototype_class", DeprecatedString::formatted("{}IteratorPrototype", interface.name)); + generator.set("prototype_class", ByteString::formatted("{}IteratorPrototype", interface.name)); generator.append(R"~~~( #pragma once @@ -4228,12 +4228,12 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface, VERIFY(interface.pair_iterator_types.has_value()); SourceGenerator generator { builder }; - generator.set("name", DeprecatedString::formatted("{}Iterator", interface.name)); + generator.set("name", ByteString::formatted("{}Iterator", interface.name)); generator.set("parent_name", interface.parent_name); - generator.set("prototype_class", DeprecatedString::formatted("{}IteratorPrototype", interface.name)); + generator.set("prototype_class", ByteString::formatted("{}IteratorPrototype", interface.name)); generator.set("prototype_base_class", interface.prototype_base_class); - generator.set("fully_qualified_name", DeprecatedString::formatted("{}Iterator", interface.fully_qualified_name)); - generator.set("possible_include_path", DeprecatedString::formatted("{}Iterator", interface.name.replace("::"sv, "/"sv, ReplaceMode::All))); + generator.set("fully_qualified_name", ByteString::formatted("{}Iterator", interface.fully_qualified_name)); + generator.set("possible_include_path", ByteString::formatted("{}Iterator", interface.name.replace("::"sv, "/"sv, ReplaceMode::All))); generator.append(R"~~~( #include diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp index 53ce7768382..e09b0004787 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp @@ -78,7 +78,7 @@ ErrorOr serenity_main(Main::Arguments arguments) builder.append(namespace_); builder.append("::"sv); builder.append(interface.name); - interface.fully_qualified_name = builder.to_deprecated_string(); + interface.fully_qualified_name = builder.to_byte_string(); } else { interface.fully_qualified_name = interface.name; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp index c506cb52399..0c6957bc8f2 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateAriaRoles.cpp @@ -56,8 +56,8 @@ namespace Web::ARIA { JsonObject const& value_object = value.as_object(); auto class_definition_generator = generator.fork(); - class_definition_generator.set("spec_link"sv, value_object.get_deprecated_string("specLink"sv).value()); - class_definition_generator.set("description"sv, value_object.get_deprecated_string("description"sv).value()); + class_definition_generator.set("spec_link"sv, value_object.get_byte_string("specLink"sv).value()); + class_definition_generator.set("description"sv, value_object.get_byte_string("description"sv).value()); class_definition_generator.set("name"sv, name); class_definition_generator.append(R"~~~( // @spec_link@ diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp index 0ee418a7c01..6dff467321f 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp @@ -77,7 +77,7 @@ enum class ValueID; enum_generator.appendln("enum class @name:titlecase@ : @enum_type@ {"); for (auto& member : members.values()) { - auto member_name = member.to_deprecated_string(); + auto member_name = member.to_byte_string(); // Don't include aliases in the enum. if (member_name.contains('=')) continue; @@ -126,7 +126,7 @@ Optional<@name:titlecase@> value_id_to_@name:snakecase@(ValueID value_id) for (auto& member : members.values()) { auto member_generator = enum_generator.fork(); - auto member_name = member.to_deprecated_string(); + auto member_name = member.to_byte_string(); if (member_name.contains('=')) { auto parts = member_name.split_view('='); member_generator.set("valueid:titlecase", title_casify(parts[0])); @@ -154,7 +154,7 @@ ValueID to_value_id(@name:titlecase@ @name:snakecase@_value) for (auto& member : members.values()) { auto member_generator = enum_generator.fork(); - auto member_name = member.to_deprecated_string(); + auto member_name = member.to_byte_string(); if (member_name.contains('=')) continue; member_generator.set("member:titlecase", title_casify(member_name)); @@ -178,7 +178,7 @@ StringView to_string(@name:titlecase@ value) for (auto& member : members.values()) { auto member_generator = enum_generator.fork(); - auto member_name = member.to_deprecated_string(); + auto member_name = member.to_byte_string(); if (member_name.contains('=')) continue; member_generator.set("member:css", member_name); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp index 0cd2fc5a487..f045518effc 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMathFunctions.cpp @@ -182,7 +182,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func // Generate some type checks VERIFY(parameters.size() == 1); auto& parameter_data = parameters[0].as_object(); - auto parameter_type_string = parameter_data.get_deprecated_string("type"sv).value(); + auto parameter_type_string = parameter_data.get_byte_string("type"sv).value(); function_generator.set("type_check", generate_calculation_type_check("argument_type"sv, parameter_type_string)); function_generator.append(R"~~~( if (!(@type_check@)) { @@ -231,11 +231,11 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func StringView previous_parameter_type_string; parameters.for_each([&](JsonValue const& parameter_value) { auto& parameter = parameter_value.as_object(); - auto parameter_type_string = parameter.get_deprecated_string("type"sv).value(); + auto parameter_type_string = parameter.get_byte_string("type"sv).value(); auto parameter_required = parameter.get_bool("required"sv).value(); auto parameter_generator = function_generator.fork(); - parameter_generator.set("parameter_name", parameter.get_deprecated_string("name"sv).value()); + parameter_generator.set("parameter_name", parameter.get_byte_string("name"sv).value()); parameter_generator.set("parameter_index", MUST(String::number(parameter_index))); bool parameter_is_calculation; @@ -245,7 +245,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func parameter_generator.set("parse_function", "parse_rounding_strategy(arguments[argument_index])"_string); parameter_generator.set("check_function", ".has_value()"_string); parameter_generator.set("release_function", ".release_value()"_string); - if (auto default_value = parameter.get_deprecated_string("default"sv); default_value.has_value()) { + if (auto default_value = parameter.get_byte_string("default"sv); default_value.has_value()) { parameter_generator.set("parameter_default", MUST(String::formatted(" = RoundingStrategy::{}", title_casify(default_value.value())))); } else { parameter_generator.set("parameter_default", ""_string); @@ -260,7 +260,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func // NOTE: We have exactly one default value in the data right now, and it's a ``, // so that's all we handle. - if (auto default_value = parameter.get_deprecated_string("default"sv); default_value.has_value()) { + if (auto default_value = parameter.get_byte_string("default"sv); default_value.has_value()) { parameter_generator.set("parameter_default", MUST(String::formatted(" = ConstantCalculationNode::create(CalculationNode::constant_type_from_string(\"{}\"sv).value())", default_value.value()))); } else { parameter_generator.set("parameter_default", ""_string); @@ -343,7 +343,7 @@ OwnPtr Parser::parse_math_function(PropertyID property_id, Func parameter_index = 0; parameters.for_each([&](JsonValue const& parameter_value) { auto& parameter = parameter_value.as_object(); - auto parameter_type_string = parameter.get_deprecated_string("type"sv).value(); + auto parameter_type_string = parameter.get_byte_string("type"sv).value(); auto parameter_generator = function_generator.fork(); parameter_generator.set("parameter_index"sv, MUST(String::number(parameter_index))); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp index 870a61d8752..a1991dc3add 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp @@ -140,7 +140,7 @@ bool media_feature_type_is_range(MediaFeatureID media_feature_id) auto member_generator = generator.fork(); member_generator.set("name:titlecase", title_casify(name)); VERIFY(feature.has("type"sv)); - auto feature_type = feature.get_deprecated_string("type"sv); + auto feature_type = feature.get_byte_string("type"sv); VERIFY(feature_type.has_value()); member_generator.set("is_range", feature_type.value() == "range" ? "true"_string : "false"_string); member_generator.append(R"~~~( diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index 33ee4bd96a6..0840fdb310d 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -43,7 +43,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto properties = json.as_object(); // Check we're in alphabetical order - DeprecatedString most_recent_name = ""; + ByteString most_recent_name = ""; properties.for_each_member([&](auto& name, auto&) { if (name < most_recent_name) { warnln("`{}` is in the wrong position in `{}`. Please keep this list alphabetical!", name, properties_json_path); @@ -65,7 +65,7 @@ ErrorOr serenity_main(Main::Arguments arguments) void replace_logical_aliases(JsonObject& properties) { - AK::HashMap logical_aliases; + AK::HashMap logical_aliases; properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); const auto& value_as_object = value.as_object(); @@ -73,7 +73,7 @@ void replace_logical_aliases(JsonObject& properties) if (logical_alias_for.has_value()) { auto const& aliased_properties = logical_alias_for.value(); for (auto const& aliased_property : aliased_properties.values()) { - logical_aliases.set(name, aliased_property.to_deprecated_string()); + logical_aliases.set(name, aliased_property.to_byte_string()); } } }); @@ -116,8 +116,8 @@ enum class PropertyID { All, )~~~"); - Vector shorthand_property_ids; - Vector longhand_property_ids; + Vector shorthand_property_ids; + Vector longhand_property_ids; properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); @@ -518,7 +518,7 @@ NonnullRefPtr property_initial_value(JS::Realm& context_realm, Prope dbgln("No initial value specified for property '{}'", name); VERIFY_NOT_REACHED(); } - auto initial_value = object.get_deprecated_string("initial"sv); + auto initial_value = object.get_byte_string("initial"sv); VERIFY(initial_value.has_value()); auto& initial_value_string = initial_value.value(); @@ -739,7 +739,7 @@ Optional property_resolves_percentages_relative_to(PropertyID propert properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); - if (auto resolved_type = value.as_object().get_deprecated_string("percentages-resolve-to"sv); resolved_type.has_value()) { + if (auto resolved_type = value.as_object().get_byte_string("percentages-resolve-to"sv); resolved_type.has_value()) { auto property_generator = generator.fork(); property_generator.set("name:titlecase", title_casify(name)); property_generator.set("resolved_type:titlecase", title_casify(resolved_type.value())); @@ -768,7 +768,7 @@ size_t property_maximum_value_count(PropertyID property_id) VERIFY(max_values.has_value() && max_values->is_number() && !max_values->is_double()); auto property_generator = generator.fork(); property_generator.set("name:titlecase", title_casify(name)); - property_generator.set("max_values", max_values->to_deprecated_string()); + property_generator.set("max_values", max_values->to_byte_string()); property_generator.append(R"~~~( case PropertyID::@name:titlecase@: return @max_values@; @@ -834,10 +834,10 @@ Vector longhands_for_shorthand(PropertyID property_id) first = false; else builder.append(", "sv); - builder.appendff("PropertyID::{}", title_casify(longhand.to_deprecated_string())); + builder.appendff("PropertyID::{}", title_casify(longhand.to_byte_string())); return IterationDecision::Continue; }); - property_generator.set("longhands", builder.to_deprecated_string()); + property_generator.set("longhands", builder.to_byte_string()); property_generator.append(R"~~~( case PropertyID::@name:titlecase@: return { @longhands@ }; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoClass.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoClass.cpp index 07efb1468a7..8c1efb07dde 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoClass.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoClass.cpp @@ -147,7 +147,7 @@ PseudoClassMetadata pseudo_class_metadata(PseudoClass pseudo_class) pseudo_classes_data.for_each_member([&](auto& name, JsonValue const& value) { auto member_generator = generator.fork(); auto& pseudo_class = value.as_object(); - auto argument_string = pseudo_class.get_deprecated_string("argument"sv).value(); + auto argument_string = pseudo_class.get_byte_string("argument"sv).value(); bool is_valid_as_identifier = argument_string.is_empty(); bool is_valid_as_function = !argument_string.is_empty(); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp index 070c3809f99..e6ca5752f6c 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp @@ -169,7 +169,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor JsonArray const& parameters = value.as_object().get_array("parameters"sv).value(); bool first = true; parameters.for_each([&](JsonValue const& value) { - GenericLexer lexer { value.as_object().get_deprecated_string("type"sv).value() }; + GenericLexer lexer { value.as_object().get_byte_string("type"sv).value() }; VERIFY(lexer.consume_specific('<')); auto parameter_type_name = lexer.consume_until('>'); VERIFY(lexer.consume_specific('>')); @@ -189,7 +189,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor member_generator.append(first ? " "sv : ", "sv); first = false; - member_generator.append(MUST(String::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get("required"sv)->to_deprecated_string()))); + member_generator.append(MUST(String::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get("required"sv)->to_byte_string()))); }); member_generator.append(R"~~~( } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp index bc3d65ea965..d2243992d76 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp @@ -57,7 +57,7 @@ enum class ValueID { identifier_data.for_each([&](auto& name) { auto member_generator = generator.fork(); - member_generator.set("name:titlecase", title_casify(name.to_deprecated_string())); + member_generator.set("name:titlecase", title_casify(name.to_byte_string())); member_generator.append(R"~~~( @name:titlecase@, @@ -105,8 +105,8 @@ HashMap g_stringv identifier_data.for_each([&](auto& name) { auto member_generator = generator.fork(); - member_generator.set("name", name.to_deprecated_string()); - member_generator.set("name:titlecase", title_casify(name.to_deprecated_string())); + member_generator.set("name", name.to_byte_string()); + member_generator.set("name:titlecase", title_casify(name.to_byte_string())); member_generator.append(R"~~~( {"@name@"sv, ValueID::@name:titlecase@}, )~~~"); @@ -126,8 +126,8 @@ StringView string_from_value_id(ValueID value_id) { identifier_data.for_each([&](auto& name) { auto member_generator = generator.fork(); - member_generator.set("name", name.to_deprecated_string()); - member_generator.set("name:titlecase", title_casify(name.to_deprecated_string())); + member_generator.set("name", name.to_byte_string()); + member_generator.set("name:titlecase", title_casify(name.to_byte_string())); member_generator.append(R"~~~( case ValueID::@name:titlecase@: return "@name@"sv; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 9e4b826997f..0c9552ad3fe 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -15,11 +15,11 @@ #include static ErrorOr add_to_interface_sets(IDL::Interface&, Vector& intrinsics, Vector& window_exposed, Vector& dedicated_worker_exposed, Vector& shared_worker_exposed); -static DeprecatedString s_error_string; +static ByteString s_error_string; struct LegacyConstructor { - DeprecatedString name; - DeprecatedString constructor_class; + ByteString name; + ByteString constructor_class; }; static void consume_whitespace(GenericLexer& lexer) @@ -52,7 +52,7 @@ static Optional const& lookup_legacy_constructor(IDL::Interfa consume_whitespace(function_lexer); auto name = function_lexer.consume_until([](auto ch) { return is_ascii_space(ch) || ch == '('; }); - auto constructor_class = DeprecatedString::formatted("{}Constructor", name); + auto constructor_class = ByteString::formatted("{}Constructor", name); s_legacy_constructors.set(interface.name, LegacyConstructor { name, move(constructor_class) }); return s_legacy_constructors.get(interface.name).value(); @@ -264,7 +264,7 @@ static ErrorOr generate_exposed_interface_header(StringView class_name, St StringBuilder builder; SourceGenerator generator(builder); - generator.set("global_object_snake_name", DeprecatedString(class_name).to_snakecase()); + generator.set("global_object_snake_name", ByteString(class_name).to_snakecase()); generator.append(R"~~~( #pragma once @@ -278,7 +278,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object&); )~~~"); - auto generated_header_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.h", class_name)).string(); + auto generated_header_path = LexicalPath(output_path).append(ByteString::formatted("{}ExposedInterfaces.h", class_name)).string(); auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); TRY(generated_header_file->write_until_depleted(generator.as_string_view().bytes())); @@ -291,7 +291,7 @@ static ErrorOr generate_exposed_interface_implementation(StringView class_ SourceGenerator generator(builder); generator.set("global_object_name", class_name); - generator.set("global_object_snake_name", DeprecatedString(class_name).to_snakecase()); + generator.set("global_object_snake_name", ByteString(class_name).to_snakecase()); generator.append(R"~~~( #include @@ -366,7 +366,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global) } )~~~"); - auto generated_implementation_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.cpp", class_name)).string(); + auto generated_implementation_path = LexicalPath(output_path).append(ByteString::formatted("{}ExposedInterfaces.cpp", class_name)).string(); auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); TRY(generated_implementation_file->write_until_depleted(generator.as_string_view().bytes())); @@ -379,7 +379,7 @@ ErrorOr serenity_main(Main::Arguments arguments) StringView output_path; StringView base_path; - Vector paths; + Vector paths; args_parser.add_option(output_path, "Path to output generated files into", "output-path", 'o', "output-path"); args_parser.add_option(base_path, "Path to root of IDL file tree", "base-path", 'b', "base-path"); @@ -392,16 +392,16 @@ ErrorOr serenity_main(Main::Arguments arguments) const LexicalPath lexical_base(base_path); // Read in all IDL files, we must own the storage for all of these for the lifetime of the program - Vector file_contents; - for (DeprecatedString const& path : paths) { + Vector file_contents; + for (ByteString const& path : paths) { auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { - s_error_string = DeprecatedString::formatted("Unable to open file {}", path); + s_error_string = ByteString::formatted("Unable to open file {}", path); return Error::from_string_view(s_error_string.view()); } auto file = file_or_error.release_value(); auto string = MUST(file->read_until_eof()); - file_contents.append(DeprecatedString(ReadonlyBytes(string))); + file_contents.append(ByteString(ReadonlyBytes(string))); } VERIFY(paths.size() == file_contents.size()); @@ -453,7 +453,7 @@ static ErrorOr parse_exposure_set(IDL::Interface& interface) auto maybe_exposed = interface.extended_attributes.get("Exposed"); if (!maybe_exposed.has_value()) { - s_error_string = DeprecatedString::formatted("Interface {} is missing extended attribute Exposed", interface.name); + s_error_string = ByteString::formatted("Interface {} is missing extended attribute Exposed", interface.name); return Error::from_string_view(s_error_string.view()); } auto exposed = maybe_exposed.value().trim_whitespace(); @@ -485,18 +485,18 @@ static ErrorOr parse_exposure_set(IDL::Interface& interface) } else if (candidate == "AudioWorklet"sv) { whom |= ExposedTo::AudioWorklet; } else { - s_error_string = DeprecatedString::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name); + s_error_string = ByteString::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name); return Error::from_string_view(s_error_string.view()); } } if (whom == ExposedTo::Nobody) { - s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name); + s_error_string = ByteString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name); return Error::from_string_view(s_error_string.view()); } return whom; } - s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name); + s_error_string = ByteString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name); return Error::from_string_view(s_error_string.view()); } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h index 3cf1c7acfbf..28c1b77d31f 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h @@ -52,7 +52,7 @@ String camel_casify(StringView dashy_name) String snake_casify(StringView dashy_name) { // FIXME: We don't really need to convert dashy_name to a String first, but currently - // all the `replace` functions that take a StringView return DeprecatedString. + // all the `replace` functions that take a StringView return ByteString. return MUST(MUST(String::from_utf8(dashy_name)).replace("-"sv, "_"sv, ReplaceMode::All)); } diff --git a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp index dac4f4d44ad..507c7f40ed9 100644 --- a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -22,8 +22,8 @@ struct Range { }; struct StateTransition { - Optional new_state; - Optional action; + Optional new_state; + Optional action; }; struct MatchedAction { @@ -32,18 +32,18 @@ struct MatchedAction { }; struct State { - DeprecatedString name; + ByteString name; Vector actions; - Optional entry_action; - Optional exit_action; + Optional entry_action; + Optional exit_action; }; struct StateMachine { - DeprecatedString name; - DeprecatedString initial_state; + ByteString name; + ByteString initial_state; Vector states; Optional anywhere; - Optional namespaces; + Optional namespaces; }; static OwnPtr @@ -159,7 +159,7 @@ parse_state_machine(StringView input) consume_whitespace(); state.exit_action = consume_identifier(); } else if (lexer.next_is('@')) { - auto directive = consume_identifier().to_deprecated_string(); + auto directive = consume_identifier().to_byte_string(); fprintf(stderr, "Unimplemented @ directive %s\n", directive.characters()); exit(1); } else { @@ -189,7 +189,7 @@ parse_state_machine(StringView input) lexer.consume_specific('@'); state_machine->anywhere = consume_state_description(); } else if (lexer.consume_specific('@')) { - auto directive = consume_identifier().to_deprecated_string(); + auto directive = consume_identifier().to_byte_string(); fprintf(stderr, "Unimplemented @ directive %s\n", directive.characters()); exit(1); } else { @@ -238,9 +238,9 @@ ErrorOr serenity_main(Main::Arguments arguments) return 0; } -HashTable actions(StateMachine const& machine) +HashTable actions(StateMachine const& machine) { - HashTable table; + HashTable table; auto do_state = [&](State const& state) { if (state.entry_action.has_value()) @@ -302,7 +302,7 @@ void output_header(StateMachine const& machine, SourceGenerator& generator) { generator.set("class_name", machine.name); generator.set("initial_state", machine.initial_state); - generator.set("state_count", DeprecatedString::number(machine.states.size() + 1)); + generator.set("state_count", ByteString::number(machine.states.size() + 1)); generator.append(R"~~~( #pragma once diff --git a/Meta/Lagom/Tools/ConfigureComponents/main.cpp b/Meta/Lagom/Tools/ConfigureComponents/main.cpp index bb2e8d3e844..b280484a996 100644 --- a/Meta/Lagom/Tools/ConfigureComponents/main.cpp +++ b/Meta/Lagom/Tools/ConfigureComponents/main.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -25,18 +25,18 @@ enum class ComponentCategory { }; struct ComponentData { - DeprecatedString name; - DeprecatedString description; + ByteString name; + ByteString description; ComponentCategory category { ComponentCategory::Optional }; bool was_selected { false }; - Vector dependencies; + Vector dependencies; bool is_selected { false }; }; struct WhiptailOption { - DeprecatedString tag; - DeprecatedString name; - DeprecatedString description; + ByteString tag; + ByteString name; + ByteString description; bool checked { false }; }; @@ -77,7 +77,7 @@ static Vector read_component_data(Core::ConfigFile const& config_ return components; } -static Result, int> run_whiptail(WhiptailMode mode, Vector const& options, StringView title, StringView description) +static Result, int> run_whiptail(WhiptailMode mode, Vector const& options, StringView title, StringView description) { struct winsize w; if (ioctl(0, TIOCGWINSZ, &w) < 0) { @@ -97,7 +97,7 @@ static Result, int> run_whiptail(WhiptailMode mode, Vec int read_fd = pipefd[0]; int write_fd = pipefd[1]; - Vector arguments = { "whiptail", "--notags", "--separate-output", "--output-fd", DeprecatedString::number(write_fd) }; + Vector arguments = { "whiptail", "--notags", "--separate-output", "--output-fd", ByteString::number(write_fd) }; if (!title.is_empty()) { arguments.append("--title"); @@ -116,13 +116,13 @@ static Result, int> run_whiptail(WhiptailMode mode, Vec } if (description.is_empty()) - arguments.append(DeprecatedString::empty()); + arguments.append(ByteString::empty()); else - arguments.append(DeprecatedString::formatted("\n {}", description)); + arguments.append(ByteString::formatted("\n {}", description)); - arguments.append(DeprecatedString::number(height)); - arguments.append(DeprecatedString::number(width)); - arguments.append(DeprecatedString::number(height - 9)); + arguments.append(ByteString::number(height)); + arguments.append(ByteString::number(width)); + arguments.append(ByteString::number(height - 9)); // Check how wide the name field needs to be. size_t max_name_width = 0; @@ -133,7 +133,7 @@ static Result, int> run_whiptail(WhiptailMode mode, Vec for (auto& option : options) { arguments.append(option.tag); - arguments.append(DeprecatedString::formatted("{:{2}} {}", option.name, option.description, max_name_width)); + arguments.append(ByteString::formatted("{:{2}} {}", option.name, option.description, max_name_width)); if (mode == WhiptailMode::Checklist) arguments.append(option.checked ? "1" : "0"); } @@ -151,7 +151,7 @@ static Result, int> run_whiptail(WhiptailMode mode, Vec return -1; } - auto full_term_variable = DeprecatedString::formatted("TERM={}", term_variable); + auto full_term_variable = ByteString::formatted("TERM={}", term_variable); auto colors = "NEWT_COLORS=root=,black\ncheckbox=black,lightgray"; char* env[3]; @@ -202,10 +202,10 @@ static Result, int> run_whiptail(WhiptailMode mode, Vec warnln("\e[31mError:\e[0m Could not read data from file descriptor: {}", data_or_error.error()); return -1; } - return DeprecatedString::copy(data_or_error.value()).split('\n'); + return ByteString::copy(data_or_error.value()).split('\n'); } -static bool run_system_command(DeprecatedString const& command, StringView command_name) +static bool run_system_command(ByteString const& command, StringView command_name) { if (command.starts_with("cmake"sv)) warnln("\e[34mRunning CMake...\e[0m"); @@ -234,7 +234,7 @@ int main() auto current_working_directory = FileSystem::current_working_directory(); if (current_working_directory.is_error()) return 1; - auto lexical_cwd = LexicalPath(current_working_directory.release_value().to_deprecated_string()); + auto lexical_cwd = LexicalPath(current_working_directory.release_value().to_byte_string()); auto& parts = lexical_cwd.parts_view(); if (parts.size() < 2 || parts[parts.size() - 2] != "Build") { warnln("\e[31mError:\e[0m This program needs to be executed from inside 'Build/*'."); @@ -281,7 +281,7 @@ int main() StringView build_type = customize ? type.substring_view(7) : type.view(); // Step 4: Customize the configuration if the user requested to. In any case, set the components component.is_selected value correctly. - Vector activated_components; + Vector activated_components; if (customize) { Vector options; @@ -297,7 +297,7 @@ int main() } // NOTE: Required components will always be preselected. - WhiptailOption option { component.name, component.name, description_builder.to_deprecated_string(), is_required }; + WhiptailOption option { component.name, component.name, description_builder.to_byte_string(), is_required }; if (build_type == "REQUIRED") { // noop } else if (build_type == "RECOMMENDED") { @@ -343,13 +343,13 @@ int main() } // Step 5: Generate the cmake command. - Vector cmake_arguments = { "cmake", "../..", "-G", "Ninja", "-DBUILD_EVERYTHING=OFF" }; + Vector cmake_arguments = { "cmake", "../..", "-G", "Ninja", "-DBUILD_EVERYTHING=OFF" }; for (auto& component : components) - cmake_arguments.append(DeprecatedString::formatted("-DBUILD_{}={}", component.name.to_uppercase(), component.is_selected ? "ON" : "OFF")); + cmake_arguments.append(ByteString::formatted("-DBUILD_{}={}", component.name.to_uppercase(), component.is_selected ? "ON" : "OFF")); warnln("\e[34mThe following command will be run:\e[0m"); outln("ninja clean \\\n && rm -rf Root \\"); - outln(" && {}", DeprecatedString::join(' ', cmake_arguments)); + outln(" && {}", ByteString::join(' ', cmake_arguments)); warn("\e[34mDo you want to run the command?\e[0m [Y/n] "); auto character = getchar(); if (character == 'n' || character == 'N') { @@ -358,7 +358,7 @@ int main() } // Step 6: Run 'ninja clean', 'rm -rf Root' and CMake - auto command = DeprecatedString::join(' ', cmake_arguments); + auto command = ByteString::join(' ', cmake_arguments); if (!run_system_command("ninja clean"sv, "Ninja"sv)) return 1; if (!run_system_command("rm -rf Root"sv, "rm"sv)) diff --git a/Meta/Lagom/Tools/IPCMagicLinter/main.cpp b/Meta/Lagom/Tools/IPCMagicLinter/main.cpp index e79937ee416..19e0666e386 100644 --- a/Meta/Lagom/Tools/IPCMagicLinter/main.cpp +++ b/Meta/Lagom/Tools/IPCMagicLinter/main.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -23,7 +23,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } // Read files, compute their hashes, ignore collisions for now. - HashMap> inverse_hashes; + HashMap> inverse_hashes; bool had_errors = false; for (auto filename : arguments.strings.slice(1)) { @@ -42,7 +42,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = file_or_error.release_value(); - DeprecatedString endpoint_name; + ByteString endpoint_name; auto const read_lines = [&]() -> ErrorOr { while (TRY(file->can_read_line())) { diff --git a/Meta/Lagom/Wasm/js_repl.cpp b/Meta/Lagom/Wasm/js_repl.cpp index ed5c78a7e9a..0eab1a3f62d 100644 --- a/Meta/Lagom/Wasm/js_repl.cpp +++ b/Meta/Lagom/Wasm/js_repl.cpp @@ -49,7 +49,7 @@ EM_JS(void, user_display, (char const* string, u32 length), { globalDisplayToUse template void display(CheckedFormatString format_string, Args const&... args) { - auto string = DeprecatedString::formatted(format_string.view(), args...); + auto string = ByteString::formatted(format_string.view(), args...); user_display(string.characters(), string.length()); } @@ -247,7 +247,7 @@ public: // 2.3. Printer(logLevel, args[, options]), https://console.spec.whatwg.org/#printer virtual JS::ThrowCompletionOr printer(JS::Console::LogLevel log_level, PrinterArguments arguments) override { - DeprecatedString indent = DeprecatedString::repeated(" "sv, m_group_stack_depth); + ByteString indent = ByteString::repeated(" "sv, m_group_stack_depth); if (log_level == JS::Console::LogLevel::Trace) { auto trace = arguments.get(); @@ -269,7 +269,7 @@ public: return JS::js_undefined(); } - auto output = DeprecatedString::join(' ', arguments.get>()); + auto output = ByteString::join(' ', arguments.get>()); switch (log_level) { case JS::Console::LogLevel::Debug: displayln("{}{}", indent, output); diff --git a/Meta/gn/secondary/AK/BUILD.gn b/Meta/gn/secondary/AK/BUILD.gn index 6e2cfdffc12..94986927c29 100644 --- a/Meta/gn/secondary/AK/BUILD.gn +++ b/Meta/gn/secondary/AK/BUILD.gn @@ -35,6 +35,7 @@ source_set("AK") { "BumpAllocator.h", "ByteBuffer.h", "ByteReader.h", + "ByteString.h", "CharacterTypes.h", "Checked.h", "CheckedFormatString.h", @@ -50,7 +51,6 @@ source_set("AK") { "DefaultDelete.h", "Demangle.h", "DeprecatedFlyString.h", - "DeprecatedString.h", "Diagnostics.h", "DisjointChunks.h", "DistinctNumeric.h", @@ -189,12 +189,12 @@ source_set("sources") { sources = [ "Assertions.cpp", "Base64.cpp", + "ByteString.cpp", "CircularBuffer.cpp", "ConstrainedStream.cpp", "CountingStream.cpp", "DOSPackedTime.cpp", "DeprecatedFlyString.cpp", - "DeprecatedString.cpp", "Error.cpp", "FloatingPointStringConversions.cpp", "FlyString.cpp", diff --git a/Meta/serenity_gdb.py b/Meta/serenity_gdb.py index 028f85e3342..9be85ec2465 100644 --- a/Meta/serenity_gdb.py +++ b/Meta/serenity_gdb.py @@ -38,7 +38,7 @@ def handler_class_for_type(type, re=re.compile('^([^<]+)(<.*>)?$')): return AKSinglyLinkedList elif klass == 'AK::String': return AKString - elif klass == 'AK::DeprecatedString': + elif klass == 'AK::ByteString': return AKDeprecatedString elif klass == 'AK::StringView': return AKStringView @@ -178,7 +178,7 @@ class AKDeprecatedString: @classmethod def prettyprint_type(cls, type): - return 'AK::DeprecatedString' + return 'AK::ByteString' class AKStringView: diff --git a/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch b/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch index 0051447a62e..69c80866a5e 100644 --- a/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch +++ b/Ports/OpenJDK/patches/0008-java.base-Enable-java.lang.Process-on-serenity.patch @@ -187,7 +187,7 @@ index 0000000000000000000000000000000000000000..9f4410816af68b2a1912255807fbbe4b + unix_getUserInfo(env, jinfo, proc.pid); + JNU_CHECK_EXCEPTION(env); + -+ auto cmdline_file = JAVA_TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/cmdline", pid), Core::File::OpenMode::Read), "Unable to open /proc/pid/cmdline"sv); ++ auto cmdline_file = JAVA_TRY(Core::File::open(ByteString::formatted("/proc/{}/cmdline", pid), Core::File::OpenMode::Read), "Unable to open /proc/pid/cmdline"sv); + auto contents = JAVA_TRY(cmdline_file->read_until_eof(), "Unable to read /proc/pid/cmdline"sv); + auto cmdline = JAVA_TRY(JsonValue::from_string(contents), "Invalid JSON in /proc/pid/cmdline"sv); + diff --git a/Tests/AK/CMakeLists.txt b/Tests/AK/CMakeLists.txt index 02dcc4ebb9d..8ccab64845e 100644 --- a/Tests/AK/CMakeLists.txt +++ b/Tests/AK/CMakeLists.txt @@ -13,13 +13,13 @@ set(AK_TEST_SOURCES TestBitStream.cpp TestBuiltinWrappers.cpp TestByteBuffer.cpp + TestByteString.cpp TestCharacterTypes.cpp TestChecked.cpp TestCircularBuffer.cpp TestCircularDeque.cpp TestCircularQueue.cpp TestComplex.cpp - TestDeprecatedString.cpp TestDisjointChunks.cpp TestDistinctNumeric.cpp TestDoublyLinkedList.cpp diff --git a/Tests/AK/TestBase64.cpp b/Tests/AK/TestBase64.cpp index f4b3d114972..02539a60612 100644 --- a/Tests/AK/TestBase64.cpp +++ b/Tests/AK/TestBase64.cpp @@ -7,14 +7,14 @@ #include #include -#include +#include #include TEST_CASE(test_decode) { auto decode_equal = [&](StringView input, StringView expected) { auto decoded = TRY_OR_FAIL(decode_base64(input)); - EXPECT(DeprecatedString::copy(decoded) == expected); + EXPECT(ByteString::copy(decoded) == expected); EXPECT(expected.length() <= calculate_base64_decoded_length(input.bytes())); }; diff --git a/Tests/AK/TestBinaryHeap.cpp b/Tests/AK/TestBinaryHeap.cpp index 8388c48d566..6b21590a2d8 100644 --- a/Tests/AK/TestBinaryHeap.cpp +++ b/Tests/AK/TestBinaryHeap.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include using namespace Test::Randomized; @@ -46,7 +46,7 @@ TEST_CASE(populate_int) TEST_CASE(populate_string) { - BinaryHeap strings; + BinaryHeap strings; strings.insert(1, "ABC"); strings.insert(2, "DEF"); EXPECT_EQ(strings.size(), 2u); diff --git a/Tests/AK/TestBinarySearch.cpp b/Tests/AK/TestBinarySearch.cpp index 4c16f67d279..4f41ac260fe 100644 --- a/Tests/AK/TestBinarySearch.cpp +++ b/Tests/AK/TestBinarySearch.cpp @@ -51,20 +51,20 @@ TEST_CASE(array_doubles) TEST_CASE(vector_strings) { - Vector strings; + Vector strings; strings.append("bat"); strings.append("cat"); strings.append("dog"); - auto string_compare = [](DeprecatedString const& a, DeprecatedString const& b) -> int { + auto string_compare = [](ByteString const& a, ByteString const& b) -> int { return strcmp(a.characters(), b.characters()); }; - auto test1 = *binary_search(strings, DeprecatedString("bat"), nullptr, string_compare); - auto test2 = *binary_search(strings, DeprecatedString("cat"), nullptr, string_compare); - auto test3 = *binary_search(strings, DeprecatedString("dog"), nullptr, string_compare); - EXPECT_EQ(test1, DeprecatedString("bat")); - EXPECT_EQ(test2, DeprecatedString("cat")); - EXPECT_EQ(test3, DeprecatedString("dog")); + auto test1 = *binary_search(strings, ByteString("bat"), nullptr, string_compare); + auto test2 = *binary_search(strings, ByteString("cat"), nullptr, string_compare); + auto test3 = *binary_search(strings, ByteString("dog"), nullptr, string_compare); + EXPECT_EQ(test1, ByteString("bat")); + EXPECT_EQ(test2, ByteString("cat")); + EXPECT_EQ(test3, ByteString("dog")); } TEST_CASE(single_element) diff --git a/Tests/AK/TestDeprecatedString.cpp b/Tests/AK/TestByteString.cpp similarity index 62% rename from Tests/AK/TestDeprecatedString.cpp rename to Tests/AK/TestByteString.cpp index 1add9f16405..2f115a1704f 100644 --- a/Tests/AK/TestDeprecatedString.cpp +++ b/Tests/AK/TestByteString.cpp @@ -6,26 +6,26 @@ #include +#include #include -#include #include #include #include TEST_CASE(construct_empty) { - EXPECT(DeprecatedString().is_empty()); - EXPECT(DeprecatedString().characters() != nullptr); + EXPECT(ByteString().is_empty()); + EXPECT(ByteString().characters() != nullptr); - EXPECT(DeprecatedString("").is_empty()); - EXPECT(DeprecatedString("").characters() != nullptr); + EXPECT(ByteString("").is_empty()); + EXPECT(ByteString("").characters() != nullptr); - EXPECT(DeprecatedString("").impl() == DeprecatedString::empty().impl()); + EXPECT(ByteString("").impl() == ByteString::empty().impl()); } TEST_CASE(construct_contents) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; EXPECT(!test_string.is_empty()); EXPECT_EQ(test_string.length(), 6u); EXPECT_EQ(test_string.length(), strlen(test_string.characters())); @@ -39,45 +39,45 @@ TEST_CASE(construct_contents) TEST_CASE(equal) { - EXPECT_EQ(DeprecatedString::empty(), DeprecatedString {}); + EXPECT_EQ(ByteString::empty(), ByteString {}); } TEST_CASE(compare) { - EXPECT("a"sv < DeprecatedString("b")); - EXPECT(!("a"sv > DeprecatedString("b"))); - EXPECT("b"sv > DeprecatedString("a")); - EXPECT(!("b"sv < DeprecatedString("b"))); - EXPECT("a"sv >= DeprecatedString("a")); - EXPECT(!("a"sv >= DeprecatedString("b"))); - EXPECT("a"sv <= DeprecatedString("a")); - EXPECT(!("b"sv <= DeprecatedString("a"))); + EXPECT("a"sv < ByteString("b")); + EXPECT(!("a"sv > ByteString("b"))); + EXPECT("b"sv > ByteString("a")); + EXPECT(!("b"sv < ByteString("b"))); + EXPECT("a"sv >= ByteString("a")); + EXPECT(!("a"sv >= ByteString("b"))); + EXPECT("a"sv <= ByteString("a")); + EXPECT(!("b"sv <= ByteString("a"))); - EXPECT(DeprecatedString("a") > DeprecatedString()); - EXPECT(!(DeprecatedString() > DeprecatedString("a"))); - EXPECT(DeprecatedString() < DeprecatedString("a")); - EXPECT(!(DeprecatedString("a") < DeprecatedString())); - EXPECT(DeprecatedString("a") >= DeprecatedString()); - EXPECT(!(DeprecatedString() >= DeprecatedString("a"))); - EXPECT(DeprecatedString() <= DeprecatedString("a")); - EXPECT(!(DeprecatedString("a") <= DeprecatedString())); + EXPECT(ByteString("a") > ByteString()); + EXPECT(!(ByteString() > ByteString("a"))); + EXPECT(ByteString() < ByteString("a")); + EXPECT(!(ByteString("a") < ByteString())); + EXPECT(ByteString("a") >= ByteString()); + EXPECT(!(ByteString() >= ByteString("a"))); + EXPECT(ByteString() <= ByteString("a")); + EXPECT(!(ByteString("a") <= ByteString())); - EXPECT(!(DeprecatedString() > DeprecatedString())); - EXPECT(!(DeprecatedString() < DeprecatedString())); - EXPECT(DeprecatedString() >= DeprecatedString()); - EXPECT(DeprecatedString() <= DeprecatedString()); + EXPECT(!(ByteString() > ByteString())); + EXPECT(!(ByteString() < ByteString())); + EXPECT(ByteString() >= ByteString()); + EXPECT(ByteString() <= ByteString()); } TEST_CASE(index_access) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; EXPECT_EQ(test_string[0], 'A'); EXPECT_EQ(test_string[1], 'B'); } TEST_CASE(starts_with) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; EXPECT(test_string.starts_with("AB"sv)); EXPECT(test_string.starts_with('A')); EXPECT(!test_string.starts_with('B')); @@ -89,7 +89,7 @@ TEST_CASE(starts_with) TEST_CASE(ends_with) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; EXPECT(test_string.ends_with("EF"sv)); EXPECT(test_string.ends_with('F')); EXPECT(!test_string.ends_with('E')); @@ -101,7 +101,7 @@ TEST_CASE(ends_with) TEST_CASE(copy_string) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; auto test_string_copy = test_string; EXPECT_EQ(test_string, test_string_copy); EXPECT_EQ(test_string.characters(), test_string_copy.characters()); @@ -109,7 +109,7 @@ TEST_CASE(copy_string) TEST_CASE(move_string) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; auto test_string_copy = test_string; auto test_string_move = move(test_string_copy); EXPECT_EQ(test_string, test_string_move); @@ -118,25 +118,25 @@ TEST_CASE(move_string) TEST_CASE(repeated) { - EXPECT_EQ(DeprecatedString::repeated('x', 0), ""); - EXPECT_EQ(DeprecatedString::repeated('x', 1), "x"); - EXPECT_EQ(DeprecatedString::repeated('x', 2), "xx"); + EXPECT_EQ(ByteString::repeated('x', 0), ""); + EXPECT_EQ(ByteString::repeated('x', 1), "x"); + EXPECT_EQ(ByteString::repeated('x', 2), "xx"); } TEST_CASE(to_int) { - EXPECT_EQ(DeprecatedString("123").to_int().value(), 123); - EXPECT_EQ(DeprecatedString("-123").to_int().value(), -123); + EXPECT_EQ(ByteString("123").to_int().value(), 123); + EXPECT_EQ(ByteString("-123").to_int().value(), -123); } TEST_CASE(to_lowercase) { - EXPECT(DeprecatedString("ABC").to_lowercase() == "abc"); + EXPECT(ByteString("ABC").to_lowercase() == "abc"); } TEST_CASE(to_uppercase) { - EXPECT(DeprecatedString("AbC").to_uppercase() == "ABC"); + EXPECT(ByteString("AbC").to_uppercase() == "ABC"); } TEST_CASE(flystring) @@ -148,12 +148,12 @@ TEST_CASE(flystring) } { - DeprecatedString a = "foo"; + ByteString a = "foo"; DeprecatedFlyString b = a; StringBuilder builder; builder.append('f'); builder.append("oo"sv); - DeprecatedFlyString c = builder.to_deprecated_string(); + DeprecatedFlyString c = builder.to_byte_string(); EXPECT_EQ(a.impl(), b.impl()); EXPECT_EQ(a.impl(), c.impl()); } @@ -161,7 +161,7 @@ TEST_CASE(flystring) TEST_CASE(replace) { - DeprecatedString test_string = "Well, hello Friends!"; + ByteString test_string = "Well, hello Friends!"; test_string = test_string.replace("Friends"sv, "Testers"sv, ReplaceMode::FirstOnly); EXPECT(test_string == "Well, hello Testers!"); @@ -172,7 +172,7 @@ TEST_CASE(replace) test_string = test_string.replace("!"sv, " :^)"sv, ReplaceMode::FirstOnly); EXPECT(test_string == "We're, he'reo Testers :^)"); - test_string = DeprecatedString("111._.111._.111"); + test_string = ByteString("111._.111._.111"); test_string = test_string.replace("111"sv, "|||"sv, ReplaceMode::All); EXPECT(test_string == "|||._.|||._.|||"); @@ -182,7 +182,7 @@ TEST_CASE(replace) TEST_CASE(count) { - DeprecatedString test_string = "Well, hello Friends!"; + ByteString test_string = "Well, hello Friends!"; u32 count = test_string.count("Friends"sv); EXPECT(count == 1); @@ -192,7 +192,7 @@ TEST_CASE(count) count = test_string.count("!"sv); EXPECT(count == 1); - test_string = DeprecatedString("111._.111._.111"); + test_string = ByteString("111._.111._.111"); count = test_string.count("111"sv); EXPECT(count == 3); @@ -202,7 +202,7 @@ TEST_CASE(count) TEST_CASE(substring) { - DeprecatedString test = "abcdef"; + ByteString test = "abcdef"; EXPECT_EQ(test.substring(0, 6), test); EXPECT_EQ(test.substring(0, 3), "abc"); EXPECT_EQ(test.substring(3, 3), "def"); @@ -212,7 +212,7 @@ TEST_CASE(substring) TEST_CASE(split) { - DeprecatedString test = "foo bar baz"; + ByteString test = "foo bar baz"; auto parts = test.split(' '); EXPECT_EQ(parts.size(), 3u); EXPECT_EQ(parts[0], "foo"); @@ -249,13 +249,13 @@ TEST_CASE(builder_zero_initial_capacity) { StringBuilder builder(0); builder.append(""sv); - auto built = builder.to_deprecated_string(); + auto built = builder.to_byte_string(); EXPECT_EQ(built.length(), 0u); } TEST_CASE(find) { - DeprecatedString a = "foobarbar"; + ByteString a = "foobarbar"; EXPECT_EQ(a.find("bar"sv), Optional { 3 }); EXPECT_EQ(a.find("baz"sv), Optional {}); EXPECT_EQ(a.find("bar"sv, 4), Optional { 6 }); @@ -271,7 +271,7 @@ TEST_CASE(find) TEST_CASE(find_with_empty_needle) { - DeprecatedString string = ""; + ByteString string = ""; EXPECT_EQ(string.find(""sv), 0u); EXPECT_EQ(string.find_all(""sv), (Vector { 0u })); @@ -282,33 +282,33 @@ TEST_CASE(find_with_empty_needle) TEST_CASE(bijective_base) { - EXPECT_EQ(DeprecatedString::bijective_base_from(0), "A"); - EXPECT_EQ(DeprecatedString::bijective_base_from(25), "Z"); - EXPECT_EQ(DeprecatedString::bijective_base_from(26), "AA"); - EXPECT_EQ(DeprecatedString::bijective_base_from(52), "BA"); - EXPECT_EQ(DeprecatedString::bijective_base_from(701), "ZZ"); - EXPECT_EQ(DeprecatedString::bijective_base_from(702), "AAA"); - EXPECT_EQ(DeprecatedString::bijective_base_from(730), "ABC"); - EXPECT_EQ(DeprecatedString::bijective_base_from(18277), "ZZZ"); + EXPECT_EQ(ByteString::bijective_base_from(0), "A"); + EXPECT_EQ(ByteString::bijective_base_from(25), "Z"); + EXPECT_EQ(ByteString::bijective_base_from(26), "AA"); + EXPECT_EQ(ByteString::bijective_base_from(52), "BA"); + EXPECT_EQ(ByteString::bijective_base_from(701), "ZZ"); + EXPECT_EQ(ByteString::bijective_base_from(702), "AAA"); + EXPECT_EQ(ByteString::bijective_base_from(730), "ABC"); + EXPECT_EQ(ByteString::bijective_base_from(18277), "ZZZ"); } TEST_CASE(roman_numerals) { - auto zero = DeprecatedString::roman_number_from(0); + auto zero = ByteString::roman_number_from(0); EXPECT_EQ(zero, ""); - auto one = DeprecatedString::roman_number_from(1); + auto one = ByteString::roman_number_from(1); EXPECT_EQ(one, "I"); - auto nine = DeprecatedString::roman_number_from(9); + auto nine = ByteString::roman_number_from(9); EXPECT_EQ(nine, "IX"); - auto fourty_eight = DeprecatedString::roman_number_from(48); + auto fourty_eight = ByteString::roman_number_from(48); EXPECT_EQ(fourty_eight, "XLVIII"); - auto one_thousand_nine_hundred_ninety_eight = DeprecatedString::roman_number_from(1998); + auto one_thousand_nine_hundred_ninety_eight = ByteString::roman_number_from(1998); EXPECT_EQ(one_thousand_nine_hundred_ninety_eight, "MCMXCVIII"); - auto four_thousand = DeprecatedString::roman_number_from(4000); + auto four_thousand = ByteString::roman_number_from(4000); EXPECT_EQ(four_thousand, "4000"); } diff --git a/Tests/AK/TestCircularDeque.cpp b/Tests/AK/TestCircularDeque.cpp index 55da938080f..a843ca7d68e 100644 --- a/Tests/AK/TestCircularDeque.cpp +++ b/Tests/AK/TestCircularDeque.cpp @@ -6,8 +6,8 @@ #include +#include #include -#include #include TEST_CASE(enqueue_begin) @@ -37,9 +37,9 @@ TEST_CASE(enqueue_begin) TEST_CASE(enqueue_begin_being_moved_from) { - CircularDeque strings; + CircularDeque strings; - DeprecatedString str { "test" }; + ByteString str { "test" }; strings.enqueue_begin(move(str)); EXPECT(str.is_empty()); } diff --git a/Tests/AK/TestCircularQueue.cpp b/Tests/AK/TestCircularQueue.cpp index 337164725d0..e3ae81b4bd1 100644 --- a/Tests/AK/TestCircularQueue.cpp +++ b/Tests/AK/TestCircularQueue.cpp @@ -6,8 +6,8 @@ #include +#include #include -#include TEST_CASE(basic) { @@ -28,7 +28,7 @@ TEST_CASE(basic) TEST_CASE(complex_type) { - CircularQueue strings; + CircularQueue strings; strings.enqueue("ABC"); strings.enqueue("DEF"); @@ -44,7 +44,7 @@ TEST_CASE(complex_type) TEST_CASE(complex_type_clear) { - CircularQueue strings; + CircularQueue strings; strings.enqueue("xxx"); strings.enqueue("xxx"); strings.enqueue("xxx"); diff --git a/Tests/AK/TestDisjointChunks.cpp b/Tests/AK/TestDisjointChunks.cpp index 15fd5319b3d..cc24d6d045a 100644 --- a/Tests/AK/TestDisjointChunks.cpp +++ b/Tests/AK/TestDisjointChunks.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include diff --git a/Tests/AK/TestFixedPoint.cpp b/Tests/AK/TestFixedPoint.cpp index a59c118225b..15683e8ba77 100644 --- a/Tests/AK/TestFixedPoint.cpp +++ b/Tests/AK/TestFixedPoint.cpp @@ -168,134 +168,134 @@ TEST_CASE(cast) TEST_CASE(formatter) { - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(123.456)), "123.455993"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-123.456)), "-123.455993"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<4>(123.456)), "123.4375"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<4>(-123.456)), "-123.4375"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16> {}), "0"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.1)), "0.100006"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.02)), "0.020004"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.003)), "0.003005"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.0004)), "0.000396"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(0.0000000005)), "0"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-0.1)), "-0.100006"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-0.02)), "-0.020004"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", FixedPoint<16>(-0.0000000005)), "0"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(123.456)), "123.455993"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-123.456)), "-123.455993"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<4>(123.456)), "123.4375"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<4>(-123.456)), "-123.4375"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16> {}), "0"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.1)), "0.100006"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.02)), "0.020004"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.003)), "0.003005"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.0004)), "0.000396"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(0.0000000005)), "0"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-0.1)), "-0.100006"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-0.02)), "-0.020004"sv); + EXPECT_EQ(ByteString::formatted("{}", FixedPoint<16>(-0.0000000005)), "0"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", Type(-1)), "-1"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", Type(-2)), "-2"sv); - EXPECT_EQ(DeprecatedString::formatted("{}", Type(-3)), "-3"sv); + EXPECT_EQ(ByteString::formatted("{}", Type(-1)), "-1"sv); + EXPECT_EQ(ByteString::formatted("{}", Type(-2)), "-2"sv); + EXPECT_EQ(ByteString::formatted("{}", Type(-3)), "-3"sv); // exact representation - EXPECT_EQ(DeprecatedString::formatted("{:.30}", FixedPoint<16>(123.456)), "123.45599365234375"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30}", FixedPoint<16>(-0.1)), "-0.100006103515625"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30}", FixedPoint<16>(-0.02)), "-0.0200042724609375"sv); + EXPECT_EQ(ByteString::formatted("{:.30}", FixedPoint<16>(123.456)), "123.45599365234375"sv); + EXPECT_EQ(ByteString::formatted("{:.30}", FixedPoint<16>(-0.1)), "-0.100006103515625"sv); + EXPECT_EQ(ByteString::formatted("{:.30}", FixedPoint<16>(-0.02)), "-0.0200042724609375"sv); // maximum fraction per precision; 1 - 2^-precision - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.99218750000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.99609375000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.99804687500000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.99902343750000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.99951171875000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.99975585937500000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.99987792968750000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.99993896484375000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.99996948242187500000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.99998474121093750000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.99999237060546875000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.99999618530273437500"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.20}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.99999809265136718750"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.99218750000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.99609375000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.99804687500000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.99902343750000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.99951171875000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.99975585937500000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.99987792968750000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.99993896484375000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.99996948242187500000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.99998474121093750000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.99999237060546875000"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.99999618530273437500"sv); + EXPECT_EQ(ByteString::formatted("{:0.20}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.99999809265136718750"sv); // maximum factor and precision >= 20 bits/digits will overflow u64: (5^20)*(2^20 - 1) > 2^64 - // EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.99999904632568359375"sv); + // EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.99999904632568359375"sv); // minimum fraction per precision; 2^-precision - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<7, u64>::create_raw(1)), "0.007812500000000000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<8, u64>::create_raw(1)), "0.003906250000000000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<9, u64>::create_raw(1)), "0.001953125000000000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<10, u64>::create_raw(1)), "0.000976562500000000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<11, u64>::create_raw(1)), "0.000488281250000000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<12, u64>::create_raw(1)), "0.000244140625000000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<13, u64>::create_raw(1)), "0.000122070312500000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<14, u64>::create_raw(1)), "0.000061035156250000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<15, u64>::create_raw(1)), "0.000030517578125000000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<16, u64>::create_raw(1)), "0.000015258789062500000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<17, u64>::create_raw(1)), "0.000007629394531250000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<18, u64>::create_raw(1)), "0.000003814697265625000000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<19, u64>::create_raw(1)), "0.000001907348632812500000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw(1)), "0.000000953674316406250000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000000476837158203125000000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<22, u64>::create_raw(1)), "0.000000238418579101562500000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<23, u64>::create_raw(1)), "0.000000119209289550781250000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<24, u64>::create_raw(1)), "0.000000059604644775390625000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<25, u64>::create_raw(1)), "0.000000029802322387695312500000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<26, u64>::create_raw(1)), "0.000000014901161193847656250000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<27, u64>::create_raw(1)), "0.000000007450580596923828125000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<7, u64>::create_raw(1)), "0.007812500000000000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<8, u64>::create_raw(1)), "0.003906250000000000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<9, u64>::create_raw(1)), "0.001953125000000000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<10, u64>::create_raw(1)), "0.000976562500000000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<11, u64>::create_raw(1)), "0.000488281250000000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<12, u64>::create_raw(1)), "0.000244140625000000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<13, u64>::create_raw(1)), "0.000122070312500000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<14, u64>::create_raw(1)), "0.000061035156250000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<15, u64>::create_raw(1)), "0.000030517578125000000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<16, u64>::create_raw(1)), "0.000015258789062500000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<17, u64>::create_raw(1)), "0.000007629394531250000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<18, u64>::create_raw(1)), "0.000003814697265625000000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<19, u64>::create_raw(1)), "0.000001907348632812500000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<20, u64>::create_raw(1)), "0.000000953674316406250000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000000476837158203125000000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<22, u64>::create_raw(1)), "0.000000238418579101562500000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<23, u64>::create_raw(1)), "0.000000119209289550781250000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<24, u64>::create_raw(1)), "0.000000059604644775390625000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<25, u64>::create_raw(1)), "0.000000029802322387695312500000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<26, u64>::create_raw(1)), "0.000000014901161193847656250000"sv); + EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<27, u64>::create_raw(1)), "0.000000007450580596923828125000"sv); // minimum factor and precision >= 28 bits/digits will overflow u64: (5^28)*(1) > 2^64 - // EXPECT_EQ(DeprecatedString::formatted("{:0.30}", AK::FixedPoint<28, u64>::create_raw(1)), "0.000000003725290298461914062500"sv); + // EXPECT_EQ(ByteString::formatted("{:0.30}", AK::FixedPoint<28, u64>::create_raw(1)), "0.000000003725290298461914062500"sv); - EXPECT_EQ(DeprecatedString::formatted("{:a}", FixedPoint<16>(42.42)), "2a.6b85"sv); - EXPECT_EQ(DeprecatedString::formatted("{:o}", FixedPoint<16>(42.42)), "52.327024"sv); - EXPECT_EQ(DeprecatedString::formatted("{:b}", FixedPoint<16>(42.42)), "101010.01101"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.10a}", FixedPoint<16>(69.69)), "45.b0a4000000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.10o}", FixedPoint<16>(69.69)), "105.5412200000"sv); - EXPECT_EQ(DeprecatedString::formatted("{:0.10b}", FixedPoint<16>(69.69)), "1000101.1011000010"sv); + EXPECT_EQ(ByteString::formatted("{:a}", FixedPoint<16>(42.42)), "2a.6b85"sv); + EXPECT_EQ(ByteString::formatted("{:o}", FixedPoint<16>(42.42)), "52.327024"sv); + EXPECT_EQ(ByteString::formatted("{:b}", FixedPoint<16>(42.42)), "101010.01101"sv); + EXPECT_EQ(ByteString::formatted("{:0.10a}", FixedPoint<16>(69.69)), "45.b0a4000000"sv); + EXPECT_EQ(ByteString::formatted("{:0.10o}", FixedPoint<16>(69.69)), "105.5412200000"sv); + EXPECT_EQ(ByteString::formatted("{:0.10b}", FixedPoint<16>(69.69)), "1000101.1011000010"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30o}", AK::FixedPoint<13, u64>::create_raw(1)), "0.00004"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0000000000001"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30o}", AK::FixedPoint<21, u64>::create_raw(0211234567)), "21.1234567"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(0b110011011010110)), "11.001101101011"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30o}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.7776"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30b}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.11111111111"sv); + EXPECT_EQ(ByteString::formatted("{:.30o}", AK::FixedPoint<13, u64>::create_raw(1)), "0.00004"sv); + EXPECT_EQ(ByteString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0000000000001"sv); + EXPECT_EQ(ByteString::formatted("{:.30o}", AK::FixedPoint<21, u64>::create_raw(0211234567)), "21.1234567"sv); + EXPECT_EQ(ByteString::formatted("{:.30b}", AK::FixedPoint<13, u64>::create_raw(0b110011011010110)), "11.001101101011"sv); + EXPECT_EQ(ByteString::formatted("{:.30o}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.7776"sv); + EXPECT_EQ(ByteString::formatted("{:.30b}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.11111111111"sv); // maximum fraction per precision rendered in hexadecimal; 1 - 2^-precision; no overflow - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.fe"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.ff"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.ff8"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.ffc"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.ffe"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.fff"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.fff8"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.fffc"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.fffe"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.ffff"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.ffff8"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.ffffc"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.ffffe"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.fffff"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw((1ull << 21) - 1)), "0.fffff8"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw((1ull << 7) - 1)), "0.fe"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw((1ull << 8) - 1)), "0.ff"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw((1ull << 9) - 1)), "0.ff8"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw((1ull << 10) - 1)), "0.ffc"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw((1ull << 11) - 1)), "0.ffe"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw((1ull << 12) - 1)), "0.fff"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw((1ull << 13) - 1)), "0.fff8"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw((1ull << 14) - 1)), "0.fffc"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw((1ull << 15) - 1)), "0.fffe"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw((1ull << 16) - 1)), "0.ffff"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw((1ull << 17) - 1)), "0.ffff8"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw((1ull << 18) - 1)), "0.ffffc"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw((1ull << 19) - 1)), "0.ffffe"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw((1ull << 20) - 1)), "0.fffff"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw((1ull << 21) - 1)), "0.fffff8"sv); // ...skip some precisions - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw((1ull << 56) - 1)), "0.ffffffffffffff"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw((1ull << 57) - 1)), "0.ffffffffffffff8"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw((1ull << 58) - 1)), "0.ffffffffffffffc"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw((1ull << 59) - 1)), "0.ffffffffffffffe"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw((1ull << 60) - 1)), "0.fffffffffffffff"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw((1ull << 61) - 1)), "0.fffffffffffffff8"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw((1ull << 62) - 1)), "0.fffffffffffffffc"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw((1ull << 63) - 1)), "0.fffffffffffffffe"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw((1ull << 56) - 1)), "0.ffffffffffffff"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw((1ull << 57) - 1)), "0.ffffffffffffff8"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw((1ull << 58) - 1)), "0.ffffffffffffffc"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw((1ull << 59) - 1)), "0.ffffffffffffffe"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw((1ull << 60) - 1)), "0.fffffffffffffff"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw((1ull << 61) - 1)), "0.fffffffffffffff8"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw((1ull << 62) - 1)), "0.fffffffffffffffc"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw((1ull << 63) - 1)), "0.fffffffffffffffe"sv); // minimum fraction per precision rendered in hexadecimal; 2^-precision; no overflow - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw(1)), "0.02"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw(1)), "0.01"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw(1)), "0.008"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw(1)), "0.004"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw(1)), "0.002"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw(1)), "0.001"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0008"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw(1)), "0.0004"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw(1)), "0.0002"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw(1)), "0.0001"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw(1)), "0.00008"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw(1)), "0.00004"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw(1)), "0.00002"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw(1)), "0.00001"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000008"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<7, u64>::create_raw(1)), "0.02"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<8, u64>::create_raw(1)), "0.01"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<9, u64>::create_raw(1)), "0.008"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<10, u64>::create_raw(1)), "0.004"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<11, u64>::create_raw(1)), "0.002"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<12, u64>::create_raw(1)), "0.001"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<13, u64>::create_raw(1)), "0.0008"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<14, u64>::create_raw(1)), "0.0004"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<15, u64>::create_raw(1)), "0.0002"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<16, u64>::create_raw(1)), "0.0001"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<17, u64>::create_raw(1)), "0.00008"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<18, u64>::create_raw(1)), "0.00004"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<19, u64>::create_raw(1)), "0.00002"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<20, u64>::create_raw(1)), "0.00001"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<21, u64>::create_raw(1)), "0.000008"sv); // ..skip some precisions - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw(1)), "0.00000000000001"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw(1)), "0.000000000000008"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw(1)), "0.000000000000004"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw(1)), "0.000000000000002"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw(1)), "0.000000000000001"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw(1)), "0.0000000000000008"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw(1)), "0.0000000000000004"sv); - EXPECT_EQ(DeprecatedString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw(1)), "0.0000000000000002"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<56, u64>::create_raw(1)), "0.00000000000001"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<57, u64>::create_raw(1)), "0.000000000000008"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<58, u64>::create_raw(1)), "0.000000000000004"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<59, u64>::create_raw(1)), "0.000000000000002"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<60, u64>::create_raw(1)), "0.000000000000001"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<61, u64>::create_raw(1)), "0.0000000000000008"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<62, u64>::create_raw(1)), "0.0000000000000004"sv); + EXPECT_EQ(ByteString::formatted("{:.30a}", AK::FixedPoint<63, u64>::create_raw(1)), "0.0000000000000002"sv); } diff --git a/Tests/AK/TestFormat.cpp b/Tests/AK/TestFormat.cpp index 32fae024a46..69b96d1ec77 100644 --- a/Tests/AK/TestFormat.cpp +++ b/Tests/AK/TestFormat.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include @@ -20,55 +20,55 @@ TEST_CASE(is_integral_works_properly) TEST_CASE(format_string_literals) { - EXPECT_EQ(DeprecatedString::formatted("prefix-{}-suffix", "abc"), "prefix-abc-suffix"); - EXPECT_EQ(DeprecatedString::formatted("{}{}{}", "a", "b", "c"), "abc"); + EXPECT_EQ(ByteString::formatted("prefix-{}-suffix", "abc"), "prefix-abc-suffix"); + EXPECT_EQ(ByteString::formatted("{}{}{}", "a", "b", "c"), "abc"); } TEST_CASE(format_integers) { - EXPECT_EQ(DeprecatedString::formatted("{}", 42u), "42"); - EXPECT_EQ(DeprecatedString::formatted("{:4}", 42u), " 42"); - EXPECT_EQ(DeprecatedString::formatted("{:08}", 42u), "00000042"); - EXPECT_EQ(DeprecatedString::formatted("{:7}", -17), " -17"); - EXPECT_EQ(DeprecatedString::formatted("{}", -17), "-17"); - EXPECT_EQ(DeprecatedString::formatted("{:04}", 13), "0013"); - EXPECT_EQ(DeprecatedString::formatted("{:08x}", 4096), "00001000"); - EXPECT_EQ(DeprecatedString::formatted("{:x}", 0x1111222233334444ull), "1111222233334444"); - EXPECT_EQ(DeprecatedString::formatted("{:4}", 12345678), "12345678"); - EXPECT_EQ(DeprecatedString::formatted("{}", AK::NumericLimits::min()), "-9223372036854775808"); - EXPECT_EQ(DeprecatedString::formatted("{:x}", AK::NumericLimits::min()), "-8000000000000000"); - EXPECT_EQ(DeprecatedString::formatted("{:'}", 0), "0"); - EXPECT_EQ(DeprecatedString::formatted("{:'}", 4096), "4,096"); - EXPECT_EQ(DeprecatedString::formatted("{:'}", 16777216), "16,777,216"); - EXPECT_EQ(DeprecatedString::formatted("{:'}", AK::NumericLimits::max()), "18,446,744,073,709,551,615"); - EXPECT_EQ(DeprecatedString::formatted("{:'}", AK::NumericLimits::max()), "18,446,744,073,709,551,615"); - EXPECT_EQ(DeprecatedString::formatted("{:'}", AK::NumericLimits::min() + 1), "-9,223,372,036,854,775,807"); - EXPECT_EQ(DeprecatedString::formatted("{:'x}", 0), "0"); - EXPECT_EQ(DeprecatedString::formatted("{:'x}", 16777216), "1,000,000"); - EXPECT_EQ(DeprecatedString::formatted("{:'x}", AK::NumericLimits::max()), "f,fff,fff,fff,fff,fff"); - EXPECT_EQ(DeprecatedString::formatted("{:'x}", AK::NumericLimits::min() + 1), "-7,fff,fff,fff,fff,fff"); - EXPECT_EQ(DeprecatedString::formatted("{:'b}", AK::NumericLimits::max()), "1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111"); + EXPECT_EQ(ByteString::formatted("{}", 42u), "42"); + EXPECT_EQ(ByteString::formatted("{:4}", 42u), " 42"); + EXPECT_EQ(ByteString::formatted("{:08}", 42u), "00000042"); + EXPECT_EQ(ByteString::formatted("{:7}", -17), " -17"); + EXPECT_EQ(ByteString::formatted("{}", -17), "-17"); + EXPECT_EQ(ByteString::formatted("{:04}", 13), "0013"); + EXPECT_EQ(ByteString::formatted("{:08x}", 4096), "00001000"); + EXPECT_EQ(ByteString::formatted("{:x}", 0x1111222233334444ull), "1111222233334444"); + EXPECT_EQ(ByteString::formatted("{:4}", 12345678), "12345678"); + EXPECT_EQ(ByteString::formatted("{}", AK::NumericLimits::min()), "-9223372036854775808"); + EXPECT_EQ(ByteString::formatted("{:x}", AK::NumericLimits::min()), "-8000000000000000"); + EXPECT_EQ(ByteString::formatted("{:'}", 0), "0"); + EXPECT_EQ(ByteString::formatted("{:'}", 4096), "4,096"); + EXPECT_EQ(ByteString::formatted("{:'}", 16777216), "16,777,216"); + EXPECT_EQ(ByteString::formatted("{:'}", AK::NumericLimits::max()), "18,446,744,073,709,551,615"); + EXPECT_EQ(ByteString::formatted("{:'}", AK::NumericLimits::max()), "18,446,744,073,709,551,615"); + EXPECT_EQ(ByteString::formatted("{:'}", AK::NumericLimits::min() + 1), "-9,223,372,036,854,775,807"); + EXPECT_EQ(ByteString::formatted("{:'x}", 0), "0"); + EXPECT_EQ(ByteString::formatted("{:'x}", 16777216), "1,000,000"); + EXPECT_EQ(ByteString::formatted("{:'x}", AK::NumericLimits::max()), "f,fff,fff,fff,fff,fff"); + EXPECT_EQ(ByteString::formatted("{:'x}", AK::NumericLimits::min() + 1), "-7,fff,fff,fff,fff,fff"); + EXPECT_EQ(ByteString::formatted("{:'b}", AK::NumericLimits::max()), "1,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111,111"); } TEST_CASE(reorder_format_arguments) { - EXPECT_EQ(DeprecatedString::formatted("{1}{0}", "a", "b"), "ba"); - EXPECT_EQ(DeprecatedString::formatted("{0}{1}", "a", "b"), "ab"); + EXPECT_EQ(ByteString::formatted("{1}{0}", "a", "b"), "ba"); + EXPECT_EQ(ByteString::formatted("{0}{1}", "a", "b"), "ab"); // Compiletime check bypass: ignoring a passed argument. - EXPECT_EQ(DeprecatedString::formatted("{0}{0}{0}"sv, "a", "b"), "aaa"); + EXPECT_EQ(ByteString::formatted("{0}{0}{0}"sv, "a", "b"), "aaa"); // Compiletime check bypass: ignoring a passed argument. - EXPECT_EQ(DeprecatedString::formatted("{1}{}{0}"sv, "a", "b", "c"), "baa"); + EXPECT_EQ(ByteString::formatted("{1}{}{0}"sv, "a", "b", "c"), "baa"); } TEST_CASE(escape_braces) { - EXPECT_EQ(DeprecatedString::formatted("{{{}", "foo"), "{foo"); - EXPECT_EQ(DeprecatedString::formatted("{}}}", "bar"), "bar}"); + EXPECT_EQ(ByteString::formatted("{{{}", "foo"), "{foo"); + EXPECT_EQ(ByteString::formatted("{}}}", "bar"), "bar}"); } TEST_CASE(everything) { - EXPECT_EQ(DeprecatedString::formatted("{{{:04}/{}/{0:8}/{1}", 42u, "foo"), "{0042/foo/ 42/foo"); + EXPECT_EQ(ByteString::formatted("{{{:04}/{}/{0:8}/{1}", 42u, "foo"), "{0042/foo/ 42/foo"); } TEST_CASE(string_builder) @@ -77,92 +77,92 @@ TEST_CASE(string_builder) builder.appendff(" {} ", 42); builder.appendff("{1}{0} ", 1, 2); - EXPECT_EQ(builder.to_deprecated_string(), " 42 21 "); + EXPECT_EQ(builder.to_byte_string(), " 42 21 "); } TEST_CASE(format_without_arguments) { - EXPECT_EQ(DeprecatedString::formatted("foo"), "foo"); + EXPECT_EQ(ByteString::formatted("foo"), "foo"); } TEST_CASE(format_upper_case_integer) { - EXPECT_EQ(DeprecatedString::formatted("{:4X}", 0xff), " FF"); - EXPECT_EQ(DeprecatedString::formatted("{:#4X}", 0xff), "0XFF"); + EXPECT_EQ(ByteString::formatted("{:4X}", 0xff), " FF"); + EXPECT_EQ(ByteString::formatted("{:#4X}", 0xff), "0XFF"); - EXPECT_EQ(DeprecatedString::formatted("{:b}", 0xff), "11111111"); - EXPECT_EQ(DeprecatedString::formatted("{:B}", 0xff), "11111111"); - EXPECT_EQ(DeprecatedString::formatted("{:#b}", 0xff), "0b11111111"); + EXPECT_EQ(ByteString::formatted("{:b}", 0xff), "11111111"); + EXPECT_EQ(ByteString::formatted("{:B}", 0xff), "11111111"); + EXPECT_EQ(ByteString::formatted("{:#b}", 0xff), "0b11111111"); } TEST_CASE(format_aligned) { - EXPECT_EQ(DeprecatedString::formatted("{:*<8}", 13), "13******"); - EXPECT_EQ(DeprecatedString::formatted("{:*^8}", 13), "***13***"); - EXPECT_EQ(DeprecatedString::formatted("{:*>8}", 13), "******13"); - EXPECT_EQ(DeprecatedString::formatted("{:*>+8}", 13), "*****+13"); - EXPECT_EQ(DeprecatedString::formatted("{:*^ 8}", 13), "** 13***"); + EXPECT_EQ(ByteString::formatted("{:*<8}", 13), "13******"); + EXPECT_EQ(ByteString::formatted("{:*^8}", 13), "***13***"); + EXPECT_EQ(ByteString::formatted("{:*>8}", 13), "******13"); + EXPECT_EQ(ByteString::formatted("{:*>+8}", 13), "*****+13"); + EXPECT_EQ(ByteString::formatted("{:*^ 8}", 13), "** 13***"); } TEST_CASE(format_octal) { - EXPECT_EQ(DeprecatedString::formatted("{:o}", 0744), "744"); - EXPECT_EQ(DeprecatedString::formatted("{:#o}", 0744), "0744"); - EXPECT_EQ(DeprecatedString::formatted("{:'o}", 054321), "54,321"); - EXPECT_EQ(DeprecatedString::formatted("{:'o}", 0567012340), "567,012,340"); + EXPECT_EQ(ByteString::formatted("{:o}", 0744), "744"); + EXPECT_EQ(ByteString::formatted("{:#o}", 0744), "0744"); + EXPECT_EQ(ByteString::formatted("{:'o}", 054321), "54,321"); + EXPECT_EQ(ByteString::formatted("{:'o}", 0567012340), "567,012,340"); } TEST_CASE(zero_pad) { - EXPECT_EQ(DeprecatedString::formatted("{: <010}", 42), "42 "); - EXPECT_EQ(DeprecatedString::formatted("{:010}", 42), "0000000042"); - EXPECT_EQ(DeprecatedString::formatted("{:/^010}", 42), "////42////"); - EXPECT_EQ(DeprecatedString::formatted("{:04x}", -32), "-0020"); - EXPECT_EQ(DeprecatedString::formatted("{:#06x}", -64), "-0x000040"); + EXPECT_EQ(ByteString::formatted("{: <010}", 42), "42 "); + EXPECT_EQ(ByteString::formatted("{:010}", 42), "0000000042"); + EXPECT_EQ(ByteString::formatted("{:/^010}", 42), "////42////"); + EXPECT_EQ(ByteString::formatted("{:04x}", -32), "-0020"); + EXPECT_EQ(ByteString::formatted("{:#06x}", -64), "-0x000040"); } TEST_CASE(replacement_field) { - EXPECT_EQ(DeprecatedString::formatted("{:*>{1}}", 13, static_cast(10)), "********13"); - EXPECT_EQ(DeprecatedString::formatted("{:*<{1}}", 7, 4), "7***"); + EXPECT_EQ(ByteString::formatted("{:*>{1}}", 13, static_cast(10)), "********13"); + EXPECT_EQ(ByteString::formatted("{:*<{1}}", 7, 4), "7***"); // Compiletime check bypass: intentionally ignoring extra arguments - EXPECT_EQ(DeprecatedString::formatted("{:{2}}"sv, -5, 8, 16), " -5"); - EXPECT_EQ(DeprecatedString::formatted("{{{:*^{1}}}}", 1, 3), "{*1*}"); - EXPECT_EQ(DeprecatedString::formatted("{:0{}}", 1, 3), "001"); + EXPECT_EQ(ByteString::formatted("{:{2}}"sv, -5, 8, 16), " -5"); + EXPECT_EQ(ByteString::formatted("{{{:*^{1}}}}", 1, 3), "{*1*}"); + EXPECT_EQ(ByteString::formatted("{:0{}}", 1, 3), "001"); } TEST_CASE(replacement_field_regression) { // FIXME: Compiletime check bypass: cannot parse '}}' correctly. - EXPECT_EQ(DeprecatedString::formatted("{:{}}"sv, "", static_cast(6)), " "); + EXPECT_EQ(ByteString::formatted("{:{}}"sv, "", static_cast(6)), " "); } TEST_CASE(complex_string_specifiers) { - EXPECT_EQ(DeprecatedString::formatted("{:.8}", "123456789"), "12345678"); - EXPECT_EQ(DeprecatedString::formatted("{:9}", "abcd"), "abcd "); - EXPECT_EQ(DeprecatedString::formatted("{:>9}", "abcd"), " abcd"); - EXPECT_EQ(DeprecatedString::formatted("{:^9}", "abcd"), " abcd "); - EXPECT_EQ(DeprecatedString::formatted("{:4.6}", "a"), "a "); - EXPECT_EQ(DeprecatedString::formatted("{:4.6}", "abcdef"), "abcdef"); - EXPECT_EQ(DeprecatedString::formatted("{:4.6}", "abcdefghi"), "abcdef"); + EXPECT_EQ(ByteString::formatted("{:.8}", "123456789"), "12345678"); + EXPECT_EQ(ByteString::formatted("{:9}", "abcd"), "abcd "); + EXPECT_EQ(ByteString::formatted("{:>9}", "abcd"), " abcd"); + EXPECT_EQ(ByteString::formatted("{:^9}", "abcd"), " abcd "); + EXPECT_EQ(ByteString::formatted("{:4.6}", "a"), "a "); + EXPECT_EQ(ByteString::formatted("{:4.6}", "abcdef"), "abcdef"); + EXPECT_EQ(ByteString::formatted("{:4.6}", "abcdefghi"), "abcdef"); } TEST_CASE(cast_integer_to_character) { - EXPECT_EQ(DeprecatedString::formatted("{:c}", static_cast('a')), "a"); - EXPECT_EQ(DeprecatedString::formatted("{:c}", static_cast('f')), "f"); + EXPECT_EQ(ByteString::formatted("{:c}", static_cast('a')), "a"); + EXPECT_EQ(ByteString::formatted("{:c}", static_cast('f')), "f"); } TEST_CASE(boolean_values) { - EXPECT_EQ(DeprecatedString::formatted("{}", true), "true"); - EXPECT_EQ(DeprecatedString::formatted("{}", false), "false"); - EXPECT_EQ(DeprecatedString::formatted("{:6}", true), "true "); - EXPECT_EQ(DeprecatedString::formatted("{:>4}", false), "false"); - EXPECT_EQ(DeprecatedString::formatted("{:d}", false), "0"); - EXPECT_EQ(DeprecatedString::formatted("{:d}", true), "1"); - EXPECT_EQ(DeprecatedString::formatted("{:#08x}", true), "0x00000001"); + EXPECT_EQ(ByteString::formatted("{}", true), "true"); + EXPECT_EQ(ByteString::formatted("{}", false), "false"); + EXPECT_EQ(ByteString::formatted("{:6}", true), "true "); + EXPECT_EQ(ByteString::formatted("{:>4}", false), "false"); + EXPECT_EQ(ByteString::formatted("{:d}", false), "0"); + EXPECT_EQ(ByteString::formatted("{:d}", true), "1"); + EXPECT_EQ(ByteString::formatted("{:#08x}", true), "0x00000001"); } TEST_CASE(pointers) @@ -170,13 +170,13 @@ TEST_CASE(pointers) void* ptr = reinterpret_cast(0x4000); if (sizeof(void*) == 4) { - EXPECT_EQ(DeprecatedString::formatted("{:p}", 32), "0x00000020"); - EXPECT_EQ(DeprecatedString::formatted("{:p}", ptr), "0x00004000"); - EXPECT_EQ(DeprecatedString::formatted("{}", ptr), "0x00004000"); + EXPECT_EQ(ByteString::formatted("{:p}", 32), "0x00000020"); + EXPECT_EQ(ByteString::formatted("{:p}", ptr), "0x00004000"); + EXPECT_EQ(ByteString::formatted("{}", ptr), "0x00004000"); } else if (sizeof(void*) == 8) { - EXPECT_EQ(DeprecatedString::formatted("{:p}", 32), "0x0000000000000020"); - EXPECT_EQ(DeprecatedString::formatted("{:p}", ptr), "0x0000000000004000"); - EXPECT_EQ(DeprecatedString::formatted("{}", ptr), "0x0000000000004000"); + EXPECT_EQ(ByteString::formatted("{:p}", 32), "0x0000000000000020"); + EXPECT_EQ(ByteString::formatted("{:p}", ptr), "0x0000000000004000"); + EXPECT_EQ(ByteString::formatted("{}", ptr), "0x0000000000004000"); } else { VERIFY_NOT_REACHED(); } @@ -188,12 +188,12 @@ TEST_CASE(pointers) // This is a bit scary, thus this test. At least this test should fail in this case. TEST_CASE(ensure_that_format_works) { - if (DeprecatedString::formatted("FAIL") != "FAIL") { + if (ByteString::formatted("FAIL") != "FAIL") { fprintf(stderr, "FAIL\n"); exit(1); } - if (DeprecatedString::formatted("{} FAIL {}", 1, 2) != "1 FAIL 2") { + if (ByteString::formatted("{} FAIL {}", 1, 2) != "1 FAIL 2") { fprintf(stderr, "FAIL\n"); exit(1); } @@ -202,13 +202,13 @@ TEST_CASE(ensure_that_format_works) TEST_CASE(format_string_literal_as_pointer) { char const* literal = "abc"; - EXPECT_EQ(DeprecatedString::formatted("{:p}", literal), DeprecatedString::formatted("{:p}", reinterpret_cast(literal))); + EXPECT_EQ(ByteString::formatted("{:p}", literal), ByteString::formatted("{:p}", reinterpret_cast(literal))); } TEST_CASE(format_character) { char a = 'a'; - EXPECT_EQ(DeprecatedString::formatted("{}", true ? a : 'b'), "a"); + EXPECT_EQ(ByteString::formatted("{}", true ? a : 'b'), "a"); } struct A { @@ -225,8 +225,8 @@ struct AK::Formatter : Formatter { TEST_CASE(format_if_supported) { - EXPECT_EQ(DeprecatedString::formatted("{}", FormatIfSupported { A {} }), "?"); - EXPECT_EQ(DeprecatedString::formatted("{}", FormatIfSupported { B {} }), "B"); + EXPECT_EQ(ByteString::formatted("{}", FormatIfSupported { A {} }), "?"); + EXPECT_EQ(ByteString::formatted("{}", FormatIfSupported { B {} }), "B"); } TEST_CASE(file_descriptor) @@ -254,39 +254,39 @@ TEST_CASE(file_descriptor) TEST_CASE(floating_point_numbers) { - EXPECT_EQ(DeprecatedString::formatted("{}", 1.12), "1.12"); - EXPECT_EQ(DeprecatedString::formatted("{}", 1.), "1"); - EXPECT_EQ(DeprecatedString::formatted("{:.3}", 1.12), "1.12"); - EXPECT_EQ(DeprecatedString::formatted("{:.1}", 1.12), "1.1"); - EXPECT_EQ(DeprecatedString::formatted("{}", -1.12), "-1.12"); - EXPECT_EQ(DeprecatedString::formatted("{:'.4}", 1234.5678), "1,234.5678"); - EXPECT_EQ(DeprecatedString::formatted("{:'.4}", -1234.5678), "-1,234.5678"); + EXPECT_EQ(ByteString::formatted("{}", 1.12), "1.12"); + EXPECT_EQ(ByteString::formatted("{}", 1.), "1"); + EXPECT_EQ(ByteString::formatted("{:.3}", 1.12), "1.12"); + EXPECT_EQ(ByteString::formatted("{:.1}", 1.12), "1.1"); + EXPECT_EQ(ByteString::formatted("{}", -1.12), "-1.12"); + EXPECT_EQ(ByteString::formatted("{:'.4}", 1234.5678), "1,234.5678"); + EXPECT_EQ(ByteString::formatted("{:'.4}", -1234.5678), "-1,234.5678"); - EXPECT_EQ(DeprecatedString::formatted("{:.30f}", 1.0), "1.000000000000000000000000000000"); - EXPECT_EQ(DeprecatedString::formatted("{:.30f}", 1.5), "1.500000000000000000000000000000"); - EXPECT_EQ(DeprecatedString::formatted("{:.30f}", -2.0), "-2.000000000000000000000000000000"); + EXPECT_EQ(ByteString::formatted("{:.30f}", 1.0), "1.000000000000000000000000000000"); + EXPECT_EQ(ByteString::formatted("{:.30f}", 1.5), "1.500000000000000000000000000000"); + EXPECT_EQ(ByteString::formatted("{:.30f}", -2.0), "-2.000000000000000000000000000000"); - EXPECT_EQ(DeprecatedString::formatted("{:.0f}", 1.4), "1"); - EXPECT_EQ(DeprecatedString::formatted("{:.0f}", 1.5), "2"); - EXPECT_EQ(DeprecatedString::formatted("{:.0f}", -1.9), "-2"); + EXPECT_EQ(ByteString::formatted("{:.0f}", 1.4), "1"); + EXPECT_EQ(ByteString::formatted("{:.0f}", 1.5), "2"); + EXPECT_EQ(ByteString::formatted("{:.0f}", -1.9), "-2"); - EXPECT_EQ(DeprecatedString::formatted("{:.1f}", 1.4), "1.4"); - EXPECT_EQ(DeprecatedString::formatted("{:.1f}", 1.99), "2.0"); - EXPECT_EQ(DeprecatedString::formatted("{:.1f}", 9.999), "10.0"); + EXPECT_EQ(ByteString::formatted("{:.1f}", 1.4), "1.4"); + EXPECT_EQ(ByteString::formatted("{:.1f}", 1.99), "2.0"); + EXPECT_EQ(ByteString::formatted("{:.1f}", 9.999), "10.0"); - EXPECT_EQ(DeprecatedString::formatted("{}", NAN), "nan"); - EXPECT_EQ(DeprecatedString::formatted("{}", INFINITY), "inf"); - EXPECT_EQ(DeprecatedString::formatted("{}", -INFINITY), "-inf"); + EXPECT_EQ(ByteString::formatted("{}", NAN), "nan"); + EXPECT_EQ(ByteString::formatted("{}", INFINITY), "inf"); + EXPECT_EQ(ByteString::formatted("{}", -INFINITY), "-inf"); // FIXME: There is always the question what we mean with the width field. Do we mean significant digits? // Do we mean the whole width? This is what was the simplest to implement: - EXPECT_EQ(DeprecatedString::formatted("{:x>5.1}", 1.12), "xx1.1"); + EXPECT_EQ(ByteString::formatted("{:x>5.1}", 1.12), "xx1.1"); } TEST_CASE(floating_point_default_precision) { #define EXPECT_FORMAT(lit, value) \ - EXPECT_EQ(DeprecatedString::formatted("{}", lit), value##sv) + EXPECT_EQ(ByteString::formatted("{}", lit), value##sv) EXPECT_FORMAT(10.3f, "10.3"); EXPECT_FORMAT(123e4f, "1230000"); @@ -307,24 +307,24 @@ TEST_CASE(floating_point_default_precision) TEST_CASE(no_precision_no_trailing_number) { - EXPECT_EQ(DeprecatedString::formatted("{:.0}", 0.1), "0"); + EXPECT_EQ(ByteString::formatted("{:.0}", 0.1), "0"); } TEST_CASE(precision_with_trailing_zeros) { - EXPECT_EQ(DeprecatedString::formatted("{:0.3}", 1.12), "1.120"); - EXPECT_EQ(DeprecatedString::formatted("{:0.1}", 1.12), "1.1"); + EXPECT_EQ(ByteString::formatted("{:0.3}", 1.12), "1.120"); + EXPECT_EQ(ByteString::formatted("{:0.1}", 1.12), "1.1"); } TEST_CASE(magnitude_less_than_zero) { - EXPECT_EQ(DeprecatedString::formatted("{}", -0.654), "-0.654"); - EXPECT_EQ(DeprecatedString::formatted("{}", 0.654), "0.654"); + EXPECT_EQ(ByteString::formatted("{}", -0.654), "-0.654"); + EXPECT_EQ(ByteString::formatted("{}", 0.654), "0.654"); } TEST_CASE(format_nullptr) { - EXPECT_EQ(DeprecatedString::formatted("{}", nullptr), DeprecatedString::formatted("{:p}", static_cast(0))); + EXPECT_EQ(ByteString::formatted("{}", nullptr), ByteString::formatted("{:p}", static_cast(0))); } struct C { @@ -340,12 +340,12 @@ struct AK::Formatter : AK::Formatter { TEST_CASE(use_format_string_formatter) { - EXPECT_EQ(DeprecatedString::formatted("{:*<10}", C { 42 }), "C(i=42)***"); + EXPECT_EQ(ByteString::formatted("{:*<10}", C { 42 }), "C(i=42)***"); } TEST_CASE(long_long_regression) { - EXPECT_EQ(DeprecatedString::formatted("{}", 0x0123456789abcdefLL), "81985529216486895"); + EXPECT_EQ(ByteString::formatted("{}", 0x0123456789abcdefLL), "81985529216486895"); StringBuilder builder; AK::FormatBuilder fmtbuilder { builder }; @@ -356,28 +356,28 @@ TEST_CASE(long_long_regression) TEST_CASE(hex_dump) { - EXPECT_EQ(DeprecatedString::formatted("{:hex-dump}", "0000"), "30303030"); - EXPECT_EQ(DeprecatedString::formatted("{:>4hex-dump}", "0000"), "30303030 0000"); - EXPECT_EQ(DeprecatedString::formatted("{:>2hex-dump}", "0000"), "3030 00\n3030 00"); - EXPECT_EQ(DeprecatedString::formatted("{:*>4hex-dump}", "0000"), "30303030****0000"); + EXPECT_EQ(ByteString::formatted("{:hex-dump}", "0000"), "30303030"); + EXPECT_EQ(ByteString::formatted("{:>4hex-dump}", "0000"), "30303030 0000"); + EXPECT_EQ(ByteString::formatted("{:>2hex-dump}", "0000"), "3030 00\n3030 00"); + EXPECT_EQ(ByteString::formatted("{:*>4hex-dump}", "0000"), "30303030****0000"); } TEST_CASE(span_format) { { Vector v { 1, 2, 3, 4 }; - EXPECT_EQ(DeprecatedString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]"); - EXPECT_EQ(DeprecatedString::formatted("{}", const_cast&>(v).span()), "[ 1, 2, 3, 4 ]"); + EXPECT_EQ(ByteString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]"); + EXPECT_EQ(ByteString::formatted("{}", const_cast&>(v).span()), "[ 1, 2, 3, 4 ]"); } { Vector v { "1"sv, "2"sv, "3"sv, "4"sv }; - EXPECT_EQ(DeprecatedString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]"); - EXPECT_EQ(DeprecatedString::formatted("{}", const_cast&>(v).span()), "[ 1, 2, 3, 4 ]"); + EXPECT_EQ(ByteString::formatted("{}", v.span()), "[ 1, 2, 3, 4 ]"); + EXPECT_EQ(ByteString::formatted("{}", const_cast&>(v).span()), "[ 1, 2, 3, 4 ]"); } { - Vector> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } }; - EXPECT_EQ(DeprecatedString::formatted("{}", v.span()), "[ [ 1, 2 ], [ 3, 4 ] ]"); - EXPECT_EQ(DeprecatedString::formatted("{}", const_cast&>(v).span()), "[ [ 1, 2 ], [ 3, 4 ] ]"); + Vector> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } }; + EXPECT_EQ(ByteString::formatted("{}", v.span()), "[ [ 1, 2 ], [ 3, 4 ] ]"); + EXPECT_EQ(ByteString::formatted("{}", const_cast&>(v).span()), "[ [ 1, 2 ], [ 3, 4 ] ]"); } } @@ -385,28 +385,28 @@ TEST_CASE(vector_format) { { Vector v { 1, 2, 3, 4 }; - EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ 1, 2, 3, 4 ]"); + EXPECT_EQ(ByteString::formatted("{}", v), "[ 1, 2, 3, 4 ]"); } { Vector v { "1"sv, "2"sv, "3"sv, "4"sv }; - EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ 1, 2, 3, 4 ]"); + EXPECT_EQ(ByteString::formatted("{}", v), "[ 1, 2, 3, 4 ]"); } { - Vector> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } }; - EXPECT_EQ(DeprecatedString::formatted("{}", v), "[ [ 1, 2 ], [ 3, 4 ] ]"); + Vector> v { { "1"sv, "2"sv }, { "3"sv, "4"sv } }; + EXPECT_EQ(ByteString::formatted("{}", v), "[ [ 1, 2 ], [ 3, 4 ] ]"); } } TEST_CASE(format_wchar) { - EXPECT_EQ(DeprecatedString::formatted("{}", L'a'), "a"); - EXPECT_EQ(DeprecatedString::formatted("{}", L'\U0001F41E'), "\xF0\x9F\x90\x9E"); - EXPECT_EQ(DeprecatedString::formatted("{:x}", L'a'), "61"); - EXPECT_EQ(DeprecatedString::formatted("{:x}", L'\U0001F41E'), "1f41e"); - EXPECT_EQ(DeprecatedString::formatted("{:d}", L'a'), "97"); - EXPECT_EQ(DeprecatedString::formatted("{:d}", L'\U0001F41E'), "128030"); + EXPECT_EQ(ByteString::formatted("{}", L'a'), "a"); + EXPECT_EQ(ByteString::formatted("{}", L'\U0001F41E'), "\xF0\x9F\x90\x9E"); + EXPECT_EQ(ByteString::formatted("{:x}", L'a'), "61"); + EXPECT_EQ(ByteString::formatted("{:x}", L'\U0001F41E'), "1f41e"); + EXPECT_EQ(ByteString::formatted("{:d}", L'a'), "97"); + EXPECT_EQ(ByteString::formatted("{:d}", L'\U0001F41E'), "128030"); - EXPECT_EQ(DeprecatedString::formatted("{:6}", L'a'), "a "); - EXPECT_EQ(DeprecatedString::formatted("{:6d}", L'a'), " 97"); - EXPECT_EQ(DeprecatedString::formatted("{:#x}", L'\U0001F41E'), "0x1f41e"); + EXPECT_EQ(ByteString::formatted("{:6}", L'a'), "a "); + EXPECT_EQ(ByteString::formatted("{:6d}", L'a'), " 97"); + EXPECT_EQ(ByteString::formatted("{:#x}", L'\U0001F41E'), "0x1f41e"); } diff --git a/Tests/AK/TestHashMap.cpp b/Tests/AK/TestHashMap.cpp index df7c5560a89..776e8e48bff 100644 --- a/Tests/AK/TestHashMap.cpp +++ b/Tests/AK/TestHashMap.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ TEST_CASE(construct) TEST_CASE(construct_from_initializer_list) { - HashMap number_to_string { + HashMap number_to_string { { 1, "One" }, { 2, "Two" }, { 3, "Three" }, @@ -31,7 +31,7 @@ TEST_CASE(construct_from_initializer_list) TEST_CASE(populate) { - HashMap number_to_string; + HashMap number_to_string; number_to_string.set(1, "One"); number_to_string.set(2, "Two"); number_to_string.set(3, "Three"); @@ -42,7 +42,7 @@ TEST_CASE(populate) TEST_CASE(range_loop) { - HashMap number_to_string; + HashMap number_to_string; EXPECT_EQ(number_to_string.set(1, "One"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(number_to_string.set(2, "Two"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(number_to_string.set(3, "Three"), AK::HashSetResult::InsertedNewEntry); @@ -57,7 +57,7 @@ TEST_CASE(range_loop) TEST_CASE(map_remove) { - HashMap number_to_string; + HashMap number_to_string; EXPECT_EQ(number_to_string.set(1, "One"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(number_to_string.set(2, "Two"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(number_to_string.set(3, "Three"), AK::HashSetResult::InsertedNewEntry); @@ -74,7 +74,7 @@ TEST_CASE(map_remove) TEST_CASE(remove_all_matching) { - HashMap map; + HashMap map; map.set(1, "One"); map.set(2, "Two"); @@ -83,27 +83,27 @@ TEST_CASE(remove_all_matching) EXPECT_EQ(map.size(), 4u); - EXPECT_EQ(map.remove_all_matching([&](int key, DeprecatedString const& value) { return key == 1 || value == "Two"; }), true); + EXPECT_EQ(map.remove_all_matching([&](int key, ByteString const& value) { return key == 1 || value == "Two"; }), true); EXPECT_EQ(map.size(), 2u); - EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return false; }), false); + EXPECT_EQ(map.remove_all_matching([&](int, ByteString const&) { return false; }), false); EXPECT_EQ(map.size(), 2u); EXPECT(map.contains(3)); EXPECT(map.contains(4)); - EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return true; }), true); - EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return false; }), false); + EXPECT_EQ(map.remove_all_matching([&](int, ByteString const&) { return true; }), true); + EXPECT_EQ(map.remove_all_matching([&](int, ByteString const&) { return false; }), false); EXPECT(map.is_empty()); - EXPECT_EQ(map.remove_all_matching([&](int, DeprecatedString const&) { return true; }), false); + EXPECT_EQ(map.remove_all_matching([&](int, ByteString const&) { return true; }), false); } TEST_CASE(case_insensitive) { - HashMap casemap; - EXPECT_EQ(DeprecatedString("nickserv").to_lowercase(), DeprecatedString("NickServ").to_lowercase()); + HashMap casemap; + EXPECT_EQ(ByteString("nickserv").to_lowercase(), ByteString("NickServ").to_lowercase()); EXPECT_EQ(casemap.set("nickserv", 3), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(casemap.set("NickServ", 3), AK::HashSetResult::ReplacedExistingEntry); EXPECT_EQ(casemap.size(), 1u); @@ -120,11 +120,11 @@ TEST_CASE(case_insensitive_stringview) TEST_CASE(hashmap_of_nonnullownptr_get) { struct Object { - Object(DeprecatedString const& s) + Object(ByteString const& s) : string(s) { } - DeprecatedString string; + ByteString string; }; HashMap> objects; @@ -151,16 +151,16 @@ TEST_CASE(hashmap_of_nonnullownptr_get) TEST_CASE(many_strings) { - HashMap strings; + HashMap strings; for (int i = 0; i < 999; ++i) { - EXPECT_EQ(strings.set(DeprecatedString::number(i), i), AK::HashSetResult::InsertedNewEntry); + EXPECT_EQ(strings.set(ByteString::number(i), i), AK::HashSetResult::InsertedNewEntry); } EXPECT_EQ(strings.size(), 999u); for (auto& it : strings) { EXPECT_EQ(it.key.to_int().value(), it.value); } for (int i = 0; i < 999; ++i) { - EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true); + EXPECT_EQ(strings.remove(ByteString::number(i)), true); } EXPECT_EQ(strings.is_empty(), true); } @@ -213,7 +213,7 @@ TEST_CASE(basic_contains) TEST_CASE(in_place_rehashing_ordered_loop_bug) { - OrderedHashMap map; + OrderedHashMap map; map.set("yt.innertube::nextId", ""); map.set("yt.innertube::requests", ""); map.remove("yt.innertube::nextId"); diff --git a/Tests/AK/TestHashTable.cpp b/Tests/AK/TestHashTable.cpp index d1ca5d1788c..fd75f4e5a29 100644 --- a/Tests/AK/TestHashTable.cpp +++ b/Tests/AK/TestHashTable.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ TEST_CASE(move_is_not_swap) TEST_CASE(populate) { - HashTable strings; + HashTable strings; strings.set("One"); strings.set("Two"); strings.set("Three"); @@ -57,7 +57,7 @@ TEST_CASE(populate) TEST_CASE(range_loop) { - HashTable strings; + HashTable strings; EXPECT_EQ(strings.set("One"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(strings.set("Two"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(strings.set("Three"), AK::HashSetResult::InsertedNewEntry); @@ -73,7 +73,7 @@ TEST_CASE(range_loop) TEST_CASE(range_loop_reverse) { Array strings = { "One"sv, "Two"sv, "Three"sv }; - OrderedHashTable table; + OrderedHashTable table; EXPECT_EQ(table.set(strings[0]), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(table.set(strings[1]), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(table.set(strings[2]), AK::HashSetResult::InsertedNewEntry); @@ -90,7 +90,7 @@ TEST_CASE(range_loop_reverse) TEST_CASE(table_remove) { - HashTable strings; + HashTable strings; EXPECT_EQ(strings.set("One"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(strings.set("Two"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(strings.set("Three"), AK::HashSetResult::InsertedNewEntry); @@ -133,8 +133,8 @@ TEST_CASE(remove_all_matching) TEST_CASE(case_insensitive) { - HashTable casetable; - EXPECT_EQ(DeprecatedString("nickserv").to_lowercase(), DeprecatedString("NickServ").to_lowercase()); + HashTable casetable; + EXPECT_EQ(ByteString("nickserv").to_lowercase(), ByteString("NickServ").to_lowercase()); EXPECT_EQ(casetable.set("nickserv"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(casetable.set("NickServ"), AK::HashSetResult::ReplacedExistingEntry); EXPECT_EQ(casetable.size(), 1u); @@ -142,33 +142,33 @@ TEST_CASE(case_insensitive) TEST_CASE(many_strings) { - HashTable strings; + HashTable strings; for (int i = 0; i < 999; ++i) { - EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry); + EXPECT_EQ(strings.set(ByteString::number(i)), AK::HashSetResult::InsertedNewEntry); } EXPECT_EQ(strings.size(), 999u); for (int i = 0; i < 999; ++i) { - EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true); + EXPECT_EQ(strings.remove(ByteString::number(i)), true); } EXPECT_EQ(strings.is_empty(), true); } TEST_CASE(many_collisions) { - struct StringCollisionTraits : public DefaultTraits { - static unsigned hash(DeprecatedString const&) { return 0; } + struct StringCollisionTraits : public DefaultTraits { + static unsigned hash(ByteString const&) { return 0; } }; - HashTable strings; + HashTable strings; for (int i = 0; i < 999; ++i) { - EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry); + EXPECT_EQ(strings.set(ByteString::number(i)), AK::HashSetResult::InsertedNewEntry); } EXPECT_EQ(strings.set("foo"), AK::HashSetResult::InsertedNewEntry); EXPECT_EQ(strings.size(), 1000u); for (int i = 0; i < 999; ++i) { - EXPECT_EQ(strings.remove(DeprecatedString::number(i)), true); + EXPECT_EQ(strings.remove(ByteString::number(i)), true); } EXPECT(strings.find("foo") != strings.end()); @@ -176,24 +176,24 @@ TEST_CASE(many_collisions) TEST_CASE(space_reuse) { - struct StringCollisionTraits : public DefaultTraits { - static unsigned hash(DeprecatedString const&) { return 0; } + struct StringCollisionTraits : public DefaultTraits { + static unsigned hash(ByteString const&) { return 0; } }; - HashTable strings; + HashTable strings; // Add a few items to allow it to do initial resizing. EXPECT_EQ(strings.set("0"), AK::HashSetResult::InsertedNewEntry); for (int i = 1; i < 5; ++i) { - EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry); - EXPECT_EQ(strings.remove(DeprecatedString::number(i - 1)), true); + EXPECT_EQ(strings.set(ByteString::number(i)), AK::HashSetResult::InsertedNewEntry); + EXPECT_EQ(strings.remove(ByteString::number(i - 1)), true); } auto capacity = strings.capacity(); for (int i = 5; i < 999; ++i) { - EXPECT_EQ(strings.set(DeprecatedString::number(i)), AK::HashSetResult::InsertedNewEntry); - EXPECT_EQ(strings.remove(DeprecatedString::number(i - 1)), true); + EXPECT_EQ(strings.set(ByteString::number(i)), AK::HashSetResult::InsertedNewEntry); + EXPECT_EQ(strings.remove(ByteString::number(i - 1)), true); } EXPECT_EQ(strings.capacity(), capacity); @@ -301,7 +301,7 @@ TEST_CASE(doubles) TEST_CASE(reinsertion) { - OrderedHashTable map; + OrderedHashTable map; map.set("ytidb::LAST_RESULT_ENTRY_KEY"); map.set("__sak"); map.remove("__sak"); @@ -445,7 +445,7 @@ TEST_CASE(ordered_remove_from_head) TEST_CASE(ordered_infinite_loop_clang_regression) { - OrderedHashTable map; + OrderedHashTable map; map.set(""); map.set("1"); map.set("_cb"); diff --git a/Tests/AK/TestIPv4Address.cpp b/Tests/AK/TestIPv4Address.cpp index aaac975daa3..e352db12b17 100644 --- a/Tests/AK/TestIPv4Address.cpp +++ b/Tests/AK/TestIPv4Address.cpp @@ -61,7 +61,7 @@ TEST_CASE(should_convert_to_string) { constexpr IPv4Address addr(1, 25, 39, 42); - EXPECT_EQ("1.25.39.42", addr.to_deprecated_string()); + EXPECT_EQ("1.25.39.42", addr.to_byte_string()); } TEST_CASE(should_make_ipv4_address_from_string) diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp index 7527868ae7e..906c4f03570 100644 --- a/Tests/AK/TestJSON.cpp +++ b/Tests/AK/TestJSON.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include @@ -14,7 +14,7 @@ TEST_CASE(load_form) { - DeprecatedString raw_form_json = R"( + ByteString raw_form_json = R"( { "name": "Form1", "widgets": [ @@ -40,7 +40,7 @@ TEST_CASE(load_form) EXPECT(form_json.is_object()); - auto name = form_json.as_object().get_deprecated_string("name"sv); + auto name = form_json.as_object().get_byte_string("name"sv); EXPECT(name.has_value()); EXPECT_EQ(name.value(), "Form1"); @@ -50,7 +50,7 @@ TEST_CASE(load_form) widgets->for_each([&](JsonValue const& widget_value) { auto& widget_object = widget_value.as_object(); - auto widget_class = widget_object.get_deprecated_string("class"sv).value(); + auto widget_class = widget_object.get_byte_string("class"sv).value(); widget_object.for_each_member([&]([[maybe_unused]] auto& property_name, [[maybe_unused]] const JsonValue& property_value) { }); }); @@ -109,13 +109,13 @@ TEST_CASE(json_duplicate_keys) json.set("test", "foo"); json.set("test", "bar"); json.set("test", "baz"); - EXPECT_EQ(json.to_deprecated_string(), "{\"test\":\"baz\"}"); + EXPECT_EQ(json.to_byte_string(), "{\"test\":\"baz\"}"); } TEST_CASE(json_u64_roundtrip) { auto big_value = 0xffffffffffffffffull; - auto json = JsonValue(big_value).to_deprecated_string(); + auto json = JsonValue(big_value).to_byte_string(); auto value = JsonValue::from_string(json); EXPECT_EQ_FORCE(value.is_error(), false); EXPECT_EQ(value.value().as_u64(), big_value); @@ -292,7 +292,7 @@ private: TEST_CASE(fallible_json_object_for_each) { - DeprecatedString raw_json = R"( + ByteString raw_json = R"( { "name": "anon", "home": "/home/anon", @@ -332,7 +332,7 @@ TEST_CASE(fallible_json_object_for_each) TEST_CASE(fallible_json_array_for_each) { - DeprecatedString raw_json = R"( + ByteString raw_json = R"( [ "anon", "/home/anon", @@ -489,7 +489,7 @@ TEST_CASE(json_array_serialize) auto array = json_value.as_array(); StringBuilder builder {}; array.serialize(builder); - EXPECT_EQ(builder.to_deprecated_string(), raw_json); + EXPECT_EQ(builder.to_byte_string(), raw_json); } TEST_CASE(json_array_values) diff --git a/Tests/AK/TestLexicalPath.cpp b/Tests/AK/TestLexicalPath.cpp index 23875af3d9a..b81d0147c18 100644 --- a/Tests/AK/TestLexicalPath.cpp +++ b/Tests/AK/TestLexicalPath.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include TEST_CASE(relative_path) diff --git a/Tests/AK/TestMACAddress.cpp b/Tests/AK/TestMACAddress.cpp index 04e0a72282d..dd1a347f52e 100644 --- a/Tests/AK/TestMACAddress.cpp +++ b/Tests/AK/TestMACAddress.cpp @@ -80,7 +80,7 @@ TEST_CASE(should_equality_compare) TEST_CASE(should_string_format) { MACAddress sut(1, 2, 3, 4, 5, 6); - EXPECT_EQ("01:02:03:04:05:06", sut.to_deprecated_string()); + EXPECT_EQ("01:02:03:04:05:06", sut.to_byte_string()); } TEST_CASE(should_make_mac_address_from_string_numbers) diff --git a/Tests/AK/TestMemory.cpp b/Tests/AK/TestMemory.cpp index b1a17caa6ef..9ee9d4e69e4 100644 --- a/Tests/AK/TestMemory.cpp +++ b/Tests/AK/TestMemory.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include @@ -78,9 +78,9 @@ TEST_CASE(kmp_two_chunks) TEST_CASE(timing_safe_compare) { - DeprecatedString data_set = "abcdefghijklmnopqrstuvwxyz123456789"; + ByteString data_set = "abcdefghijklmnopqrstuvwxyz123456789"; EXPECT_EQ(true, AK::timing_safe_compare(data_set.characters(), data_set.characters(), data_set.length())); - DeprecatedString reversed = data_set.reverse(); + ByteString reversed = data_set.reverse(); EXPECT_EQ(false, AK::timing_safe_compare(data_set.characters(), reversed.characters(), reversed.length())); } diff --git a/Tests/AK/TestNonnullOwnPtr.cpp b/Tests/AK/TestNonnullOwnPtr.cpp index 233c65fa6ee..bc37322937a 100644 --- a/Tests/AK/TestNonnullOwnPtr.cpp +++ b/Tests/AK/TestNonnullOwnPtr.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include diff --git a/Tests/AK/TestNonnullRefPtr.cpp b/Tests/AK/TestNonnullRefPtr.cpp index 60621b4b487..268f5abcb12 100644 --- a/Tests/AK/TestNonnullRefPtr.cpp +++ b/Tests/AK/TestNonnullRefPtr.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include diff --git a/Tests/AK/TestOptional.cpp b/Tests/AK/TestOptional.cpp index 99c1da21532..5c75b5b84cd 100644 --- a/Tests/AK/TestOptional.cpp +++ b/Tests/AK/TestOptional.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include @@ -59,7 +59,7 @@ TEST_CASE(optional_rvalue_ref_qualified_getters) TEST_CASE(optional_leak_1) { struct Structure { - Optional str; + Optional str; }; // This used to leak, it does not anymore. @@ -81,7 +81,7 @@ TEST_CASE(comparison_without_values) { Optional opt0; Optional opt1; - Optional opt2; + Optional opt2; EXPECT_EQ(opt0, opt1); EXPECT_EQ(opt0, opt2); } @@ -90,7 +90,7 @@ TEST_CASE(comparison_with_values) { Optional opt0; Optional opt1 = "foo"sv; - Optional opt2 = "foo"sv; + Optional opt2 = "foo"sv; Optional opt3 = "bar"sv; EXPECT_NE(opt0, opt1); EXPECT_EQ(opt1, opt2); @@ -99,14 +99,14 @@ TEST_CASE(comparison_with_values) TEST_CASE(comparison_to_underlying_types) { - Optional opt0; - EXPECT_NE(opt0, DeprecatedString()); + Optional opt0; + EXPECT_NE(opt0, ByteString()); EXPECT_NE(opt0, "foo"); Optional opt1 = "foo"sv; EXPECT_EQ(opt1, "foo"); EXPECT_NE(opt1, "bar"); - EXPECT_EQ(opt1, DeprecatedString("foo")); + EXPECT_EQ(opt1, ByteString("foo")); } TEST_CASE(comparison_with_numeric_types) @@ -262,7 +262,7 @@ TEST_CASE(comparison_reference) StringView test = "foo"sv; Optional opt0; Optional opt1 = test; - Optional opt2 = "foo"sv; + Optional opt2 = "foo"sv; Optional opt3 = "bar"sv; EXPECT_NE(opt0, opt1); diff --git a/Tests/AK/TestQueue.cpp b/Tests/AK/TestQueue.cpp index 2e527925c84..25384bc1bdb 100644 --- a/Tests/AK/TestQueue.cpp +++ b/Tests/AK/TestQueue.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include TEST_CASE(construct) @@ -32,7 +32,7 @@ TEST_CASE(populate_int) TEST_CASE(populate_string) { - Queue strings; + Queue strings; strings.enqueue("ABC"); strings.enqueue("DEF"); EXPECT_EQ(strings.size(), 2u); @@ -43,11 +43,11 @@ TEST_CASE(populate_string) TEST_CASE(order) { - Queue strings; + Queue strings; EXPECT(strings.is_empty()); for (size_t i = 0; i < 10000; ++i) { - strings.enqueue(DeprecatedString::number(i)); + strings.enqueue(ByteString::number(i)); EXPECT_EQ(strings.size(), i + 1); } diff --git a/Tests/AK/TestRefPtr.cpp b/Tests/AK/TestRefPtr.cpp index 20c3e10bec0..6eac893eaa4 100644 --- a/Tests/AK/TestRefPtr.cpp +++ b/Tests/AK/TestRefPtr.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include struct Object : public RefCounted { diff --git a/Tests/AK/TestStack.cpp b/Tests/AK/TestStack.cpp index a48f43d5968..be19c50721a 100644 --- a/Tests/AK/TestStack.cpp +++ b/Tests/AK/TestStack.cpp @@ -26,7 +26,7 @@ TEST_CASE(basic) TEST_CASE(complex_type) { - AK::Stack stack; + AK::Stack stack; EXPECT_EQ(stack.is_empty(), true); EXPECT(stack.push("Well")); diff --git a/Tests/AK/TestStringUtils.cpp b/Tests/AK/TestStringUtils.cpp index d4b0765378e..7339311b79a 100644 --- a/Tests/AK/TestStringUtils.cpp +++ b/Tests/AK/TestStringUtils.cpp @@ -22,11 +22,11 @@ TEST_CASE(hash_compatible) static_assert(AK::Concepts::HashCompatible); static_assert(AK::Concepts::HashCompatible); - static_assert(AK::Concepts::HashCompatible); - static_assert(AK::Concepts::HashCompatible); - static_assert(AK::Concepts::HashCompatible); + static_assert(AK::Concepts::HashCompatible); + static_assert(AK::Concepts::HashCompatible); + static_assert(AK::Concepts::HashCompatible); static_assert(AK::Concepts::HashCompatible); - static_assert(AK::Concepts::HashCompatible); + static_assert(AK::Concepts::HashCompatible); static_assert(AK::Concepts::HashCompatible); static_assert(AK::Concepts::HashCompatible); @@ -328,7 +328,7 @@ TEST_CASE(convert_to_floating_point) TEST_CASE(ends_with) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; EXPECT(AK::StringUtils::ends_with(test_string, "DEF"sv, CaseSensitivity::CaseSensitive)); EXPECT(AK::StringUtils::ends_with(test_string, "ABCDEF"sv, CaseSensitivity::CaseSensitive)); EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDE"sv, CaseSensitivity::CaseSensitive)); @@ -339,7 +339,7 @@ TEST_CASE(ends_with) TEST_CASE(starts_with) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; EXPECT(AK::StringUtils::starts_with(test_string, "ABC"sv, CaseSensitivity::CaseSensitive)); EXPECT(AK::StringUtils::starts_with(test_string, "ABCDEF"sv, CaseSensitivity::CaseSensitive)); EXPECT(!AK::StringUtils::starts_with(test_string, "BCDEF"sv, CaseSensitivity::CaseSensitive)); @@ -350,7 +350,7 @@ TEST_CASE(starts_with) TEST_CASE(contains) { - DeprecatedString test_string = "ABCDEFABCXYZ"; + ByteString test_string = "ABCDEFABCXYZ"; EXPECT(AK::StringUtils::contains(test_string, "ABC"sv, CaseSensitivity::CaseSensitive)); EXPECT(AK::StringUtils::contains(test_string, "ABC"sv, CaseSensitivity::CaseInsensitive)); EXPECT(AK::StringUtils::contains(test_string, "AbC"sv, CaseSensitivity::CaseInsensitive)); @@ -368,7 +368,7 @@ TEST_CASE(contains) EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseSensitive)); EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseInsensitive)); - DeprecatedString command_palette_bug_string = "Go Go Back"; + ByteString command_palette_bug_string = "Go Go Back"; EXPECT(AK::StringUtils::contains(command_palette_bug_string, "Go Back"sv, AK::CaseSensitivity::CaseSensitive)); EXPECT(AK::StringUtils::contains(command_palette_bug_string, "gO bAcK"sv, AK::CaseSensitivity::CaseInsensitive)); } @@ -397,7 +397,7 @@ TEST_CASE(trim) TEST_CASE(find) { - DeprecatedString test_string = "1234567"; + ByteString test_string = "1234567"; EXPECT_EQ(AK::StringUtils::find(test_string, "1"sv).value_or(1), 0u); EXPECT_EQ(AK::StringUtils::find(test_string, "2"sv).value_or(2), 1u); EXPECT_EQ(AK::StringUtils::find(test_string, "3"sv).value_or(3), 2u); diff --git a/Tests/AK/TestStringView.cpp b/Tests/AK/TestStringView.cpp index bc098bc1378..1487b848301 100644 --- a/Tests/AK/TestStringView.cpp +++ b/Tests/AK/TestStringView.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include TEST_CASE(construct_empty) @@ -29,8 +29,8 @@ TEST_CASE(view_literal) TEST_CASE(compare_views) { - DeprecatedString foo1 = "foo"; - DeprecatedString foo2 = "foo"; + ByteString foo1 = "foo"; + ByteString foo2 = "foo"; auto view1 = foo1.view(); auto view2 = foo2.view(); @@ -43,7 +43,7 @@ TEST_CASE(compare_views) TEST_CASE(string_view_literal_operator) { StringView literal_view = "foo"sv; - DeprecatedString test_string = "foo"; + ByteString test_string = "foo"; EXPECT_EQ(literal_view.length(), test_string.length()); EXPECT_EQ(literal_view, test_string); @@ -51,7 +51,7 @@ TEST_CASE(string_view_literal_operator) TEST_CASE(starts_with) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; StringView test_string_view = test_string.view(); EXPECT(test_string_view.starts_with('A')); EXPECT(!test_string_view.starts_with('B')); @@ -64,7 +64,7 @@ TEST_CASE(starts_with) TEST_CASE(ends_with) { - DeprecatedString test_string = "ABCDEF"; + ByteString test_string = "ABCDEF"; StringView test_string_view = test_string.view(); EXPECT(test_string_view.ends_with("DEF"sv)); EXPECT(test_string_view.ends_with('F')); @@ -78,23 +78,23 @@ TEST_CASE(ends_with) TEST_CASE(lines) { - DeprecatedString test_string = "a\rb\nc\r\nd"; + ByteString test_string = "a\rb\nc\r\nd"; StringView test_string_view = test_string.view(); Vector test_string_vector = test_string_view.lines(); EXPECT_EQ(test_string_vector.size(), 4u); - EXPECT(test_string_vector.at(0) == DeprecatedString("a")); - EXPECT(test_string_vector.at(1) == DeprecatedString("b")); - EXPECT(test_string_vector.at(2) == DeprecatedString("c")); - EXPECT(test_string_vector.at(3) == DeprecatedString("d")); + EXPECT(test_string_vector.at(0) == ByteString("a")); + EXPECT(test_string_vector.at(1) == ByteString("b")); + EXPECT(test_string_vector.at(2) == ByteString("c")); + EXPECT(test_string_vector.at(3) == ByteString("d")); test_string = "```\nHello there\r\nHello there\n```"; test_string_view = test_string.view(); test_string_vector = test_string_view.lines(); EXPECT_EQ(test_string_vector.size(), 4u); - EXPECT(test_string_vector.at(0) == DeprecatedString("```")); - EXPECT(test_string_vector.at(1) == DeprecatedString("Hello there")); - EXPECT(test_string_vector.at(2) == DeprecatedString("Hello there")); - EXPECT(test_string_vector.at(3) == DeprecatedString("```")); + EXPECT(test_string_vector.at(0) == ByteString("```")); + EXPECT(test_string_vector.at(1) == ByteString("Hello there")); + EXPECT(test_string_vector.at(2) == ByteString("Hello there")); + EXPECT(test_string_vector.at(3) == ByteString("```")); test_string = "\n\n\n"; test_string_view = test_string.view(); diff --git a/Tests/AK/TestTrie.cpp b/Tests/AK/TestTrie.cpp index c698ae35492..7fbdfb9f664 100644 --- a/Tests/AK/TestTrie.cpp +++ b/Tests/AK/TestTrie.cpp @@ -11,12 +11,12 @@ TEST_CASE(normal_behavior) { - Trie dictionary('/', ""); + Trie dictionary('/', ""); constexpr StringView data[] { "test"sv, "example"sv, "foo"sv, "foobar"sv }; constexpr size_t total_chars = 18; // root (1), 'test' (4), 'example' (7), 'foo' (3), 'foobar' (3, "foo" already stored). for (auto& view : data) { auto it = view.begin(); - MUST(dictionary.insert(it, view.end(), view, [](auto& parent, auto& it) -> Optional { return DeprecatedString::formatted("{}{}", parent.metadata_value(), *it); })); + MUST(dictionary.insert(it, view.end(), view, [](auto& parent, auto& it) -> Optional { return ByteString::formatted("{}{}", parent.metadata_value(), *it); })); } size_t i = 0; diff --git a/Tests/AK/TestTuple.cpp b/Tests/AK/TestTuple.cpp index 1690f77905f..258c28dc081 100644 --- a/Tests/AK/TestTuple.cpp +++ b/Tests/AK/TestTuple.cpp @@ -10,41 +10,41 @@ TEST_CASE(basic) { - Tuple value { 1, "foo" }; + Tuple value { 1, "foo" }; EXPECT_EQ(value.get(), 1); - EXPECT_EQ(value.get(), "foo"); + EXPECT_EQ(value.get(), "foo"); EXPECT_EQ(value.get<0>(), 1); EXPECT_EQ(value.get<1>(), "foo"); // Move assignment value = { 2, "bar" }; EXPECT_EQ(value.get(), 2); - EXPECT_EQ(value.get(), "bar"); + EXPECT_EQ(value.get(), "bar"); EXPECT_EQ(value.get<0>(), 2); EXPECT_EQ(value.get<1>(), "bar"); // Copy ctor auto other_value { value }; EXPECT_EQ(other_value.get(), 2); - EXPECT_EQ(other_value.get(), "bar"); + EXPECT_EQ(other_value.get(), "bar"); EXPECT_EQ(other_value.get<0>(), 2); EXPECT_EQ(other_value.get<1>(), "bar"); // Move ctor auto moved_to_value { move(value) }; EXPECT_EQ(moved_to_value.get(), 2); - EXPECT_EQ(moved_to_value.get(), "bar"); + EXPECT_EQ(moved_to_value.get(), "bar"); EXPECT_EQ(moved_to_value.get<0>(), 2); EXPECT_EQ(moved_to_value.get<1>(), "bar"); // Copy assignment value = moved_to_value; EXPECT_EQ(moved_to_value.get(), 2); - EXPECT_EQ(moved_to_value.get(), "bar"); + EXPECT_EQ(moved_to_value.get(), "bar"); EXPECT_EQ(moved_to_value.get<0>(), 2); EXPECT_EQ(moved_to_value.get<1>(), "bar"); EXPECT_EQ(value.get(), 2); - EXPECT_EQ(value.get(), "bar"); + EXPECT_EQ(value.get(), "bar"); EXPECT_EQ(value.get<0>(), 2); EXPECT_EQ(value.get<1>(), "bar"); } @@ -68,12 +68,12 @@ TEST_CASE(no_copy) TEST_CASE(apply) { - Tuple args { 1, 2, "foo" }; + Tuple args { 1, 2, "foo" }; // With copy { bool was_called = false; - args.apply_as_args([&](int a, int b, DeprecatedString c) { + args.apply_as_args([&](int a, int b, ByteString c) { was_called = true; EXPECT_EQ(a, 1); EXPECT_EQ(b, 2); @@ -85,7 +85,7 @@ TEST_CASE(apply) // With reference { bool was_called = false; - args.apply_as_args([&](int& a, int& b, DeprecatedString& c) { + args.apply_as_args([&](int& a, int& b, ByteString& c) { was_called = true; EXPECT_EQ(a, 1); EXPECT_EQ(b, 2); @@ -98,7 +98,7 @@ TEST_CASE(apply) { bool was_called = false; auto const& args_ref = args; - args_ref.apply_as_args([&](int const& a, int const& b, DeprecatedString const& c) { + args_ref.apply_as_args([&](int const& a, int const& b, ByteString const& c) { was_called = true; EXPECT_EQ(a, 1); EXPECT_EQ(b, 2); diff --git a/Tests/AK/TestURL.cpp b/Tests/AK/TestURL.cpp index 8589c896acd..aed1bf7e6d0 100644 --- a/Tests/AK/TestURL.cpp +++ b/Tests/AK/TestURL.cpp @@ -412,21 +412,21 @@ TEST_CASE(leading_whitespace) { URL url { " https://foo.com/"sv }; EXPECT(url.is_valid()); - EXPECT_EQ(url.to_deprecated_string(), "https://foo.com/"); + EXPECT_EQ(url.to_byte_string(), "https://foo.com/"); } TEST_CASE(trailing_whitespace) { URL url { "https://foo.com/ "sv }; EXPECT(url.is_valid()); - EXPECT_EQ(url.to_deprecated_string(), "https://foo.com/"); + EXPECT_EQ(url.to_byte_string(), "https://foo.com/"); } TEST_CASE(leading_and_trailing_whitespace) { URL url { " https://foo.com/ "sv }; EXPECT(url.is_valid()); - EXPECT_EQ(url.to_deprecated_string(), "https://foo.com/"); + EXPECT_EQ(url.to_byte_string(), "https://foo.com/"); } TEST_CASE(unicode) diff --git a/Tests/AK/TestUtf8.cpp b/Tests/AK/TestUtf8.cpp index 8dcc7d67fb3..bc0d5b24ee3 100644 --- a/Tests/AK/TestUtf8.cpp +++ b/Tests/AK/TestUtf8.cpp @@ -34,7 +34,7 @@ TEST_CASE(decode_utf8) EXPECT(valid_bytes == (size_t)utf8.byte_length()); u32 expected[] = { 1055, 1088, 1080, 1074, 1077, 1090, 44, 32, 1084, 1080, 1088, 33, 32, 128512, 32, 947, 949, 953, 940, 32, 963, 959, 965, 32, 954, 972, 963, 956, 959, 962, 32, 12371, 12435, 12395, 12385, 12399, 19990, 30028 }; - DeprecatedString expected_underlying_bytes[] = { "П", "р", "и", "в", "е", "т", ",", " ", "м", "и", "р", "!", " ", "😀", " ", "γ", "ε", "ι", "ά", " ", "σ", "ο", "υ", " ", "κ", "ό", "σ", "μ", "ο", "ς", " ", "こ", "ん", "に", "ち", "は", "世", "界" }; + ByteString expected_underlying_bytes[] = { "П", "р", "и", "в", "е", "т", ",", " ", "м", "и", "р", "!", " ", "😀", " ", "γ", "ε", "ι", "ά", " ", "σ", "ο", "υ", " ", "κ", "ό", "σ", "μ", "ο", "ς", " ", "こ", "ん", "に", "ち", "は", "世", "界" }; size_t expected_size = sizeof(expected) / sizeof(expected[0]); size_t i = 0; @@ -166,7 +166,7 @@ TEST_CASE(decode_invalid_ut8) char raw_data[] = { 'a', 'b', (char)0xA0, 'd' }; Utf8View view { StringView { raw_data, 4 } }; u32 expected_characters[] = { 'a', 'b', 0xFFFD, 'd' }; - DeprecatedString expected_underlying_bytes[] = { "a", "b", "\xA0", "d" }; + ByteString expected_underlying_bytes[] = { "a", "b", "\xA0", "d" }; size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]); size_t i = 0; for (auto it = view.begin(); it != view.end(); ++it) { @@ -184,7 +184,7 @@ TEST_CASE(decode_invalid_ut8) char raw_data[] = { 'a', 'b', (char)0xC0, 'd', 'e' }; Utf8View view { StringView { raw_data, 5 } }; u32 expected_characters[] = { 'a', 'b', 0xFFFD, 'd', 'e' }; - DeprecatedString expected_underlying_bytes[] = { "a", "b", "\xC0", "d", "e" }; + ByteString expected_underlying_bytes[] = { "a", "b", "\xC0", "d", "e" }; size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]); size_t i = 0; for (auto it = view.begin(); it != view.end(); ++it) { @@ -202,7 +202,7 @@ TEST_CASE(decode_invalid_ut8) char raw_data[] = { 'a', 'b', (char)0x90, 'd' }; Utf8View view { StringView { raw_data, 4 } }; u32 expected_characters[] = { 'a', 'b', 0xFFFD, 'd' }; - DeprecatedString expected_underlying_bytes[] = { "a", "b", "\x90", "d" }; + ByteString expected_underlying_bytes[] = { "a", "b", "\x90", "d" }; size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]); size_t i = 0; for (auto it = view.begin(); it != view.end(); ++it) { @@ -220,7 +220,7 @@ TEST_CASE(decode_invalid_ut8) char raw_data[] = { 'a', 'b', 'c', (char)0x90 }; Utf8View view { StringView { raw_data, 4 } }; u32 expected_characters[] = { 'a', 'b', 'c', 0xFFFD }; - DeprecatedString expected_underlying_bytes[] = { "a", "b", "c", "\x90" }; + ByteString expected_underlying_bytes[] = { "a", "b", "c", "\x90" }; size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]); size_t i = 0; for (auto it = view.begin(); it != view.end(); ++it) { @@ -247,7 +247,7 @@ TEST_CASE(decode_invalid_ut8) // https://www.unicode.org/versions/Unicode14.0.0/ch03.pdf , section "U+FFFD Substitution of Maximal Subparts" // However, that would go against how we deal with several other kinds of errors, so we stick to emitting only one U+FFFD. u32 expected_characters[] = { 'a', 0xFFFD, 'b' }; - DeprecatedString expected_underlying_bytes[] = { "a", "\xF4\xA3\x91\x96", "b" }; + ByteString expected_underlying_bytes[] = { "a", "\xF4\xA3\x91\x96", "b" }; size_t expected_size = sizeof(expected_characters) / sizeof(expected_characters[0]); size_t i = 0; for (auto it = view.begin(); it != view.end(); ++it) { diff --git a/Tests/AK/TestVariant.cpp b/Tests/AK/TestVariant.cpp index 1e075758f69..d965a85c7d3 100644 --- a/Tests/AK/TestVariant.cpp +++ b/Tests/AK/TestVariant.cpp @@ -18,21 +18,21 @@ struct Object : public RefCounted { TEST_CASE(basic) { - Variant the_value { 42 }; + Variant the_value { 42 }; EXPECT(the_value.has()); EXPECT_EQ(the_value.get(), 42); - the_value = DeprecatedString("42"); - EXPECT(the_value.has()); - EXPECT_EQ(the_value.get(), "42"); + the_value = ByteString("42"); + EXPECT(the_value.has()); + EXPECT_EQ(the_value.get(), "42"); } TEST_CASE(visit) { bool correct = false; - Variant the_value { 42.0f }; + Variant the_value { 42.0f }; the_value.visit( [&](int const&) { correct = false; }, - [&](DeprecatedString const&) { correct = false; }, + [&](ByteString const&) { correct = false; }, [&](float const&) { correct = true; }); EXPECT(correct); } @@ -40,10 +40,10 @@ TEST_CASE(visit) TEST_CASE(visit_const) { bool correct = false; - Variant const the_value { "42"sv }; + Variant const the_value { "42"sv }; the_value.visit( - [&](DeprecatedString const&) { correct = true; }, + [&](ByteString const&) { correct = true; }, [&](auto&) {}, [&](auto const&) {}); @@ -52,7 +52,7 @@ TEST_CASE(visit_const) correct = false; auto the_value_but_not_const = the_value; the_value_but_not_const.visit( - [&](DeprecatedString const&) { correct = true; }, + [&](ByteString const&) { correct = true; }, [&](auto&) {}); EXPECT(correct); @@ -168,13 +168,13 @@ TEST_CASE(duplicated_types) TEST_CASE(return_values) { - using MyVariant = Variant; + using MyVariant = Variant; { MyVariant the_value { 42.0f }; float value = the_value.visit( [&](int const&) { return 1.0f; }, - [&](DeprecatedString const&) { return 2.0f; }, + [&](ByteString const&) { return 2.0f; }, [&](float const& f) { return f; }); EXPECT_EQ(value, 42.0f); } @@ -183,17 +183,17 @@ TEST_CASE(return_values) int value = the_value.visit( [&](int& i) { return i; }, - [&](DeprecatedString&) { return 2; }, + [&](ByteString&) { return 2; }, [&](float&) { return 3; }); EXPECT_EQ(value, 42); } { const MyVariant the_value { "str" }; - DeprecatedString value = the_value.visit( - [&](int const&) { return DeprecatedString { "wrong" }; }, - [&](DeprecatedString const& s) { return s; }, - [&](float const&) { return DeprecatedString { "wrong" }; }); + ByteString value = the_value.visit( + [&](int const&) { return ByteString { "wrong" }; }, + [&](ByteString const& s) { return s; }, + [&](float const&) { return ByteString { "wrong" }; }); EXPECT_EQ(value, "str"); } } @@ -201,11 +201,11 @@ TEST_CASE(return_values) TEST_CASE(return_values_by_reference) { auto ref = adopt_ref_if_nonnull(new (nothrow) Object()); - Variant the_value { 42.0f }; + Variant the_value { 42.0f }; auto& value = the_value.visit( [&](int const&) -> RefPtr& { return ref; }, - [&](DeprecatedString const&) -> RefPtr& { return ref; }, + [&](ByteString const&) -> RefPtr& { return ref; }, [&](float const&) -> RefPtr& { return ref; }); EXPECT_EQ(ref, value); @@ -223,7 +223,7 @@ struct HoldsFloat { TEST_CASE(copy_assign) { { - Variant the_value { 42.0f }; + Variant the_value { 42.0f }; VERIFY(the_value.has()); EXPECT_EQ(the_value.get(), 42.0f); @@ -233,12 +233,12 @@ TEST_CASE(copy_assign) VERIFY(the_value.has()); EXPECT_EQ(the_value.get(), 12); - the_value = DeprecatedString("Hello, world!"); - VERIFY(the_value.has()); - EXPECT_EQ(the_value.get(), "Hello, world!"); + the_value = ByteString("Hello, world!"); + VERIFY(the_value.has()); + EXPECT_EQ(the_value.get(), "Hello, world!"); } { - Variant the_value { HoldsFloat { 42.0f } }; + Variant the_value { HoldsFloat { 42.0f } }; VERIFY(the_value.has()); EXPECT_EQ(the_value.get().f, 42.0f); @@ -248,9 +248,9 @@ TEST_CASE(copy_assign) VERIFY(the_value.has()); EXPECT_EQ(the_value.get().i, 12); - the_value = DeprecatedString("Hello, world!"); - VERIFY(the_value.has()); - EXPECT_EQ(the_value.get(), "Hello, world!"); + the_value = ByteString("Hello, world!"); + VERIFY(the_value.has()); + EXPECT_EQ(the_value.get(), "Hello, world!"); } } diff --git a/Tests/AK/TestVector.cpp b/Tests/AK/TestVector.cpp index edbd451dd78..4250f29356d 100644 --- a/Tests/AK/TestVector.cpp +++ b/Tests/AK/TestVector.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include @@ -38,18 +38,18 @@ TEST_CASE(ints) TEST_CASE(strings) { - Vector strings; + Vector strings; strings.append("ABC"); strings.append("DEF"); int loop_counter = 0; - for (DeprecatedString const& string : strings) { + for (ByteString const& string : strings) { EXPECT(!string.is_empty()); ++loop_counter; } loop_counter = 0; - for (auto& string : (const_cast const&>(strings))) { + for (auto& string : (const_cast const&>(strings))) { EXPECT(!string.is_empty()); ++loop_counter; } @@ -58,7 +58,7 @@ TEST_CASE(strings) TEST_CASE(strings_insert_ordered) { - Vector strings; + Vector strings; strings.append("abc"); strings.append("def"); strings.append("ghi"); @@ -161,12 +161,12 @@ TEST_CASE(vector_compare) EXPECT_EQ(ints.size(), 1000u); EXPECT_EQ(ints, same_ints); - Vector strings; - Vector same_strings; + Vector strings; + Vector same_strings; for (int i = 0; i < 1000; ++i) { - strings.append(DeprecatedString::number(i)); - same_strings.append(DeprecatedString::number(i)); + strings.append(ByteString::number(i)); + same_strings.append(ByteString::number(i)); } EXPECT_EQ(strings.size(), 1000u); @@ -176,9 +176,9 @@ TEST_CASE(vector_compare) TEST_CASE(grow_past_inline_capacity) { auto make_vector = [] { - Vector strings; + Vector strings; for (int i = 0; i < 32; ++i) { - strings.append(DeprecatedString::number(i)); + strings.append(ByteString::number(i)); } return strings; }; @@ -284,7 +284,7 @@ TEST_CASE(remove_all_matching) TEST_CASE(nonnullownptrvector) { struct Object { - DeprecatedString string; + ByteString string; }; Vector> objects; diff --git a/Tests/AK/TestWeakPtr.cpp b/Tests/AK/TestWeakPtr.cpp index b673294585b..3c44aae5f2f 100644 --- a/Tests/AK/TestWeakPtr.cpp +++ b/Tests/AK/TestWeakPtr.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include diff --git a/Tests/JSSpecCompiler/test-runner.cpp b/Tests/JSSpecCompiler/test-runner.cpp index f926ea40806..eaedb29d4c1 100644 --- a/Tests/JSSpecCompiler/test-runner.cpp +++ b/Tests/JSSpecCompiler/test-runner.cpp @@ -49,9 +49,9 @@ static const LexicalPath path_to_compiler_binary = [] { }(); static const LexicalPath path_to_tests_directory { relative_path_to_test }; -Vector build_command_line_arguments(LexicalPath const& test_source, TestDescription const& description) +Vector build_command_line_arguments(LexicalPath const& test_source, TestDescription const& description) { - Vector result; + Vector result; StringBuilder dump_ast_option; StringBuilder dump_cfg_option; @@ -69,9 +69,9 @@ Vector build_command_line_arguments(LexicalPath const& test_so } } if (!dump_ast_option.is_empty()) - result.append(DeprecatedString::formatted("--dump-ast={}", dump_ast_option.string_view())); + result.append(ByteString::formatted("--dump-ast={}", dump_ast_option.string_view())); if (!dump_cfg_option.is_empty()) - result.append(DeprecatedString::formatted("--dump-cfg={}", dump_cfg_option.string_view())); + result.append(ByteString::formatted("--dump-cfg={}", dump_cfg_option.string_view())); if (test_source.has_extension(".cpp"sv)) result.append("-xc++"sv); @@ -149,7 +149,7 @@ TEST_CASE(test_regression) dbgln("Running {}...", source); auto path_to_test = LexicalPath::join(path_to_tests_directory.string(), source); - auto path_to_expectation = LexicalPath::join(path_to_tests_directory.string(), DeprecatedString::formatted("{}.expectation", source)); + auto path_to_expectation = LexicalPath::join(path_to_tests_directory.string(), ByteString::formatted("{}.expectation", source)); auto process = MUST(Core::Process::spawn({ .path = path_to_compiler_binary.string(), diff --git a/Tests/Kernel/TestKernelFilePermissions.cpp b/Tests/Kernel/TestKernelFilePermissions.cpp index 12b7831d0a1..70da9deb497 100644 --- a/Tests/Kernel/TestKernelFilePermissions.cpp +++ b/Tests/Kernel/TestKernelFilePermissions.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -81,11 +81,11 @@ TEST_CASE(test_change_file_location) ftruncate(fd, 0); EXPECT(fchmod(fd, 06755) != -1); - auto suid_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto suid_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto suid_path = suid_path_string.to_deprecated_string(); + auto suid_path = suid_path_string.to_byte_string(); EXPECT(suid_path.characters()); - auto new_path = DeprecatedString::formatted("{}.renamed", suid_path); + auto new_path = ByteString::formatted("{}.renamed", suid_path); rename(suid_path.characters(), new_path.characters()); diff --git a/Tests/Kernel/TestKernelPledge.cpp b/Tests/Kernel/TestKernelPledge.cpp index 89ff01e5a0b..6cc45ae7090 100644 --- a/Tests/Kernel/TestKernelPledge.cpp +++ b/Tests/Kernel/TestKernelPledge.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -18,7 +18,7 @@ TEST_CASE(test_nonexistent_pledge) TEST_CASE(test_pledge_argument_validation) { - auto const long_argument = DeprecatedString::repeated('a', 2048); + auto const long_argument = ByteString::repeated('a', 2048); auto res = pledge(long_argument.characters(), "stdio"); EXPECT_EQ(res, -1); diff --git a/Tests/Kernel/crash.cpp b/Tests/Kernel/crash.cpp index 608926b1946..0c128f437ab 100644 --- a/Tests/Kernel/crash.cpp +++ b/Tests/Kernel/crash.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #if ARCH(X86_64) # include diff --git a/Tests/Kernel/fuzz-syscalls.cpp b/Tests/Kernel/fuzz-syscalls.cpp index aab8ab49377..aefa2ef6b3a 100644 --- a/Tests/Kernel/fuzz-syscalls.cpp +++ b/Tests/Kernel/fuzz-syscalls.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -101,7 +101,7 @@ static void do_weird_call(size_t attempt, int syscall_fn, size_t arg1, size_t ar builder.appendff("{:p}", fake_params[i]); } builder.append(']'); - dbgln("{}", builder.to_deprecated_string()); + dbgln("{}", builder.to_byte_string()); // Actually do the syscall ('fake_params' is passed indirectly, if any of arg1, arg2, or arg3 point to it. int rc = syscall(Syscall::Function(syscall_fn), arg1, arg2, arg3); diff --git a/Tests/Kernel/stress-truncate.cpp b/Tests/Kernel/stress-truncate.cpp index 1e066155c5a..72803ca8f1e 100644 --- a/Tests/Kernel/stress-truncate.cpp +++ b/Tests/Kernel/stress-truncate.cpp @@ -18,7 +18,7 @@ int main(int argc, char** argv) for (auto i = 0; i < argc; ++i) arguments.append({ argv[i], strlen(argv[i]) }); - DeprecatedString target; + ByteString target; int max_file_size = 1024 * 1024; int count = 1024; diff --git a/Tests/Kernel/stress-writeread.cpp b/Tests/Kernel/stress-writeread.cpp index 352cdb16af6..f8cfdb8010c 100644 --- a/Tests/Kernel/stress-writeread.cpp +++ b/Tests/Kernel/stress-writeread.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) for (auto i = 0; i < argc; ++i) arguments.append({ argv[i], strlen(argv[i]) }); - DeprecatedString target; + ByteString target; int min_block_offset = 0; int block_length = 2048; int block_size = 512; diff --git a/Tests/LibAudio/TestFLACSpec.cpp b/Tests/LibAudio/TestFLACSpec.cpp index 34c8dd06cff..6192064c1e6 100644 --- a/Tests/LibAudio/TestFLACSpec.cpp +++ b/Tests/LibAudio/TestFLACSpec.cpp @@ -17,21 +17,21 @@ struct DiscoverFLACTestsHack { auto path = LexicalPath::join(directory.path().string(), entry.name); if (path.extension() == "flac"sv) { Test::add_test_case_to_suite(adopt_ref(*new ::Test::TestCase( - DeprecatedString::formatted("flac_spec_test_{}", path.basename()), + ByteString::formatted("flac_spec_test_{}", path.basename()), [path = move(path)]() { auto file = Core::File::open(path.string(), Core::File::OpenMode::Read); if (file.is_error()) { - FAIL(DeprecatedString::formatted("{}", file.error())); + FAIL(ByteString::formatted("{}", file.error())); return; } auto buffered_file = Core::InputBufferedFile::create(file.release_value()); if (buffered_file.is_error()) { - FAIL(DeprecatedString::formatted("{}", buffered_file.error())); + FAIL(ByteString::formatted("{}", buffered_file.error())); return; } auto result = Audio::FlacLoaderPlugin::create(buffered_file.release_value()); if (result.is_error()) { - FAIL(DeprecatedString::formatted("{}", result.error())); + FAIL(ByteString::formatted("{}", result.error())); return; } @@ -40,7 +40,7 @@ struct DiscoverFLACTestsHack { while (true) { auto maybe_samples = loader->load_chunks(2 * MiB); if (maybe_samples.is_error()) { - FAIL(DeprecatedString::formatted("{}", maybe_samples.error())); + FAIL(ByteString::formatted("{}", maybe_samples.error())); return; } maybe_samples.value().remove_all_matching([](auto& chunk) { return chunk.is_empty(); }); diff --git a/Tests/LibC/TestLibCInodeWatcher.cpp b/Tests/LibC/TestLibCInodeWatcher.cpp index 285bc23df38..fb2e8de5e9a 100644 --- a/Tests/LibC/TestLibCInodeWatcher.cpp +++ b/Tests/LibC/TestLibCInodeWatcher.cpp @@ -23,12 +23,12 @@ static int read_event(int fd) return rc; } -static DeprecatedString get_event_name() +static ByteString get_event_name() { if (event->name_length == 0) - return DeprecatedString(); + return ByteString(); - return DeprecatedString { event->name, event->name_length - 1 }; + return ByteString { event->name, event->name_length - 1 }; } TEST_CASE(inode_watcher_metadata_modified_event) diff --git a/Tests/LibC/TestLibCMkTemp.cpp b/Tests/LibC/TestLibCMkTemp.cpp index 658f55ad04b..ccbd2cf38cf 100644 --- a/Tests/LibC/TestLibCMkTemp.cpp +++ b/Tests/LibC/TestLibCMkTemp.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -23,7 +23,7 @@ TEST_CASE(test_mktemp_unique_filename) if (fork() == 0) { char path[] = "/tmp/test.mktemp.XXXXXX"; - auto temp_path = DeprecatedString::formatted("{}", mktemp(path)); + auto temp_path = ByteString::formatted("{}", mktemp(path)); EXPECT(temp_path.characters()); unlink(path); @@ -33,10 +33,10 @@ TEST_CASE(test_mktemp_unique_filename) } else { wait(NULL); - auto path1 = DeprecatedString::formatted("{}", reinterpret_cast(ptr)); + auto path1 = ByteString::formatted("{}", reinterpret_cast(ptr)); char path[] = "/tmp/test.mktemp.XXXXXX"; - auto path2 = DeprecatedString::formatted("{}", mktemp(path)); + auto path2 = ByteString::formatted("{}", mktemp(path)); EXPECT(path2.characters()); unlink(path); @@ -53,7 +53,7 @@ TEST_CASE(test_mkdtemp_unique_filename) if (fork() == 0) { char path[] = "/tmp/test.mkdtemp.XXXXXX"; - auto temp_path = DeprecatedString::formatted("{}", mkdtemp(path)); + auto temp_path = ByteString::formatted("{}", mkdtemp(path)); EXPECT(temp_path.characters()); rmdir(path); @@ -63,10 +63,10 @@ TEST_CASE(test_mkdtemp_unique_filename) } else { wait(NULL); - auto path1 = DeprecatedString::formatted("{}", reinterpret_cast(ptr)); + auto path1 = ByteString::formatted("{}", reinterpret_cast(ptr)); char path[] = "/tmp/test.mkdtemp.XXXXXX"; - auto path2 = DeprecatedString::formatted("{}", mkdtemp(path)); + auto path2 = ByteString::formatted("{}", mkdtemp(path)); EXPECT(path2.characters()); rmdir(path); @@ -86,8 +86,8 @@ TEST_CASE(test_mkstemp_unique_filename) auto fd = mkstemp(path); EXPECT_NE(fd, -1); - auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto temp_path = temp_path_string.to_deprecated_string(); + auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto temp_path = temp_path_string.to_byte_string(); EXPECT(temp_path.characters()); close(fd); @@ -99,14 +99,14 @@ TEST_CASE(test_mkstemp_unique_filename) } else { wait(NULL); - auto path1 = DeprecatedString::formatted("{}", reinterpret_cast(ptr)); + auto path1 = ByteString::formatted("{}", reinterpret_cast(ptr)); char path[] = "/tmp/test.mkstemp.XXXXXX"; auto fd = mkstemp(path); EXPECT(fd != -1); - auto path2_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto path2 = path2_string.to_deprecated_string(); + auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto path2 = path2_string.to_byte_string(); EXPECT(path2.characters()); close(fd); @@ -128,8 +128,8 @@ TEST_CASE(test_mkstemps_unique_filename) auto fd = mkstemps(path, 6); EXPECT_NE(fd, -1); - auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto temp_path = temp_path_string.to_deprecated_string(); + auto temp_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto temp_path = temp_path_string.to_byte_string(); EXPECT(temp_path.characters()); close(fd); @@ -145,14 +145,14 @@ TEST_CASE(test_mkstemps_unique_filename) } else { wait(NULL); - auto path1 = DeprecatedString::formatted("{}", reinterpret_cast(ptr)); + auto path1 = ByteString::formatted("{}", reinterpret_cast(ptr)); char path[] = "/tmp/test.mkstemps.prefixXXXXXXsuffix"; auto fd = mkstemps(path, 6); EXPECT(fd != -1); - auto path2_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto path2 = path2_string.to_deprecated_string(); + auto path2_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto path2 = path2_string.to_byte_string(); EXPECT(path2.characters()); close(fd); diff --git a/Tests/LibC/TestMemmem.cpp b/Tests/LibC/TestMemmem.cpp index 5e814b16d54..3ba65dfe949 100644 --- a/Tests/LibC/TestMemmem.cpp +++ b/Tests/LibC/TestMemmem.cpp @@ -37,7 +37,7 @@ TEST_CASE(memmem_search) auto expected = test_case.matching_offset >= 0 ? test_case.haystack + test_case.matching_offset : nullptr; auto result = memmem(test_case.haystack, test_case.haystack_length, test_case.needle, test_case.needle_length); if (result != expected) { - FAIL(DeprecatedString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result)); + FAIL(ByteString::formatted("Test {} FAILED! expected {:p}, got {:p}", i, expected, result)); } ++i; } diff --git a/Tests/LibC/TestMkDir.cpp b/Tests/LibC/TestMkDir.cpp index 37da5d1f99d..d8bb27879c5 100644 --- a/Tests/LibC/TestMkDir.cpp +++ b/Tests/LibC/TestMkDir.cpp @@ -12,9 +12,9 @@ #include #include -static DeprecatedString random_dirname() +static ByteString random_dirname() { - return DeprecatedString::formatted("/tmp/test_mkdir_{:04x}", (u16)rand()); + return ByteString::formatted("/tmp/test_mkdir_{:04x}", (u16)rand()); } TEST_SETUP @@ -46,7 +46,7 @@ TEST_CASE(insufficient_permissions) TEST_CASE(nonexistent_parent) { auto parent = random_dirname(); - auto child = DeprecatedString::formatted("{}/foo", parent); + auto child = ByteString::formatted("{}/foo", parent); int res = mkdir(child.characters(), 0755); int cached_errno = errno; EXPECT(res < 0); diff --git a/Tests/LibC/TestPwd.cpp b/Tests/LibC/TestPwd.cpp index ed7e35b2046..7a65d7bb0ae 100644 --- a/Tests/LibC/TestPwd.cpp +++ b/Tests/LibC/TestPwd.cpp @@ -10,7 +10,7 @@ #include struct PasswdEntry { - DeprecatedString name; + ByteString name; uid_t uid {}; }; diff --git a/Tests/LibC/TestQsort.cpp b/Tests/LibC/TestQsort.cpp index dbc0b46b651..587451ec878 100644 --- a/Tests/LibC/TestQsort.cpp +++ b/Tests/LibC/TestQsort.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include @@ -54,7 +54,7 @@ TEST_CASE(quick_sort) auto const& key1 = test_objects[i].m_key; auto const& key2 = test_objects[i + 1].m_key; if (key1 > key2) { - FAIL(DeprecatedString::formatted("saw key {} before key {}\n", key1, key2)); + FAIL(ByteString::formatted("saw key {} before key {}\n", key1, key2)); } } // Check that the object's payloads have not been corrupted @@ -62,7 +62,7 @@ TEST_CASE(quick_sort) auto const expected = calc_payload_for_pos(i); auto const payload = test_objects[i].m_payload; if (payload != expected) { - FAIL(DeprecatedString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload)); + FAIL(ByteString::formatted("Expected payload {} for pos {}, got payload {}", expected, i, payload)); } } } diff --git a/Tests/LibC/TestRealpath.cpp b/Tests/LibC/TestRealpath.cpp index 613858fc9cf..2d6256a7d10 100644 --- a/Tests/LibC/TestRealpath.cpp +++ b/Tests/LibC/TestRealpath.cpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ static constexpr size_t ITERATION_DEPTH = 17; static void check_result(char const* what, StringView expected, char const* actual) { if (expected != actual) - FAIL(DeprecatedString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0)); + FAIL(ByteString::formatted("Expected {} to be \"{}\" ({} characters)", what, actual, actual ? strlen(actual) : 0)); } TEST_CASE(overlong_realpath) @@ -50,7 +50,7 @@ TEST_CASE(overlong_realpath) expected.append({ tmp_dir, strlen(tmp_dir) }); // But first, demonstrate the functionality at a reasonable depth: - auto expected_str = expected.to_deprecated_string(); + auto expected_str = expected.to_byte_string(); check_result("getwd", expected_str, getwd(static_cast(calloc(1, PATH_MAX)))); check_result("getcwd", expected_str, getcwd(nullptr, 0)); check_result("realpath", expected_str, realpath(".", nullptr)); @@ -59,7 +59,7 @@ TEST_CASE(overlong_realpath) ret = mkdir(PATH_LOREM_250, S_IRWXU); if (ret < 0) { perror("mkdir iter"); - FAIL(DeprecatedString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i)); + FAIL(ByteString::formatted("Unable to mkdir the overlong path fragment in iteration {}", i)); return; } expected.append('/'); @@ -67,14 +67,14 @@ TEST_CASE(overlong_realpath) ret = chdir(PATH_LOREM_250); if (ret < 0) { perror("chdir iter"); - FAIL(DeprecatedString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i)); + FAIL(ByteString::formatted("Unable to chdir to the overlong path fragment in iteration {}", i)); return; } } outln("cwd should now be ridiculously large"); // Evaluate - expected_str = expected.to_deprecated_string(); + expected_str = expected.to_byte_string(); check_result("getwd", {}, getwd(static_cast(calloc(1, PATH_MAX)))); check_result("getcwd", expected_str, getcwd(nullptr, 0)); diff --git a/Tests/LibC/TestSearch.cpp b/Tests/LibC/TestSearch.cpp index b1df6533c3b..2b7a0d30ad8 100644 --- a/Tests/LibC/TestSearch.cpp +++ b/Tests/LibC/TestSearch.cpp @@ -165,7 +165,7 @@ void twalk_action(void const* node, VISIT order, int depth) // Special case: End signaled by tester. if (depth == TWALK_CHECK_END) { if (tests[count].depth != TWALK_END_MARKER) { - FAIL(DeprecatedString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.", + FAIL(ByteString::formatted("Expected action (node={:#x}, order={}, depth={}), but twalk ended early.", tests[count].node, U8(tests[count].order), tests[count].depth)); } return; @@ -173,7 +173,7 @@ void twalk_action(void const* node, VISIT order, int depth) // Special case: End marker reached. if (tests[count].depth == TWALK_END_MARKER) { - FAIL(DeprecatedString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).", + FAIL(ByteString::formatted("Expected end, but twalk sent another action (node={:#x}, order={}, depth={}).", node, U8(order), depth)); return; } diff --git a/Tests/LibC/TestSnprintf.cpp b/Tests/LibC/TestSnprintf.cpp index 17c3b62acbd..91a8ac2c780 100644 --- a/Tests/LibC/TestSnprintf.cpp +++ b/Tests/LibC/TestSnprintf.cpp @@ -28,7 +28,7 @@ struct Testcase { size_t dest_expected_n; // == dest_n }; -static DeprecatedString show(ByteBuffer const& buf) +static ByteString show(ByteBuffer const& buf) { StringBuilder builder; for (size_t i = 0; i < buf.size(); ++i) { @@ -43,7 +43,7 @@ static DeprecatedString show(ByteBuffer const& buf) builder.append('_'); } builder.append(')'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } template diff --git a/Tests/LibC/TestStrlcpy.cpp b/Tests/LibC/TestStrlcpy.cpp index 98317e13a3a..dbc697f1a77 100644 --- a/Tests/LibC/TestStrlcpy.cpp +++ b/Tests/LibC/TestStrlcpy.cpp @@ -22,7 +22,7 @@ struct Testcase { size_t dest_expected_n; // == dest_n }; -static DeprecatedString show(ByteBuffer const& buf) +static ByteString show(ByteBuffer const& buf) { StringBuilder builder; for (size_t i = 0; i < buf.size(); ++i) { @@ -37,7 +37,7 @@ static DeprecatedString show(ByteBuffer const& buf) builder.append('_'); } builder.append(')'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } static bool test_single(Testcase const& testcase) diff --git a/Tests/LibC/TestStrtodAccuracy.cpp b/Tests/LibC/TestStrtodAccuracy.cpp index 15005ae40c6..9b7c5012fd8 100644 --- a/Tests/LibC/TestStrtodAccuracy.cpp +++ b/Tests/LibC/TestStrtodAccuracy.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include #include @@ -330,7 +330,7 @@ static long long hex_to_ll(char const* hex) } else if ('a' <= ch && ch <= 'f') { digit = ch - 'a' + 10; } else { - FAIL(DeprecatedString::formatted("\n!!! Encountered char {:02x} at {}", ch, i)); + FAIL(ByteString::formatted("\n!!! Encountered char {:02x} at {}", ch, i)); return result; } result <<= 4; @@ -366,7 +366,7 @@ TEST_CASE(strtod_accuracy) } outln("Out of {} tests, saw {} successes and {} fails.", NUM_TESTCASES, successes, fails); if (fails != 0) { - FAIL(DeprecatedString::formatted("{} strtod tests failed", fails)); + FAIL(ByteString::formatted("{} strtod tests failed", fails)); } outln("PASS (with leniency up to {} ULP from the exact solution)", LENIENCY); diff --git a/Tests/LibC/TestWchar.cpp b/Tests/LibC/TestWchar.cpp index 804d837f276..37876c0c63e 100644 --- a/Tests/LibC/TestWchar.cpp +++ b/Tests/LibC/TestWchar.cpp @@ -215,7 +215,7 @@ TEST_CASE(mbsinit) size_t ret = mbrtowc(nullptr, "\xdf", 1, &state); if (ret != -2ul) - FAIL(DeprecatedString::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast(ret))); + FAIL(ByteString::formatted("mbrtowc accepted partial multibyte sequence with return code {} (expected -2)", static_cast(ret))); // Ensure that we are not in an initial state. EXPECT(mbsinit(&state) == 0); @@ -224,7 +224,7 @@ TEST_CASE(mbsinit) ret = mbrtowc(nullptr, "\xbf", 1, &state); if (ret != 1ul) - FAIL(DeprecatedString::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast(ret))); + FAIL(ByteString::formatted("mbrtowc did not consume the expected number of bytes (1), returned {} instead", static_cast(ret))); // Ensure that we are in an initial state again. EXPECT(mbsinit(&state) != 0); diff --git a/Tests/LibCompress/TestBrotli.cpp b/Tests/LibCompress/TestBrotli.cpp index fcf8ed4a58e..e31a1bcb26e 100644 --- a/Tests/LibCompress/TestBrotli.cpp +++ b/Tests/LibCompress/TestBrotli.cpp @@ -13,15 +13,15 @@ static void run_test(StringView const file_name) { // This makes sure that the tests will run both on target and in Lagom. #ifdef AK_OS_SERENITY - DeprecatedString path = DeprecatedString::formatted("/usr/Tests/LibCompress/brotli-test-files/{}", file_name); + ByteString path = ByteString::formatted("/usr/Tests/LibCompress/brotli-test-files/{}", file_name); #else - DeprecatedString path = DeprecatedString::formatted("brotli-test-files/{}", file_name); + ByteString path = ByteString::formatted("brotli-test-files/{}", file_name); #endif auto cmp_file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); auto cmp_data = MUST(cmp_file->read_until_eof()); - DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path); + ByteString path_compressed = ByteString::formatted("{}.br", path); auto file = MUST(Core::File::open(path_compressed, Core::File::OpenMode::Read)); auto brotli_stream = Compress::BrotliDecompressionStream { MaybeOwned { *file } }; @@ -89,12 +89,12 @@ TEST_CASE(brotli_decompress_zero_one_bin) { // This makes sure that the tests will run both on target and in Lagom. #ifdef AK_OS_SERENITY - DeprecatedString path = "/usr/Tests/LibCompress/brotli-test-files/zero-one.bin"; + ByteString path = "/usr/Tests/LibCompress/brotli-test-files/zero-one.bin"; #else - DeprecatedString path = "brotli-test-files/zero-one.bin"; + ByteString path = "brotli-test-files/zero-one.bin"; #endif - DeprecatedString path_compressed = DeprecatedString::formatted("{}.br", path); + ByteString path_compressed = ByteString::formatted("{}.br", path); auto file = MUST(Core::File::open(path_compressed, Core::File::OpenMode::Read)); auto brotli_stream = Compress::BrotliDecompressionStream { MaybeOwned { *file } }; diff --git a/Tests/LibCore/TestLibCoreArgsParser.cpp b/Tests/LibCore/TestLibCoreArgsParser.cpp index 33635536185..c4bd89792cb 100644 --- a/Tests/LibCore/TestLibCoreArgsParser.cpp +++ b/Tests/LibCore/TestLibCoreArgsParser.cpp @@ -115,7 +115,7 @@ TEST_CASE(bool_option) TEST_CASE(positional_string_argument) { // Single required string argument - DeprecatedString name = ""; + ByteString name = ""; auto parser_result = run_parser({ "app"sv, "buggie"sv }, [&](auto& parser) { parser.add_positional_argument(name, "name", "name", Core::ArgsParser::Required::Yes); }); diff --git a/Tests/LibCpp/test-cpp-parser.cpp b/Tests/LibCpp/test-cpp-parser.cpp index fda7cf827ed..a1f8249e8e9 100644 --- a/Tests/LibCpp/test-cpp-parser.cpp +++ b/Tests/LibCpp/test-cpp-parser.cpp @@ -13,13 +13,13 @@ constexpr StringView TESTS_ROOT_DIR = "/home/anon/Tests/cpp-tests/parser"sv; -static DeprecatedString read_all(DeprecatedString const& path) +static ByteString read_all(ByteString const& path) { auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); auto file_size = MUST(file->size()); auto content = MUST(ByteBuffer::create_uninitialized(file_size)); MUST(file->read_until_filled(content.bytes())); - return DeprecatedString { content.bytes() }; + return ByteString { content.bytes() }; } TEST_CASE(test_regression) @@ -32,7 +32,7 @@ TEST_CASE(test_regression) outln("Checking {}...", path.basename()); auto file_path = path.string(); - auto ast_file_path = DeprecatedString::formatted("{}.ast", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1)); + auto ast_file_path = ByteString::formatted("{}.ast", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1)); auto source = read_all(file_path); auto target_ast = read_all(ast_file_path); @@ -68,7 +68,7 @@ TEST_CASE(test_regression) fclose(input_stream); - DeprecatedString content { reinterpret_cast(buffer.data()), buffer.size() }; + ByteString content { reinterpret_cast(buffer.data()), buffer.size() }; auto equal = content == target_ast; EXPECT(equal); diff --git a/Tests/LibCpp/test-cpp-preprocessor.cpp b/Tests/LibCpp/test-cpp-preprocessor.cpp index 89685aff749..51bea505df3 100644 --- a/Tests/LibCpp/test-cpp-preprocessor.cpp +++ b/Tests/LibCpp/test-cpp-preprocessor.cpp @@ -12,13 +12,13 @@ constexpr StringView TESTS_ROOT_DIR = "/home/anon/Tests/cpp-tests/preprocessor"sv; -static DeprecatedString read_all(DeprecatedString const& path) +static ByteString read_all(ByteString const& path) { auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); auto file_size = MUST(file->size()); auto content = MUST(ByteBuffer::create_uninitialized(file_size)); MUST(file->read_until_filled(content.bytes())); - return DeprecatedString { content.bytes() }; + return ByteString { content.bytes() }; } TEST_CASE(test_regression) @@ -31,7 +31,7 @@ TEST_CASE(test_regression) outln("Checking {}...", path.basename()); auto file_path = path.string(); - auto ast_file_path = DeprecatedString::formatted("{}.txt", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1)); + auto ast_file_path = ByteString::formatted("{}.txt", file_path.substring(0, file_path.length() - sizeof(".cpp") + 1)); auto source = read_all(file_path); auto target = read_all(ast_file_path); @@ -44,7 +44,7 @@ TEST_CASE(test_regression) EXPECT_EQ(tokens.size(), target_lines.size()); for (size_t i = 0; i < tokens.size(); ++i) { - EXPECT_EQ(tokens[i].to_deprecated_string(), target_lines[i]); + EXPECT_EQ(tokens[i].to_byte_string(), target_lines[i]); } return IterationDecision::Continue; })); diff --git a/Tests/LibCrypto/TestChecksum.cpp b/Tests/LibCrypto/TestChecksum.cpp index 5faa6281dc0..a3a41ac9eaf 100644 --- a/Tests/LibCrypto/TestChecksum.cpp +++ b/Tests/LibCrypto/TestChecksum.cpp @@ -15,11 +15,11 @@ TEST_CASE(test_adler32) EXPECT_EQ(digest, expected_result); }; - do_test(DeprecatedString("").bytes(), 0x1); - do_test(DeprecatedString("a").bytes(), 0x00620062); - do_test(DeprecatedString("abc").bytes(), 0x024d0127); - do_test(DeprecatedString("message digest").bytes(), 0x29750586); - do_test(DeprecatedString("abcdefghijklmnopqrstuvwxyz").bytes(), 0x90860b20); + do_test(ByteString("").bytes(), 0x1); + do_test(ByteString("a").bytes(), 0x00620062); + do_test(ByteString("abc").bytes(), 0x024d0127); + do_test(ByteString("message digest").bytes(), 0x29750586); + do_test(ByteString("abcdefghijklmnopqrstuvwxyz").bytes(), 0x90860b20); } TEST_CASE(test_crc32) @@ -29,7 +29,7 @@ TEST_CASE(test_crc32) EXPECT_EQ(digest, expected_result); }; - do_test(DeprecatedString("").bytes(), 0x0); - do_test(DeprecatedString("The quick brown fox jumps over the lazy dog").bytes(), 0x414FA339); - do_test(DeprecatedString("various CRC algorithms input data").bytes(), 0x9BD366AE); + do_test(ByteString("").bytes(), 0x0); + do_test(ByteString("The quick brown fox jumps over the lazy dog").bytes(), 0x414FA339); + do_test(ByteString("various CRC algorithms input data").bytes(), 0x9BD366AE); } diff --git a/Tests/LibELF/test-elf.cpp b/Tests/LibELF/test-elf.cpp index 70c0b106c07..e808c50263b 100644 --- a/Tests/LibELF/test-elf.cpp +++ b/Tests/LibELF/test-elf.cpp @@ -58,8 +58,8 @@ TEST_CASE(test_interp_header_tiny_p_filesz) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto elf_path = elf_path_string.to_deprecated_string(); + auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto elf_path = elf_path_string.to_byte_string(); EXPECT(elf_path.characters()); int rc = execl(elf_path.characters(), "test-elf", nullptr); @@ -113,8 +113,8 @@ TEST_CASE(test_interp_header_p_filesz_larger_than_p_memsz) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto elf_path = elf_path_string.to_deprecated_string(); + auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto elf_path = elf_path_string.to_byte_string(); EXPECT(elf_path.characters()); int rc = execl(elf_path.characters(), "test-elf", nullptr); @@ -172,8 +172,8 @@ TEST_CASE(test_interp_header_p_filesz_plus_p_offset_overflow_p_memsz) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto elf_path = elf_path_string.to_deprecated_string(); + auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto elf_path = elf_path_string.to_byte_string(); EXPECT(elf_path.characters()); int rc = execl(elf_path.characters(), "test-elf", nullptr); @@ -228,8 +228,8 @@ TEST_CASE(test_load_header_p_memsz_zero) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto elf_path = elf_path_string.to_deprecated_string(); + auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto elf_path = elf_path_string.to_byte_string(); EXPECT(elf_path.characters()); int rc = execl(elf_path.characters(), "test-elf", nullptr); @@ -284,8 +284,8 @@ TEST_CASE(test_load_header_p_memsz_not_equal_to_p_align) int nwritten = write(fd, buffer, sizeof(buffer)); EXPECT(nwritten); - auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd))); - auto elf_path = elf_path_string.to_deprecated_string(); + auto elf_path_string = TRY_OR_FAIL(FileSystem::read_link(ByteString::formatted("/proc/{}/fd/{}", getpid(), fd))); + auto elf_path = elf_path_string.to_byte_string(); EXPECT(elf_path.characters()); int rc = execl(elf_path.characters(), "test-elf", nullptr); diff --git a/Tests/LibGL/TestRender.cpp b/Tests/LibGL/TestRender.cpp index a69e14f7259..3c4cddeac05 100644 --- a/Tests/LibGL/TestRender.cpp +++ b/Tests/LibGL/TestRender.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -31,7 +31,7 @@ static NonnullOwnPtr create_testing_context(int width, int height static void expect_bitmap_equals_reference(Gfx::Bitmap const& bitmap, StringView test_name) { - auto reference_filename = DeprecatedString::formatted("{}.qoi", test_name); + auto reference_filename = ByteString::formatted("{}.qoi", test_name); if constexpr (SAVE_OUTPUT) { auto target_path = LexicalPath("/home/anon").append(reference_filename); @@ -40,7 +40,7 @@ static void expect_bitmap_equals_reference(Gfx::Bitmap const& bitmap, StringView MUST(qoi_output_stream->write_until_depleted(qoi_buffer)); } - auto reference_image_path = DeprecatedString::formatted(REFERENCE_IMAGE_DIR "/{}", reference_filename); + auto reference_image_path = ByteString::formatted(REFERENCE_IMAGE_DIR "/{}", reference_filename); auto reference_bitmap = MUST(Gfx::Bitmap::load_from_file(reference_image_path)); EXPECT_EQ(reference_bitmap->visually_equals(bitmap), true); } diff --git a/Tests/LibGLSL/test-parser.cpp b/Tests/LibGLSL/test-parser.cpp index 2a32a514fef..26fcecc4b3b 100644 --- a/Tests/LibGLSL/test-parser.cpp +++ b/Tests/LibGLSL/test-parser.cpp @@ -28,7 +28,7 @@ TEST_CASE(test_regression) return IterationDecision::Continue; outln("Checking {}...", path.basename()); - String file_path = MUST(String::from_deprecated_string(path.string())); + String file_path = MUST(String::from_byte_string(path.string())); auto ast_file_path = MUST(String::formatted("{}.ast", MUST(file_path.substring_from_byte_offset(0, file_path.bytes_as_string_view().length() - sizeof(".glsl") + 1)))); diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 796f8ed5927..a30626bca84 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include diff --git a/Tests/LibIMAP/TestQuotedPrintable.cpp b/Tests/LibIMAP/TestQuotedPrintable.cpp index 9a97ce61caa..4b392c2087b 100644 --- a/Tests/LibIMAP/TestQuotedPrintable.cpp +++ b/Tests/LibIMAP/TestQuotedPrintable.cpp @@ -44,7 +44,7 @@ TEST_CASE(test_decode) illegal_character_builder.append(byte); } - auto illegal_character_decode = MUST(IMAP::decode_quoted_printable(illegal_character_builder.to_deprecated_string())); + auto illegal_character_decode = MUST(IMAP::decode_quoted_printable(illegal_character_builder.to_byte_string())); EXPECT(illegal_character_decode.is_empty()); // If an escape sequence is invalid the characters are output unaltered. Illegal characters are ignored as usual. diff --git a/Tests/LibJS/test-js.cpp b/Tests/LibJS/test-js.cpp index 86174d778bf..bed738fe2d1 100644 --- a/Tests/LibJS/test-js.cpp +++ b/Tests/LibJS/test-js.cpp @@ -22,7 +22,7 @@ TESTJS_GLOBAL_FUNCTION(is_strict_mode, isStrictMode, 0) TESTJS_GLOBAL_FUNCTION(can_parse_source, canParseSource) { - auto source = TRY(vm.argument(0).to_deprecated_string(vm)); + auto source = TRY(vm.argument(0).to_byte_string(vm)); auto parser = JS::Parser(JS::Lexer(source)); (void)parser.parse_program(); return JS::Value(!parser.has_errors()); @@ -65,14 +65,14 @@ TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage) return execution_context->lexical_environment != nullptr; }); if (!outer_environment.has_value()) - return vm.throw_completion(JS::ErrorType::UnknownIdentifier, variable_name.deprecated_string()); + return vm.throw_completion(JS::ErrorType::UnknownIdentifier, variable_name.byte_string()); - auto reference = TRY(vm.resolve_binding(variable_name.deprecated_string(), outer_environment.value()->lexical_environment)); + auto reference = TRY(vm.resolve_binding(variable_name.byte_string(), outer_environment.value()->lexical_environment)); auto value = TRY(reference.get_value(vm)); if (!can_be_held_weakly(value)) - return vm.throw_completion(JS::ErrorType::CannotBeHeldWeakly, DeprecatedString::formatted("Variable with name {}", variable_name.deprecated_string())); + return vm.throw_completion(JS::ErrorType::CannotBeHeldWeakly, ByteString::formatted("Variable with name {}", variable_name.byte_string())); vm.heap().uproot_cell(&value.as_cell()); TRY(reference.delete_(vm)); @@ -111,7 +111,7 @@ TESTJS_GLOBAL_FUNCTION(set_time_zone, setTimeZone) return current_time_zone; } -TESTJS_RUN_FILE_FUNCTION(DeprecatedString const& test_file, JS::Realm& realm, JS::ExecutionContext&) +TESTJS_RUN_FILE_FUNCTION(ByteString const& test_file, JS::Realm& realm, JS::ExecutionContext&) { if (!test262_parser_tests) return Test::JS::RunFileHookResult::RunAsNormal; @@ -146,8 +146,8 @@ TESTJS_RUN_FILE_FUNCTION(DeprecatedString const& test_file, JS::Realm& realm, JS parse_succeeded = !Test::JS::parse_script(test_file, realm).is_error(); bool test_passed = true; - DeprecatedString message; - DeprecatedString expectation_string; + ByteString message; + ByteString expectation_string; switch (expectation) { case Early: diff --git a/Tests/LibJS/test-test262.cpp b/Tests/LibJS/test-test262.cpp index 43e5d481fa2..cbb8d2082a8 100644 --- a/Tests/LibJS/test-test262.cpp +++ b/Tests/LibJS/test-test262.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -107,7 +107,7 @@ static StringView emoji_for_result(TestResult result) static constexpr StringView total_test_emoji = "🧪"sv; -static ErrorOr> run_test_files(Span files, size_t offset, StringView command, char const* const arguments[]) +static ErrorOr> run_test_files(Span files, size_t offset, StringView command, char const* const arguments[]) { HashMap results {}; TRY(results.try_ensure_capacity(files.size())); @@ -133,12 +133,12 @@ static ErrorOr> run_test_files(Spanread_all(); - DeprecatedString output; + ByteString output; if (output_or_error.is_error()) warnln("Got error: {} while reading runner output", output_or_error.error()); else - output = DeprecatedString(output_or_error.release_value().standard_error.bytes(), Chomp); + output = ByteString(output_or_error.release_value().standard_error.bytes(), Chomp); auto status_or_error = runner_process->status(); bool failed = false; @@ -162,7 +162,7 @@ static ErrorOr> run_test_files(Span> run_test_files(Span const& result_map, Vector const& paths, StringView per_file_name, double time_taken_in_ms); +void write_per_file(HashMap const& result_map, Vector const& paths, StringView per_file_name, double time_taken_in_ms); ErrorOr serenity_main(Main::Arguments arguments) { @@ -213,12 +213,12 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); // Normalize the path to ensure filenames are consistent - Vector paths; + Vector paths; if (!FileSystem::is_directory(test_directory)) { paths.append(test_directory); } else { - Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](DeprecatedString const& file_path) { + Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](ByteString const& file_path) { if (file_path.contains("_FIXTURE"sv)) return; // FIXME: Add ignored file set @@ -230,7 +230,7 @@ ErrorOr serenity_main(Main::Arguments arguments) outln("Found {} tests", paths.size()); auto parameters = pass_through_parameters.split_view(' '); - Vector args; + Vector args; args.ensure_capacity(parameters.size() + 2); args.append(runner_command); if (!dont_disable_core_dump) @@ -301,7 +301,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return 0; } -void write_per_file(HashMap const& result_map, Vector const& paths, StringView per_file_name, double time_taken_in_ms) +void write_per_file(HashMap const& result_map, Vector const& paths, StringView per_file_name, double time_taken_in_ms) { auto file_or_error = Core::File::open(per_file_name, Core::File::OpenMode::Write); @@ -320,7 +320,7 @@ void write_per_file(HashMap const& result_map, Vectorwrite_until_depleted(complete_results.to_deprecated_string().bytes()).is_error()) + if (file->write_until_depleted(complete_results.to_byte_string().bytes()).is_error()) warnln("Failed to write per-file"); file->close(); } diff --git a/Tests/LibJS/test262-runner.cpp b/Tests/LibJS/test262-runner.cpp index ef87d86fad2..83e1faedd40 100644 --- a/Tests/LibJS/test262-runner.cpp +++ b/Tests/LibJS/test262-runner.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -32,9 +32,9 @@ # include #endif -static DeprecatedString s_current_test = ""; +static ByteString s_current_test = ""; static bool s_parse_only = false; -static DeprecatedString s_harness_file_directory; +static ByteString s_harness_file_directory; static bool s_automatic_harness_detection_mode = false; enum class NegativePhase { @@ -46,9 +46,9 @@ enum class NegativePhase { struct TestError { NegativePhase phase { NegativePhase::ParseOrEarly }; - DeprecatedString type; - DeprecatedString details; - DeprecatedString harness_file; + ByteString type; + ByteString details; + ByteString harness_file; }; using ScriptOrModuleProgram = Variant, JS::NonnullGCPtr>; @@ -61,7 +61,7 @@ static Result parse_program(JS::Realm& realm, return TestError { NegativePhase::ParseOrEarly, "SyntaxError", - script_or_error.error()[0].to_deprecated_string(), + script_or_error.error()[0].to_byte_string(), "" }; } @@ -92,39 +92,39 @@ static Result run_program(InterpreterT& interpreter, ScriptOrMo auto name = object.get_without_side_effects("name"); if (!name.is_empty() && !name.is_accessor()) { - error.type = name.to_string_without_side_effects().to_deprecated_string(); + error.type = name.to_string_without_side_effects().to_byte_string(); } else { auto constructor = object.get_without_side_effects("constructor"); if (constructor.is_object()) { name = constructor.as_object().get_without_side_effects("name"); if (!name.is_undefined()) - error.type = name.to_string_without_side_effects().to_deprecated_string(); + error.type = name.to_string_without_side_effects().to_byte_string(); } } auto message = object.get_without_side_effects("message"); if (!message.is_empty() && !message.is_accessor()) - error.details = message.to_string_without_side_effects().to_deprecated_string(); + error.details = message.to_string_without_side_effects().to_byte_string(); } if (error.type.is_empty()) - error.type = error_value.to_string_without_side_effects().to_deprecated_string(); + error.type = error_value.to_string_without_side_effects().to_byte_string(); return error; } return {}; } -static HashMap s_cached_harness_files; +static HashMap s_cached_harness_files; static Result read_harness_file(StringView harness_file) { auto cache = s_cached_harness_files.find(harness_file); if (cache == s_cached_harness_files.end()) { - auto file_or_error = Core::File::open(DeprecatedString::formatted("{}{}", s_harness_file_directory, harness_file), Core::File::OpenMode::Read); + auto file_or_error = Core::File::open(ByteString::formatted("{}{}", s_harness_file_directory, harness_file), Core::File::OpenMode::Read); if (file_or_error.is_error()) { return TestError { NegativePhase::Harness, "filesystem", - DeprecatedString::formatted("Could not open file: {}", harness_file), + ByteString::formatted("Could not open file: {}", harness_file), harness_file }; } @@ -134,13 +134,13 @@ static Result read_harness_file(StringView harness_file) return TestError { NegativePhase::Harness, "filesystem", - DeprecatedString::formatted("Could not read file: {}", harness_file), + ByteString::formatted("Could not read file: {}", harness_file), harness_file }; } StringView contents_view = contents_or_error.value(); - s_cached_harness_files.set(harness_file, contents_view.to_deprecated_string()); + s_cached_harness_files.set(harness_file, contents_view.to_byte_string()); cache = s_cached_harness_files.find(harness_file); VERIFY(cache != s_cached_harness_files.end()); } @@ -206,7 +206,7 @@ static Result run_test(StringView source, StringView filepath, return TestError { NegativePhase::ParseOrEarly, "SyntaxError", - parser.errors()[0].to_deprecated_string(), + parser.errors()[0].to_byte_string(), "" }; } @@ -250,14 +250,14 @@ static Result run_test(StringView source, StringView filepath, return run_program(vm->bytecode_interpreter(), program_or_error.value()); } -static Result extract_metadata(StringView source) +static Result extract_metadata(StringView source) { auto lines = source.lines(); TestMetadata metadata; bool parsing_negative = false; - DeprecatedString failed_message; + ByteString failed_message; auto parse_list = [&](StringView line) { auto start = line.find('['); @@ -268,7 +268,7 @@ static Result extract_metadata(StringView source auto end = line.find_last(']'); if (!end.has_value() || end.value() <= start.value()) { - failed_message = DeprecatedString::formatted("Can't parse list in '{}'", line); + failed_message = ByteString::formatted("Can't parse list in '{}'", line); return items; } @@ -281,7 +281,7 @@ static Result extract_metadata(StringView source auto second_word = [&](StringView line) { auto separator = line.find(' '); if (!separator.has_value() || separator.value() >= (line.length() - 1u)) { - failed_message = DeprecatedString::formatted("Can't parse value after space in '{}'", line); + failed_message = ByteString::formatted("Can't parse value after space in '{}'", line); return ""sv; } return line.substring_view(separator.value() + 1); @@ -335,7 +335,7 @@ static Result extract_metadata(StringView source metadata.phase = NegativePhase::Runtime; } else { has_phase = false; - failed_message = DeprecatedString::formatted("Unknown negative phase: {}", phase); + failed_message = ByteString::formatted("Unknown negative phase: {}", phase); break; } } else if (line.starts_with("type:"sv)) { @@ -392,7 +392,7 @@ static Result extract_metadata(StringView source } if (failed_message.is_empty()) - failed_message = DeprecatedString::formatted("Never reached end of comment '---*/'"); + failed_message = ByteString::formatted("Never reached end of comment '---*/'"); return failed_message; } @@ -416,7 +416,7 @@ static bool verify_test(Result& result, TestMetadata const& met } if (metadata.is_async && output.has("output"sv)) { - auto output_messages = output.get_deprecated_string("output"sv); + auto output_messages = output.get_byte_string("output"sv); VERIFY(output_messages.has_value()); if (output_messages->contains("AsyncTestFailure:InternalError: TODO("sv)) { output.set("todo_error", true); @@ -467,7 +467,7 @@ static bool verify_test(Result& result, TestMetadata const& met JsonObject expected_error_object; expected_error_object.set("phase", phase_to_string(metadata.phase)); - expected_error_object.set("type", metadata.type.to_deprecated_string()); + expected_error_object.set("type", metadata.type.to_byte_string()); expected_error = expected_error_object; @@ -506,7 +506,7 @@ static bool verify_test(Result& result, TestMetadata const& met return error.phase == metadata.phase && error.type == metadata.type; } -static bool extract_harness_directory(DeprecatedString const& test_file_path) +static bool extract_harness_directory(ByteString const& test_file_path) { auto test_directory_index = test_file_path.find("test/"sv); if (!test_directory_index.has_value()) { @@ -514,7 +514,7 @@ static bool extract_harness_directory(DeprecatedString const& test_file_path) return false; } - s_harness_file_directory = DeprecatedString::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value())); + s_harness_file_directory = ByteString::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value())); return true; } @@ -532,7 +532,7 @@ static bool g_in_assert = false; assert_fail_result.set("assert_fail", true); assert_fail_result.set("result", "assert_fail"); assert_fail_result.set("output", assert_failed_message); - outln(saved_stdout_fd, "RESULT {}{}", assert_fail_result.to_deprecated_string(), '\0'); + outln(saved_stdout_fd, "RESULT {}{}", assert_fail_result.to_byte_string(), '\0'); // (Attempt to) Ensure that messages are written before quitting. fflush(saved_stdout_fd); fflush(stderr); @@ -555,7 +555,7 @@ extern "C" __attribute__((__noreturn__)) void __assert_fail(char const* assertio extern "C" __attribute__((__noreturn__)) void __assert_fail(char const* assertion, char const* file, unsigned int line, char const* function) # endif { - auto full_message = DeprecatedString::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion); + auto full_message = ByteString::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion); handle_failed_assert(full_message.characters()); } #endif @@ -598,7 +598,7 @@ int main(int argc, char** argv) if (s_harness_file_directory.is_empty()) { s_automatic_harness_detection_mode = true; } else if (!s_harness_file_directory.ends_with('/')) { - s_harness_file_directory = DeprecatedString::formatted("{}/", s_harness_file_directory); + s_harness_file_directory = ByteString::formatted("{}/", s_harness_file_directory); } if (timeout <= 0) { @@ -651,10 +651,10 @@ int main(int argc, char** argv) auto collect_output = [&] { fflush(stdout); auto nread = read(stdout_pipe[0], buffer, BUFFER_SIZE); - Optional value; + Optional value; if (nread > 0) { - value = DeprecatedString { buffer, static_cast(nread) }; + value = ByteString { buffer, static_cast(nread) }; while (nread > 0) { nread = read(stdout_pipe[0], buffer, BUFFER_SIZE); } @@ -707,7 +707,7 @@ int main(int argc, char** argv) count++; - DeprecatedString source_with_strict; + ByteString source_with_strict; static StringView use_strict = "'use strict';\n"sv; static size_t strict_length = use_strict.length(); @@ -721,7 +721,7 @@ int main(int argc, char** argv) StringBuilder builder { contents.size() + strict_length }; builder.append(use_strict); builder.append(contents); - source_with_strict = builder.to_deprecated_string(); + source_with_strict = builder.to_byte_string(); } StringView with_strict = source_with_strict.view(); @@ -731,7 +731,7 @@ int main(int argc, char** argv) result_object.set("test", path); ScopeGuard output_guard = [&] { - outln(saved_stdout_fd, "RESULT {}{}", result_object.to_deprecated_string(), '\0'); + outln(saved_stdout_fd, "RESULT {}{}", result_object.to_byte_string(), '\0'); fflush(saved_stdout_fd); }; diff --git a/Tests/LibMarkdown/TestCommonmark.cpp b/Tests/LibMarkdown/TestCommonmark.cpp index 9c748197dc6..56372b79249 100644 --- a/Tests/LibMarkdown/TestCommonmark.cpp +++ b/Tests/LibMarkdown/TestCommonmark.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -23,20 +23,20 @@ TEST_SETUP auto file_size = MUST(file->size()); auto content = MUST(ByteBuffer::create_uninitialized(file_size)); MUST(file->read_until_filled(content.bytes())); - DeprecatedString test_data { content.bytes() }; + ByteString test_data { content.bytes() }; auto tests = JsonParser(test_data).parse().value().as_array(); for (size_t i = 0; i < tests.size(); ++i) { auto testcase = tests[i].as_object(); - auto name = DeprecatedString::formatted("{}_ex{}_{}..{}", + auto name = ByteString::formatted("{}_ex{}_{}..{}", testcase.get("section"sv).value(), testcase.get("example"sv).value(), testcase.get("start_line"sv).value(), testcase.get("end_line"sv).value()); - DeprecatedString markdown = testcase.get_deprecated_string("markdown"sv).value(); - DeprecatedString html = testcase.get_deprecated_string("html"sv).value(); + ByteString markdown = testcase.get_byte_string("markdown"sv).value(); + ByteString html = testcase.get_byte_string("html"sv).value(); Test::TestSuite::the().add_case(adopt_ref(*new Test::TestCase( name, [markdown, html]() { diff --git a/Tests/LibPDF/TestPDF.cpp b/Tests/LibPDF/TestPDF.cpp index da721d032ac..450e8d71762 100644 --- a/Tests/LibPDF/TestPDF.cpp +++ b/Tests/LibPDF/TestPDF.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -65,7 +65,7 @@ TEST_CASE(encodig) TEST_CASE(truncated_pdf_header_issue_10717) { - AK::DeprecatedString string { "%PDF-2.11%" }; + AK::ByteString string { "%PDF-2.11%" }; auto document = PDF::Document::create(string.bytes()); EXPECT(document.is_error()); } diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index 76b217b98fa..555def1b56d 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -122,7 +122,7 @@ TEST_CASE(regex_lexer) TEST_CASE(parser_error_parens) { - DeprecatedString pattern = "test()test"; + ByteString pattern = "test()test"; Lexer l(pattern); PosixExtendedParser p(l); p.parse(); @@ -132,7 +132,7 @@ TEST_CASE(parser_error_parens) TEST_CASE(parser_error_special_characters_used_at_wrong_place) { - DeprecatedString pattern; + ByteString pattern; Vector chars = { '*', '+', '?', '{' }; StringBuilder b; @@ -143,7 +143,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) // First in ere b.clear(); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); l.set_source(pattern); p.parse(); EXPECT(p.has_error()); @@ -153,7 +153,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.clear(); b.append("a|"sv); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); l.set_source(pattern); p.parse(); EXPECT(p.has_error()); @@ -163,7 +163,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.clear(); b.append('^'); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); l.set_source(pattern); p.parse(); EXPECT(p.has_error()); @@ -173,7 +173,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.clear(); b.append('$'); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); l.set_source(pattern); p.parse(); EXPECT(p.has_error()); @@ -184,7 +184,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.append('('); b.append(ch); b.append(')'); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); l.set_source(pattern); p.parse(); EXPECT(p.has_error()); @@ -267,7 +267,7 @@ TEST_CASE(catch_all_newline) Regex re("^.*$", PosixFlags::Multiline | PosixFlags::StringCopyMatches); RegexResult result; auto lambda = [&result, &re]() { - DeprecatedString aaa = "Hello World\nTest\n1234\n"; + ByteString aaa = "Hello World\nTest\n1234\n"; result = match(aaa, re); EXPECT_EQ(result.success, true); }; @@ -283,11 +283,11 @@ TEST_CASE(catch_all_newline_view) Regex re("^.*$", PosixFlags::Multiline); RegexResult result; - DeprecatedString aaa = "Hello World\nTest\n1234\n"; + ByteString aaa = "Hello World\nTest\n1234\n"; result = match(aaa, re); EXPECT_EQ(result.success, true); EXPECT_EQ(result.count, 3u); - DeprecatedString str = "Hello World"; + ByteString str = "Hello World"; EXPECT_EQ(result.matches.at(0).view, str.view()); EXPECT_EQ(result.matches.at(1).view, "Test"); EXPECT_EQ(result.matches.at(2).view, "1234"); @@ -313,7 +313,7 @@ TEST_CASE(catch_all_newline_2) TEST_CASE(match_all_character_class) { Regex re("[[:alpha:]]"); - DeprecatedString str = "[Window]\nOpacity=255\nAudibleBeep=0\n"; + ByteString str = "[Window]\nOpacity=255\nAudibleBeep=0\n"; RegexResult result = match(str, re, PosixFlags::Global | PosixFlags::StringCopyMatches); EXPECT_EQ(result.success, true); @@ -326,7 +326,7 @@ TEST_CASE(match_all_character_class) TEST_CASE(match_character_class_with_assertion) { Regex re("[[:alpha:]]+$"); - DeprecatedString str = "abcdef"; + ByteString str = "abcdef"; RegexResult result = match(str, re); EXPECT_EQ(result.success, true); @@ -372,13 +372,13 @@ TEST_CASE(ini_file_entries) regex_dbg.print_bytecode(re); } - DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; + ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true); EXPECT_EQ(result.count, 3u); if constexpr (REGEX_DEBUG) { for (auto& v : result.matches) - fprintf(stderr, "%s\n", v.view.to_deprecated_string().characters()); + fprintf(stderr, "%s\n", v.view.to_byte_string().characters()); } EXPECT_EQ(result.matches.at(0).view, "[Window]"); @@ -400,7 +400,7 @@ TEST_CASE(ini_file_entries2) Regex re("[[:alpha:]]*=([[:digit:]]*)"); RegexResult result; - DeprecatedString haystack = "ViewMode=Icon"; + ByteString haystack = "ViewMode=Icon"; EXPECT_EQ(re.match(haystack.view(), result), false); EXPECT_EQ(result.count, 0u); @@ -421,7 +421,7 @@ TEST_CASE(named_capture_group) regex_dbg.print_bytecode(re); } - DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; + ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; EXPECT_EQ(re.search(haystack, result, PosixFlags::Multiline), true); EXPECT_EQ(result.count, 2u); EXPECT_EQ(result.matches.at(0).view, "Opacity=255"); @@ -444,7 +444,7 @@ TEST_CASE(ecma262_named_capture_group_with_dollar_sign) regex_dbg.print_bytecode(re); } - DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; + ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; EXPECT_EQ(re.search(haystack, result, ECMAScriptFlags::Multiline), true); EXPECT_EQ(result.count, 2u); EXPECT_EQ(result.matches.at(0).view, "Opacity=255"); @@ -467,7 +467,7 @@ TEST_CASE(a_star) regex_dbg.print_bytecode(re); } - DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; + ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; EXPECT_EQ(re.search(haystack.view(), result, PosixFlags::Multiline), true); EXPECT_EQ(result.count, 32u); if (result.count == 32u) { @@ -500,7 +500,7 @@ TEST_CASE(posix_extended_nested_capture_group) EXPECT_EQ(result.capture_group_matches[0][2].view, "llo"sv); } -auto parse_test_case_long_disjunction_chain = DeprecatedString::repeated("a|"sv, 100000); +auto parse_test_case_long_disjunction_chain = ByteString::repeated("a|"sv, 100000); TEST_CASE(ECMA262_parse) { @@ -730,7 +730,7 @@ TEST_CASE(ECMA262_unicode_match) StringBuilder builder; for (u32 code_point : space_and_line_terminator_code_points) builder.append_code_point(code_point); - auto space_and_line_terminators = builder.to_deprecated_string(); + auto space_and_line_terminators = builder.to_byte_string(); struct _test { StringView pattern; @@ -969,7 +969,7 @@ TEST_CASE(case_insensitive_match) TEST_CASE(extremely_long_fork_chain) { Regex re("(?:aa)*"); - auto result = re.match(DeprecatedString::repeated('a', 1000)); + auto result = re.match(ByteString::repeated('a', 1000)); EXPECT_EQ(result.success, true); } @@ -988,7 +988,7 @@ TEST_CASE(theoretically_infinite_loop) } } -static auto g_lots_of_a_s = DeprecatedString::repeated('a', 10'000'000); +static auto g_lots_of_a_s = ByteString::repeated('a', 10'000'000); BENCHMARK_CASE(fork_performance) { @@ -1137,7 +1137,7 @@ TEST_CASE(single_match_flag) auto result = re.match("ABC"sv); EXPECT_EQ(result.success, true); EXPECT_EQ(result.matches.size(), 1u); - EXPECT_EQ(result.matches.first().view.to_deprecated_string(), "A"sv); + EXPECT_EQ(result.matches.first().view.to_byte_string(), "A"sv); } } @@ -1149,7 +1149,7 @@ TEST_CASE(empty_string_wildcard_match) auto result = re.match(""sv); EXPECT_EQ(result.success, true); EXPECT_EQ(result.matches.size(), 1u); - EXPECT_EQ(result.matches.first().view.to_deprecated_string(), ""sv); + EXPECT_EQ(result.matches.first().view.to_byte_string(), ""sv); } } @@ -1162,7 +1162,7 @@ TEST_CASE(inversion_state_in_char_class) auto result = re.match("hello"sv); EXPECT_EQ(result.success, true); EXPECT_EQ(result.matches.size(), 1u); - EXPECT_EQ(result.matches.first().view.to_deprecated_string(), "h"sv); + EXPECT_EQ(result.matches.first().view.to_byte_string(), "h"sv); } { Regex re("^(?:([^\\s!\"#%-,\\./;->@\\[-\\^`\\{-~]+(?=([=~}\\s/.)|]))))"sv, ECMAScriptFlags::Global); @@ -1170,8 +1170,8 @@ TEST_CASE(inversion_state_in_char_class) auto result = re.match("slideNumbers}}"sv); EXPECT_EQ(result.success, true); EXPECT_EQ(result.matches.size(), 1u); - EXPECT_EQ(result.matches.first().view.to_deprecated_string(), "slideNumbers"sv); - EXPECT_EQ(result.capture_group_matches.first()[0].view.to_deprecated_string(), "slideNumbers"sv); - EXPECT_EQ(result.capture_group_matches.first()[1].view.to_deprecated_string(), "}"sv); + EXPECT_EQ(result.matches.first().view.to_byte_string(), "slideNumbers"sv); + EXPECT_EQ(result.capture_group_matches.first()[0].view.to_byte_string(), "slideNumbers"sv); + EXPECT_EQ(result.capture_group_matches.first()[1].view.to_byte_string(), "}"sv); } } diff --git a/Tests/LibRegex/RegexLibC.cpp b/Tests/LibRegex/RegexLibC.cpp index aff5c25fda0..0e98b1d4c5b 100644 --- a/Tests/LibRegex/RegexLibC.cpp +++ b/Tests/LibRegex/RegexLibC.cpp @@ -13,7 +13,7 @@ TEST_CASE(catch_all) { - DeprecatedString pattern = "^.*$"; + ByteString pattern = "^.*$"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -24,7 +24,7 @@ TEST_CASE(catch_all) TEST_CASE(simple_start) { - DeprecatedString pattern = "^hello friends"; + ByteString pattern = "^hello friends"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -37,7 +37,7 @@ TEST_CASE(simple_start) TEST_CASE(simple_end) { - DeprecatedString pattern = ".*hello\\.\\.\\. there$"; + ByteString pattern = ".*hello\\.\\.\\. there$"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -51,7 +51,7 @@ TEST_CASE(simple_end) TEST_CASE(simple_period) { - DeprecatedString pattern = "hello."; + ByteString pattern = "hello."; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -65,7 +65,7 @@ TEST_CASE(simple_period) TEST_CASE(simple_period_end) { - DeprecatedString pattern = "hello.$"; + ByteString pattern = "hello.$"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB), REG_NOERR); @@ -79,7 +79,7 @@ TEST_CASE(simple_period_end) TEST_CASE(simple_escaped) { - DeprecatedString pattern = "hello\\."; + ByteString pattern = "hello\\."; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -91,7 +91,7 @@ TEST_CASE(simple_escaped) TEST_CASE(simple_period2_end) { - DeprecatedString pattern = ".*hi... there$"; + ByteString pattern = ".*hi... there$"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -106,7 +106,7 @@ TEST_CASE(simple_period2_end) TEST_CASE(simple_plus) { - DeprecatedString pattern = "a+"; + ByteString pattern = "a+"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB), REG_NOERR); @@ -120,7 +120,7 @@ TEST_CASE(simple_plus) TEST_CASE(simple_questionmark) { - DeprecatedString pattern = "da?d"; + ByteString pattern = "da?d"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -137,7 +137,7 @@ TEST_CASE(simple_questionmark) TEST_CASE(simple_questionmark_matchall) { - DeprecatedString pattern = "da?d"; + ByteString pattern = "da?d"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -170,12 +170,12 @@ TEST_CASE(simple_questionmark_matchall) TEST_CASE(character_class) { - DeprecatedString pattern = "[[:alpha:]]"; + ByteString pattern = "[[:alpha:]]"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; - DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; + ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); EXPECT_EQ(regexec(®ex, haystack.characters(), num_matches, matches, 0), REG_NOMATCH); EXPECT_EQ(matches[0].rm_cnt, 0); @@ -189,12 +189,12 @@ TEST_CASE(character_class) TEST_CASE(character_class2) { - DeprecatedString pattern = "[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]"; + ByteString pattern = "[[:alpha:]]*=([[:digit:]]*)|\\[(.*)\\]"; regex_t regex; static constexpr int num_matches { 9 }; regmatch_t matches[num_matches]; - DeprecatedString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; + ByteString haystack = "[Window]\nOpacity=255\nAudibleBeep=0\n"; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NEWLINE), REG_NOERR); EXPECT_EQ(regexec(®ex, haystack.characters(), num_matches, matches, 0), REG_NOERR); @@ -204,7 +204,7 @@ TEST_CASE(character_class2) fprintf(stderr, "Matches[%i].rm_so: %li, .rm_eo: %li .rm_cnt: %li: ", i, matches[i].rm_so, matches[i].rm_eo, matches[i].rm_cnt); fprintf(stderr, "haystack length: %lu\n", haystack.length()); if (matches[i].rm_so != -1) - fprintf(stderr, "%s\n", haystack.substring_view(matches[i].rm_so, matches[i].rm_eo - matches[i].rm_so).to_deprecated_string().characters()); + fprintf(stderr, "%s\n", haystack.substring_view(matches[i].rm_so, matches[i].rm_eo - matches[i].rm_so).to_byte_string().characters()); } #endif @@ -235,7 +235,7 @@ TEST_CASE(character_class2) TEST_CASE(escaped_char_questionmark) { - DeprecatedString pattern = "This\\.?And\\.?That"; + ByteString pattern = "This\\.?And\\.?That"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -249,7 +249,7 @@ TEST_CASE(escaped_char_questionmark) TEST_CASE(char_qualifier_asterisk) { - DeprecatedString pattern = "regex*"; + ByteString pattern = "regex*"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -263,7 +263,7 @@ TEST_CASE(char_qualifier_asterisk) TEST_CASE(char_utf8) { - DeprecatedString pattern = "😀"; + ByteString pattern = "😀"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -277,7 +277,7 @@ TEST_CASE(char_utf8) TEST_CASE(parens) { - DeprecatedString pattern = "test(hello)test"; + ByteString pattern = "test(hello)test"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -297,7 +297,7 @@ TEST_CASE(parens) TEST_CASE(parser_error_parens) { - DeprecatedString pattern = "test()test"; + ByteString pattern = "test()test"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -310,7 +310,7 @@ TEST_CASE(parser_error_parens) TEST_CASE(parser_error_special_characters_used_at_wrong_place) { - DeprecatedString pattern; + ByteString pattern; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -325,7 +325,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) // First in ere b.clear(); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); regfree(®ex); @@ -334,7 +334,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.clear(); b.append("a|"sv); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); regfree(®ex); @@ -343,7 +343,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.clear(); b.append('^'); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); regfree(®ex); @@ -352,7 +352,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.clear(); b.append('$'); b.append(ch); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); regfree(®ex); @@ -362,7 +362,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) b.append('('); b.append(ch); b.append(')'); - pattern = b.to_deprecated_string(); + pattern = b.to_byte_string(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); EXPECT_EQ(regexec(®ex, "test", num_matches, matches, 0), error_code_to_check); regfree(®ex); @@ -371,7 +371,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) TEST_CASE(parser_error_vertical_line_used_at_wrong_place) { - DeprecatedString pattern; + ByteString pattern; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -403,7 +403,7 @@ TEST_CASE(parser_error_vertical_line_used_at_wrong_place) TEST_CASE(parens_qualifier_questionmark) { - DeprecatedString pattern = "test(hello)?test"; + ByteString pattern = "test(hello)?test"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -433,7 +433,7 @@ TEST_CASE(parens_qualifier_questionmark) TEST_CASE(parens_qualifier_asterisk) { - DeprecatedString pattern = "test(hello)*test"; + ByteString pattern = "test(hello)*test"; regex_t regex; static constexpr int num_matches { 6 }; regmatch_t matches[num_matches]; @@ -479,7 +479,7 @@ TEST_CASE(parens_qualifier_asterisk) TEST_CASE(parens_qualifier_asterisk_2) { - DeprecatedString pattern = "test(.*)test"; + ByteString pattern = "test(.*)test"; regex_t regex; static constexpr int num_matches { 6 }; regmatch_t matches[num_matches]; @@ -523,7 +523,7 @@ TEST_CASE(parens_qualifier_asterisk_2) TEST_CASE(mulit_parens_qualifier_too_less_result_values) { - DeprecatedString pattern = "test(a)?(b)?(c)?test"; + ByteString pattern = "test(a)?(b)?(c)?test"; regex_t regex; static constexpr int num_matches { 4 }; regmatch_t matches[num_matches]; @@ -587,7 +587,7 @@ TEST_CASE(mulit_parens_qualifier_too_less_result_values) TEST_CASE(multi_parens_qualifier_questionmark) { - DeprecatedString pattern = "test(a)?(b)?(c)?test"; + ByteString pattern = "test(a)?(b)?(c)?test"; regex_t regex; static constexpr int num_matches { 8 }; regmatch_t matches[num_matches]; @@ -651,7 +651,7 @@ TEST_CASE(multi_parens_qualifier_questionmark) TEST_CASE(simple_alternative) { - DeprecatedString pattern = "test|hello|friends"; + ByteString pattern = "test|hello|friends"; regex_t regex; static constexpr int num_matches { 1 }; regmatch_t matches[num_matches]; @@ -678,7 +678,7 @@ TEST_CASE(simple_alternative) TEST_CASE(alternative_match_groups) { - DeprecatedString pattern = "test(a)?(b)?|hello ?(dear|my)? friends"; + ByteString pattern = "test(a)?(b)?|hello ?(dear|my)? friends"; regex_t regex; static constexpr int num_matches { 8 }; regmatch_t matches[num_matches]; @@ -784,7 +784,7 @@ TEST_CASE(alternative_match_groups) TEST_CASE(parens_qualifier_exact) { - DeprecatedString pattern = "(hello){3}"; + ByteString pattern = "(hello){3}"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -831,7 +831,7 @@ TEST_CASE(parens_qualifier_exact) TEST_CASE(parens_qualifier_minimum) { - DeprecatedString pattern = "(hello){3,}"; + ByteString pattern = "(hello){3,}"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -889,7 +889,7 @@ TEST_CASE(parens_qualifier_minimum) TEST_CASE(parens_qualifier_maximum) { - DeprecatedString pattern = "(hello){2,3}"; + ByteString pattern = "(hello){2,3}"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -946,7 +946,7 @@ TEST_CASE(parens_qualifier_maximum) TEST_CASE(char_qualifier_min_max) { - DeprecatedString pattern = "c{3,30}"; + ByteString pattern = "c{3,30}"; regex_t regex; static constexpr int num_matches { 5 }; regmatch_t matches[num_matches]; @@ -966,7 +966,7 @@ TEST_CASE(char_qualifier_min_max) TEST_CASE(simple_bracket_chars) { - DeprecatedString pattern = "[abc]"; + ByteString pattern = "[abc]"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -980,7 +980,7 @@ TEST_CASE(simple_bracket_chars) TEST_CASE(simple_bracket_chars_inverse) { - DeprecatedString pattern = "[^abc]"; + ByteString pattern = "[^abc]"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -994,7 +994,7 @@ TEST_CASE(simple_bracket_chars_inverse) TEST_CASE(simple_bracket_chars_range) { - DeprecatedString pattern = "[a-d]"; + ByteString pattern = "[a-d]"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -1008,7 +1008,7 @@ TEST_CASE(simple_bracket_chars_range) TEST_CASE(simple_bracket_chars_range_inverse) { - DeprecatedString pattern = "[^a-df-z]"; + ByteString pattern = "[^a-df-z]"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -1024,7 +1024,7 @@ TEST_CASE(simple_bracket_chars_range_inverse) TEST_CASE(bracket_character_class_uuid) { - DeprecatedString pattern = "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$"; + ByteString pattern = "^([[:xdigit:]]{8})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{4})-([[:xdigit:]]{12})$"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -1036,7 +1036,7 @@ TEST_CASE(bracket_character_class_uuid) TEST_CASE(simple_bracket_character_class_inverse) { - DeprecatedString pattern = "[^[:digit:]]"; + ByteString pattern = "[^[:digit:]]"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -1050,7 +1050,7 @@ TEST_CASE(simple_bracket_character_class_inverse) TEST_CASE(email_address) { - DeprecatedString pattern = "^[A-Z0-9a-z._%+-]{1,64}@(?:[A-Za-z0-9-]{1,63}\\.){1,125}[A-Za-z]{2,63}$"; + ByteString pattern = "^[A-Z0-9a-z._%+-]{1,64}@(?:[A-Za-z0-9-]{1,63}\\.){1,125}[A-Za-z]{2,63}$"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_NOERR); @@ -1062,7 +1062,7 @@ TEST_CASE(email_address) TEST_CASE(error_message) { - DeprecatedString pattern = "^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$"; + ByteString pattern = "^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), REG_EBRACK); @@ -1070,7 +1070,7 @@ TEST_CASE(error_message) char buf[1024]; size_t buflen = 1024; auto len = regerror(0, ®ex, buf, buflen); - DeprecatedString expected = "Error during parsing of regular expression:\n ^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$\n ^---- [ ] imbalance."; + ByteString expected = "Error during parsing of regular expression:\n ^[A-Z0-9[a-z._%+-]{1,64}@[A-Za-z0-9-]{1,63}\\.{1,125}[A-Za-z]{2,63}$\n ^---- [ ] imbalance."; for (size_t i = 0; i < len; ++i) { EXPECT_EQ(buf[i], expected[i]); } @@ -1080,7 +1080,7 @@ TEST_CASE(error_message) TEST_CASE(simple_ignorecase) { - DeprecatedString pattern = "^hello friends"; + ByteString pattern = "^hello friends"; regex_t regex; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB | REG_ICASE), REG_NOERR); @@ -1098,8 +1098,8 @@ TEST_CASE(simple_ignorecase) TEST_CASE(simple_notbol_noteol) { - DeprecatedString pattern = "^hello friends$"; - DeprecatedString pattern2 = "hello friends"; + ByteString pattern = "^hello friends$"; + ByteString pattern2 = "hello friends"; regex_t regex, regex2; EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED | REG_NOSUB | REG_ICASE), REG_NOERR); diff --git a/Tests/LibSQL/TestSqlDatabase.cpp b/Tests/LibSQL/TestSqlDatabase.cpp index 911e5c48390..1d5e66c1e83 100644 --- a/Tests/LibSQL/TestSqlDatabase.cpp +++ b/Tests/LibSQL/TestSqlDatabase.cpp @@ -46,7 +46,7 @@ static void insert_into_table(SQL::Database& db, int count) StringBuilder builder; builder.appendff("Test{}", ix); - row["TextColumn"] = builder.to_deprecated_string(); + row["TextColumn"] = builder.to_byte_string(); row["IntColumn"] = ix; TRY_OR_FAIL(db.insert(row)); } @@ -62,7 +62,7 @@ static void verify_table_contents(SQL::Database& db, int expected_count) for (auto& row : rows) { StringBuilder builder; builder.appendff("Test{}", row["IntColumn"].to_int().value()); - EXPECT_EQ(row["TextColumn"].to_deprecated_string(), builder.to_deprecated_string()); + EXPECT_EQ(row["TextColumn"].to_byte_string(), builder.to_byte_string()); count++; sum += row["IntColumn"].to_int().value(); } diff --git a/Tests/LibSQL/TestSqlExpressionParser.cpp b/Tests/LibSQL/TestSqlExpressionParser.cpp index 1dce2341840..39957487b70 100644 --- a/Tests/LibSQL/TestSqlExpressionParser.cpp +++ b/Tests/LibSQL/TestSqlExpressionParser.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ public: } }; -using ParseResult = AK::Result, DeprecatedString>; +using ParseResult = AK::Result, ByteString>; ParseResult parse(StringView sql) { @@ -39,7 +39,7 @@ ParseResult parse(StringView sql) auto expression = parser.parse(); if (parser.has_errors()) { - return parser.errors()[0].to_deprecated_string(); + return parser.errors()[0].to_byte_string(); } return expression; @@ -225,14 +225,14 @@ TEST_CASE(binary_operator) StringBuilder builder; builder.append("1 "sv); builder.append(op.key); - EXPECT(parse(builder.to_deprecated_string()).is_error()); + EXPECT(parse(builder.to_byte_string()).is_error()); builder.clear(); if (op.key != "+" && op.key != "-") { // "+1" and "-1" are fine (unary operator). builder.append(op.key); builder.append(" 1"sv); - EXPECT(parse(builder.to_deprecated_string()).is_error()); + EXPECT(parse(builder.to_byte_string()).is_error()); } } @@ -251,7 +251,7 @@ TEST_CASE(binary_operator) builder.append("1 "sv); builder.append(op.key); builder.append(" 1"sv); - validate(builder.to_deprecated_string(), op.value); + validate(builder.to_byte_string(), op.value); } } @@ -438,12 +438,12 @@ TEST_CASE(match_expression) StringBuilder builder; builder.append("1 "sv); builder.append(op.key); - EXPECT(parse(builder.to_deprecated_string()).is_error()); + EXPECT(parse(builder.to_byte_string()).is_error()); builder.clear(); builder.append(op.key); builder.append(" 1"sv); - EXPECT(parse(builder.to_deprecated_string()).is_error()); + EXPECT(parse(builder.to_byte_string()).is_error()); } auto validate = [](StringView sql, SQL::AST::MatchOperator expected_operator, bool expected_invert_expression, bool expect_escape) { @@ -463,19 +463,19 @@ TEST_CASE(match_expression) builder.append("1 "sv); builder.append(op.key); builder.append(" 1"sv); - validate(builder.to_deprecated_string(), op.value, false, false); + validate(builder.to_byte_string(), op.value, false, false); builder.clear(); builder.append("1 NOT "sv); builder.append(op.key); builder.append(" 1"sv); - validate(builder.to_deprecated_string(), op.value, true, false); + validate(builder.to_byte_string(), op.value, true, false); builder.clear(); builder.append("1 NOT "sv); builder.append(op.key); builder.append(" 1 ESCAPE '+'"sv); - validate(builder.to_deprecated_string(), op.value, true, true); + validate(builder.to_byte_string(), op.value, true, true); } } @@ -598,7 +598,7 @@ TEST_CASE(in_selection_expression) TEST_CASE(expression_tree_depth_limit) { - auto too_deep_expression = DeprecatedString::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth); + auto too_deep_expression = ByteString::formatted("{:+^{}}1", "", SQL::AST::Limits::maximum_expression_tree_depth); EXPECT(!parse(too_deep_expression.substring_view(1)).is_error()); EXPECT(parse(too_deep_expression).is_error()); } diff --git a/Tests/LibSQL/TestSqlStatementExecution.cpp b/Tests/LibSQL/TestSqlStatementExecution.cpp index 930823cc1a2..e4c21138f28 100644 --- a/Tests/LibSQL/TestSqlStatementExecution.cpp +++ b/Tests/LibSQL/TestSqlStatementExecution.cpp @@ -21,17 +21,17 @@ namespace { constexpr char const* db_name = "/tmp/test.db"; -SQL::ResultOr try_execute(NonnullRefPtr database, DeprecatedString const& sql, Vector placeholder_values = {}) +SQL::ResultOr try_execute(NonnullRefPtr database, ByteString const& sql, Vector placeholder_values = {}) { auto parser = SQL::AST::Parser(SQL::AST::Lexer(sql)); auto statement = parser.next_statement(); EXPECT(!parser.has_errors()); if (parser.has_errors()) - outln("{}", parser.errors()[0].to_deprecated_string()); + outln("{}", parser.errors()[0].to_byte_string()); return statement->execute(move(database), placeholder_values); } -SQL::ResultSet execute(NonnullRefPtr database, DeprecatedString const& sql, Vector placeholder_values = {}) +SQL::ResultSet execute(NonnullRefPtr database, ByteString const& sql, Vector placeholder_values = {}) { auto result = try_execute(move(database), sql, move(placeholder_values)); if (result.is_error()) { @@ -101,7 +101,7 @@ TEST_CASE(insert_into_table) int count = 0; auto rows = TRY_OR_FAIL(database->select_all(*table)); for (auto& row : rows) { - EXPECT_EQ(row["TEXTCOLUMN"].to_deprecated_string(), "Test"); + EXPECT_EQ(row["TEXTCOLUMN"].to_byte_string(), "Test"); EXPECT_EQ(row["INTCOLUMN"].to_int(), 42); count++; } @@ -380,8 +380,8 @@ TEST_CASE(select_inner_join) EXPECT_EQ(result.size(), 1u); EXPECT_EQ(result[0].row.size(), 3u); EXPECT_EQ(result[0].row[0].to_int(), 42); - EXPECT_EQ(result[0].row[1].to_deprecated_string(), "Test_1"); - EXPECT_EQ(result[0].row[2].to_deprecated_string(), "Test_12"); + EXPECT_EQ(result[0].row[1].to_byte_string(), "Test_1"); + EXPECT_EQ(result[0].row[2].to_byte_string(), "Test_12"); } TEST_CASE(select_with_like) @@ -467,11 +467,11 @@ TEST_CASE(select_with_order) result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY TextColumn;"); EXPECT_EQ(result.size(), 5u); - EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_1"); - EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_2"); - EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_3"); - EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_4"); - EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_5"); + EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_1"); + EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_2"); + EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_3"); + EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_4"); + EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_5"); } TEST_CASE(select_with_regexp) @@ -542,15 +542,15 @@ TEST_CASE(select_with_order_two_columns) result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY TextColumn, IntColumn;"); EXPECT_EQ(result.size(), 5u); - EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_1"); + EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_1"); EXPECT_EQ(result[0].row[1].to_int(), 47); - EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_2"); + EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_2"); EXPECT_EQ(result[1].row[1].to_int(), 40); - EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_2"); + EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_2"); EXPECT_EQ(result[2].row[1].to_int(), 42); - EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_4"); + EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_4"); EXPECT_EQ(result[3].row[1].to_int(), 41); - EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_5"); + EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_5"); EXPECT_EQ(result[4].row[1].to_int(), 44); } @@ -571,11 +571,11 @@ TEST_CASE(select_with_order_by_column_not_in_result) result = execute(database, "SELECT TextColumn FROM TestSchema.TestTable ORDER BY IntColumn;"); EXPECT_EQ(result.size(), 5u); - EXPECT_EQ(result[0].row[0].to_deprecated_string(), "Test_3"); - EXPECT_EQ(result[1].row[0].to_deprecated_string(), "Test_4"); - EXPECT_EQ(result[2].row[0].to_deprecated_string(), "Test_2"); - EXPECT_EQ(result[3].row[0].to_deprecated_string(), "Test_5"); - EXPECT_EQ(result[4].row[0].to_deprecated_string(), "Test_1"); + EXPECT_EQ(result[0].row[0].to_byte_string(), "Test_3"); + EXPECT_EQ(result[1].row[0].to_byte_string(), "Test_4"); + EXPECT_EQ(result[2].row[0].to_byte_string(), "Test_2"); + EXPECT_EQ(result[3].row[0].to_byte_string(), "Test_5"); + EXPECT_EQ(result[4].row[0].to_byte_string(), "Test_1"); } TEST_CASE(select_with_limit) @@ -586,7 +586,7 @@ TEST_CASE(select_with_limit) create_table(database); for (auto count = 0; count < 100; count++) { auto result = execute(database, - DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); + ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); EXPECT(result.size() == 1); } auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10;"); @@ -602,7 +602,7 @@ TEST_CASE(select_with_limit_and_offset) create_table(database); for (auto count = 0; count < 100; count++) { auto result = execute(database, - DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); + ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); EXPECT(result.size() == 1); } auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 10;"); @@ -617,7 +617,7 @@ TEST_CASE(select_with_order_limit_and_offset) create_table(database); for (auto count = 0; count < 100; count++) { auto result = execute(database, - DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); + ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); EXPECT(result.size() == 1); } auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable ORDER BY IntColumn LIMIT 10 OFFSET 10;"); @@ -642,7 +642,7 @@ TEST_CASE(select_with_limit_out_of_bounds) create_table(database); for (auto count = 0; count < 100; count++) { auto result = execute(database, - DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); + ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); EXPECT(result.size() == 1); } auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 500;"); @@ -657,7 +657,7 @@ TEST_CASE(select_with_offset_out_of_bounds) create_table(database); for (auto count = 0; count < 100; count++) { auto result = execute(database, - DeprecatedString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); + ByteString::formatted("INSERT INTO TestSchema.TestTable ( TextColumn, IntColumn ) VALUES ( 'Test_{}', {} );", count, count)); EXPECT(result.size() == 1); } auto result = execute(database, "SELECT TextColumn, IntColumn FROM TestSchema.TestTable LIMIT 10 OFFSET 200;"); @@ -673,11 +673,11 @@ TEST_CASE(describe_table) auto result = execute(database, "DESCRIBE TABLE TestSchema.TestTable;"); EXPECT_EQ(result.size(), 2u); - EXPECT_EQ(result[0].row[0].to_deprecated_string(), "TEXTCOLUMN"); - EXPECT_EQ(result[0].row[1].to_deprecated_string(), "text"); + EXPECT_EQ(result[0].row[0].to_byte_string(), "TEXTCOLUMN"); + EXPECT_EQ(result[0].row[1].to_byte_string(), "text"); - EXPECT_EQ(result[1].row[0].to_deprecated_string(), "INTCOLUMN"); - EXPECT_EQ(result[1].row[1].to_deprecated_string(), "int"); + EXPECT_EQ(result[1].row[0].to_byte_string(), "INTCOLUMN"); + EXPECT_EQ(result[1].row[1].to_byte_string(), "int"); } TEST_CASE(binary_operator_execution) @@ -688,7 +688,7 @@ TEST_CASE(binary_operator_execution) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } @@ -762,7 +762,7 @@ TEST_CASE(binary_operator_failure) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } @@ -772,7 +772,7 @@ TEST_CASE(binary_operator_failure) auto error = result.release_error(); EXPECT_EQ(error.error(), SQL::SQLErrorCode::NumericOperatorTypeMismatch); - auto message = DeprecatedString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op); + auto message = ByteString::formatted("NumericOperatorTypeMismatch: Cannot apply '{}' operator to non-numeric operands", op); EXPECT_EQ(error.error_string(), message); }; @@ -832,7 +832,7 @@ TEST_CASE(delete_single_row) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } @@ -876,7 +876,7 @@ TEST_CASE(delete_multiple_rows) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } @@ -916,7 +916,7 @@ TEST_CASE(delete_all_rows) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } @@ -950,7 +950,7 @@ TEST_CASE(update_single_row) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } @@ -995,7 +995,7 @@ TEST_CASE(update_multiple_rows) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } @@ -1036,7 +1036,7 @@ TEST_CASE(update_all_rows) create_table(database); for (auto count = 0; count < 10; ++count) { - auto result = execute(database, DeprecatedString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); + auto result = execute(database, ByteString::formatted("INSERT INTO TestSchema.TestTable VALUES ( 'T{}', {} );", count, count)); EXPECT_EQ(result.size(), 1u); } diff --git a/Tests/LibSQL/TestSqlStatementParser.cpp b/Tests/LibSQL/TestSqlStatementParser.cpp index 81de1868cfb..9092c7f4c52 100644 --- a/Tests/LibSQL/TestSqlStatementParser.cpp +++ b/Tests/LibSQL/TestSqlStatementParser.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ namespace { -using ParseResult = AK::Result, DeprecatedString>; +using ParseResult = AK::Result, ByteString>; ParseResult parse(StringView sql) { @@ -27,7 +27,7 @@ ParseResult parse(StringView sql) auto statement = parser.next_statement(); if (parser.has_errors()) { - return parser.errors()[0].to_deprecated_string(); + return parser.errors()[0].to_byte_string(); } return statement; @@ -393,7 +393,7 @@ TEST_CASE(update) EXPECT(parse("UPDATE OR table_name SET column_name=4;"sv).is_error()); EXPECT(parse("UPDATE OR foo table_name SET column_name=4;"sv).is_error()); - auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector expected_returned_column_aliases) { + auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector expected_returned_column_aliases) { auto statement = TRY_OR_FAIL(parse(sql)); EXPECT(is(*statement)); @@ -437,7 +437,7 @@ TEST_CASE(update) } }; - Vector> update_columns { { "COLUMN_NAME" } }; + Vector> update_columns { { "COLUMN_NAME" } }; validate("UPDATE OR ABORT table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); validate("UPDATE OR FAIL table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); validate("UPDATE OR IGNORE table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); @@ -578,7 +578,7 @@ TEST_CASE(select) }; struct Ordering { - DeprecatedString collation_name; + ByteString collation_name; SQL::Order order; SQL::Nulls nulls; }; @@ -752,16 +752,16 @@ TEST_CASE(common_table_expression) TEST_CASE(nested_subquery_limit) { - auto subquery = DeprecatedString::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1); - EXPECT(!parse(DeprecatedString::formatted("SELECT * FROM {};"sv, subquery)).is_error()); - EXPECT(parse(DeprecatedString::formatted("SELECT * FROM ({});"sv, subquery)).is_error()); + auto subquery = ByteString::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1); + EXPECT(!parse(ByteString::formatted("SELECT * FROM {};"sv, subquery)).is_error()); + EXPECT(parse(ByteString::formatted("SELECT * FROM ({});"sv, subquery)).is_error()); } TEST_CASE(bound_parameter_limit) { - auto subquery = DeprecatedString::repeated("?, "sv, SQL::AST::Limits::maximum_bound_parameters); - EXPECT(!parse(DeprecatedString::formatted("INSERT INTO table_name VALUES ({}42);"sv, subquery)).is_error()); - EXPECT(parse(DeprecatedString::formatted("INSERT INTO table_name VALUES ({}?);"sv, subquery)).is_error()); + auto subquery = ByteString::repeated("?, "sv, SQL::AST::Limits::maximum_bound_parameters); + EXPECT(!parse(ByteString::formatted("INSERT INTO table_name VALUES ({}42);"sv, subquery)).is_error()); + EXPECT(parse(ByteString::formatted("INSERT INTO table_name VALUES ({}?);"sv, subquery)).is_error()); } TEST_CASE(describe_table) diff --git a/Tests/LibSQL/TestSqlValueAndTuple.cpp b/Tests/LibSQL/TestSqlValueAndTuple.cpp index cacdfe61cb3..65263531339 100644 --- a/Tests/LibSQL/TestSqlValueAndTuple.cpp +++ b/Tests/LibSQL/TestSqlValueAndTuple.cpp @@ -17,7 +17,7 @@ TEST_CASE(null_value) { SQL::Value v(SQL::SQLType::Null); EXPECT_EQ(v.type(), SQL::SQLType::Null); - EXPECT_EQ(v.to_deprecated_string(), "(null)"sv); + EXPECT_EQ(v.to_byte_string(), "(null)"sv); EXPECT(!v.to_bool().has_value()); EXPECT(!v.to_int().has_value()); EXPECT(!v.to_int().has_value()); @@ -44,25 +44,25 @@ TEST_CASE(text_value) v = "Test"sv; EXPECT_EQ(v.type(), SQL::SQLType::Text); - EXPECT_EQ(v.to_deprecated_string(), "Test"sv); + EXPECT_EQ(v.to_byte_string(), "Test"sv); } { - SQL::Value v(DeprecatedString("String Test"sv)); + SQL::Value v(ByteString("String Test"sv)); EXPECT_EQ(v.type(), SQL::SQLType::Text); - EXPECT_EQ(v.to_deprecated_string(), "String Test"sv); + EXPECT_EQ(v.to_byte_string(), "String Test"sv); - v = DeprecatedString("String Test 2"sv); + v = ByteString("String Test 2"sv); EXPECT_EQ(v.type(), SQL::SQLType::Text); - EXPECT_EQ(v.to_deprecated_string(), "String Test 2"sv); + EXPECT_EQ(v.to_byte_string(), "String Test 2"sv); } { SQL::Value v("const char * Test"); EXPECT_EQ(v.type(), SQL::SQLType::Text); - EXPECT_EQ(v.to_deprecated_string(), "const char * Test"sv); + EXPECT_EQ(v.to_byte_string(), "const char * Test"sv); v = "const char * Test 2"; EXPECT_EQ(v.type(), SQL::SQLType::Text); - EXPECT_EQ(v.to_deprecated_string(), "const char * Test 2"sv); + EXPECT_EQ(v.to_byte_string(), "const char * Test 2"sv); } } @@ -149,7 +149,7 @@ TEST_CASE(integer_value) EXPECT(v.to_int().has_value()); EXPECT_EQ(v.to_int().value(), 42); - EXPECT_EQ(v.to_deprecated_string(), "42"sv); + EXPECT_EQ(v.to_byte_string(), "42"sv); EXPECT(v.to_double().has_value()); EXPECT((v.to_double().value() - 42.0) < NumericLimits().epsilon()); @@ -261,7 +261,7 @@ TEST_CASE(float_value) EXPECT(v.to_int().has_value()); EXPECT_EQ(v.to_int().value(), 3); - EXPECT_EQ(v.to_deprecated_string(), "3.14"); + EXPECT_EQ(v.to_byte_string(), "3.14"); EXPECT(v.to_bool().has_value()); EXPECT(v.to_bool().value()); @@ -274,7 +274,7 @@ TEST_CASE(float_value) EXPECT(v.to_int().has_value()); EXPECT_EQ(v.to_int().value(), 0); - EXPECT_EQ(v.to_deprecated_string(), "0"sv); + EXPECT_EQ(v.to_byte_string(), "0"sv); EXPECT(v.to_bool().has_value()); EXPECT(!v.to_bool().value()); @@ -420,7 +420,7 @@ TEST_CASE(bool_value) EXPECT(v.to_int().has_value()); EXPECT_EQ(v.to_int().value(), 1); - EXPECT_EQ(v.to_deprecated_string(), "true"sv); + EXPECT_EQ(v.to_byte_string(), "true"sv); EXPECT(v.to_double().has_value()); EXPECT((v.to_double().value() - 1.0) < NumericLimits().epsilon()); @@ -434,7 +434,7 @@ TEST_CASE(bool_value) EXPECT(v.to_int().has_value()); EXPECT_EQ(v.to_int().value(), 0); - EXPECT_EQ(v.to_deprecated_string(), "false"sv); + EXPECT_EQ(v.to_byte_string(), "false"sv); EXPECT(v.to_double().has_value()); EXPECT(v.to_double().value() < NumericLimits().epsilon()); @@ -448,7 +448,7 @@ TEST_CASE(bool_value) EXPECT(v.to_int().has_value()); EXPECT_EQ(v.to_int().value(), 1); - EXPECT_EQ(v.to_deprecated_string(), "true"sv); + EXPECT_EQ(v.to_byte_string(), "true"sv); EXPECT(v.to_double().has_value()); EXPECT((v.to_double().value() - 1.0) < NumericLimits().epsilon()); diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp index b4feabdb17b..4cdc6bcd191 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -24,14 +24,14 @@ static ByteBuffer operator""_b(char const* string, size_t length) } ErrorOr> load_certificates(); -DeprecatedString locate_ca_certs_file(); +ByteString locate_ca_certs_file(); -DeprecatedString locate_ca_certs_file() +ByteString locate_ca_certs_file() { if (FileSystem::exists(ca_certs_file)) { return ca_certs_file; } - auto on_target_path = DeprecatedString("/etc/cacert.pem"); + auto on_target_path = ByteString("/etc/cacert.pem"); if (FileSystem::exists(on_target_path)) { return on_target_path; } diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index b1e5d17cf66..f9ee31c46e0 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -21,7 +21,7 @@ TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile) return StringView { error_string, strlen(error_string) }; }; - auto filename = TRY(vm.argument(0).to_deprecated_string(vm)); + auto filename = TRY(vm.argument(0).to_byte_string(vm)); auto file = Core::File::open(filename, Core::File::OpenMode::Read); if (file.is_error()) return vm.throw_completion(error_code_to_string(file.error().code())); @@ -114,7 +114,7 @@ TESTJS_GLOBAL_FUNCTION(parse_webassembly_module, parseWebAssemblyModule) FixedMemoryStream stream { array.data() }; auto result = Wasm::Module::parse(stream); if (result.is_error()) - return vm.throw_completion(Wasm::parse_error_to_deprecated_string(result.error())); + return vm.throw_completion(Wasm::parse_error_to_byte_string(result.error())); HashMap imports; auto import_value = vm.argument(1); @@ -157,7 +157,7 @@ void WebAssemblyModule::initialize(JS::Realm& realm) JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export) { - auto name = TRY(vm.argument(0).to_deprecated_string(vm)); + auto name = TRY(vm.argument(0).to_byte_string(vm)); auto this_value = vm.this_value(); auto object = TRY(this_value.to_object(vm)); if (!is(*object)) diff --git a/Tests/LibWeb/TestHTMLTokenizer.cpp b/Tests/LibWeb/TestHTMLTokenizer.cpp index b4ac3b0fbfc..1bb25f3336d 100644 --- a/Tests/LibWeb/TestHTMLTokenizer.cpp +++ b/Tests/LibWeb/TestHTMLTokenizer.cpp @@ -234,7 +234,7 @@ TEST_CASE(regression) auto file_size = MUST(file->size()); auto content = MUST(ByteBuffer::create_uninitialized(file_size)); MUST(file->read_until_filled(content.bytes())); - DeprecatedString file_contents { content.bytes() }; + ByteString file_contents { content.bytes() }; auto tokens = run_tokenizer(file_contents); u32 hash = hash_tokens(tokens); EXPECT_EQ(hash, 3657343287u); diff --git a/Tests/Spreadsheet/test-spreadsheet.cpp b/Tests/Spreadsheet/test-spreadsheet.cpp index 541728182a0..3b366beeddf 100644 --- a/Tests/Spreadsheet/test-spreadsheet.cpp +++ b/Tests/Spreadsheet/test-spreadsheet.cpp @@ -15,13 +15,13 @@ static constexpr auto s_spreadsheet_runtime_path = "/res/js/Spreadsheet/runtime. static constexpr auto s_spreadsheet_runtime_path = "../../../../Base/res/js/Spreadsheet/runtime.js"sv; #endif -TESTJS_RUN_FILE_FUNCTION(DeprecatedString const&, JS::Realm& realm, JS::ExecutionContext& global_execution_context) +TESTJS_RUN_FILE_FUNCTION(ByteString const&, JS::Realm& realm, JS::ExecutionContext& global_execution_context) { auto run_file = [&](StringView name) { auto result = Test::JS::parse_script(name, realm); if (result.is_error()) { warnln("Unable to parse {}", name); - warnln("{}", result.error().error.to_deprecated_string()); + warnln("{}", result.error().error.to_byte_string()); warnln("{}", result.error().hint); Test::cleanup_and_exit(); } diff --git a/Tests/Utilities/TestSed.cpp b/Tests/Utilities/TestSed.cpp index be6fc1089a7..c6b111251ad 100644 --- a/Tests/Utilities/TestSed.cpp +++ b/Tests/Utilities/TestSed.cpp @@ -20,7 +20,7 @@ static void run_sed(Vector&& arguments, StringView standard_input, auto [stdout, stderr] = MUST(sed->read_all()); auto status = MUST(sed->status()); if (status != Core::Command::ProcessResult::DoneWithZeroExitCode) { - FAIL(DeprecatedString::formatted("sed didn't exit cleanly: status: {}, stdout:{}, stderr: {}", static_cast(status), StringView { stdout.bytes() }, StringView { stderr.bytes() })); + FAIL(ByteString::formatted("sed didn't exit cleanly: status: {}, stdout:{}, stderr: {}", static_cast(status), StringView { stdout.bytes() }, StringView { stderr.bytes() })); } EXPECT_EQ(StringView { expected_stdout.bytes() }, StringView { stdout.bytes() }); } diff --git a/Userland/Applets/Audio/main.cpp b/Userland/Applets/Audio/main.cpp index 2e0019e6c37..6a7b295f756 100644 --- a/Userland/Applets/Audio/main.cpp +++ b/Userland/Applets/Audio/main.cpp @@ -170,7 +170,7 @@ private: painter.blit({}, audio_bitmap, audio_bitmap.rect()); if (show_percent()) { - auto volume_text = m_audio_muted ? "mute" : DeprecatedString::formatted("{}%", m_audio_volume); + auto volume_text = m_audio_muted ? "mute" : ByteString::formatted("{}%", m_audio_volume); painter.draw_text(Gfx::IntRect { 16, 3, 24, 16 }, volume_text, Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::TopLeft, palette().window_text()); } } diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp index 6bd26f3d5f0..6dba68357f9 100644 --- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp +++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp @@ -39,7 +39,7 @@ ErrorOr ClipboardHistoryModel::column_name(int column) const } } -static StringView bpp_for_format_resilient(DeprecatedString format) +static StringView bpp_for_format_resilient(ByteString format) { unsigned format_uint = format.to_uint().value_or(static_cast(Gfx::BitmapFormat::Invalid)); // Cannot use Gfx::Bitmap::bpp_for_format here, as we have to accept invalid enum values. @@ -64,7 +64,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode switch (index.column()) { case Column::Data: if (data_and_type.mime_type.starts_with("text/"sv)) - return DeprecatedString::copy(data_and_type.data); + return ByteString::copy(data_and_type.data); if (data_and_type.mime_type == "image/x-serenityos") { StringBuilder builder; builder.append('['); @@ -75,7 +75,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode builder.append(bpp_for_format_resilient(data_and_type.metadata.get("format").value_or("0"))); builder.append(']'); builder.append(" bitmap"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } if (data_and_type.mime_type.starts_with("glyph/"sv)) { StringBuilder builder; @@ -90,7 +90,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode builder.append_code_point(start); builder.appendff(") [{}x{}]", width, height); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } return "<...>"; case Column::Type: @@ -98,13 +98,13 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode case Column::Size: return AK::human_readable_size(data_and_type.data.size()); case Column::Time: - return time.to_deprecated_string(); + return time.to_byte_string(); default: VERIFY_NOT_REACHED(); } } -void ClipboardHistoryModel::clipboard_content_did_change(DeprecatedString const&) +void ClipboardHistoryModel::clipboard_content_did_change(ByteString const&) { auto data_and_type = GUI::Clipboard::the().fetch_data_and_type(); if (!(data_and_type.data.is_empty() && data_and_type.mime_type.is_empty() && data_and_type.metadata.is_empty())) @@ -184,7 +184,7 @@ ErrorOr ClipboardHistoryModel::ClipboardItem::to_json() const return object; } -ErrorOr ClipboardHistoryModel::read_from_file(DeprecatedString const& path) +ErrorOr ClipboardHistoryModel::read_from_file(ByteString const& path) { m_path = path; @@ -219,7 +219,7 @@ ErrorOr ClipboardHistoryModel::write_to_file(bool rewrite_all) auto const write_element = [](Core::File& file, ClipboardItem const& item) -> ErrorOr { if (!item.data_and_type.mime_type.starts_with("text/"sv)) return {}; - TRY(file.write_until_depleted(TRY(item.to_json()).to_deprecated_string().bytes())); + TRY(file.write_until_depleted(TRY(item.to_json()).to_byte_string().bytes())); TRY(file.write_until_depleted("\n"sv.bytes())); return {}; }; diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h index bb9ea568509..0d33407c065 100644 --- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h +++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.h @@ -44,7 +44,7 @@ public: void clear(); bool is_empty() { return m_history_items.is_empty(); } - ErrorOr read_from_file(DeprecatedString const& path); + ErrorOr read_from_file(ByteString const& path); ErrorOr write_to_file(bool rewrite_all); ErrorOr invalidate_model_and_file(bool rewrite_all); @@ -64,10 +64,10 @@ private: virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; } // ^GUI::Clipboard::ClipboardClient - virtual void clipboard_content_did_change(DeprecatedString const&) override; + virtual void clipboard_content_did_change(ByteString const&) override; Vector m_history_items; size_t m_history_limit; - DeprecatedString m_path; + ByteString m_path; }; diff --git a/Userland/Applets/ClipboardHistory/main.cpp b/Userland/Applets/ClipboardHistory/main.cpp index 09585638061..5f685691ec9 100644 --- a/Userland/Applets/ClipboardHistory/main.cpp +++ b/Userland/Applets/ClipboardHistory/main.cpp @@ -23,7 +23,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::create(arguments)); auto clipboard_config = TRY(Core::ConfigFile::open_for_app("ClipboardHistory")); - auto const default_path = DeprecatedString::formatted("{}/{}", Core::StandardPaths::data_directory(), "Clipboard/ClipboardHistory.json"sv); + auto const default_path = ByteString::formatted("{}/{}", Core::StandardPaths::data_directory(), "Clipboard/ClipboardHistory.json"sv); auto const clipboard_file_path = clipboard_config->read_entry("Clipboard", "ClipboardFilePath", default_path); auto const parent_path = LexicalPath(clipboard_file_path); TRY(Core::Directory::create(parent_path.dirname(), Core::Directory::CreateDirectories::Yes)); diff --git a/Userland/Applets/Keymap/KeymapStatusWidget.cpp b/Userland/Applets/Keymap/KeymapStatusWidget.cpp index 7b6f2fae222..27afd9fa77d 100644 --- a/Userland/Applets/Keymap/KeymapStatusWidget.cpp +++ b/Userland/Applets/Keymap/KeymapStatusWidget.cpp @@ -63,10 +63,10 @@ ErrorOr KeymapStatusWidget::refresh_menu() return {}; } -void KeymapStatusWidget::set_current_keymap(DeprecatedString const& keymap) +void KeymapStatusWidget::set_current_keymap(ByteString const& keymap) { m_current_keymap = keymap; - set_tooltip(MUST(String::from_deprecated_string(keymap))); + set_tooltip(MUST(String::from_byte_string(keymap))); update(); } diff --git a/Userland/Applets/Keymap/KeymapStatusWidget.h b/Userland/Applets/Keymap/KeymapStatusWidget.h index 8ee174cf2be..adaac8aa17a 100644 --- a/Userland/Applets/Keymap/KeymapStatusWidget.h +++ b/Userland/Applets/Keymap/KeymapStatusWidget.h @@ -15,7 +15,7 @@ class KeymapStatusWidget final : public GUI::Widget { public: virtual ~KeymapStatusWidget() override; - void set_current_keymap(DeprecatedString const& keymap); + void set_current_keymap(ByteString const& keymap); private: KeymapStatusWidget(); @@ -27,6 +27,6 @@ private: RefPtr m_context_menu; - DeprecatedString m_current_keymap; + ByteString m_current_keymap; GUI::ActionGroup m_keymaps_group; }; diff --git a/Userland/Applets/Keymap/KeymapStatusWindow.cpp b/Userland/Applets/Keymap/KeymapStatusWindow.cpp index a5ad58f0e23..03c1001d483 100644 --- a/Userland/Applets/Keymap/KeymapStatusWindow.cpp +++ b/Userland/Applets/Keymap/KeymapStatusWindow.cpp @@ -27,7 +27,7 @@ void KeymapStatusWindow::wm_event(GUI::WMEvent& event) } } -void KeymapStatusWindow::set_keymap_text(DeprecatedString const& keymap) +void KeymapStatusWindow::set_keymap_text(ByteString const& keymap) { m_status_widget->set_current_keymap(keymap); } diff --git a/Userland/Applets/Keymap/KeymapStatusWindow.h b/Userland/Applets/Keymap/KeymapStatusWindow.h index 0ba3c106dc8..0c6e5d9e4b8 100644 --- a/Userland/Applets/Keymap/KeymapStatusWindow.h +++ b/Userland/Applets/Keymap/KeymapStatusWindow.h @@ -23,5 +23,5 @@ private: RefPtr m_status_widget; - void set_keymap_text(DeprecatedString const& keymap); + void set_keymap_text(ByteString const& keymap); }; diff --git a/Userland/Applets/Network/main.cpp b/Userland/Applets/Network/main.cpp index fd7f8e3655f..3e40d1a7298 100644 --- a/Userland/Applets/Network/main.cpp +++ b/Userland/Applets/Network/main.cpp @@ -113,8 +113,8 @@ private: int connected_adapters = 0; json.as_array().for_each([&adapter_info, &connected_adapters](auto& value) { auto& if_object = value.as_object(); - auto ip_address = if_object.get_deprecated_string("ipv4_address"sv).value_or("no IP"); - auto ifname = if_object.get_deprecated_string("name"sv).value(); + auto ip_address = if_object.get_byte_string("ipv4_address"sv).value_or("no IP"); + auto ifname = if_object.get_byte_string("name"sv).value(); auto link_up = if_object.get_bool("link_up"sv).value(); auto link_speed = if_object.get_i32("link_speed"sv).value(); diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index bdd94df5b55..a7fd039b0a1 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -292,13 +292,13 @@ void GLContextWidget::timer_event(Core::TimerEvent&) bool GLContextWidget::load_file(String const& filename, NonnullOwnPtr file) { if (!filename.bytes_as_string_view().ends_with(".obj"sv)) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Opening \"{}\" failed: invalid file type", filename), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Opening \"{}\" failed: invalid file type", filename), "Error"sv, GUI::MessageBox::Type::Error); return false; } auto new_mesh = m_mesh_loader->load(filename, move(file)); if (new_mesh.is_error()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Reading \"{}\" failed: {}", filename, new_mesh.release_error()), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Reading \"{}\" failed: {}", filename, new_mesh.release_error()), "Error"sv, GUI::MessageBox::Type::Error); return false; } @@ -330,7 +330,7 @@ bool GLContextWidget::load_file(String const& filename, NonnullOwnPtrtriangle_count()); - window()->set_title(DeprecatedString::formatted("{} - 3D File Viewer", filename)); + window()->set_title(ByteString::formatted("{} - 3D File Viewer", filename)); return true; } @@ -580,7 +580,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, filename); if (file.is_error()) { if (file.error().code() != ENOENT) - GUI::MessageBox::show(window, DeprecatedString::formatted("Opening \"{}\" failed: {}", filename, strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, ByteString::formatted("Opening \"{}\" failed: {}", filename, strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return 1; } widget->load_file(file.value().filename(), file.value().release_stream()); diff --git a/Userland/Applications/AnalogClock/AnalogClock.cpp b/Userland/Applications/AnalogClock/AnalogClock.cpp index c421a5680e5..54524fe2846 100644 --- a/Userland/Applications/AnalogClock/AnalogClock.cpp +++ b/Userland/Applications/AnalogClock/AnalogClock.cpp @@ -130,7 +130,7 @@ void AnalogClock::paint_event(GUI::PaintEvent& event) void AnalogClock::update_title_date() { - window()->set_title(Core::DateTime::now().to_deprecated_string("%Y-%m-%d"sv)); + window()->set_title(Core::DateTime::now().to_byte_string("%Y-%m-%d"sv)); } void AnalogClock::context_menu_event(GUI::ContextMenuEvent& event) diff --git a/Userland/Applications/AnalogClock/main.cpp b/Userland/Applications/AnalogClock/main.cpp index ecb3b87d324..5f356feee79 100644 --- a/Userland/Applications/AnalogClock/main.cpp +++ b/Userland/Applications/AnalogClock/main.cpp @@ -26,7 +26,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-analog-clock"sv)); auto window = GUI::Window::construct(); - window->set_title(Core::DateTime::now().to_deprecated_string("%Y-%m-%d"sv)); + window->set_title(Core::DateTime::now().to_byte_string("%Y-%m-%d"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->resize(170, 170); window->set_resizable(false); diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index c0c66a46873..11c5e85c4db 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -70,7 +70,7 @@ AppProvider::AppProvider() }); } -void AppProvider::query(DeprecatedString const& query, Function>)> on_complete) +void AppProvider::query(ByteString const& query, Function>)> on_complete) { if (query.starts_with('=') || query.starts_with('$')) return; @@ -80,7 +80,7 @@ void AppProvider::query(DeprecatedString const& query, Functionname())) score = NumericLimits::max(); @@ -98,7 +98,7 @@ void AppProvider::query(DeprecatedString const& query, Function>)> on_complete) +void CalculatorProvider::query(ByteString const& query, Function>)> on_complete) { if (!query.starts_with('=')) return; @@ -116,11 +116,11 @@ void CalculatorProvider::query(DeprecatedString const& query, Function> results; @@ -138,7 +138,7 @@ FileProvider::FileProvider() build_filesystem_cache(); } -void FileProvider::query(DeprecatedString const& query, Function>)> on_complete) +void FileProvider::query(ByteString const& query, Function>)> on_complete) { build_filesystem_cache(); @@ -147,7 +147,7 @@ void FileProvider::query(DeprecatedString const& query, Function>>>::construct( [this, query](auto& task) -> Optional>> { - BinaryHeap sorted_results; + BinaryHeap sorted_results; for (auto& path : m_full_path_cache) { if (task.is_canceled()) @@ -204,7 +204,7 @@ void FileProvider::build_filesystem_cache() (void)Threading::BackgroundAction::construct( [this, strong_ref = NonnullRefPtr(*this)](auto&) { - DeprecatedString slash = "/"; + ByteString slash = "/"; auto timer = Core::ElapsedTimer::start_new(); while (!m_work_queue.is_empty()) { auto base_directory = m_work_queue.dequeue(); @@ -241,7 +241,7 @@ void FileProvider::build_filesystem_cache() }); } -void TerminalProvider::query(DeprecatedString const& query, Function>)> on_complete) +void TerminalProvider::query(ByteString const& query, Function>)> on_complete) { if (!query.starts_with('$')) return; @@ -253,7 +253,7 @@ void TerminalProvider::query(DeprecatedString const& query, Function>)> on_complete) +void URLProvider::query(ByteString const& query, Function>)> on_complete) { if (query.is_empty() || query.starts_with('=') || query.starts_with('$')) return; @@ -263,7 +263,7 @@ void URLProvider::query(DeprecatedString const& query, Function() || url.host() == String {}) - url.set_host(String::from_deprecated_string(query).release_value_but_fixme_should_propagate_errors()); + url.set_host(String::from_byte_string(query).release_value_but_fixme_should_propagate_errors()); if (url.path_segment_count() == 0) url.set_paths({ "" }); diff --git a/Userland/Applications/Assistant/Providers.h b/Userland/Applications/Assistant/Providers.h index 091411c7f3d..b4450bcd7d7 100644 --- a/Userland/Applications/Assistant/Providers.h +++ b/Userland/Applications/Assistant/Providers.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -27,7 +27,7 @@ public: virtual Gfx::Bitmap const* bitmap() const = 0; - DeprecatedString const& title() const { return m_title; } + ByteString const& title() const { return m_title; } String const& tooltip() const { return m_tooltip; } int score() const { return m_score; } bool equals(Result const& other) const @@ -38,7 +38,7 @@ public: } protected: - Result(DeprecatedString title, String tooltip, int score = 0) + Result(ByteString title, String tooltip, int score = 0) : m_title(move(title)) , m_tooltip(move(tooltip)) , m_score(score) @@ -46,14 +46,14 @@ protected: } private: - DeprecatedString m_title; + ByteString m_title; String m_tooltip; int m_score { 0 }; }; class AppResult final : public Result { public: - AppResult(RefPtr bitmap, DeprecatedString title, String tooltip, NonnullRefPtr af, DeprecatedString arguments, int score) + AppResult(RefPtr bitmap, ByteString title, String tooltip, NonnullRefPtr af, ByteString arguments, int score) : Result(move(title), move(tooltip), score) , m_app_file(move(af)) , m_arguments(move(arguments)) @@ -67,13 +67,13 @@ public: private: NonnullRefPtr m_app_file; - DeprecatedString m_arguments; + ByteString m_arguments; RefPtr m_bitmap; }; class CalculatorResult final : public Result { public: - explicit CalculatorResult(DeprecatedString title) + explicit CalculatorResult(ByteString title) : Result(move(title), "Copy to Clipboard"_string, 100) , m_bitmap(GUI::Icon::default_icon("app-calculator"sv).bitmap_for_size(16)) { @@ -89,7 +89,7 @@ private: class FileResult final : public Result { public: - explicit FileResult(DeprecatedString title, int score) + explicit FileResult(ByteString title, int score) : Result(move(title), String(), score) { } @@ -101,7 +101,7 @@ public: class TerminalResult final : public Result { public: - explicit TerminalResult(DeprecatedString command) + explicit TerminalResult(ByteString command) : Result(move(command), "Run command in Terminal"_string, 100) , m_bitmap(GUI::Icon::default_icon("app-terminal"sv).bitmap_for_size(16)) { @@ -118,7 +118,7 @@ private: class URLResult final : public Result { public: explicit URLResult(const URL& url) - : Result(url.to_deprecated_string(), "Open URL in Browser"_string, 50) + : Result(url.to_byte_string(), "Open URL in Browser"_string, 50) , m_bitmap(GUI::Icon::default_icon("app-browser"sv).bitmap_for_size(16)) { } @@ -135,14 +135,14 @@ class Provider : public RefCounted { public: virtual ~Provider() = default; - virtual void query(DeprecatedString const&, Function>)> on_complete) = 0; + virtual void query(ByteString const&, Function>)> on_complete) = 0; }; class AppProvider final : public Provider { public: AppProvider(); - void query(DeprecatedString const& query, Function>)> on_complete) override; + void query(ByteString const& query, Function>)> on_complete) override; private: Vector> m_app_file_cache; @@ -150,31 +150,31 @@ private: class CalculatorProvider final : public Provider { public: - void query(DeprecatedString const& query, Function>)> on_complete) override; + void query(ByteString const& query, Function>)> on_complete) override; }; class FileProvider final : public Provider { public: FileProvider(); - void query(DeprecatedString const& query, Function>)> on_complete) override; + void query(ByteString const& query, Function>)> on_complete) override; void build_filesystem_cache(); private: RefPtr>>>> m_fuzzy_match_work; bool m_building_cache { false }; - Vector m_full_path_cache; - Queue m_work_queue; + Vector m_full_path_cache; + Queue m_work_queue; }; class TerminalProvider final : public Provider { public: - void query(DeprecatedString const& query, Function>)> on_complete) override; + void query(ByteString const& query, Function>)> on_complete) override; }; class URLProvider final : public Provider { public: - void query(DeprecatedString const& query, Function>)> on_complete) override; + void query(ByteString const& query, Function>)> on_complete) override; }; } diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index 83aec39c260..a3cd79c3948 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -7,7 +7,7 @@ #include "Providers.h" #include -#include +#include #include #include #include @@ -40,7 +40,7 @@ struct AppState { size_t visible_result_count { 0 }; Threading::Mutex lock; - DeprecatedString last_query; + ByteString last_query; }; class ResultRow final : public GUI::Button { @@ -57,7 +57,7 @@ class ResultRow final : public GUI::Button { if (!m_context_menu) { m_context_menu = GUI::Menu::construct(); - if (LexicalPath path { text().to_deprecated_string() }; path.is_absolute()) { + if (LexicalPath path { text().to_byte_string() }; path.is_absolute()) { m_context_menu->add_action(GUI::Action::create("&Show in File Manager", MUST(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)), [=](auto&) { Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname(), path.basename())); })); @@ -86,7 +86,7 @@ public: Function>&&)> on_new_results; - void search(DeprecatedString const& query) + void search(ByteString const& query) { auto should_display_precached_results = false; for (size_t i = 0; i < ProviderCount; ++i) { @@ -139,7 +139,7 @@ private: Array, ProviderCount> m_providers; Threading::Mutex m_mutex; - HashMap>>, ProviderCount>> m_result_cache; + HashMap>>, ProviderCount>> m_result_cache; }; } @@ -249,7 +249,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& result = app_state.results[i]; auto& match = results_container.add(); match.set_icon(result->bitmap()); - match.set_text(String::from_deprecated_string(result->title()).release_value_but_fixme_should_propagate_errors()); + match.set_text(String::from_byte_string(result->title()).release_value_but_fixme_should_propagate_errors()); match.set_tooltip(result->tooltip()); match.on_click = [&result](auto) { result->activate(); diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp index 6b854e52029..56701c9cede 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.cpp +++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp @@ -88,12 +88,12 @@ private: }; } - DeprecatedString title() const + ByteString title() const { return m_title_textbox->text(); } - DeprecatedString url() const + ByteString url() const { return m_url_textbox->text(); } @@ -111,7 +111,7 @@ BookmarksBarWidget& BookmarksBarWidget::the() return *s_the; } -BookmarksBarWidget::BookmarksBarWidget(DeprecatedString const& bookmarks_file, bool enabled) +BookmarksBarWidget::BookmarksBarWidget(ByteString const& bookmarks_file, bool enabled) { s_the = this; set_layout(2, 0); @@ -207,8 +207,8 @@ void BookmarksBarWidget::model_did_update(unsigned) int width = 0; for (int item_index = 0; item_index < model()->row_count(); ++item_index) { - auto title = model()->index(item_index, 0).data().to_deprecated_string(); - auto url = model()->index(item_index, 1).data().to_deprecated_string(); + auto title = model()->index(item_index, 0).data().to_byte_string(); + auto url = model()->index(item_index, 1).data().to_byte_string(); Gfx::IntRect rect { width, 0, font().width_rounded_up(title) + 32, height() }; @@ -216,12 +216,12 @@ void BookmarksBarWidget::model_did_update(unsigned) m_bookmarks.append(button); button.set_button_style(Gfx::ButtonStyle::Coolbar); - button.set_text(String::from_deprecated_string(title).release_value_but_fixme_should_propagate_errors()); + button.set_text(String::from_byte_string(title).release_value_but_fixme_should_propagate_errors()); button.set_icon(g_icon_bag.filetype_html); button.set_fixed_size(font().width(title) + 32, 20); button.set_relative_rect(rect); button.set_focus_policy(GUI::FocusPolicy::TabFocus); - button.set_tooltip(MUST(String::from_deprecated_string(url))); + button.set_tooltip(MUST(String::from_byte_string(url))); button.set_allowed_mouse_buttons_for_pressing(GUI::MouseButton::Primary | GUI::MouseButton::Middle); button.on_click = [title, url, this](auto) { @@ -275,7 +275,7 @@ void BookmarksBarWidget::update_content_size() for (size_t i = m_last_visible_index; i < m_bookmarks.size(); ++i) { auto& bookmark = m_bookmarks.at(i); bookmark->set_visible(false); - m_additional_menu->add_action(GUI::Action::create(bookmark->text().to_deprecated_string(), g_icon_bag.filetype_html, [&](auto&) { bookmark->on_click(0); })); + m_additional_menu->add_action(GUI::Action::create(bookmark->text().to_byte_string(), g_icon_bag.filetype_html, [&](auto&) { bookmark->on_click(0); })); } } } @@ -284,7 +284,7 @@ bool BookmarksBarWidget::contains_bookmark(StringView url) { for (int item_index = 0; item_index < model()->row_count(); ++item_index) { - auto item_url = model()->index(item_index, 1).data().to_deprecated_string(); + auto item_url = model()->index(item_index, 1).data().to_byte_string(); if (item_url == url) { return true; } @@ -296,7 +296,7 @@ ErrorOr BookmarksBarWidget::remove_bookmark(StringView url) { for (int item_index = 0; item_index < model()->row_count(); ++item_index) { - auto item_url = model()->index(item_index, 1).data().to_deprecated_string(); + auto item_url = model()->index(item_index, 1).data().to_byte_string(); if (item_url == url) { auto& json_model = *static_cast(model()); @@ -332,7 +332,7 @@ ErrorOr BookmarksBarWidget::add_bookmark(StringView url, StringView title) auto model_has_updated = false; for (int item_index = 0; item_index < model()->row_count(); item_index++) { - auto item_url = model()->index(item_index, 1).data().to_deprecated_string(); + auto item_url = model()->index(item_index, 1).data().to_byte_string(); if (item_url == url) { TRY(update_model(values, [item_index](auto& model, auto&& values) { @@ -355,8 +355,8 @@ ErrorOr BookmarksBarWidget::add_bookmark(StringView url, StringView title) ErrorOr BookmarksBarWidget::edit_bookmark(StringView url) { for (int item_index = 0; item_index < model()->row_count(); ++item_index) { - auto item_title = model()->index(item_index, 0).data().to_deprecated_string(); - auto item_url = model()->index(item_index, 1).data().to_deprecated_string(); + auto item_title = model()->index(item_index, 0).data().to_byte_string(); + auto item_url = model()->index(item_index, 1).data().to_byte_string(); if (item_url == url) { auto values = BookmarkEditor::edit_bookmark(window(), item_title, item_url, PerformEditOn::ExistingBookmark); diff --git a/Userland/Applications/Browser/BookmarksBarWidget.h b/Userland/Applications/Browser/BookmarksBarWidget.h index 7741eb707f1..b4640fd0c0f 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.h +++ b/Userland/Applications/Browser/BookmarksBarWidget.h @@ -32,8 +32,8 @@ public: InNewWindow }; - Function on_bookmark_click; - Function on_bookmark_hover; + Function on_bookmark_click; + Function on_bookmark_hover; Function on_bookmark_change; bool contains_bookmark(StringView url); @@ -48,7 +48,7 @@ public: } private: - BookmarksBarWidget(DeprecatedString const&, bool enabled); + BookmarksBarWidget(ByteString const&, bool enabled); // ^GUI::ModelClient virtual void model_did_update(unsigned) override; @@ -67,7 +67,7 @@ private: RefPtr m_context_menu; RefPtr m_context_menu_default_action; - DeprecatedString m_context_menu_url; + ByteString m_context_menu_url; Vector> m_bookmarks; diff --git a/Userland/Applications/Browser/Browser.h b/Userland/Applications/Browser/Browser.h index 5e940301315..a1d4e07b4fb 100644 --- a/Userland/Applications/Browser/Browser.h +++ b/Userland/Applications/Browser/Browser.h @@ -6,22 +6,22 @@ #pragma once -#include +#include #include #include namespace Browser { -extern DeprecatedString g_home_url; -extern DeprecatedString g_new_tab_url; -extern DeprecatedString g_search_engine; +extern ByteString g_home_url; +extern ByteString g_new_tab_url; +extern ByteString g_search_engine; extern Vector g_content_filters; extern bool g_content_filters_enabled; extern Vector g_autoplay_allowlist; extern bool g_autoplay_allowed_on_all_websites; -extern Vector g_proxies; -extern HashMap g_proxy_mappings; +extern Vector g_proxies; +extern HashMap g_proxy_mappings; extern IconBag g_icon_bag; -extern DeprecatedString g_webdriver_content_ipc_path; +extern ByteString g_webdriver_content_ipc_path; } diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index ee16b1a490f..3a16d7159c3 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -41,12 +41,12 @@ namespace Browser { -static DeprecatedString bookmarks_file_path() +static ByteString bookmarks_file_path() { StringBuilder builder; builder.append(Core::StandardPaths::config_directory()); builder.append("/bookmarks.json"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, Vector const& initial_urls) @@ -275,11 +275,11 @@ void BrowserWindow::build_menus() m_change_homepage_action = GUI::Action::create( "Set Homepage URL...", g_icon_bag.go_home, [this](auto&) { - String homepage_url = String::from_deprecated_string(Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, Browser::default_homepage_url())).release_value_but_fixme_should_propagate_errors(); + String homepage_url = String::from_byte_string(Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, Browser::default_homepage_url())).release_value_but_fixme_should_propagate_errors(); if (GUI::InputBox::show(this, homepage_url, "Enter a URL:"sv, "Change Homepage"sv) == GUI::InputBox::ExecResult::OK) { if (URL(homepage_url).is_valid()) { Config::write_string("Browser"sv, "Preferences"sv, "Home"sv, homepage_url); - Browser::g_home_url = homepage_url.to_deprecated_string(); + Browser::g_home_url = homepage_url.to_byte_string(); } else { GUI::MessageBox::show_error(this, "The URL you have entered is not valid"sv); } @@ -412,7 +412,7 @@ void BrowserWindow::build_menus() m_disable_user_agent_spoofing->activate(); return; } - active_tab().view().debug_request("spoof-user-agent", user_agent.to_deprecated_string()); + active_tab().view().debug_request("spoof-user-agent", user_agent.to_byte_string()); action.set_status_tip(user_agent); }); spoof_user_agent_menu->add_action(custom_user_agent); @@ -497,7 +497,7 @@ ErrorOr BrowserWindow::load_search_engines(GUI::Menu& settings_menu) return; } - g_search_engine = search_engine.to_deprecated_string(); + g_search_engine = search_engine.to_byte_string(); Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, g_search_engine); action.set_status_tip(search_engine); }); @@ -506,7 +506,7 @@ ErrorOr BrowserWindow::load_search_engines(GUI::Menu& settings_menu) if (!search_engine_set && !g_search_engine.is_empty()) { custom_search_engine_action->set_checked(true); - custom_search_engine_action->set_status_tip(TRY(String::from_deprecated_string(g_search_engine))); + custom_search_engine_action->set_status_tip(TRY(String::from_byte_string(g_search_engine))); } return {}; @@ -526,7 +526,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab) { auto& title = tab.title(); auto url = tab.url(); - set_title(DeprecatedString::formatted("{} - Ladybird", title.is_empty() ? url.to_deprecated_string() : title)); + set_title(ByteString::formatted("{} - Ladybird", title.is_empty() ? url.to_byte_string() : title)); } Tab& BrowserWindow::create_new_tab(URL const& url, Web::HTML::ActivateTab activate) @@ -536,7 +536,7 @@ Tab& BrowserWindow::create_new_tab(URL const& url, Web::HTML::ActivateTab activa m_tab_widget->set_bar_visible(!is_fullscreen() && m_tab_widget->children().size() > 1); new_tab.on_title_change = [this, &new_tab](auto& title) { - m_tab_widget->set_tab_title(new_tab, String::from_deprecated_string(title).release_value_but_fixme_should_propagate_errors()); + m_tab_widget->set_tab_title(new_tab, String::from_byte_string(title).release_value_but_fixme_should_propagate_errors()); if (m_tab_widget->active_widget() == &new_tab) set_window_title_for_tab(new_tab); }; @@ -582,7 +582,7 @@ Tab& BrowserWindow::create_new_tab(URL const& url, Web::HTML::ActivateTab activa return m_cookie_jar.get_named_cookie(url, name); }; - new_tab.on_get_cookie = [this](auto& url, auto source) -> DeprecatedString { + new_tab.on_get_cookie = [this](auto& url, auto source) -> ByteString { return m_cookie_jar.get_cookie(url, source); }; @@ -622,7 +622,7 @@ Tab& BrowserWindow::create_new_tab(URL const& url, Web::HTML::ActivateTab activa void BrowserWindow::create_new_window(URL const& url) { - GUI::Process::spawn_or_show_error(this, "/bin/Browser"sv, Array { url.to_deprecated_string() }); + GUI::Process::spawn_or_show_error(this, "/bin/Browser"sv, Array { url.to_byte_string() }); } void BrowserWindow::content_filters_changed() diff --git a/Userland/Applications/Browser/CookiesModel.cpp b/Userland/Applications/Browser/CookiesModel.cpp index 4466599cc16..fbae8291045 100644 --- a/Userland/Applications/Browser/CookiesModel.cpp +++ b/Userland/Applications/Browser/CookiesModel.cpp @@ -95,7 +95,7 @@ GUI::Model::MatchResult CookiesModel::data_matches(GUI::ModelIndex const& index, return { TriState::True }; auto const& cookie = m_cookies[index.row()]; - auto haystack = DeprecatedString::formatted("{} {} {} {}", cookie.domain, cookie.path, cookie.name, cookie.value); + auto haystack = ByteString::formatted("{} {} {} {}", cookie.domain, cookie.path, cookie.name, cookie.value); auto match_result = fuzzy_match(needle, haystack); if (match_result.score > 0) return { TriState::True, match_result.score }; diff --git a/Userland/Applications/Browser/DownloadWidget.cpp b/Userland/Applications/Browser/DownloadWidget.cpp index 0ef34f2677e..82e68c5d834 100644 --- a/Userland/Applications/Browser/DownloadWidget.cpp +++ b/Userland/Applications/Browser/DownloadWidget.cpp @@ -35,7 +35,7 @@ DownloadWidget::DownloadWidget(const URL& url) builder.append(Core::StandardPaths::downloads_directory()); builder.append('/'); builder.append(m_url.basename()); - m_destination_path = builder.to_deprecated_string(); + m_destination_path = builder.to_byte_string(); } auto close_on_finish = Config::read_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, Browser::default_close_download_widget_on_finish); @@ -50,7 +50,7 @@ DownloadWidget::DownloadWidget(const URL& url) { auto file_or_error = Core::File::open(m_destination_path, Core::File::OpenMode::Write); if (file_or_error.is_error()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Cannot open {} for writing", m_destination_path), "Download failed"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Cannot open {} for writing", m_destination_path), "Download failed"sv, GUI::MessageBox::Type::Error); window()->close(); return; } @@ -86,7 +86,7 @@ DownloadWidget::DownloadWidget(const URL& url) m_progress_label->set_fixed_height(16); m_progress_label->set_text_wrapping(Gfx::TextWrapping::DontWrap); - auto destination_label_path = LexicalPath(m_destination_path).dirname().to_deprecated_string(); + auto destination_label_path = LexicalPath(m_destination_path).dirname().to_byte_string(); auto& destination_label = add(String::formatted("To: {}", destination_label_path).release_value_but_fixme_should_propagate_errors()); destination_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); @@ -145,7 +145,7 @@ void DownloadWidget::did_progress(Optional total_size, u64 downloaded_size) } builder.append(" of "sv); builder.append(m_url.basename()); - window()->set_title(builder.to_deprecated_string()); + window()->set_title(builder.to_byte_string()); } } @@ -164,7 +164,7 @@ void DownloadWidget::did_finish(bool success) m_cancel_button->update(); if (!success) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Download failed for some reason"), "Download failed"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Download failed for some reason"), "Download failed"sv, GUI::MessageBox::Type::Error); window()->close(); return; } diff --git a/Userland/Applications/Browser/DownloadWidget.h b/Userland/Applications/Browser/DownloadWidget.h index 3e131476ddd..4d15dc3375c 100644 --- a/Userland/Applications/Browser/DownloadWidget.h +++ b/Userland/Applications/Browser/DownloadWidget.h @@ -29,7 +29,7 @@ private: void did_finish(bool success); URL m_url; - DeprecatedString m_destination_path; + ByteString m_destination_path; RefPtr m_download; RefPtr m_progressbar; RefPtr m_progress_label; diff --git a/Userland/Applications/Browser/History/HistoryModel.cpp b/Userland/Applications/Browser/History/HistoryModel.cpp index 7ee0216a78f..78941566060 100644 --- a/Userland/Applications/Browser/History/HistoryModel.cpp +++ b/Userland/Applications/Browser/History/HistoryModel.cpp @@ -79,7 +79,7 @@ GUI::Model::MatchResult HistoryModel::data_matches(GUI::ModelIndex const& index, return { TriState::True }; auto const& history_entry = m_entries[index.row()]; - auto haystack = DeprecatedString::formatted("{} {}", history_entry.title, history_entry.url.serialize()); + auto haystack = ByteString::formatted("{} {}", history_entry.title, history_entry.url.serialize()); auto match_result = fuzzy_match(needle, haystack); if (match_result.score > 0) return { TriState::True, match_result.score }; diff --git a/Userland/Applications/Browser/InspectorWidget.cpp b/Userland/Applications/Browser/InspectorWidget.cpp index b67b77dbcb7..b6e8c91f67c 100644 --- a/Userland/Applications/Browser/InspectorWidget.cpp +++ b/Userland/Applications/Browser/InspectorWidget.cpp @@ -84,7 +84,7 @@ InspectorWidget::InspectorWidget(WebView::OutOfProcessWebView& content_view) }; m_inspector_client->on_requested_dom_node_tag_context_menu = [this](auto position, auto const& tag) { - m_edit_node_action->set_text(DeprecatedString::formatted("&Edit \"{}\"", tag)); + m_edit_node_action->set_text(ByteString::formatted("&Edit \"{}\"", tag)); m_copy_node_action->set_text("&Copy HTML"); m_dom_node_tag_context_menu->popup(to_widget_position(position)); @@ -94,9 +94,9 @@ InspectorWidget::InspectorWidget(WebView::OutOfProcessWebView& content_view) static constexpr size_t MAX_ATTRIBUTE_VALUE_LENGTH = 32; m_copy_node_action->set_text("&Copy HTML"); - m_edit_node_action->set_text(DeprecatedString::formatted("&Edit attribute \"{}\"", attribute.name)); - m_remove_attribute_action->set_text(DeprecatedString::formatted("&Remove attribute \"{}\"", attribute.name)); - m_copy_attribute_value_action->set_text(DeprecatedString::formatted("Copy attribute &value \"{:.{}}{}\"", + m_edit_node_action->set_text(ByteString::formatted("&Edit attribute \"{}\"", attribute.name)); + m_remove_attribute_action->set_text(ByteString::formatted("&Remove attribute \"{}\"", attribute.name)); + m_copy_attribute_value_action->set_text(ByteString::formatted("Copy attribute &value \"{:.{}}{}\"", attribute.value, MAX_ATTRIBUTE_VALUE_LENGTH, attribute.value.bytes_as_string_view().length() > MAX_ATTRIBUTE_VALUE_LENGTH ? "..."sv : ""sv)); diff --git a/Userland/Applications/Browser/StorageModel.cpp b/Userland/Applications/Browser/StorageModel.cpp index 724914ef545..42cca352aea 100644 --- a/Userland/Applications/Browser/StorageModel.cpp +++ b/Userland/Applications/Browser/StorageModel.cpp @@ -85,7 +85,7 @@ GUI::Model::MatchResult StorageModel::data_matches(GUI::ModelIndex const& index, auto const& local_storage_key = keys[index.row()]; auto const& local_storage_value = m_local_storage_entries.get(local_storage_key).value_or({}); - auto haystack = DeprecatedString::formatted("{} {}", local_storage_key, local_storage_value); + auto haystack = ByteString::formatted("{} {}", local_storage_key, local_storage_value); auto match_result = fuzzy_match(needle, haystack); if (match_result.score > 0) return { TriState::True, match_result.score }; diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 0b2a15835b4..ca886b43aa4 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -58,13 +58,13 @@ void Tab::start_download(const URL& url) { auto window = GUI::Window::construct(&this->window()); window->resize(300, 170); - window->set_title(DeprecatedString::formatted("0% of {}", url.basename())); + window->set_title(ByteString::formatted("0% of {}", url.basename())); window->set_resizable(false); (void)window->set_main_widget(url); window->show(); } -void Tab::view_source(const URL& url, DeprecatedString const& source) +void Tab::view_source(const URL& url, ByteString const& source) { auto window = GUI::Window::construct(&this->window()); auto editor = window->set_main_widget(); @@ -74,7 +74,7 @@ void Tab::view_source(const URL& url, DeprecatedString const& source) editor->set_ruler_visible(true); editor->set_visualize_trailing_whitespace(false); window->resize(640, 480); - window->set_title(url.to_deprecated_string()); + window->set_title(url.to_byte_string()); window->set_icon(g_icon_bag.filetype_text); window->set_window_mode(GUI::WindowMode::Modeless); window->show(); @@ -132,7 +132,7 @@ Tab::Tab(BrowserWindow& window) m_go_back_context_menu = GUI::Menu::construct(); for (auto& url : m_history.get_back_title_history()) { i++; - m_go_back_context_menu->add_action(GUI::Action::create(url.to_deprecated_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_back(i); })); + m_go_back_context_menu->add_action(GUI::Action::create(url.to_byte_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_back(i); })); } m_go_back_context_menu->popup(go_back_button.screen_relative_rect().bottom_left().moved_up(1)); }; @@ -145,7 +145,7 @@ Tab::Tab(BrowserWindow& window) m_go_forward_context_menu = GUI::Menu::construct(); for (auto& url : m_history.get_forward_title_history()) { i++; - m_go_forward_context_menu->add_action(GUI::Action::create(url.to_deprecated_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_forward(i); })); + m_go_forward_context_menu->add_action(GUI::Action::create(url.to_byte_string(), g_icon_bag.filetype_html, [this, i](auto&) { go_forward(i); })); } m_go_forward_context_menu->popup(go_forward_button.screen_relative_rect().bottom_left().moved_up(1)); }; @@ -220,7 +220,7 @@ Tab::Tab(BrowserWindow& window) update_status(); m_location_box->set_icon(nullptr); - m_location_box->set_text(url.to_deprecated_string()); + m_location_box->set_text(url.to_byte_string()); // don't add to history if back or forward is pressed if (!m_is_history_navigation) @@ -228,7 +228,7 @@ Tab::Tab(BrowserWindow& window) m_is_history_navigation = false; update_actions(); - update_bookmark_button(url.to_deprecated_string()); + update_bookmark_button(url.to_byte_string()); if (m_dom_inspector_widget) m_dom_inspector_widget->reset(); @@ -353,7 +353,7 @@ Tab::Tab(BrowserWindow& window) GUI::Clipboard::the().set_bitmap(*m_image_context_menu_bitmap.bitmap()); })); m_image_context_menu->add_action(GUI::Action::create("Copy Image &URL", g_icon_bag.copy, [this](auto&) { - GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_byte_string()); })); m_image_context_menu->add_separator(); m_image_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) { @@ -397,7 +397,7 @@ Tab::Tab(BrowserWindow& window) })); m_audio_context_menu->add_separator(); m_audio_context_menu->add_action(GUI::Action::create("Copy Audio &URL", g_icon_bag.copy, [this](auto&) { - GUI::Clipboard::the().set_plain_text(m_media_context_menu_url.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(m_media_context_menu_url.to_byte_string()); })); m_audio_context_menu->add_separator(); m_audio_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) { @@ -420,7 +420,7 @@ Tab::Tab(BrowserWindow& window) })); m_video_context_menu->add_separator(); m_video_context_menu->add_action(GUI::Action::create("Copy Video &URL", g_icon_bag.copy, [this](auto&) { - GUI::Clipboard::the().set_plain_text(m_media_context_menu_url.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(m_media_context_menu_url.to_byte_string()); })); m_video_context_menu->add_separator(); m_video_context_menu->add_action(GUI::Action::create("&Download", g_icon_bag.download, [this](auto&) { @@ -490,7 +490,7 @@ Tab::Tab(BrowserWindow& window) return {}; }; - view().on_get_cookie = [this](auto& url, auto source) -> DeprecatedString { + view().on_get_cookie = [this](auto& url, auto source) -> ByteString { if (on_get_cookie) return on_get_cookie(url, source); return {}; @@ -609,7 +609,7 @@ Tab::Tab(BrowserWindow& window) m_statusbar = *find_descendant_of_type_named("statusbar"); view().on_link_hover = [this](auto& url) { - update_status(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors()); + update_status(String::from_byte_string(url.to_byte_string()).release_value_but_fixme_should_propagate_errors()); }; view().on_link_unhover = [this]() { @@ -631,7 +631,7 @@ Tab::Tab(BrowserWindow& window) }; view().on_insert_clipboard_entry = [](auto const& data, auto const&, auto const& mime_type) { - GUI::Clipboard::the().set_data(data.bytes(), mime_type.to_deprecated_string()); + GUI::Clipboard::the().set_data(data.bytes(), mime_type.to_byte_string()); }; m_tab_context_menu = GUI::Menu::construct(); @@ -705,7 +705,7 @@ Tab::Tab(BrowserWindow& window) if (m_page_context_menu_search_text.has_value()) { auto action_text = WebView::format_search_query_for_display(g_search_engine, *m_page_context_menu_search_text); - search_selected_text_action->set_text(action_text.to_deprecated_string()); + search_selected_text_action->set_text(action_text.to_byte_string()); search_selected_text_action->set_visible(true); } else { search_selected_text_action->set_visible(false); @@ -719,7 +719,7 @@ Tab::Tab(BrowserWindow& window) void Tab::select_dropdown_add_item(GUI::Menu& menu, Web::HTML::SelectItem const& item) { if (item.type == Web::HTML::SelectItem::Type::OptionGroup) { - auto subtitle = GUI::Action::create(MUST(DeprecatedString::from_utf8(item.label.value_or(""_string))), nullptr); + auto subtitle = GUI::Action::create(MUST(ByteString::from_utf8(item.label.value_or(""_string))), nullptr); subtitle->set_enabled(false); menu.add_action(subtitle); @@ -728,7 +728,7 @@ void Tab::select_dropdown_add_item(GUI::Menu& menu, Web::HTML::SelectItem const& } } if (item.type == Web::HTML::SelectItem::Type::Option) { - auto action = GUI::Action::create(MUST(DeprecatedString::from_utf8(item.label.value_or(""_string))), [this, item](GUI::Action&) { + auto action = GUI::Action::create(MUST(ByteString::from_utf8(item.label.value_or(""_string))), [this, item](GUI::Action&) { m_select_dropdown_closed_by_action = true; view().select_dropdown_closed(item.value.value_or(""_string)); }); @@ -804,7 +804,7 @@ void Tab::update_actions() ErrorOr Tab::bookmark_current_url() { - auto url = this->url().to_deprecated_string(); + auto url = this->url().to_byte_string(); if (BookmarksBarWidget::the().contains_bookmark(url)) { TRY(BookmarksBarWidget::the().remove_bookmark(url)); } else { @@ -837,11 +837,11 @@ void Tab::did_become_active() }; BookmarksBarWidget::the().on_bookmark_hover = [this](auto&, auto& url) { - m_statusbar->set_text(String::from_deprecated_string(url).release_value_but_fixme_should_propagate_errors()); + m_statusbar->set_text(String::from_byte_string(url).release_value_but_fixme_should_propagate_errors()); }; BookmarksBarWidget::the().on_bookmark_change = [this]() { - update_bookmark_button(url().to_deprecated_string()); + update_bookmark_button(url().to_byte_string()); }; BookmarksBarWidget::the().remove_from_parent(); diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h index 01edfd54760..eeec0257276 100644 --- a/Userland/Applications/Browser/Tab.h +++ b/Userland/Applications/Browser/Tab.h @@ -63,7 +63,7 @@ public: void window_position_changed(Gfx::IntPoint); void window_size_changed(Gfx::IntSize); - Function on_title_change; + Function on_title_change; Function on_tab_open_request; Function on_activate_tab_request; Function on_tab_close_request; @@ -71,8 +71,8 @@ public: Function on_window_open_request; Function on_favicon_change; Function(AK::URL const& url)> on_get_all_cookies; - Function(AK::URL const& url, DeprecatedString const& name)> on_get_named_cookie; - Function on_get_cookie; + Function(AK::URL const& url, ByteString const& name)> on_get_named_cookie; + Function on_get_cookie; Function on_set_cookie; Function on_dump_cookies; Function on_update_cookie; @@ -93,7 +93,7 @@ public: void update_reset_zoom_button(); - DeprecatedString const& title() const { return m_title; } + ByteString const& title() const { return m_title; } Gfx::Bitmap const* icon() const { return m_icon; } WebView::OutOfProcessWebView& view() { return *m_web_content_view; } @@ -111,7 +111,7 @@ private: ErrorOr bookmark_current_url(); void update_bookmark_button(StringView url); void start_download(const URL& url); - void view_source(const URL& url, DeprecatedString const& source); + void view_source(const URL& url, ByteString const& source); void update_status(Optional text_override = {}, i32 count_waiting = 0); void close_sub_widgets(); @@ -160,7 +160,7 @@ private: RefPtr m_select_dropdown; bool m_select_dropdown_closed_by_action { false }; - DeprecatedString m_title; + ByteString m_title; RefPtr m_icon; Optional m_navigating_url; diff --git a/Userland/Applications/Browser/WindowActions.cpp b/Userland/Applications/Browser/WindowActions.cpp index 5ce96d620e2..94286b47a1d 100644 --- a/Userland/Applications/Browser/WindowActions.cpp +++ b/Userland/Applications/Browser/WindowActions.cpp @@ -60,7 +60,7 @@ WindowActions::WindowActions(GUI::Window& window) for (auto i = 0; i <= 7; ++i) { m_tab_actions.append(GUI::Action::create( - DeprecatedString::formatted("Tab {}", i + 1), { Mod_Ctrl, static_cast(Key_1 + i) }, [this, i](auto&) { + ByteString::formatted("Tab {}", i + 1), { Mod_Ctrl, static_cast(Key_1 + i) }, [this, i](auto&) { if (on_tabs[i]) on_tabs[i](); }, diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index f850552dc12..74310675893 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -33,17 +33,17 @@ namespace Browser { -DeprecatedString g_search_engine; -DeprecatedString g_home_url; -DeprecatedString g_new_tab_url; +ByteString g_search_engine; +ByteString g_home_url; +ByteString g_new_tab_url; Vector g_content_filters; bool g_content_filters_enabled { true }; Vector g_autoplay_allowlist; bool g_autoplay_allowed_on_all_websites { false }; -Vector g_proxies; -HashMap g_proxy_mappings; +Vector g_proxies; +HashMap g_proxy_mappings; IconBag g_icon_bag; -DeprecatedString g_webdriver_content_ipc_path; +ByteString g_webdriver_content_ipc_path; } @@ -182,7 +182,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } window->content_filters_changed(); }; - TRY(content_filters_watcher->add_watch(DeprecatedString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::FileWatcherEvent::Type::ContentModified)); + TRY(content_filters_watcher->add_watch(ByteString::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::FileWatcherEvent::Type::ContentModified)); auto autoplay_allowlist_watcher = TRY(Core::FileWatcher::create()); autoplay_allowlist_watcher->on_change = [&](Core::FileWatcherEvent const&) { @@ -193,7 +193,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } window->autoplay_allowlist_changed(); }; - TRY(autoplay_allowlist_watcher->add_watch(DeprecatedString::formatted("{}/BrowserAutoplayAllowlist.txt", Core::StandardPaths::config_directory()), Core::FileWatcherEvent::Type::ContentModified)); + TRY(autoplay_allowlist_watcher->add_watch(ByteString::formatted("{}/BrowserAutoplayAllowlist.txt", Core::StandardPaths::config_directory()), Core::FileWatcherEvent::Type::ContentModified)); app->on_action_enter = [&](GUI::Action& action) { if (auto* browser_window = dynamic_cast(app->active_window())) { diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp index feed66188a9..abba6c51a00 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp @@ -15,8 +15,8 @@ #include struct ColorScheme { - DeprecatedString title; - DeprecatedString setting_value; + ByteString title; + ByteString setting_value; }; class ColorSchemeModel final : public GUI::Model { @@ -140,8 +140,8 @@ ErrorOr BrowserSettingsWidget::setup() m_search_engine_combobox->set_model(adopt_ref(*new SearchEngineModel())); m_search_engine_combobox->set_only_allow_values_from_model(true); - m_search_engine_combobox->on_change = [this](AK::DeprecatedString const&, GUI::ModelIndex const& cursor_index) { - auto url_format = m_search_engine_combobox->model()->index(cursor_index.row(), 1).data().to_deprecated_string(); + m_search_engine_combobox->on_change = [this](AK::ByteString const&, GUI::ModelIndex const& cursor_index) { + auto url_format = m_search_engine_combobox->model()->index(cursor_index.row(), 1).data().to_byte_string(); m_is_custom_search_engine = url_format.is_empty(); m_custom_search_engine_group->set_enabled(m_is_custom_search_engine); set_modified(true); @@ -159,7 +159,7 @@ void BrowserSettingsWidget::set_color_scheme(StringView color_scheme) { bool found_color_scheme = false; for (int item_index = 0; item_index < m_color_scheme_combobox->model()->row_count(); ++item_index) { - auto scheme = m_color_scheme_combobox->model()->index(item_index, 1).data().to_deprecated_string(); + auto scheme = m_color_scheme_combobox->model()->index(item_index, 1).data().to_byte_string(); if (scheme == color_scheme) { m_color_scheme_combobox->set_selected_index(item_index, GUI::AllowCallback::No); found_color_scheme = true; @@ -183,7 +183,7 @@ void BrowserSettingsWidget::set_search_engine_url(StringView url) bool found_url = false; for (int item_index = 0; item_index < m_search_engine_combobox->model()->row_count(); ++item_index) { - auto url_format = m_search_engine_combobox->model()->index(item_index, 1).data().to_deprecated_string(); + auto url_format = m_search_engine_combobox->model()->index(item_index, 1).data().to_byte_string(); if (url_format == url) { m_search_engine_combobox->set_selected_index(item_index, GUI::AllowCallback::No); found_url = true; @@ -226,7 +226,7 @@ void BrowserSettingsWidget::apply_settings() Config::write_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, m_show_bookmarks_bar_checkbox->is_checked()); auto color_scheme_index = m_color_scheme_combobox->selected_index(); - auto color_scheme = m_color_scheme_combobox->model()->index(color_scheme_index, 1).data().to_deprecated_string(); + auto color_scheme = m_color_scheme_combobox->model()->index(color_scheme_index, 1).data().to_byte_string(); Config::write_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, color_scheme); if (!m_enable_search_engine_checkbox->is_checked()) { @@ -235,7 +235,7 @@ void BrowserSettingsWidget::apply_settings() Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, m_custom_search_engine_textbox->text()); } else { auto selected_index = m_search_engine_combobox->selected_index(); - auto url = m_search_engine_combobox->model()->index(selected_index, 1).data().to_deprecated_string(); + auto url = m_search_engine_combobox->model()->index(selected_index, 1).data().to_byte_string(); Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, url); } diff --git a/Userland/Applications/Calculator/CalculatorWidget.cpp b/Userland/Applications/Calculator/CalculatorWidget.cpp index e10f048ecbe..266f5440fa1 100644 --- a/Userland/Applications/Calculator/CalculatorWidget.cpp +++ b/Userland/Applications/Calculator/CalculatorWidget.cpp @@ -130,7 +130,7 @@ void CalculatorWidget::add_digit_button(GUI::Button& button, int digit) String CalculatorWidget::get_entry() { - return String::from_deprecated_string(m_entry->text()).release_value_but_fixme_should_propagate_errors(); + return String::from_byte_string(m_entry->text()).release_value_but_fixme_should_propagate_errors(); } void CalculatorWidget::set_entry(Crypto::BigFraction value) diff --git a/Userland/Applications/Calculator/Keypad.cpp b/Userland/Applications/Calculator/Keypad.cpp index df1c1b17519..b2291dfa306 100644 --- a/Userland/Applications/Calculator/Keypad.cpp +++ b/Userland/Applications/Calculator/Keypad.cpp @@ -124,12 +124,12 @@ void Keypad::set_to_0() ErrorOr Keypad::to_string() const { if (m_state == State::External || m_state == State::TypedExternal) - return String::from_deprecated_string(m_internal_value.to_deprecated_string(m_displayed_fraction_length)); + return String::from_byte_string(m_internal_value.to_byte_string(m_displayed_fraction_length)); StringBuilder builder; - DeprecatedString const integer_value = m_int_value.to_base_deprecated(10); - DeprecatedString const frac_value = m_frac_value.to_base_deprecated(10); + ByteString const integer_value = m_int_value.to_base_deprecated(10); + ByteString const frac_value = m_frac_value.to_base_deprecated(10); unsigned const number_pre_zeros = m_frac_length.to_u64() - (frac_value.length() - 1) - (frac_value == "0" ? 0 : 1); builder.append(integer_value); diff --git a/Userland/Applications/Calculator/main.cpp b/Userland/Applications/Calculator/main.cpp index 870482ebcdb..246ea6acb4b 100644 --- a/Userland/Applications/Calculator/main.cpp +++ b/Userland/Applications/Calculator/main.cpp @@ -85,7 +85,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Optional last_rounding_mode = 1; for (unsigned i {}; i < rounding_modes.size(); ++i) { - auto round_action = GUI::Action::create_checkable(DeprecatedString::formatted("To &{} Digits", rounding_modes[i]), + auto round_action = GUI::Action::create_checkable(ByteString::formatted("To &{} Digits", rounding_modes[i]), [&widget, rounding_mode = rounding_modes[i], &last_rounding_mode, i](auto&) { widget->set_rounding_length(rounding_mode); last_rounding_mode = i; @@ -96,11 +96,11 @@ ErrorOr serenity_main(Main::Arguments arguments) } constexpr auto format { "&Custom - {}..."sv }; - auto round_custom = GUI::Action::create_checkable(DeprecatedString::formatted(format, 0), [&](auto& action) { + auto round_custom = GUI::Action::create_checkable(ByteString::formatted(format, 0), [&](auto& action) { int custom_rounding_length = widget->rounding_length(); auto result = GUI::InputBox::show_numeric(window, custom_rounding_length, 0, 100, "Digits to Round"sv); if (!result.is_error() && result.value() == GUI::Dialog::ExecResult::OK) { - action.set_text(DeprecatedString::formatted(format, custom_rounding_length)); + action.set_text(ByteString::formatted(format, custom_rounding_length)); widget->set_rounding_length(custom_rounding_length); last_rounding_mode.clear(); } else if (last_rounding_mode.has_value()) @@ -115,7 +115,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto result = GUI::InputBox::show_numeric(window, shrink_length, 0, 100, "Digits to Shrink"sv); if (!result.is_error() && result.value() == GUI::Dialog::ExecResult::OK) { round_custom->set_checked(true); - round_custom->set_text(DeprecatedString::formatted(format, shrink_length)); + round_custom->set_text(ByteString::formatted(format, shrink_length)); widget->set_rounding_length(shrink_length); widget->shrink(shrink_length); } diff --git a/Userland/Applications/Calendar/CalendarWidget.cpp b/Userland/Applications/Calendar/CalendarWidget.cpp index e85616dc78d..20668ebcb4e 100644 --- a/Userland/Applications/Calendar/CalendarWidget.cpp +++ b/Userland/Applications/Calendar/CalendarWidget.cpp @@ -123,7 +123,7 @@ void CalendarWidget::load_file(FileSystemAccessClient::File file) { auto result = m_event_calendar->event_manager().load_file(file); if (result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Cannot load file: {}", result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Cannot load file: {}", result.error())); return; } @@ -139,13 +139,13 @@ NonnullRefPtr CalendarWidget::create_save_action(GUI::Action& save_ return; } - auto response = FileSystemAccessClient::Client::the().request_file(window(), current_filename().to_deprecated_string(), Core::File::OpenMode::Write); + auto response = FileSystemAccessClient::Client::the().request_file(window(), current_filename().to_byte_string(), Core::File::OpenMode::Write); if (response.is_error()) return; auto result = m_event_calendar->event_manager().save(response.value()); if (result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Cannot save file: {}", result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Cannot save file: {}", result.error())); return; } @@ -163,7 +163,7 @@ NonnullRefPtr CalendarWidget::create_save_as_action() auto result = m_event_calendar->event_manager().save(response.value()); if (result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Cannot save file: {}", result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Cannot save file: {}", result.error())); return; } @@ -184,7 +184,7 @@ ErrorOr> CalendarWidget::create_new_calendar_action() auto result = m_event_calendar->event_manager().save(response.value()); if (result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Cannot save file: {}", result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Cannot save file: {}", result.error())); return; } @@ -225,7 +225,7 @@ void CalendarWidget::update_window_title() builder.append(current_filename()); builder.append("[*] - Calendar"sv); - window()->set_title(builder.to_deprecated_string()); + window()->set_title(builder.to_byte_string()); } ErrorOr> CalendarWidget::create_add_event_action() diff --git a/Userland/Applications/Calendar/EventCalendar.cpp b/Userland/Applications/Calendar/EventCalendar.cpp index 5ca66a46b12..807e413ee8b 100644 --- a/Userland/Applications/Calendar/EventCalendar.cpp +++ b/Userland/Applications/Calendar/EventCalendar.cpp @@ -36,12 +36,12 @@ void EventCalendar::paint_tile(GUI::Painter& painter, GUI::Calendar::Tile& tile, if (!event.has("start_date"sv) || !event.has("start_date"sv) || !event.has("summary"sv)) return; - auto start_date = event.get("start_date"sv).value().to_deprecated_string(); - auto start_time = event.get("start_time"sv).value().to_deprecated_string(); - auto summary = event.get("summary"sv).value().to_deprecated_string(); - auto combined_text = DeprecatedString::formatted("{} {}", start_time, summary); + auto start_date = event.get("start_date"sv).value().to_byte_string(); + auto start_time = event.get("start_time"sv).value().to_byte_string(); + auto summary = event.get("summary"sv).value().to_byte_string(); + auto combined_text = ByteString::formatted("{} {}", start_time, summary); - if (start_date == DeprecatedString::formatted("{}-{:0>2d}-{:0>2d}", tile.year, tile.month, tile.day)) { + if (start_date == ByteString::formatted("{}-{:0>2d}-{:0>2d}", tile.year, tile.month, tile.day)) { auto text_rect = tile.rect.translated(4, 4 + (font_height + 4) * ++index); painter.draw_text(text_rect, combined_text, Gfx::FontDatabase::default_font(), Gfx::TextAlignment::TopLeft, palette().base_text(), Gfx::TextElision::Right); diff --git a/Userland/Applications/Calendar/EventManager.cpp b/Userland/Applications/Calendar/EventManager.cpp index 28c3e0e2867..d0df59103cc 100644 --- a/Userland/Applications/Calendar/EventManager.cpp +++ b/Userland/Applications/Calendar/EventManager.cpp @@ -41,7 +41,7 @@ ErrorOr EventManager::save(FileSystemAccessClient::File& file) set_dirty(false); auto stream = file.release_stream(); - TRY(stream->write_some(m_events.to_deprecated_string().bytes())); + TRY(stream->write_some(m_events.to_byte_string().bytes())); stream->close(); return {}; diff --git a/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp b/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp index c56b4c300f4..d2c65424893 100644 --- a/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp +++ b/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp @@ -75,7 +75,7 @@ GUI::Variant CertificateStoreModel::data(GUI::ModelIndex const& index, GUI::Mode return issued_by; } case Column::Expire: - return cert.validity.not_after.to_deprecated_string("%Y-%m-%d"sv); + return cert.validity.not_after.to_byte_string("%Y-%m-%d"sv); default: VERIFY_NOT_REACHED(); } @@ -141,7 +141,7 @@ ErrorOr CertificateStoreWidget::export_pem() filename = TRY(filename.replace(" "sv, "_"sv, ReplaceMode::All)); - auto file = FileSystemAccessClient::Client::the().save_file(window(), filename.to_deprecated_string(), "pem"sv); + auto file = FileSystemAccessClient::Client::the().save_file(window(), filename.to_byte_string(), "pem"sv); if (file.is_error()) return {}; @@ -183,7 +183,7 @@ ErrorOr CertificateStoreWidget::initialize() m_import_ca_button->on_click = [&](auto) { auto import_result = import_pem(); if (import_result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("{}", import_result.release_error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("{}", import_result.release_error())); } }; @@ -191,7 +191,7 @@ ErrorOr CertificateStoreWidget::initialize() m_export_ca_button->on_click = [&](auto) { auto export_result = export_pem(); if (export_result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("{}", export_result.release_error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("{}", export_result.release_error())); } }; diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp index 2deb1dfb33a..1ae875c36a3 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp @@ -54,7 +54,7 @@ CharacterMapWidget::CharacterMapWidget() continue; builder.append_code_point(code_point); } - GUI::Clipboard::the().set_plain_text(builder.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(builder.to_byte_string()); }); m_copy_selection_action->set_status_tip("Copy the highlighted characters to the clipboard"_string); @@ -139,7 +139,7 @@ CharacterMapWidget::CharacterMapWidget() for (auto& block : unicode_blocks) m_unicode_block_list.append(block.display_name); - m_unicode_block_model = GUI::ItemListModel::create(m_unicode_block_list); + m_unicode_block_model = GUI::ItemListModel::create(m_unicode_block_list); m_unicode_block_listview->set_model(*m_unicode_block_model); m_unicode_block_listview->set_activates_on_selection(true); m_unicode_block_listview->horizontal_scrollbar().set_visible(false); diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.h b/Userland/Applications/CharacterMap/CharacterMapWidget.h index 562185a86ff..9c2f7bff537 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.h +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.h @@ -42,6 +42,6 @@ private: RefPtr m_go_to_glyph_action; RefPtr m_find_glyphs_action; - Vector m_unicode_block_list; + Vector m_unicode_block_list; Unicode::CodePointRange m_range { 0x0000, 0x10FFFF }; }; diff --git a/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp b/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp index 4d6e082a468..1788e364bc0 100644 --- a/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterSearchWidget.cpp @@ -12,8 +12,8 @@ struct SearchResult { u32 code_point; - DeprecatedString code_point_string; - DeprecatedString display_text; + ByteString code_point_string; + ByteString display_text; }; class CharacterSearchModel final : public GUI::Model { @@ -93,7 +93,7 @@ void CharacterSearchWidget::search() StringBuilder builder; builder.append_code_point(code_point); - model.add_result({ code_point, builder.to_deprecated_string(), move(display_name) }); + model.add_result({ code_point, builder.to_byte_string(), move(display_name) }); // Stop when we reach 250 results. // This is already too many for the search to be useful, and means we don't spend forever recalculating the column size. diff --git a/Userland/Applications/CharacterMap/SearchCharacters.cpp b/Userland/Applications/CharacterMap/SearchCharacters.cpp index ba359cf590a..2e8313cb7cb 100644 --- a/Userland/Applications/CharacterMap/SearchCharacters.cpp +++ b/Userland/Applications/CharacterMap/SearchCharacters.cpp @@ -7,9 +7,9 @@ #include "SearchCharacters.h" #include -void for_each_character_containing(StringView query, Function callback) +void for_each_character_containing(StringView query, Function callback) { - DeprecatedString uppercase_query = query.to_uppercase_string(); + ByteString uppercase_query = query.to_uppercase_string(); StringView uppercase_query_view = uppercase_query.view(); constexpr u32 maximum_code_point = 0x10FFFF; // FIXME: There's probably a better way to do this than just looping, but it still only takes ~150ms to run for me! diff --git a/Userland/Applications/CharacterMap/SearchCharacters.h b/Userland/Applications/CharacterMap/SearchCharacters.h index 209973d453c..51194c115fe 100644 --- a/Userland/Applications/CharacterMap/SearchCharacters.h +++ b/Userland/Applications/CharacterMap/SearchCharacters.h @@ -6,8 +6,8 @@ #pragma once -#include +#include #include #include -void for_each_character_containing(StringView query, Function callback); +void for_each_character_containing(StringView query, Function callback); diff --git a/Userland/Applications/CharacterMap/main.cpp b/Userland/Applications/CharacterMap/main.cpp index e64b00947d6..afb939850b1 100644 --- a/Userland/Applications/CharacterMap/main.cpp +++ b/Userland/Applications/CharacterMap/main.cpp @@ -17,7 +17,7 @@ #include #include -static void search_and_print_results(DeprecatedString const& query) +static void search_and_print_results(ByteString const& query) { outln("Searching for '{}'", query); u32 result_count = 0; @@ -53,7 +53,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - DeprecatedString query; + ByteString query; Core::ArgsParser args_parser; args_parser.add_option(query, "Search character names using this query, and print them as a list.", "search", 's', "query"); args_parser.parse(arguments); diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.h b/Userland/Applications/ClockSettings/ClockSettingsWidget.h index 227e792b261..df338a350a7 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.h +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.h @@ -32,5 +32,5 @@ private: RefPtr m_clock_preview_update_timer; - DeprecatedString m_time_format; + ByteString m_time_format; }; diff --git a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp index 521145ae949..3eadb11c3f4 100644 --- a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp +++ b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp @@ -146,7 +146,7 @@ void TimeZoneSettingsWidget::set_time_zone_location() auto name = Locale::format_time_zone(locale, m_time_zone, Locale::CalendarPatternStyle::Long, now); auto offset = Locale::format_time_zone(locale, m_time_zone, Locale::CalendarPatternStyle::LongOffset, now); - m_time_zone_text = DeprecatedString::formatted("{}\n({})", name, offset); + m_time_zone_text = ByteString::formatted("{}\n({})", name, offset); } // https://en.wikipedia.org/wiki/Mercator_projection#Derivation diff --git a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.h b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.h index b00c078ca0b..dc7b89f4173 100644 --- a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.h +++ b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -30,11 +30,11 @@ private: Optional compute_time_zone_location() const; void set_time_zone(); - DeprecatedString m_time_zone; + ByteString m_time_zone; RefPtr m_time_zone_combo_box; RefPtr m_time_zone_map; RefPtr m_time_zone_marker; Optional m_time_zone_location; - DeprecatedString m_time_zone_text; + ByteString m_time_zone_text; }; diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index eded509c6ca..78a3746e93a 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -44,8 +44,8 @@ #include struct TitleAndText { - DeprecatedString title; - DeprecatedString text; + ByteString title; + ByteString text; }; struct ThreadBacktracesAndCpuRegisters { @@ -104,17 +104,17 @@ static TitleAndText build_backtrace(Coredump::Reader const& coredump, ELF::Core: first_entry = false; else builder.append('\n'); - builder.append(entry.to_deprecated_string()); + builder.append(entry.to_byte_string()); } dbgln("--- Backtrace for thread #{} (TID {}) ---", thread_index, thread_info.tid); for (auto& entry : backtrace.entries()) { - dbgln("{}", entry.to_deprecated_string(true)); + dbgln("{}", entry.to_byte_string(true)); } return { - DeprecatedString::formatted("Thread #{} (TID {})", thread_index, thread_info.tid), - builder.to_deprecated_string() + ByteString::formatted("Thread #{} (TID {})", thread_index, thread_info.tid), + builder.to_byte_string() }; } @@ -151,8 +151,8 @@ static TitleAndText build_cpu_registers(const ELF::Core::ThreadInfo& thread_info #endif return { - DeprecatedString::formatted("Thread #{} (TID {})", thread_index, thread_info.tid), - builder.to_deprecated_string() + ByteString::formatted("Thread #{} (TID {})", thread_index, thread_info.tid), + builder.to_byte_string() }; } @@ -168,7 +168,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::create(arguments)); - DeprecatedString coredump_path {}; + ByteString coredump_path {}; bool unlink_on_exit = false; StringBuilder full_backtrace; @@ -184,9 +184,9 @@ ErrorOr serenity_main(Main::Arguments arguments) return 1; } - Vector memory_regions; + Vector memory_regions; coredump->for_each_memory_region_info([&](auto& memory_region_info) { - memory_regions.append(DeprecatedString::formatted("{:p} - {:p}: {}", memory_region_info.region_start, memory_region_info.region_end, memory_region_info.region_name)); + memory_regions.append(ByteString::formatted("{:p} - {:p}: {}", memory_region_info.region_start, memory_region_info.region_end, memory_region_info.region_name)); return IterationDecision::Continue; }); @@ -223,14 +223,14 @@ ErrorOr serenity_main(Main::Arguments arguments) description_label.set_text(TRY(String::formatted("\"{}\" (PID {}) has crashed - {} (signal {})", app_name, pid, strsignal(termination_signal), termination_signal))); auto& executable_link_label = *widget->find_descendant_of_type_named("executable_link"); - executable_link_label.set_text(TRY(String::from_deprecated_string(LexicalPath::canonicalized_path(executable_path)))); + executable_link_label.set_text(TRY(String::from_byte_string(LexicalPath::canonicalized_path(executable_path)))); executable_link_label.on_click = [&] { LexicalPath path { executable_path }; Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname(), path.basename())); }; auto& coredump_link_label = *widget->find_descendant_of_type_named("coredump_link"); - coredump_link_label.set_text(TRY(String::from_deprecated_string(LexicalPath::canonicalized_path(coredump_path)))); + coredump_link_label.set_text(TRY(String::from_byte_string(LexicalPath::canonicalized_path(coredump_path)))); coredump_link_label.on_click = [&] { LexicalPath path { coredump_path }; Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname(), path.basename())); @@ -266,7 +266,7 @@ ErrorOr serenity_main(Main::Arguments arguments) environment_tab.set_layout(4); auto& environment_text_editor = environment_tab.add(); - environment_text_editor.set_text(DeprecatedString::join('\n', environment)); + environment_text_editor.set_text(ByteString::join('\n', environment)); environment_text_editor.set_mode(GUI::TextEditor::Mode::ReadOnly); environment_text_editor.set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); environment_text_editor.set_should_hide_unnecessary_scrollbars(true); @@ -275,7 +275,7 @@ ErrorOr serenity_main(Main::Arguments arguments) memory_regions_tab.set_layout(4); auto& memory_regions_text_editor = memory_regions_tab.add(); - memory_regions_text_editor.set_text(DeprecatedString::join('\n', memory_regions)); + memory_regions_text_editor.set_text(ByteString::join('\n', memory_regions)); memory_regions_text_editor.set_mode(GUI::TextEditor::Mode::ReadOnly); memory_regions_text_editor.set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); memory_regions_text_editor.set_should_hide_unnecessary_scrollbars(true); @@ -296,23 +296,23 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& save_backtrace_button = *widget->find_descendant_of_type_named("save_backtrace_button"); save_backtrace_button.set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"sv))); save_backtrace_button.on_click = [&](auto) { - LexicalPath lexical_path(DeprecatedString::formatted("{}_{}_backtrace.txt", pid, app_name)); + LexicalPath lexical_path(ByteString::formatted("{}_{}_backtrace.txt", pid, app_name)); auto file_or_error = FileSystemAccessClient::Client::the().save_file(window, lexical_path.title(), lexical_path.extension()); if (file_or_error.is_error()) { - GUI::MessageBox::show(window, DeprecatedString::formatted("Communication failed with FileSystemAccessServer: {}.", file_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, ByteString::formatted("Communication failed with FileSystemAccessServer: {}.", file_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); return; } auto file = file_or_error.release_value().release_stream(); auto byte_buffer_or_error = full_backtrace.to_byte_buffer(); if (byte_buffer_or_error.is_error()) { - GUI::MessageBox::show(window, DeprecatedString::formatted("Couldn't create backtrace: {}.", byte_buffer_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, ByteString::formatted("Couldn't create backtrace: {}.", byte_buffer_or_error.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); return; } auto byte_buffer = byte_buffer_or_error.release_value(); if (auto result = file->write_until_depleted(byte_buffer); result.is_error()) - GUI::MessageBox::show(window, DeprecatedString::formatted("Couldn't save file: {}.", result.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, ByteString::formatted("Couldn't save file: {}.", result.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); }; save_backtrace_button.set_enabled(false); @@ -336,7 +336,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }, [&](auto results) -> ErrorOr { for (auto& backtrace : results.thread_backtraces) { - auto& container = backtrace_tab_widget.add_tab(TRY(String::from_deprecated_string(backtrace.title))); + auto& container = backtrace_tab_widget.add_tab(TRY(String::from_byte_string(backtrace.title))); container.template set_layout(4); auto& backtrace_text_editor = container.template add(); backtrace_text_editor.set_text(backtrace.text); @@ -347,7 +347,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } for (auto& cpu_registers : results.thread_cpu_registers) { - auto& container = cpu_registers_tab_widget.add_tab(TRY(String::from_deprecated_string(cpu_registers.title))); + auto& container = cpu_registers_tab_widget.add_tab(TRY(String::from_byte_string(cpu_registers.title))); container.template set_layout(4); auto& cpu_registers_text_editor = container.template add(); cpu_registers_text_editor.set_text(cpu_registers.text); diff --git a/Userland/Applications/Debugger/main.cpp b/Userland/Applications/Debugger/main.cpp index 1791f343720..20c6e802d3e 100644 --- a/Userland/Applications/Debugger/main.cpp +++ b/Userland/Applications/Debugger/main.cpp @@ -56,7 +56,7 @@ static void handle_print_registers(PtraceRegisters const& regs) #endif } -static bool handle_disassemble_command(DeprecatedString const& command, FlatPtr first_instruction) +static bool handle_disassemble_command(ByteString const& command, FlatPtr first_instruction) { auto parts = command.split(' '); size_t number_of_instructions_to_disassemble = 5; @@ -88,7 +88,7 @@ static bool handle_disassemble_command(DeprecatedString const& command, FlatPtr if (!insn.has_value()) break; - outln(" {:p} <+{}>:\t{}", offset + first_instruction, offset, insn.value().to_deprecated_string(offset)); + outln(" {:p} <+{}>:\t{}", offset + first_instruction, offset, insn.value().to_byte_string(offset)); } return true; @@ -106,7 +106,7 @@ static bool insert_breakpoint_at_address(FlatPtr address) return g_debug_session->insert_breakpoint(address); } -static bool insert_breakpoint_at_source_position(DeprecatedString const& file, size_t line) +static bool insert_breakpoint_at_source_position(ByteString const& file, size_t line) { auto result = g_debug_session->insert_breakpoint(file, line); if (!result.has_value()) { @@ -117,7 +117,7 @@ static bool insert_breakpoint_at_source_position(DeprecatedString const& file, s return true; } -static bool insert_breakpoint_at_symbol(DeprecatedString const& symbol) +static bool insert_breakpoint_at_symbol(ByteString const& symbol) { auto result = g_debug_session->insert_breakpoint(symbol); if (!result.has_value()) { @@ -128,7 +128,7 @@ static bool insert_breakpoint_at_symbol(DeprecatedString const& symbol) return true; } -static bool handle_breakpoint_command(DeprecatedString const& command) +static bool handle_breakpoint_command(ByteString const& command) { auto parts = command.split(' '); if (parts.size() != 2) @@ -155,7 +155,7 @@ static bool handle_breakpoint_command(DeprecatedString const& command) return insert_breakpoint_at_symbol(argument); } -static bool handle_examine_command(DeprecatedString const& command) +static bool handle_examine_command(ByteString const& command) { auto parts = command.split(' '); if (parts.size() != 2) diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp index 115e28e9454..44f375a46ef 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp @@ -63,7 +63,7 @@ ErrorOr BackgroundSettingsWidget::create_frame() String path; if (!m_wallpaper_view->selection().is_empty()) { auto index = m_wallpaper_view->selection().first(); - auto path_or_error = String::from_deprecated_string(static_cast(m_wallpaper_view->model())->full_path(index)); + auto path_or_error = String::from_byte_string(static_cast(m_wallpaper_view->model())->full_path(index)); if (path_or_error.is_error()) { GUI::MessageBox::show_error(window(), "Unable to load wallpaper"sv); return; @@ -78,7 +78,7 @@ ErrorOr BackgroundSettingsWidget::create_frame() m_context_menu = GUI::Menu::construct(); auto const file_manager_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)); m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", file_manager_icon, [this](GUI::Action const&) { - LexicalPath path { m_monitor_widget->wallpaper().value().to_deprecated_string() }; + LexicalPath path { m_monitor_widget->wallpaper().value().to_byte_string() }; Desktop::Launcher::open(URL::create_with_file_scheme(path.dirname(), path.basename())); }); m_context_menu->add_action(*m_show_in_file_manager_action); @@ -88,7 +88,7 @@ ErrorOr BackgroundSettingsWidget::create_frame() [this](auto&) { auto wallpaper = m_monitor_widget->wallpaper(); if (wallpaper.has_value()) - GUI::Clipboard::the().set_data(URL::create_with_file_scheme(wallpaper.value().to_deprecated_string()).to_deprecated_string().bytes(), "text/uri-list"); + GUI::Clipboard::the().set_data(URL::create_with_file_scheme(wallpaper.value().to_byte_string()).to_byte_string().bytes(), "text/uri-list"); }, this); m_context_menu->add_action(*m_copy_action); @@ -144,14 +144,14 @@ ErrorOr BackgroundSettingsWidget::load_current_settings() { auto ws_config = TRY(Core::ConfigFile::open("/etc/WindowServer.ini")); - auto selected_wallpaper = TRY(String::from_deprecated_string(Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv))); + auto selected_wallpaper = TRY(String::from_byte_string(Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv))); if (!selected_wallpaper.is_empty()) { - auto index = static_cast(m_wallpaper_view->model())->index(selected_wallpaper.to_deprecated_string(), m_wallpaper_view->model_column()); + auto index = static_cast(m_wallpaper_view->model())->index(selected_wallpaper.to_byte_string(), m_wallpaper_view->model_column()); m_wallpaper_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set); m_monitor_widget->set_wallpaper(selected_wallpaper); } - auto mode = TRY(String::from_deprecated_string(ws_config->read_entry("Background", "Mode", "Center"))); + auto mode = TRY(String::from_byte_string(ws_config->read_entry("Background", "Mode", "Center"))); if (!m_modes.contains_slow(mode)) { warnln("Invalid background mode '{}' in WindowServer config, falling back to 'Center'", mode); mode = "Center"_string; diff --git a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp index 2bc6d39cb2e..b26b3414c97 100644 --- a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp @@ -79,9 +79,9 @@ static void update_label_with_font(GUI::Label& label, Gfx::Font const& font) void FontSettingsWidget::apply_settings() { GUI::ConnectionToWindowServer::the().set_system_fonts( - m_default_font_label->font().qualified_name().to_deprecated_string(), - m_fixed_width_font_label->font().qualified_name().to_deprecated_string(), - m_window_title_font_label->font().qualified_name().to_deprecated_string()); + m_default_font_label->font().qualified_name().to_byte_string(), + m_fixed_width_font_label->font().qualified_name().to_byte_string(), + m_window_title_font_label->font().qualified_name().to_byte_string()); } } diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index 39b2c52438f..30b57eb2a24 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -142,7 +142,7 @@ static ErrorOr display_name_from_edid(EDID::Parser const& edid) auto build_manufacturer_product_name = [&]() -> ErrorOr { if (product_name.is_empty()) - return TRY(String::from_deprecated_string(manufacturer_name)); + return TRY(String::from_byte_string(manufacturer_name)); return String::formatted("{} {}", manufacturer_name, product_name); }; @@ -170,7 +170,7 @@ ErrorOr MonitorSettingsWidget::load_current_settings() TRY(m_screen_edids.try_append(edid.release_value())); } else { dbgln("Error getting EDID from device {}: {}", m_screen_layout.screens[i].device.value(), edid.error()); - screen_display_name = TRY(String::from_deprecated_string(m_screen_layout.screens[i].device.value())); + screen_display_name = TRY(String::from_byte_string(m_screen_layout.screens[i].device.value())); TRY(m_screen_edids.try_append({})); } } else { diff --git a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp index 4adc8d06313..d65d5d1e855 100644 --- a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp +++ b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp @@ -20,8 +20,8 @@ ThemePreviewWidget::ThemePreviewWidget(Gfx::Palette const& palette) ErrorOr ThemePreviewWidget::set_theme(String path) { - auto config_file = TRY(Core::File::open(path.to_deprecated_string(), Core::File::OpenMode::Read)); - TRY(set_theme_from_file(path.to_deprecated_string(), move(config_file))); + auto config_file = TRY(Core::File::open(path.to_byte_string(), Core::File::OpenMode::Read)); + TRY(set_theme_from_file(path.to_byte_string(), move(config_file))); return {}; } diff --git a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp index 36ec4cb92ba..682d4f1aae3 100644 --- a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp @@ -20,7 +20,7 @@ namespace DisplaySettings { static ErrorOr get_color_scheme_name_from_pathname(StringView color_scheme_path) { - return TRY(String::from_deprecated_string(color_scheme_path.replace("/res/color-schemes/"sv, ""sv, ReplaceMode::FirstOnly).replace(".ini"sv, ""sv, ReplaceMode::FirstOnly))); + return TRY(String::from_byte_string(color_scheme_path.replace("/res/color-schemes/"sv, ""sv, ReplaceMode::FirstOnly).replace(".ini"sv, ""sv, ReplaceMode::FirstOnly))); } ErrorOr> ThemesSettingsWidget::try_create(bool& background_settings_changed) @@ -40,7 +40,7 @@ ErrorOr ThemesSettingsWidget::setup_interface() auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme(); TRY(m_theme_names.try_ensure_capacity(m_themes.size())); for (auto& theme_meta : m_themes) { - TRY(m_theme_names.try_append(TRY(String::from_deprecated_string(theme_meta.name)))); + TRY(m_theme_names.try_append(TRY(String::from_byte_string(theme_meta.name)))); if (current_theme_name == theme_meta.name) { m_selected_theme = &theme_meta; current_theme_index = m_theme_names.size() - 1; @@ -53,7 +53,7 @@ ErrorOr ThemesSettingsWidget::setup_interface() m_themes_combo->set_model(*GUI::ItemListModel::create(m_theme_names)); m_themes_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { m_selected_theme = &m_themes.at(index.row()); - auto selected_theme_path = String::from_deprecated_string(m_selected_theme->path); + auto selected_theme_path = String::from_byte_string(m_selected_theme->path); ErrorOr set_theme_result; if (!selected_theme_path.is_error()) set_theme_result = m_theme_preview->set_theme(selected_theme_path.release_value()); @@ -98,7 +98,7 @@ ErrorOr ThemesSettingsWidget::setup_interface() } } color_scheme_combo.on_change = [this](auto&, const GUI::ModelIndex& index) { - auto result = String::from_deprecated_string(index.data().as_string()); + auto result = String::from_byte_string(index.data().as_string()); if (result.is_error()) return; m_selected_color_scheme_name = result.release_value(); @@ -139,7 +139,7 @@ ErrorOr ThemesSettingsWidget::setup_interface() if (current_theme_name == theme_meta.name) { m_themes_combo->set_selected_index(index, GUI::AllowCallback::No); m_selected_theme = &m_themes.at(index); - auto selected_theme_path = String::from_deprecated_string(m_selected_theme->path); + auto selected_theme_path = String::from_byte_string(m_selected_theme->path); ErrorOr set_theme_result; if (!selected_theme_path.is_error()) set_theme_result = m_theme_preview->set_theme(selected_theme_path.release_value()); @@ -178,7 +178,7 @@ void ThemesSettingsWidget::apply_settings() if (!set_theme_result) GUI::MessageBox::show_error(window(), "Failed to apply theme settings"sv); } else if (find_descendant_of_type_named("custom_color_scheme_checkbox")->is_checked()) { - auto set_theme_result = GUI::ConnectionToWindowServer::the().set_system_theme(m_selected_theme->path, m_selected_theme->name, m_background_settings_changed, color_scheme_path.to_deprecated_string()); + auto set_theme_result = GUI::ConnectionToWindowServer::the().set_system_theme(m_selected_theme->path, m_selected_theme->name, m_background_settings_changed, color_scheme_path.to_byte_string()); if (!set_theme_result) GUI::MessageBox::show_error(window(), "Failed to apply theme settings"sv); } else { diff --git a/Userland/Applications/Escalator/EscalatorWindow.cpp b/Userland/Applications/Escalator/EscalatorWindow.cpp index 78732fb13f1..000bfba8a2b 100644 --- a/Userland/Applications/Escalator/EscalatorWindow.cpp +++ b/Userland/Applications/Escalator/EscalatorWindow.cpp @@ -56,7 +56,7 @@ EscalatorWindow::EscalatorWindow(StringView executable, Vector argum m_ok_button->on_click = [this](auto) { auto result = check_password(); if (result.is_error()) { - GUI::MessageBox::show_error(this, DeprecatedString::formatted("Failed to execute command: {}", result.error())); + GUI::MessageBox::show_error(this, ByteString::formatted("Failed to execute command: {}", result.error())); } close(); }; @@ -72,7 +72,7 @@ EscalatorWindow::EscalatorWindow(StringView executable, Vector argum ErrorOr EscalatorWindow::check_password() { - DeprecatedString password = m_password_input->text(); + ByteString password = m_password_input->text(); if (password.is_empty()) { GUI::MessageBox::show_error(this, "Please enter a password."sv); return {}; diff --git a/Userland/Applications/Escalator/main.cpp b/Userland/Applications/Escalator/main.cpp index 6b238073a0b..019ba1dea2a 100644 --- a/Userland/Applications/Escalator/main.cpp +++ b/Userland/Applications/Escalator/main.cpp @@ -7,7 +7,7 @@ */ #include "EscalatorWindow.h" -#include +#include #include #include #include @@ -39,7 +39,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto executable_path = Core::System::resolve_executable_from_environment(command[0], AT_EACCESS); if (executable_path.is_error()) { - GUI::MessageBox::show_error(nullptr, DeprecatedString::formatted("Could not execute command {}: Command not found.", command[0])); + GUI::MessageBox::show_error(nullptr, ByteString::formatted("Could not execute command {}: Command not found.", command[0])); return 127; } diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 2c848c79101..7447e62d211 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -76,7 +76,7 @@ Vector> DirectoryView::get_launch_handlers(URL co return handlers; } -Vector> DirectoryView::get_launch_handlers(DeprecatedString const& path) +Vector> DirectoryView::get_launch_handlers(ByteString const& path) { return get_launch_handlers(URL::create_with_file_scheme(path)); } @@ -92,7 +92,7 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index) struct stat st; if (stat(path.characters(), &st) < 0) { perror("stat"); - auto error_message = DeprecatedString::formatted("Could not stat {}: {}", path, strerror(errno)); + auto error_message = ByteString::formatted("Could not stat {}: {}", path, strerror(errno)); GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error); return; } @@ -112,11 +112,11 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index) if (default_launcher) { auto launch_origin_rect = current_view().to_widget_rect(current_view().content_rect(index)).translated(current_view().screen_relative_rect().location()); - setenv("__libgui_launch_origin_rect", DeprecatedString::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1); + setenv("__libgui_launch_origin_rect", ByteString::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1); launch(url, *default_launcher); unsetenv("__libgui_launch_origin_rect"); } else { - auto error_message = DeprecatedString::formatted("Could not open {}", path); + auto error_message = ByteString::formatted("Could not open {}", path); GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error); } } @@ -168,7 +168,7 @@ void DirectoryView::setup_model() }; m_model->on_rename_error = [this](int, char const* error_string) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Unable to rename file: {}", error_string)); + GUI::MessageBox::show_error(window(), ByteString::formatted("Unable to rename file: {}", error_string)); }; m_model->on_complete = [this] { @@ -340,7 +340,7 @@ void DirectoryView::model_did_update(unsigned flags) update_statusbar(); } -void DirectoryView::set_view_mode_from_string(DeprecatedString const& mode) +void DirectoryView::set_view_mode_from_string(ByteString const& mode) { if (m_mode == Mode::Desktop) return; @@ -389,7 +389,7 @@ void DirectoryView::set_view_mode(ViewMode mode) VERIFY_NOT_REACHED(); } -void DirectoryView::add_path_to_history(DeprecatedString path) +void DirectoryView::add_path_to_history(ByteString path) { if (m_path_history.size() && m_path_history.at(m_path_history_position) == path) return; @@ -401,7 +401,7 @@ void DirectoryView::add_path_to_history(DeprecatedString path) m_path_history_position = m_path_history.size() - 1; } -bool DirectoryView::open(DeprecatedString const& path) +bool DirectoryView::open(ByteString const& path) { auto error_or_real_path = FileSystem::real_path(path); if (error_or_real_path.is_error() || !FileSystem::is_directory(path)) @@ -413,11 +413,11 @@ bool DirectoryView::open(DeprecatedString const& path) warnln("Failed to open '{}': {}", real_path, result.error()); } - if (model().root_path() == real_path.to_deprecated_string()) { + if (model().root_path() == real_path.to_byte_string()) { refresh(); } else { set_active_widget(¤t_view()); - model().set_root_path(real_path.to_deprecated_string()); + model().set_root_path(real_path.to_byte_string()); } return true; } @@ -528,15 +528,15 @@ void DirectoryView::launch(URL const&, LauncherHandler const& launcher_handler) } } -Vector DirectoryView::selected_file_paths() const +Vector DirectoryView::selected_file_paths() const { - Vector paths; + Vector paths; auto& view = current_view(); auto& model = *view.model(); view.selection().for_each_index([&](GUI::ModelIndex const& index) { auto parent_index = model.parent_index(index); auto name_index = model.index(index.row(), GUI::FileSystemModel::Column::Name, parent_index); - auto path = name_index.data(GUI::ModelRole::Custom).to_deprecated_string(); + auto path = name_index.data(GUI::ModelRole::Custom).to_byte_string(); paths.append(path); }); return paths; @@ -580,11 +580,11 @@ void DirectoryView::setup_actions() String value; auto icon = Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors(); if (GUI::InputBox::show(window(), value, "Enter a name:"sv, "New Directory"sv, GUI::InputType::NonemptyText, {}, move(icon)) == GUI::InputBox::ExecResult::OK) { - auto new_dir_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value)); + auto new_dir_path = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", path(), value)); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { auto saved_errno = errno; - GUI::MessageBox::show(window(), DeprecatedString::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); } } }); @@ -593,22 +593,22 @@ void DirectoryView::setup_actions() String value; auto icon = Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors(); if (GUI::InputBox::show(window(), value, "Enter a name:"sv, "New File"sv, GUI::InputType::NonemptyText, {}, move(icon)) == GUI::InputBox::ExecResult::OK) { - auto new_file_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value)); + auto new_file_path = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", path(), value)); struct stat st; int rc = stat(new_file_path.characters(), &st); if ((rc < 0 && errno != ENOENT)) { auto saved_errno = errno; - GUI::MessageBox::show(window(), DeprecatedString::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); return; } if (rc == 0) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error); return; } int fd = creat(new_file_path.characters(), 0666); if (fd < 0) { auto saved_errno = errno; - GUI::MessageBox::show(window(), DeprecatedString::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); return; } rc = close(fd); diff --git a/Userland/Applications/FileManager/DirectoryView.h b/Userland/Applications/FileManager/DirectoryView.h index 281c678f762..3ef39a48000 100644 --- a/Userland/Applications/FileManager/DirectoryView.h +++ b/Userland/Applications/FileManager/DirectoryView.h @@ -51,8 +51,8 @@ public: virtual ~DirectoryView() override; - bool open(DeprecatedString const& path); - DeprecatedString path() const { return model().root_path(); } + bool open(ByteString const& path); + ByteString path() const { return model().root_path(); } void open_parent_directory(); void open_previous_directory(); void open_next_directory(); @@ -60,7 +60,7 @@ public: int path_history_position() const { return m_path_history_position; } static RefPtr get_default_launch_handler(Vector> const& handlers); static Vector> get_launch_handlers(URL const& url); - static Vector> get_launch_handlers(DeprecatedString const& path); + static Vector> get_launch_handlers(ByteString const& path); void refresh(); @@ -82,7 +82,7 @@ public: void set_view_mode(ViewMode); ViewMode view_mode() const { return m_view_mode; } - void set_view_mode_from_string(DeprecatedString const&); + void set_view_mode_from_string(ByteString const&); GUI::AbstractView& current_view() { @@ -120,7 +120,7 @@ public: bool is_desktop() const { return m_mode == Mode::Desktop; } - Vector selected_file_paths() const; + Vector selected_file_paths() const; GUI::Action& mkdir_action() { return *m_mkdir_action; } GUI::Action& touch_action() { return *m_touch_action; } @@ -166,8 +166,8 @@ private: NonnullRefPtr m_model; NonnullRefPtr m_sorting_model; size_t m_path_history_position { 0 }; - Vector m_path_history; - void add_path_to_history(DeprecatedString); + Vector m_path_history; + void add_path_to_history(ByteString); RefPtr m_error_label; diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp index 100b8e76ffe..8d4033068a1 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp @@ -134,11 +134,11 @@ void FileOperationProgressWidget::did_error(StringView message) { // FIXME: Communicate more with the user about errors. close_pipe(); - GUI::MessageBox::show(window(), DeprecatedString::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(window(), ByteString::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); window()->close(); } -DeprecatedString FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_byte_count) +ByteString FileOperationProgressWidget::estimate_time(off_t bytes_done, off_t total_byte_count) { i64 const elapsed_seconds = m_elapsed_timer.elapsed_time().to_seconds(); @@ -149,7 +149,7 @@ DeprecatedString FileOperationProgressWidget::estimate_time(off_t bytes_done, of int seconds_remaining = (bytes_left * elapsed_seconds) / bytes_done; if (seconds_remaining < 30) - return DeprecatedString::formatted("{} seconds", 5 + seconds_remaining - seconds_remaining % 5); + return ByteString::formatted("{} seconds", 5 + seconds_remaining - seconds_remaining % 5); if (seconds_remaining < 60) return "About a minute"; if (seconds_remaining < 90) @@ -162,14 +162,14 @@ DeprecatedString FileOperationProgressWidget::estimate_time(off_t bytes_done, of if (minutes_remaining < 60) { if (seconds_remaining < 30) - return DeprecatedString::formatted("About {} minutes", minutes_remaining); - return DeprecatedString::formatted("Over {} minutes", minutes_remaining); + return ByteString::formatted("About {} minutes", minutes_remaining); + return ByteString::formatted("Over {} minutes", minutes_remaining); } time_t hours_remaining = minutes_remaining / 60; minutes_remaining %= 60; - return DeprecatedString::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining); + return ByteString::formatted("{} hours and {} minutes", hours_remaining, minutes_remaining); } void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, [[maybe_unused]] off_t current_file_done, [[maybe_unused]] off_t current_file_size, StringView current_filename) @@ -195,7 +195,7 @@ void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byt VERIFY_NOT_REACHED(); } - estimated_time_label.set_text(String::from_deprecated_string(estimate_time(bytes_done, total_byte_count)).release_value_but_fixme_should_propagate_errors()); + estimated_time_label.set_text(String::from_byte_string(estimate_time(bytes_done, total_byte_count)).release_value_but_fixme_should_propagate_errors()); if (total_byte_count) { window()->set_progress(100.0f * bytes_done / total_byte_count); diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.h b/Userland/Applications/FileManager/FileOperationProgressWidget.h index 79f07d51db6..3a404531d7c 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.h +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.h @@ -29,7 +29,7 @@ private: void close_pipe(); - DeprecatedString estimate_time(off_t bytes_done, off_t total_byte_count); + ByteString estimate_time(off_t bytes_done, off_t total_byte_count); Core::ElapsedTimer m_elapsed_timer; FileOperation m_operation; diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp index 3132d54c8a4..bdce233702c 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -19,13 +19,13 @@ namespace FileManager { HashTable> file_operation_windows; -void delete_paths(Vector const& paths, bool should_confirm, GUI::Window* parent_window) +void delete_paths(Vector const& paths, bool should_confirm, GUI::Window* parent_window) { - DeprecatedString message; + ByteString message; if (paths.size() == 1) { - message = DeprecatedString::formatted("Are you sure you want to delete \"{}\"?", LexicalPath::basename(paths[0])); + message = ByteString::formatted("Are you sure you want to delete \"{}\"?", LexicalPath::basename(paths[0])); } else { - message = DeprecatedString::formatted("Are you sure you want to delete {} files?", paths.size()); + message = ByteString::formatted("Are you sure you want to delete {} files?", paths.size()); } if (should_confirm) { @@ -42,7 +42,7 @@ void delete_paths(Vector const& paths, bool should_confirm, GU _exit(1); } -ErrorOr run_file_operation(FileOperation operation, Vector const& sources, DeprecatedString const& destination, GUI::Window* parent_window) +ErrorOr run_file_operation(FileOperation operation, Vector const& sources, ByteString const& destination, GUI::Window* parent_window) { auto pipe_fds = TRY(Core::System::pipe2(0)); @@ -110,7 +110,7 @@ ErrorOr run_file_operation(FileOperation operation, Vector handle_drop(GUI::DropEvent const& event, DeprecatedString const& destination, GUI::Window* window) +ErrorOr handle_drop(GUI::DropEvent const& event, ByteString const& destination, GUI::Window* window) { bool has_accepted_drop = false; @@ -127,12 +127,12 @@ ErrorOr handle_drop(GUI::DropEvent const& event, DeprecatedString const& d if (!FileSystem::is_directory(target)) return has_accepted_drop; - Vector paths_to_copy; + Vector paths_to_copy; for (auto& url_to_copy : urls) { auto file_path = url_to_copy.serialize_path(); if (!url_to_copy.is_valid() || file_path == target) continue; - auto new_path = DeprecatedString::formatted("{}/{}", target, LexicalPath::basename(file_path)); + auto new_path = ByteString::formatted("{}/{}", target, LexicalPath::basename(file_path)); if (file_path == new_path) continue; diff --git a/Userland/Applications/FileManager/FileUtils.h b/Userland/Applications/FileManager/FileUtils.h index b64b4133703..d43a10f207a 100644 --- a/Userland/Applications/FileManager/FileUtils.h +++ b/Userland/Applications/FileManager/FileUtils.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include @@ -19,8 +19,8 @@ enum class FileOperation { Delete, }; -void delete_paths(Vector const&, bool should_confirm, GUI::Window*); +void delete_paths(Vector const&, bool should_confirm, GUI::Window*); -ErrorOr run_file_operation(FileOperation, Vector const& sources, DeprecatedString const& destination, GUI::Window*); -ErrorOr handle_drop(GUI::DropEvent const& event, DeprecatedString const& destination, GUI::Window* window); +ErrorOr run_file_operation(FileOperation, Vector const& sources, ByteString const& destination, GUI::Window*); +ErrorOr handle_drop(GUI::DropEvent const& event, ByteString const& destination, GUI::Window* window); } diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 6264f6f6945..e4dbd5b9a57 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -47,7 +47,7 @@ #include #include -ErrorOr> PropertiesWindow::try_create(DeprecatedString const& path, bool disable_rename, Window* parent) +ErrorOr> PropertiesWindow::try_create(ByteString const& path, bool disable_rename, Window* parent) { auto window = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PropertiesWindow(path, parent))); window->set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"sv))); @@ -55,7 +55,7 @@ ErrorOr> PropertiesWindow::try_create(Deprecated return window; } -PropertiesWindow::PropertiesWindow(DeprecatedString const& path, Window* parent_window) +PropertiesWindow::PropertiesWindow(ByteString const& path, Window* parent_window) : Window(parent_window) { auto lexical_path = LexicalPath(path); @@ -134,15 +134,15 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b }; auto* location = general_tab.find_descendant_of_type_named("location"); - location->set_text(TRY(String::from_deprecated_string(m_path))); + location->set_text(TRY(String::from_byte_string(m_path))); location->on_click = [this] { Desktop::Launcher::open(URL::create_with_file_scheme(m_parent_path, m_name)); }; auto st = TRY(Core::System::lstat(m_path)); - DeprecatedString owner_name; - DeprecatedString group_name; + ByteString owner_name; + ByteString group_name; if (auto* pw = getpwuid(st.st_uid)) { owner_name = pw->pw_name; @@ -171,7 +171,7 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b auto* link_location = general_tab.find_descendant_of_type_named("link_location"); link_location->set_text(link_destination); link_location->on_click = [link_destination] { - auto link_directory = LexicalPath(link_destination.to_deprecated_string()); + auto link_directory = LexicalPath(link_destination.to_byte_string()); Desktop::Launcher::open(URL::create_with_file_scheme(link_directory.dirname(), link_directory.basename())); }; } @@ -183,7 +183,7 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b m_size_label = general_tab.find_descendant_of_type_named("size"); m_size_label->set_text(S_ISDIR(st.st_mode) ? "Calculating..."_string - : TRY(String::from_deprecated_string(human_readable_size_long(st.st_size, UseThousandsSeparator::Yes)))); + : TRY(String::from_byte_string(human_readable_size_long(st.st_size, UseThousandsSeparator::Yes)))); auto* owner = general_tab.find_descendant_of_type_named("owner"); owner->set_text(String::formatted("{} ({})", owner_name, st.st_uid).release_value_but_fixme_should_propagate_errors()); @@ -192,10 +192,10 @@ ErrorOr PropertiesWindow::create_general_tab(GUI::TabWidget& tab_widget, b group->set_text(String::formatted("{} ({})", group_name, st.st_gid).release_value_but_fixme_should_propagate_errors()); auto* created_at = general_tab.find_descendant_of_type_named("created_at"); - created_at->set_text(String::from_deprecated_string(GUI::FileSystemModel::timestamp_string(st.st_ctime)).release_value_but_fixme_should_propagate_errors()); + created_at->set_text(String::from_byte_string(GUI::FileSystemModel::timestamp_string(st.st_ctime)).release_value_but_fixme_should_propagate_errors()); auto* last_modified = general_tab.find_descendant_of_type_named("last_modified"); - last_modified->set_text(String::from_deprecated_string(GUI::FileSystemModel::timestamp_string(st.st_mtime)).release_value_but_fixme_should_propagate_errors()); + last_modified->set_text(String::from_byte_string(GUI::FileSystemModel::timestamp_string(st.st_mtime)).release_value_but_fixme_should_propagate_errors()); auto* owner_read = general_tab.find_descendant_of_type_named("owner_read"); auto* owner_write = general_tab.find_descendant_of_type_named("owner_write"); @@ -263,7 +263,7 @@ ErrorOr PropertiesWindow::create_archive_tab(GUI::TabWidget& tab_widget, N tab.find_descendant_of_type_named("archive_file_count")->set_text(TRY(String::number(statistics.file_count()))); tab.find_descendant_of_type_named("archive_format")->set_text("ZIP"_string); tab.find_descendant_of_type_named("archive_directory_count")->set_text(TRY(String::number(statistics.directory_count()))); - tab.find_descendant_of_type_named("archive_uncompressed_size")->set_text(TRY(String::from_deprecated_string(AK::human_readable_size(statistics.total_uncompressed_bytes())))); + tab.find_descendant_of_type_named("archive_uncompressed_size")->set_text(TRY(String::from_byte_string(AK::human_readable_size(statistics.total_uncompressed_bytes())))); return {}; } @@ -280,9 +280,9 @@ ErrorOr PropertiesWindow::create_audio_tab(GUI::TabWidget& tab_widget, Non auto& tab = tab_widget.add_tab("Audio"_string); TRY(tab.load_from_gml(properties_window_audio_tab_gml)); - tab.find_descendant_of_type_named("audio_type")->set_text(TRY(String::from_deprecated_string(loader->format_name()))); + tab.find_descendant_of_type_named("audio_type")->set_text(TRY(String::from_byte_string(loader->format_name()))); auto duration_seconds = loader->total_samples() / loader->sample_rate(); - tab.find_descendant_of_type_named("audio_duration")->set_text(TRY(String::from_deprecated_string(human_readable_digital_time(duration_seconds)))); + tab.find_descendant_of_type_named("audio_duration")->set_text(TRY(String::from_byte_string(human_readable_digital_time(duration_seconds)))); tab.find_descendant_of_type_named("audio_sample_rate")->set_text(TRY(String::formatted("{} Hz", loader->sample_rate()))); tab.find_descendant_of_type_named("audio_format")->set_text(TRY(String::formatted("{}-bit", loader->bits_per_sample()))); @@ -487,12 +487,12 @@ ErrorOr PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu if (maybe_info_dict.is_error()) { warnln("Failed to read InfoDict from '{}': {}", m_path, maybe_info_dict.error().message()); } else if (maybe_info_dict.value().has_value()) { - auto get_info_string = [](PDF::PDFErrorOr> input) -> ErrorOr { + auto get_info_string = [](PDF::PDFErrorOr> input) -> ErrorOr { if (input.is_error()) return String {}; if (!input.value().has_value()) return String {}; - return String::from_deprecated_string(input.value().value()); + return String::from_byte_string(input.value().value()); }; auto info_dict = maybe_info_dict.release_value().release_value(); @@ -512,7 +512,7 @@ ErrorOr PropertiesWindow::create_pdf_tab(GUI::TabWidget& tab_widget, Nonnu void PropertiesWindow::update() { m_icon->set_bitmap(GUI::FileIconProvider::icon_for_path(make_full_path(m_name), m_mode).bitmap_for_size(32)); - set_title(DeprecatedString::formatted("{} - Properties", m_name)); + set_title(ByteString::formatted("{} - Properties", m_name)); } void PropertiesWindow::permission_changed(mode_t mask, bool set) @@ -527,24 +527,24 @@ void PropertiesWindow::permission_changed(mode_t mask, bool set) m_apply_button->set_enabled(m_name_dirty || m_permissions_dirty); } -DeprecatedString PropertiesWindow::make_full_path(DeprecatedString const& name) +ByteString PropertiesWindow::make_full_path(ByteString const& name) { - return DeprecatedString::formatted("{}/{}", m_parent_path, name); + return ByteString::formatted("{}/{}", m_parent_path, name); } bool PropertiesWindow::apply_changes() { if (m_name_dirty) { - DeprecatedString new_name = m_name_box->text(); - DeprecatedString new_file = make_full_path(new_name).characters(); + ByteString new_name = m_name_box->text(); + ByteString new_file = make_full_path(new_name).characters(); if (FileSystem::exists(new_file)) { - GUI::MessageBox::show(this, DeprecatedString::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, ByteString::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error); return false; } if (rename(make_full_path(m_name).characters(), new_file.characters())) { - GUI::MessageBox::show(this, DeprecatedString::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, ByteString::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return false; } @@ -555,7 +555,7 @@ bool PropertiesWindow::apply_changes() if (m_permissions_dirty) { if (chmod(make_full_path(m_name).characters(), m_mode)) { - GUI::MessageBox::show(this, DeprecatedString::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, ByteString::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return false; } @@ -606,7 +606,7 @@ void PropertiesWindow::close() m_directory_statistics_calculator->stop(); } -PropertiesWindow::DirectoryStatisticsCalculator::DirectoryStatisticsCalculator(DeprecatedString path) +PropertiesWindow::DirectoryStatisticsCalculator::DirectoryStatisticsCalculator(ByteString path) { m_work_queue.enqueue(path); } diff --git a/Userland/Applications/FileManager/PropertiesWindow.h b/Userland/Applications/FileManager/PropertiesWindow.h index cbf54466dbf..877ff582ac2 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.h +++ b/Userland/Applications/FileManager/PropertiesWindow.h @@ -20,13 +20,13 @@ class PropertiesWindow final : public GUI::Window { C_OBJECT(PropertiesWindow); public: - static ErrorOr> try_create(DeprecatedString const& path, bool disable_rename, Window* parent = nullptr); + static ErrorOr> try_create(ByteString const& path, bool disable_rename, Window* parent = nullptr); virtual ~PropertiesWindow() override = default; virtual void close() final; private: - PropertiesWindow(DeprecatedString const& path, Window* parent = nullptr); + PropertiesWindow(ByteString const& path, Window* parent = nullptr); ErrorOr create_widgets(bool disable_rename); ErrorOr create_general_tab(GUI::TabWidget&, bool disable_rename); ErrorOr create_file_type_specific_tabs(GUI::TabWidget&); @@ -44,7 +44,7 @@ private: class DirectoryStatisticsCalculator final : public RefCounted { public: - DirectoryStatisticsCalculator(DeprecatedString path); + DirectoryStatisticsCalculator(ByteString path); void start(); void stop(); Function on_update; @@ -54,7 +54,7 @@ private: size_t m_file_count { 0 }; size_t m_directory_count { 0 }; RefPtr> m_background_action; - Queue m_work_queue; + Queue m_work_queue; }; static StringView const get_description(mode_t const mode) @@ -84,7 +84,7 @@ private: void permission_changed(mode_t mask, bool set); bool apply_changes(); void update(); - DeprecatedString make_full_path(DeprecatedString const& name); + ByteString make_full_path(ByteString const& name); RefPtr m_apply_button; RefPtr m_name_box; @@ -92,9 +92,9 @@ private: RefPtr m_size_label; RefPtr m_directory_statistics_calculator; RefPtr m_on_escape; - DeprecatedString m_name; - DeprecatedString m_parent_path; - DeprecatedString m_path; + ByteString m_name; + ByteString m_parent_path; + ByteString m_path; mode_t m_mode { 0 }; mode_t m_old_mode { 0 }; bool m_permissions_dirty { false }; diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index c4757ab1c3e..29c7bfd8ca1 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -59,15 +59,15 @@ using namespace FileManager; static ErrorOr run_in_desktop_mode(); -static ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, DeprecatedString const& entry_focused_on_init); -static void do_copy(Vector const& selected_file_paths, FileOperation file_operation); -static void do_paste(DeprecatedString const& target_directory, GUI::Window* window); -static void do_create_link(Vector const& selected_file_paths, GUI::Window* window); -static void do_create_archive(Vector const& selected_file_paths, GUI::Window* window); -static void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window); -static void do_unzip_archive(Vector const& selected_file_paths, GUI::Window* window); -static void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector const& selected, GUI::Window* window); -static bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr& default_action, Vector>& current_file_launch_handlers); +static ErrorOr run_in_windowed_mode(ByteString const& initial_location, ByteString const& entry_focused_on_init); +static void do_copy(Vector const& selected_file_paths, FileOperation file_operation); +static void do_paste(ByteString const& target_directory, GUI::Window* window); +static void do_create_link(Vector const& selected_file_paths, GUI::Window* window); +static void do_create_archive(Vector const& selected_file_paths, GUI::Window* window); +static void do_set_wallpaper(ByteString const& file_path, GUI::Window* window); +static void do_unzip_archive(Vector const& selected_file_paths, GUI::Window* window); +static void show_properties(ByteString const& container_dir_path, ByteString const& path, Vector const& selected, GUI::Window* window); +static bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView const& directory_view, ByteString const& full_path, RefPtr& default_action, Vector>& current_file_launch_handlers); ErrorOr serenity_main(Main::Arguments arguments) { @@ -82,7 +82,7 @@ ErrorOr serenity_main(Main::Arguments arguments) bool is_desktop_mode { false }; bool is_selection_mode { false }; bool ignore_path_resolution { false }; - DeprecatedString initial_location; + ByteString initial_location; args_parser.add_option(is_desktop_mode, "Run in desktop mode", "desktop", 'd'); args_parser.add_option(is_selection_mode, "Show entry in parent folder", "select", 's'); args_parser.add_option(ignore_path_resolution, "Use raw path, do not resolve real path", "raw", 'r'); @@ -109,7 +109,7 @@ ErrorOr serenity_main(Main::Arguments arguments) LexicalPath path(initial_location); if (!initial_location.is_empty()) { if (auto error_or_path = FileSystem::real_path(initial_location); !ignore_path_resolution && !error_or_path.is_error()) - initial_location = error_or_path.release_value().to_deprecated_string(); + initial_location = error_or_path.release_value().to_byte_string(); if (!FileSystem::is_directory(initial_location)) { // We want to extract zips to a temporary directory when FileManager is launched with a .zip file as its first argument @@ -134,7 +134,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return -1; } - return run_in_windowed_mode(temp_directory_path.to_deprecated_string(), path.basename()); + return run_in_windowed_mode(temp_directory_path.to_byte_string(), path.basename()); } is_selection_mode = true; @@ -142,7 +142,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } if (auto error_or_cwd = FileSystem::current_working_directory(); initial_location.is_empty() && !error_or_cwd.is_error()) - initial_location = error_or_cwd.release_value().to_deprecated_string(); + initial_location = error_or_cwd.release_value().to_byte_string(); if (initial_location.is_empty()) initial_location = Core::StandardPaths::home_directory(); @@ -150,7 +150,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (initial_location.is_empty()) initial_location = "/"; - DeprecatedString focused_entry; + ByteString focused_entry; if (is_selection_mode) { initial_location = path.dirname(); focused_entry = path.basename(); @@ -159,7 +159,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return run_in_windowed_mode(initial_location, focused_entry); } -void do_copy(Vector const& selected_file_paths, FileOperation file_operation) +void do_copy(Vector const& selected_file_paths, FileOperation file_operation) { VERIFY(!selected_file_paths.is_empty()); @@ -171,17 +171,17 @@ void do_copy(Vector const& selected_file_paths, FileOperation auto url = URL::create_with_file_scheme(path); copy_text.appendff("{}\n", url); } - GUI::Clipboard::the().set_data(copy_text.to_deprecated_string().bytes(), "text/uri-list"); + GUI::Clipboard::the().set_data(copy_text.to_byte_string().bytes(), "text/uri-list"); } -void do_paste(DeprecatedString const& target_directory, GUI::Window* window) +void do_paste(ByteString const& target_directory, GUI::Window* window) { auto data_and_type = GUI::Clipboard::the().fetch_data_and_type(); if (data_and_type.mime_type != "text/uri-list") { dbgln("Cannot paste clipboard type {}", data_and_type.mime_type); return; } - auto copied_lines = DeprecatedString::copy(data_and_type.data).split('\n'); + auto copied_lines = ByteString::copy(data_and_type.data).split('\n'); if (copied_lines.is_empty()) { dbgln("No files to paste"); return; @@ -193,7 +193,7 @@ void do_paste(DeprecatedString const& target_directory, GUI::Window* window) copied_lines.remove(0); } - Vector source_paths; + Vector source_paths; for (auto& uri_as_string : copied_lines) { if (uri_as_string.is_empty()) continue; @@ -211,17 +211,17 @@ void do_paste(DeprecatedString const& target_directory, GUI::Window* window) } } -void do_create_link(Vector const& selected_file_paths, GUI::Window* window) +void do_create_link(Vector const& selected_file_paths, GUI::Window* window) { auto path = selected_file_paths.first(); - auto destination = DeprecatedString::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path)); + auto destination = ByteString::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path)); if (auto result = FileSystem::link_file(destination, path); result.is_error()) { - GUI::MessageBox::show(window, DeprecatedString::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv, + GUI::MessageBox::show(window, ByteString::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv, GUI::MessageBox::Type::Error); } } -void do_create_archive(Vector const& selected_file_paths, GUI::Window* window) +void do_create_archive(Vector const& selected_file_paths, GUI::Window* window) { String archive_name; if (GUI::InputBox::show(window, archive_name, "Enter name:"sv, "Create Archive"sv) != GUI::InputBox::ExecResult::OK) @@ -240,7 +240,7 @@ void do_create_archive(Vector const& selected_file_paths, GUI: if (!AK::StringUtils::ends_with(archive_name, ".zip"sv, CaseSensitivity::CaseSensitive)) path_builder.append(".zip"sv); } - auto output_path = path_builder.to_deprecated_string(); + auto output_path = path_builder.to_byte_string(); pid_t zip_pid = fork(); if (zip_pid < 0) { @@ -249,7 +249,7 @@ void do_create_archive(Vector const& selected_file_paths, GUI: } if (!zip_pid) { - Vector relative_paths; + Vector relative_paths; Vector arg_list; arg_list.append("/bin/zip"); arg_list.append("-r"); @@ -273,10 +273,10 @@ void do_create_archive(Vector const& selected_file_paths, GUI: } } -void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window) +void do_set_wallpaper(ByteString const& file_path, GUI::Window* window) { auto show_error = [&] { - GUI::MessageBox::show(window, DeprecatedString::formatted("Failed to set {} as wallpaper.", file_path), "Failed to set wallpaper"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, ByteString::formatted("Failed to set {} as wallpaper.", file_path), "Failed to set wallpaper"sv, GUI::MessageBox::Type::Error); }; auto bitmap_or_error = Gfx::Bitmap::load_from_file(file_path); @@ -289,10 +289,10 @@ void do_set_wallpaper(DeprecatedString const& file_path, GUI::Window* window) show_error(); } -void do_unzip_archive(Vector const& selected_file_paths, GUI::Window* window) +void do_unzip_archive(Vector const& selected_file_paths, GUI::Window* window) { - DeprecatedString archive_file_path = selected_file_paths.first(); - DeprecatedString output_directory_path = archive_file_path.substring(0, archive_file_path.length() - 4); + ByteString archive_file_path = selected_file_paths.first(); + ByteString output_directory_path = archive_file_path.substring(0, archive_file_path.length() - 4); pid_t unzip_pid = fork(); if (unzip_pid < 0) { @@ -315,7 +315,7 @@ void do_unzip_archive(Vector const& selected_file_paths, GUI:: } } -void show_properties(DeprecatedString const& container_dir_path, DeprecatedString const& path, Vector const& selected, GUI::Window* window) +void show_properties(ByteString const& container_dir_path, ByteString const& path, Vector const& selected, GUI::Window* window) { ErrorOr> properties_or_error = nullptr; if (selected.is_empty()) { @@ -337,7 +337,7 @@ void show_properties(DeprecatedString const& container_dir_path, DeprecatedStrin properties->show(); } -bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView const& directory_view, DeprecatedString const& full_path, RefPtr& default_action, Vector>& current_file_launch_handlers) +bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView const& directory_view, ByteString const& full_path, RefPtr& default_action, Vector>& current_file_launch_handlers) { current_file_launch_handlers = directory_view.get_launch_handlers(full_path); @@ -348,9 +348,9 @@ bool add_launch_handler_actions_to_menu(RefPtr& menu, DirectoryView c directory_view.launch(URL::create_with_file_scheme(full_path), launcher_handler); }); if (default_file_handler->details().launcher_type == Desktop::Launcher::LauncherType::Application) - file_open_action->set_text(DeprecatedString::formatted("Run {}", file_open_action->text())); + file_open_action->set_text(ByteString::formatted("Run {}", file_open_action->text())); else - file_open_action->set_text(DeprecatedString::formatted("Open in {}", file_open_action->text())); + file_open_action->set_text(ByteString::formatted("Open in {}", file_open_action->text())); default_action = file_open_action; @@ -458,8 +458,8 @@ ErrorOr run_in_desktop_mode() auto properties_action = GUI::CommonActions::make_properties_action( [&](auto&) { - DeprecatedString path = directory_view->path(); - Vector selected = directory_view->selected_file_paths(); + ByteString path = directory_view->path(); + Vector selected = directory_view->selected_file_paths(); show_properties(path, path, selected, directory_view->window()); }, @@ -472,7 +472,7 @@ ErrorOr run_in_desktop_mode() window); paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "text/uri-list" && access(directory_view->path().characters(), W_OK) == 0); - GUI::Clipboard::the().on_change = [&](DeprecatedString const& data_type) { + GUI::Clipboard::the().on_change = [&](ByteString const& data_type) { paste_action->set_enabled(data_type == "text/uri-list" && access(directory_view->path().characters(), W_OK) == 0); }; @@ -604,7 +604,7 @@ ErrorOr run_in_desktop_mode() return GUI::Application::the()->exec(); } -ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, DeprecatedString const& entry_focused_on_init) +ErrorOr run_in_windowed_mode(ByteString const& initial_location, ByteString const& entry_focused_on_init) { auto window = GUI::Window::construct(); window->set_title("File Manager"); @@ -762,7 +762,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr view_type_action_group->add_action(directory_view->view_as_columns_action()); auto tree_view_selected_file_paths = [&] { - Vector paths; + Vector paths; auto& view = tree_view; view.selection().for_each_index([&](GUI::ModelIndex const& index) { paths.append(directories_model->full_path(index)); @@ -802,7 +802,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr auto copy_path_action = GUI::Action::create( "Copy Path", [&](GUI::Action const&) { - Vector selected_paths; + Vector selected_paths; if (directory_view->active_widget()->is_focused()) { selected_paths = directory_view->selected_file_paths(); } else if (tree_view.is_focused()) { @@ -822,7 +822,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr {}, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-file-manager.png"sv)), [&](GUI::Action const& action) { - Vector paths; + Vector paths; if (action.activator() == tree_view_directory_context_menu) paths = tree_view_selected_file_paths(); else @@ -841,7 +841,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr {}, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"sv)), [&](GUI::Action const& action) { - Vector paths; + Vector paths; if (action.activator() == tree_view_directory_context_menu) paths = tree_view_selected_file_paths(); else @@ -911,9 +911,9 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr auto properties_action = GUI::CommonActions::make_properties_action( [&](auto& action) { - DeprecatedString container_dir_path; - DeprecatedString path; - Vector selected; + ByteString container_dir_path; + ByteString path; + Vector selected; if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) { path = directory_view->path(); container_dir_path = path; @@ -930,7 +930,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr auto paste_action = GUI::CommonActions::make_paste_action( [&](GUI::Action const& action) { - DeprecatedString target_directory; + ByteString target_directory; if (action.activator() == directory_context_menu) target_directory = directory_view->selected_file_paths()[0]; else @@ -942,7 +942,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr auto folder_specific_paste_action = GUI::CommonActions::make_paste_action( [&](GUI::Action const& action) { - DeprecatedString target_directory; + ByteString target_directory; if (action.activator() == directory_context_menu) target_directory = directory_view->selected_file_paths()[0]; else @@ -970,7 +970,7 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr }, window); - GUI::Clipboard::the().on_change = [&](DeprecatedString const& data_type) { + GUI::Clipboard::the().on_change = [&](ByteString const& data_type) { auto current_location = directory_view->path(); paste_action->set_enabled(data_type == "text/uri-list" && access(current_location.characters(), W_OK) == 0); }; @@ -1108,12 +1108,12 @@ ErrorOr run_in_windowed_mode(DeprecatedString const& initial_location, Depr } }; - directory_view->on_path_change = [&](DeprecatedString const& new_path, bool can_read_in_path, bool can_write_in_path) { + directory_view->on_path_change = [&](ByteString const& new_path, bool can_read_in_path, bool can_write_in_path) { auto icon = GUI::FileIconProvider::icon_for_path(new_path); auto* bitmap = icon.bitmap_for_size(16); window->set_icon(bitmap); - window->set_title(DeprecatedString::formatted("{} - File Manager", new_path)); + window->set_title(ByteString::formatted("{} - File Manager", new_path)); breadcrumbbar.set_current_path(new_path); diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 4f7cf3cf5e5..231552bca39 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -90,8 +90,8 @@ ErrorOr> MainWidget::create_preview_window() m_preview_textbox = find_descendant_of_type_named("preview_textbox"); m_preview_textbox->on_change = [this] { - auto maybe_preview = [](DeprecatedString const& deprecated_text) -> ErrorOr { - auto text = TRY(String::from_deprecated_string(deprecated_text)); + auto maybe_preview = [](ByteString const& deprecated_text) -> ErrorOr { + auto text = TRY(String::from_byte_string(deprecated_text)); return TRY(String::formatted("{}\n{}", text, TRY(text.to_uppercase()))); }(m_preview_textbox->text()); if (maybe_preview.is_error()) @@ -150,7 +150,7 @@ ErrorOr MainWidget::create_actions() m_save_action = GUI::CommonActions::make_save_action([this](auto&) { if (m_path.is_empty()) return m_save_as_action->activate(); - auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path.to_deprecated_string(), Core::File::OpenMode::Truncate | Core::File::OpenMode::Write); + auto response = FileSystemAccessClient::Client::the().request_file(window(), m_path.to_byte_string(), Core::File::OpenMode::Truncate | Core::File::OpenMode::Write); if (response.is_error()) return; auto file = response.release_value(); @@ -185,7 +185,7 @@ ErrorOr MainWidget::create_actions() }); m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type() == "glyph/x-fonteditor"); - GUI::Clipboard::the().on_change = [this](DeprecatedString const& data_type) { + GUI::Clipboard::the().on_change = [this](ByteString const& data_type) { m_paste_action->set_enabled(data_type == "glyph/x-fonteditor"); }; @@ -369,7 +369,7 @@ ErrorOr MainWidget::create_actions() continue; builder.append_code_point(code_point); } - GUI::Clipboard::the().set_plain_text(builder.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(builder.to_byte_string()); }); m_copy_text_action->set_status_tip("Copy to clipboard as text"_string); @@ -478,9 +478,9 @@ void MainWidget::update_action_text() }; if (auto maybe_text = text_or_error("&Undo"sv, m_undo_stack->undo_action_text()); !maybe_text.is_error()) - m_undo_action->set_text(maybe_text.release_value().to_deprecated_string()); + m_undo_action->set_text(maybe_text.release_value().to_byte_string()); if (auto maybe_text = text_or_error("&Redo"sv, m_undo_stack->redo_action_text()); !maybe_text.is_error()) - m_redo_action->set_text(maybe_text.release_value().to_deprecated_string()); + m_redo_action->set_text(maybe_text.release_value().to_byte_string()); } ErrorOr MainWidget::create_widgets() @@ -533,13 +533,13 @@ ErrorOr MainWidget::create_widgets() m_name_textbox = find_descendant_of_type_named("name_textbox"); m_name_textbox->on_change = [this] { - m_font->set_name(MUST(String::from_deprecated_string(m_name_textbox->text()))); + m_font->set_name(MUST(String::from_byte_string(m_name_textbox->text()))); did_modify_font(); }; m_family_textbox = find_descendant_of_type_named("family_textbox"); m_family_textbox->on_change = [this] { - m_font->set_family(MUST(String::from_deprecated_string(m_family_textbox->text()))); + m_font->set_family(MUST(String::from_byte_string(m_family_textbox->text()))); did_modify_font(); }; @@ -918,7 +918,7 @@ void MainWidget::update_title() else title.append(m_path); title.append("[*] - Font Editor"sv); - window()->set_title(title.to_deprecated_string()); + window()->set_title(title.to_byte_string()); } void MainWidget::did_modify_font() @@ -1034,11 +1034,11 @@ ErrorOr MainWidget::copy_selected_glyphs() TRY(buffer.try_append(rows)); TRY(buffer.try_append(widths)); - HashMap metadata; - metadata.set("start", DeprecatedString::number(selection.start())); - metadata.set("count", DeprecatedString::number(selection.size())); - metadata.set("width", DeprecatedString::number(m_font->max_glyph_width())); - metadata.set("height", DeprecatedString::number(m_font->glyph_height())); + HashMap metadata; + metadata.set("start", ByteString::number(selection.start())); + metadata.set("count", ByteString::number(selection.size())); + metadata.set("width", ByteString::number(m_font->max_glyph_width())); + metadata.set("height", ByteString::number(m_font->glyph_height())); GUI::Clipboard::the().set_data(buffer.bytes(), "glyph/x-fonteditor", metadata); return {}; diff --git a/Userland/Applications/FontEditor/NewFontDialog.cpp b/Userland/Applications/FontEditor/NewFontDialog.cpp index 2527f96c417..0f5696453e9 100644 --- a/Userland/Applications/FontEditor/NewFontDialog.cpp +++ b/Userland/Applications/FontEditor/NewFontDialog.cpp @@ -218,8 +218,8 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window) void NewFontDialog::save_metadata() { - m_new_font_metadata.name = MUST(String::from_deprecated_string(m_name_textbox->text())); - m_new_font_metadata.family = MUST(String::from_deprecated_string(m_family_textbox->text())); + m_new_font_metadata.name = MUST(String::from_byte_string(m_name_textbox->text())); + m_new_font_metadata.family = MUST(String::from_byte_string(m_family_textbox->text())); m_new_font_metadata.weight = Gfx::name_to_weight(m_weight_combobox->text()); m_new_font_metadata.slope = Gfx::name_to_slope(m_slope_combobox->text()); m_new_font_metadata.presentation_size = m_presentation_spinbox->value(); diff --git a/Userland/Applications/FontEditor/UndoSelection.h b/Userland/Applications/FontEditor/UndoSelection.h index 67a15d1cad8..e6b2d585e0d 100644 --- a/Userland/Applications/FontEditor/UndoSelection.h +++ b/Userland/Applications/FontEditor/UndoSelection.h @@ -97,7 +97,7 @@ public: else warnln("Restoring state failed"); } - virtual DeprecatedString action_text() const override { return m_action_text.to_deprecated_string(); } + virtual ByteString action_text() const override { return m_action_text.to_byte_string(); } private: NonnullRefPtr m_undo_state; diff --git a/Userland/Applications/FontEditor/main.cpp b/Userland/Applications/FontEditor/main.cpp index abb5f19489c..6d85f83415a 100644 --- a/Userland/Applications/FontEditor/main.cpp +++ b/Userland/Applications/FontEditor/main.cpp @@ -59,7 +59,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->show(); - auto default_path = TRY(String::from_deprecated_string(Config::read_string("FontEditor"sv, "Defaults"sv, "Font"sv, {}))); + auto default_path = TRY(String::from_byte_string(Config::read_string("FontEditor"sv, "Defaults"sv, "Font"sv, {}))); auto path_to_load = path.is_empty() ? default_path : path; if (!path_to_load.is_empty()) { auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path_to_load); diff --git a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp index abdf3befd58..fda40fcc069 100644 --- a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp +++ b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp @@ -88,7 +88,7 @@ ErrorOr CardSettingsWidget::initialize() TRY(m_card_front_sets.try_append(entry.name)); return IterationDecision::Continue; })); - auto piece_set_model = GUI::ItemListModel::create(m_card_front_sets); + auto piece_set_model = GUI::ItemListModel::create(m_card_front_sets); m_card_front_images_combo_box->set_model(piece_set_model); auto card_front_set = Config::read_string("Games"sv, "Cards"sv, "CardFrontImages"sv, default_card_front_image_set); if (card_front_set.is_empty()) @@ -103,7 +103,7 @@ ErrorOr CardSettingsWidget::initialize() m_card_back_image_view = find_descendant_of_type_named("cards_back_image"); m_card_back_image_view->set_model(GUI::FileSystemModel::create("/res/graphics/cards/backs")); m_card_back_image_view->set_model_column(GUI::FileSystemModel::Column::Name); - if (!set_card_back_image_path(TRY(String::from_deprecated_string(Config::read_string("Games"sv, "Cards"sv, "CardBackImage"sv))))) + if (!set_card_back_image_path(TRY(String::from_byte_string(Config::read_string("Games"sv, "Cards"sv, "CardBackImage"sv))))) set_card_back_image_path(default_card_back_image_path); m_card_back_image_view->on_selection_change = [&]() { auto& card_back_selection = m_card_back_image_view->selection(); @@ -140,7 +140,7 @@ void CardSettingsWidget::reset_default_values() bool CardSettingsWidget::set_card_back_image_path(StringView path) { - auto index = static_cast(m_card_back_image_view->model())->index(path.to_deprecated_string(), m_card_back_image_view->model_column()); + auto index = static_cast(m_card_back_image_view->model())->index(path.to_byte_string(), m_card_back_image_view->model_column()); if (index.is_valid()) { m_card_back_image_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set); Cards::CardPainter::the().set_back_image_path(path); @@ -156,7 +156,7 @@ String CardSettingsWidget::card_back_image_path() const GUI::ModelIndex card_back_image_index = m_last_selected_card_back; if (!card_back_selection.is_empty()) card_back_image_index = card_back_selection.first(); - return String::from_deprecated_string(static_cast(m_card_back_image_view->model())->full_path(card_back_image_index)).release_value_but_fixme_should_propagate_errors(); + return String::from_byte_string(static_cast(m_card_back_image_view->model())->full_path(card_back_image_index)).release_value_but_fixme_should_propagate_errors(); } String CardSettingsWidget::card_front_images_set_name() const @@ -164,7 +164,7 @@ String CardSettingsWidget::card_front_images_set_name() const auto selected_set_name = m_card_front_images_combo_box->text(); if (selected_set_name == "None") return {}; - return MUST(String::from_deprecated_string(selected_set_name)); + return MUST(String::from_byte_string(selected_set_name)); } } diff --git a/Userland/Applications/GamesSettings/CardSettingsWidget.h b/Userland/Applications/GamesSettings/CardSettingsWidget.h index 7308f9e802a..e75dcb46152 100644 --- a/Userland/Applications/GamesSettings/CardSettingsWidget.h +++ b/Userland/Applications/GamesSettings/CardSettingsWidget.h @@ -35,7 +35,7 @@ private: String card_back_image_path() const; String card_front_images_set_name() const; - Vector m_card_front_sets; + Vector m_card_front_sets; RefPtr m_preview_frame; RefPtr m_background_color_input; diff --git a/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp b/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp index 48177afe37e..19a63a477d4 100644 --- a/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp +++ b/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp @@ -251,12 +251,12 @@ ErrorOr ChessSettingsWidget::initialize() TRY(m_piece_sets.try_append(entry.name)); return IterationDecision::Continue; })); - auto piece_set_model = GUI::ItemListModel::create(m_piece_sets); + auto piece_set_model = GUI::ItemListModel::create(m_piece_sets); m_piece_set_combobox->set_model(piece_set_model); m_piece_set_combobox->set_text(piece_set_name, GUI::AllowCallback::No); m_piece_set_combobox->on_change = [&](auto& value, auto&) { set_modified(true); - m_preview->set_piece_set_name(MUST(String::from_deprecated_string(value))); + m_preview->set_piece_set_name(MUST(String::from_byte_string(value))); }; m_board_theme_combobox = find_descendant_of_type_named("board_theme"); @@ -283,7 +283,7 @@ ErrorOr ChessSettingsWidget::initialize() set_modified(true); }; - m_preview->set_piece_set_name(TRY(String::from_deprecated_string(piece_set_name))); + m_preview->set_piece_set_name(TRY(String::from_byte_string(piece_set_name))); m_preview->set_dark_square_color(board_theme.dark_square_color); m_preview->set_light_square_color(board_theme.light_square_color); m_preview->set_show_coordinates(show_coordinates); diff --git a/Userland/Applications/GamesSettings/ChessSettingsWidget.h b/Userland/Applications/GamesSettings/ChessSettingsWidget.h index 704823b0441..26b743dbe31 100644 --- a/Userland/Applications/GamesSettings/ChessSettingsWidget.h +++ b/Userland/Applications/GamesSettings/ChessSettingsWidget.h @@ -28,7 +28,7 @@ private: ChessSettingsWidget() = default; ErrorOr initialize(); - Vector m_piece_sets; + Vector m_piece_sets; RefPtr m_preview; RefPtr m_piece_set_combobox; diff --git a/Userland/Applications/Help/History.cpp b/Userland/Applications/Help/History.cpp index 2bbab72c9d3..6c8dc490ee4 100644 --- a/Userland/Applications/Help/History.cpp +++ b/Userland/Applications/Help/History.cpp @@ -16,7 +16,7 @@ void History::push(StringView history_item) m_current_history_item++; } -DeprecatedString History::current() +ByteString History::current() { if (m_current_history_item == -1) return {}; diff --git a/Userland/Applications/Help/History.h b/Userland/Applications/Help/History.h index c5f56c96268..d2d2fe00d3a 100644 --- a/Userland/Applications/Help/History.h +++ b/Userland/Applications/Help/History.h @@ -6,13 +6,13 @@ #pragma once -#include +#include #include class History final { public: void push(StringView history_item); - DeprecatedString current(); + ByteString current(); void go_back(); void go_forward(); @@ -23,6 +23,6 @@ public: void clear(); private: - Vector m_items; + Vector m_items; int m_current_history_item { -1 }; }; diff --git a/Userland/Applications/Help/MainWidget.cpp b/Userland/Applications/Help/MainWidget.cpp index 2443ec08347..0a26a5373b9 100644 --- a/Userland/Applications/Help/MainWidget.cpp +++ b/Userland/Applications/Help/MainWidget.cpp @@ -132,7 +132,7 @@ ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) return; } m_history.push(path.string()); - auto string_path = String::from_deprecated_string(path.string()); + auto string_path = String::from_byte_string(path.string()); if (string_path.is_error()) return; open_page(string_path.value()); @@ -156,7 +156,7 @@ ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) }; m_web_view->on_link_hover = [this](URL const& url) { if (url.is_valid()) - m_statusbar->set_text(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors()); + m_statusbar->set_text(String::from_byte_string(url.to_byte_string()).release_value_but_fixme_should_propagate_errors()); else m_statusbar->set_text({}); }; @@ -166,12 +166,12 @@ ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) m_go_back_action = GUI::CommonActions::make_go_back_action([this](auto&) { m_history.go_back(); - open_page(MUST(String::from_deprecated_string(m_history.current()))); + open_page(MUST(String::from_byte_string(m_history.current()))); }); m_go_forward_action = GUI::CommonActions::make_go_forward_action([this](auto&) { m_history.go_forward(); - open_page(MUST(String::from_deprecated_string(m_history.current()))); + open_page(MUST(String::from_byte_string(m_history.current()))); }); m_go_back_action->set_enabled(false); @@ -261,7 +261,7 @@ void MainWidget::open_url(URL const& url) return; auto title = String::formatted("{} - Help", page_and_section.value()); if (!title.is_error()) - window()->set_title(title.release_value().to_deprecated_string()); + window()->set_title(title.release_value().to_byte_string()); } else { window()->set_title("Help"); } @@ -271,7 +271,7 @@ void MainWidget::open_url(URL const& url) void MainWidget::open_external(URL const& url) { if (!Desktop::Launcher::open(url)) - GUI::MessageBox::show(window(), DeprecatedString::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error); } void MainWidget::open_page(Optional const& path) @@ -285,7 +285,7 @@ void MainWidget::open_page(Optional const& path) return; } dbgln("open page: {}", path.value()); - open_url(URL::create_with_url_or_path(path.value().to_deprecated_string())); + open_url(URL::create_with_url_or_path(path.value().to_byte_string())); } } diff --git a/Userland/Applications/Help/ManualModel.cpp b/Userland/Applications/Help/ManualModel.cpp index b0c61a8882a..941d0ec8e1b 100644 --- a/Userland/Applications/Help/ManualModel.cpp +++ b/Userland/Applications/Help/ManualModel.cpp @@ -183,8 +183,8 @@ GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role return {}; if (auto path = page_path(index); path.has_value()) if (auto page = page_view(path.release_value()); !page.is_error()) - // FIXME: We already provide String, but GUI::Variant still needs DeprecatedString. - return DeprecatedString(page.release_value()); + // FIXME: We already provide String, but GUI::Variant still needs ByteString. + return ByteString(page.release_value()); return {}; case GUI::ModelRole::Display: if (auto name = node->name(); !name.is_error()) diff --git a/Userland/Applications/Help/main.cpp b/Userland/Applications/Help/main.cpp index c39baaa6093..d4ab1fe6965 100644 --- a/Userland/Applications/Help/main.cpp +++ b/Userland/Applications/Help/main.cpp @@ -31,8 +31,8 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - DeprecatedString first_query_parameter; - DeprecatedString second_query_parameter; + ByteString first_query_parameter; + ByteString second_query_parameter; Core::ArgsParser args_parser; // The actual "page query" parsing happens when we set the main widget's start page. diff --git a/Userland/Applications/HexEditor/FindDialog.cpp b/Userland/Applications/HexEditor/FindDialog.cpp index f7b3c715470..9e36cc1c65e 100644 --- a/Userland/Applications/HexEditor/FindDialog.cpp +++ b/Userland/Applications/HexEditor/FindDialog.cpp @@ -142,7 +142,7 @@ FindDialog::FindDialog(NonnullRefPtr find_widget) }; m_find_button->on_click = [this](auto) { - auto text = String::from_deprecated_string(m_text_editor->text()).release_value_but_fixme_should_propagate_errors(); + auto text = String::from_byte_string(m_text_editor->text()).release_value_but_fixme_should_propagate_errors(); if (!text.is_empty()) { m_text_value = text; done(ExecResult::OK); diff --git a/Userland/Applications/HexEditor/GoToOffsetDialog.cpp b/Userland/Applications/HexEditor/GoToOffsetDialog.cpp index 62d318264d0..ccde68295ed 100644 --- a/Userland/Applications/HexEditor/GoToOffsetDialog.cpp +++ b/Userland/Applications/HexEditor/GoToOffsetDialog.cpp @@ -51,14 +51,14 @@ GUI::Dialog::ExecResult GoToOffsetDialog::show(GUI::Window* parent_window, int& int GoToOffsetDialog::process_input() { - auto input_offset = String::from_deprecated_string(m_text_editor->text().trim_whitespace()).release_value_but_fixme_should_propagate_errors(); + auto input_offset = String::from_byte_string(m_text_editor->text().trim_whitespace()).release_value_but_fixme_should_propagate_errors(); int offset; auto type = m_offset_type_box->text().trim_whitespace(); if (type == "Decimal") { offset = input_offset.to_number().value_or(0); } else if (type == "Hexadecimal") { // FIXME: Find a better way of parsing hex to a number that doesn't require a zero terminated string - offset = strtol(input_offset.to_deprecated_string().characters(), nullptr, 16); + offset = strtol(input_offset.to_byte_string().characters(), nullptr, 16); } else { VERIFY_NOT_REACHED(); } diff --git a/Userland/Applications/HexEditor/HexDocument.h b/Userland/Applications/HexEditor/HexDocument.h index 402e9b8c14d..f575feff397 100644 --- a/Userland/Applications/HexEditor/HexDocument.h +++ b/Userland/Applications/HexEditor/HexDocument.h @@ -95,7 +95,7 @@ public: virtual void undo() override; virtual void redo() override; - virtual DeprecatedString action_text() const override { return "Update cell"; } + virtual ByteString action_text() const override { return "Update cell"; } virtual bool merge_with(GUI::Command const& other) override; diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index 1ca9a0a788b..d792552dd2e 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -9,8 +9,8 @@ #include "HexEditor.h" #include "SearchResultsModel.h" +#include #include -#include #include #include #include @@ -180,7 +180,7 @@ bool HexEditor::copy_selected_hex_to_clipboard() for (size_t i = m_selection_start; i < m_selection_end; i++) output_string_builder.appendff("{:02X} ", m_document->get(i).value); - GUI::Clipboard::the().set_plain_text(output_string_builder.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(output_string_builder.to_byte_string()); return true; } @@ -193,7 +193,7 @@ bool HexEditor::copy_selected_text_to_clipboard() for (size_t i = m_selection_start; i < m_selection_end; i++) output_string_builder.append(isprint(m_document->get(i).value) ? m_document->get(i).value : '.'); - GUI::Clipboard::the().set_plain_text(output_string_builder.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(output_string_builder.to_byte_string()); return true; } @@ -216,7 +216,7 @@ bool HexEditor::copy_selected_hex_to_clipboard_as_c_code() } output_string_builder.append("\n};\n"sv); - GUI::Clipboard::the().set_plain_text(output_string_builder.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(output_string_builder.to_byte_string()); return true; } @@ -490,7 +490,7 @@ void HexEditor::keydown_event(GUI::KeyEvent& event) result = text_mode_keydown_event(event); } if (result.is_error()) - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("{}", result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("{}", result.error())); } event.ignore(); diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index d91fec4fceb..2a11bb1a8f2 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -112,7 +112,7 @@ ErrorOr HexEditorWidget::setup() } if (auto error = m_editor->open_new_file(file_size.value()); error.is_error()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Unable to open new file: {}"sv, error.error()), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Unable to open new file: {}"sv, error.error()), "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -137,7 +137,7 @@ ErrorOr HexEditorWidget::setup() return m_save_as_action->activate(); if (auto result = m_editor->save(); result.is_error()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Unable to save file: {}\n"sv, result.error()), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Unable to save file: {}\n"sv, result.error()), "Error"sv, GUI::MessageBox::Type::Error); } else { window()->set_modified(false); m_editor->update(); @@ -151,7 +151,7 @@ ErrorOr HexEditorWidget::setup() return; auto file = response.release_value(); if (auto result = m_editor->save_as(file.release_stream()); result.is_error()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Unable to save file: {}\n"sv, result.error()), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Unable to save file: {}\n"sv, result.error()), "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -180,11 +180,11 @@ ErrorOr HexEditorWidget::setup() m_search_results->update(); if (matches.is_empty()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not Found"sv, GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(window(), ByteString::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not Found"sv, GUI::MessageBox::Type::Warning); return; } - GUI::MessageBox::show(window(), DeprecatedString::formatted("Found {} matches for \"{}\" in this file", matches.size(), m_search_text), DeprecatedString::formatted("{} Matches", matches.size()), GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(window(), ByteString::formatted("Found {} matches for \"{}\" in this file", matches.size(), m_search_text), ByteString::formatted("{} Matches", matches.size()), GUI::MessageBox::Type::Warning); set_search_results_visible(true); } else { bool same_buffers = false; @@ -196,7 +196,7 @@ ErrorOr HexEditorWidget::setup() auto result = m_editor->find_and_highlight(m_search_buffer, same_buffers ? last_found_index() : 0); if (!result.has_value()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not Found"sv, GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(window(), ByteString::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not Found"sv, GUI::MessageBox::Type::Warning); return; } @@ -252,7 +252,7 @@ ErrorOr HexEditorWidget::setup() auto fill_byte = strtol(value.bytes_as_string_view().characters_without_null_termination(), nullptr, 16); auto result = m_editor->fill_selection(fill_byte); if (result.is_error()) - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("{}", result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("{}", result.error())); } }); m_fill_selection_action->set_enabled(false); @@ -464,7 +464,7 @@ ErrorOr HexEditorWidget::initialize_menubar(GUI::Window& window) auto result = m_editor->find_and_highlight(m_search_buffer, last_found_index()); if (!result.has_value()) { - GUI::MessageBox::show(&window, DeprecatedString::formatted("No more matches for \"{}\" found in this file", m_search_text), "Not Found"sv, GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(&window, ByteString::formatted("No more matches for \"{}\" found in this file", m_search_text), "Not Found"sv, GUI::MessageBox::Type::Warning); return; } m_editor->update(); @@ -512,7 +512,7 @@ ErrorOr HexEditorWidget::initialize_menubar(GUI::Window& window) m_bytes_per_row_actions.set_exclusive(true); auto bytes_per_row_menu = view_menu->add_submenu("Bytes per &Row"_string); for (int i = 8; i <= 32; i += 8) { - auto action = GUI::Action::create_checkable(DeprecatedString::number(i), [this, i](auto&) { + auto action = GUI::Action::create_checkable(ByteString::number(i), [this, i](auto&) { m_editor->set_bytes_per_row(i); m_editor->update(); Config::write_i32("HexEditor"sv, "Layout"sv, "BytesPerRow"sv, i); @@ -582,14 +582,14 @@ void HexEditorWidget::update_title() else builder.append(m_path); builder.append("[*] - Hex Editor"sv); - window()->set_title(builder.to_deprecated_string()); + window()->set_title(builder.to_byte_string()); } void HexEditorWidget::open_file(String const& filename, NonnullOwnPtr file) { window()->set_modified(false); m_editor->open_file(move(file)); - set_path(filename.to_deprecated_string()); + set_path(filename.to_byte_string()); GUI::Application::the()->set_most_recently_open_file(filename); } diff --git a/Userland/Applications/HexEditor/HexEditorWidget.h b/Userland/Applications/HexEditor/HexEditorWidget.h index 500e7592900..53d6dc26f10 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.h +++ b/Userland/Applications/HexEditor/HexEditorWidget.h @@ -46,9 +46,9 @@ private: virtual void drop_event(GUI::DropEvent&) override; RefPtr m_editor; - DeprecatedString m_path; - DeprecatedString m_name; - DeprecatedString m_extension; + ByteString m_path; + ByteString m_name; + ByteString m_extension; int m_goto_history { 0 }; String m_search_text; diff --git a/Userland/Applications/HexEditor/SearchResultsModel.h b/Userland/Applications/HexEditor/SearchResultsModel.h index afe6ccb37c8..29f4f6a1506 100644 --- a/Userland/Applications/HexEditor/SearchResultsModel.h +++ b/Userland/Applications/HexEditor/SearchResultsModel.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -63,7 +63,7 @@ public: auto& match = m_matches.at(index.row()); switch (index.column()) { case Column::Offset: - return DeprecatedString::formatted("{:#08X}", match.offset); + return ByteString::formatted("{:#08X}", match.offset); case Column::Value: { Utf8View utf8_view(match.value); if (!utf8_view.validate()) diff --git a/Userland/Applications/HexEditor/ValueInspectorModel.h b/Userland/Applications/HexEditor/ValueInspectorModel.h index da5f0ebf213..7fa3bc44063 100644 --- a/Userland/Applications/HexEditor/ValueInspectorModel.h +++ b/Userland/Applications/HexEditor/ValueInspectorModel.h @@ -121,7 +121,7 @@ public: if (role == GUI::ModelRole::Display) { switch (index.column()) { case Column::Type: - return inspector_value_type_to_string(static_cast(index.row())).to_deprecated_string(); + return inspector_value_type_to_string(static_cast(index.row())).to_byte_string(); case Column::Value: return m_values.at(index.row()); } diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index dea7573f3d7..f3ae54932ca 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -118,14 +118,14 @@ bool ViewWidget::is_previous_available() const // FIXME: Convert to `String` & use LibFileSystemAccessClient + `Core::System::unveil(nullptr, nullptr)` // - Converting to String is not super-trivial due to the LexicalPath usage, while we can do a bunch of -// String::from_deprecated_string() and String.to_deprecated_string(), it is quite ugly to read and +// String::from_byte_string() and String.to_byte_string(), it is quite ugly to read and // probably not the best approach. // // - If we go full-unveil (`Core::System::unveil(nullptr, nullptr)`) this functionality does not work, // we can not access the list of contents of a directory through LibFileSystemAccessClient at the moment. -Vector ViewWidget::load_files_from_directory(DeprecatedString const& path) const +Vector ViewWidget::load_files_from_directory(ByteString const& path) const { - Vector files_in_directory; + Vector files_in_directory; auto current_dir = LexicalPath(path).parent().string(); // FIXME: Propagate errors @@ -141,8 +141,8 @@ Vector ViewWidget::load_files_from_directory(DeprecatedString void ViewWidget::set_path(String const& path) { m_path = path; - m_files_in_same_dir = load_files_from_directory(path.to_deprecated_string()); - m_current_index = m_files_in_same_dir.find_first_index(path.to_deprecated_string()); + m_files_in_same_dir = load_files_from_directory(path.to_byte_string()); + m_current_index = m_files_in_same_dir.find_first_index(path.to_byte_string()); } void ViewWidget::navigate(Directions direction) diff --git a/Userland/Applications/ImageViewer/ViewWidget.h b/Userland/Applications/ImageViewer/ViewWidget.h index 44cff4853a7..e509cb8efb7 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.h +++ b/Userland/Applications/ImageViewer/ViewWidget.h @@ -138,7 +138,7 @@ private: void set_image(Image const* image); void animate(); - Vector load_files_from_directory(DeprecatedString const& path) const; + Vector load_files_from_directory(ByteString const& path) const; ErrorOr try_open_file(String const&, Core::File&); String m_path; @@ -162,7 +162,7 @@ private: int m_toolbar_height { 28 }; bool m_scaled_for_first_image { false }; - Vector m_files_in_same_dir; + Vector m_files_in_same_dir; Optional m_current_index; Gfx::Painter::ScalingMode m_scaling_mode { Gfx::Painter::ScalingMode::NearestNeighbor }; }; diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index a88f9b8fb58..3b2c75897cd 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -82,7 +82,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return; } - window->set_title(DeprecatedString::formatted("{} {} {}% - Image Viewer", widget.path(), widget.image()->size().to_deprecated_string(), (int)(scale * 100))); + window->set_title(ByteString::formatted("{} {} {}% - Image Viewer", widget.path(), widget.image()->size().to_byte_string(), (int)(scale * 100))); if (!widget.scaled_for_first_image()) { widget.set_scaled_for_first_image(true); @@ -140,7 +140,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return; auto msgbox_result = GUI::MessageBox::show(window, - DeprecatedString::formatted("Are you sure you want to delete {}?", path), + ByteString::formatted("Are you sure you want to delete {}?", path), "Confirm Deletion"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); @@ -151,7 +151,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto unlinked_or_error = Core::System::unlink(widget.path()); if (unlinked_or_error.is_error()) { GUI::MessageBox::show(window, - DeprecatedString::formatted("unlink({}) failed: {}", path, unlinked_or_error.error()), + ByteString::formatted("unlink({}) failed: {}", path, unlinked_or_error.error()), "Delete Failed"sv, GUI::MessageBox::Type::Error); @@ -188,7 +188,7 @@ ErrorOr serenity_main(Main::Arguments arguments) [&](auto&) { if (!GUI::Desktop::the().set_wallpaper(widget.image()->bitmap(GUI::Desktop::the().rect().size()).release_value_but_fixme_should_propagate_errors(), widget.path())) { GUI::MessageBox::show(window, - DeprecatedString::formatted("set_wallpaper({}) failed", widget.path()), + ByteString::formatted("set_wallpaper({}) failed", widget.path()), "Could not set wallpaper"sv, GUI::MessageBox::Type::Error); } diff --git a/Userland/Applications/KeyboardMapper/KeyPositions.h b/Userland/Applications/KeyboardMapper/KeyPositions.h index 9a976be5855..b5ae6eef6d6 100644 --- a/Userland/Applications/KeyboardMapper/KeyPositions.h +++ b/Userland/Applications/KeyboardMapper/KeyPositions.h @@ -6,7 +6,7 @@ #pragma once -#include +#include struct KeyPosition { u32 scancode; @@ -16,7 +16,7 @@ struct KeyPosition { int height; bool enabled; int map_index; - DeprecatedString name; + ByteString name; }; #define KEY_COUNT 63 diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 17620e05dbf..ba9756ef46d 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -51,7 +51,7 @@ void KeyboardMapperWidget::create_frame() auto& tmp_button = main_widget.add(); tmp_button.set_relative_rect(rect); - tmp_button.set_text(String::from_deprecated_string(keys[i].name).release_value_but_fixme_should_propagate_errors()); + tmp_button.set_text(String::from_byte_string(keys[i].name).release_value_but_fixme_should_propagate_errors()); tmp_button.set_enabled(keys[i].enabled); tmp_button.on_click = [this, &tmp_button]() { @@ -125,7 +125,7 @@ u32* KeyboardMapperWidget::map_from_name(const StringView map_name) return map; } -ErrorOr KeyboardMapperWidget::load_map_from_file(DeprecatedString const& filename) +ErrorOr KeyboardMapperWidget::load_map_from_file(ByteString const& filename) { auto character_map = TRY(Keyboard::CharacterMapFile::load_from_file(filename)); @@ -147,7 +147,7 @@ ErrorOr KeyboardMapperWidget::load_map_from_system() { auto character_map = TRY(Keyboard::CharacterMap::fetch_system_map()); - m_filename = DeprecatedString::formatted("/res/keymaps/{}.json", character_map.character_map_name()); + m_filename = ByteString::formatted("/res/keymaps/{}.json", character_map.character_map_name()); m_character_map = character_map.character_map_data(); set_current_map("map"); @@ -169,14 +169,14 @@ ErrorOr KeyboardMapperWidget::save_to_file(StringView filename) { JsonObject map_json; - auto add_array = [&](DeprecatedString name, u32* values) { + auto add_array = [&](ByteString name, u32* values) { JsonArray items; for (int i = 0; i < 90; i++) { StringBuilder sb; if (values[i]) sb.append_code_point(values[i]); - JsonValue val(sb.to_deprecated_string()); + JsonValue val(sb.to_byte_string()); items.must_append(move(val)); } map_json.set(name, move(items)); @@ -189,7 +189,7 @@ ErrorOr KeyboardMapperWidget::save_to_file(StringView filename) add_array("shift_altgr_map", m_character_map.shift_altgr_map); // Write to file. - DeprecatedString file_content = map_json.to_deprecated_string(); + ByteString file_content = map_json.to_byte_string(); auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write)); TRY(file->write_until_depleted(file_content.bytes())); file->close(); @@ -234,7 +234,7 @@ void KeyboardMapperWidget::keyup_event(GUI::KeyEvent& event) } } -void KeyboardMapperWidget::set_current_map(const DeprecatedString current_map) +void KeyboardMapperWidget::set_current_map(const ByteString current_map) { m_current_map_name = current_map; u32* map = map_from_name(m_current_map_name); @@ -259,7 +259,7 @@ void KeyboardMapperWidget::update_window_title() sb.append(m_filename); sb.append("[*] - Keyboard Mapper"sv); - window()->set_title(sb.to_deprecated_string()); + window()->set_title(sb.to_byte_string()); } void KeyboardMapperWidget::show_error_to_user(Error error) diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h index fcd14be56ef..c46af2a14d7 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.h @@ -18,7 +18,7 @@ public: virtual ~KeyboardMapperWidget() override = default; void create_frame(); - ErrorOr load_map_from_file(DeprecatedString const&); + ErrorOr load_map_from_file(ByteString const&); ErrorOr load_map_from_system(); ErrorOr save(); ErrorOr save_to_file(StringView); @@ -31,7 +31,7 @@ protected: virtual void keydown_event(GUI::KeyEvent&) override; virtual void keyup_event(GUI::KeyEvent&) override; - void set_current_map(const DeprecatedString); + void set_current_map(const ByteString); void update_window_title(); private: @@ -43,8 +43,8 @@ private: u32* map_from_name(const StringView map_name); void update_modifier_radio_buttons(GUI::KeyEvent&); - DeprecatedString m_filename; + ByteString m_filename; Keyboard::CharacterMapData m_character_map; - DeprecatedString m_current_map_name; + ByteString m_current_map_name; bool m_automatic_modifier { false }; }; diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp index de1c6e62635..6941265a17b 100644 --- a/Userland/Applications/KeyboardMapper/main.cpp +++ b/Userland/Applications/KeyboardMapper/main.cpp @@ -48,7 +48,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!keyboard_mapper_widget->request_close()) return; - Optional path = GUI::FilePicker::get_open_filepath(window, "Open"sv, "/res/keymaps/"sv); + Optional path = GUI::FilePicker::get_open_filepath(window, "Open"sv, "/res/keymaps/"sv); if (!path.has_value()) return; @@ -63,8 +63,8 @@ ErrorOr serenity_main(Main::Arguments arguments) }); auto save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { - DeprecatedString name = "Unnamed"; - Optional save_path = GUI::FilePicker::get_save_filepath(window, name, "json"); + ByteString name = "Unnamed"; + Optional save_path = GUI::FilePicker::get_save_filepath(window, name, "json"); if (!save_path.has_value()) return; diff --git a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp index 2f3fe76d936..755fee69991 100644 --- a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp +++ b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp @@ -34,7 +34,7 @@ class KeymapSelectionDialog final : public GUI::Dialog { public: virtual ~KeymapSelectionDialog() override = default; - static DeprecatedString select_keymap(Window* parent_window, Vector const& selected_keymaps) + static ByteString select_keymap(Window* parent_window, Vector const& selected_keymaps) { auto dialog = KeymapSelectionDialog::construct(parent_window, selected_keymaps); dialog->set_title("Add a keymap"); @@ -43,13 +43,13 @@ public: return dialog->selected_keymap(); } - return DeprecatedString::empty(); + return ByteString::empty(); } - DeprecatedString selected_keymap() { return m_selected_keymap; } + ByteString selected_keymap() { return m_selected_keymap; } private: - KeymapSelectionDialog(Window* parent_window, Vector const& selected_keymaps) + KeymapSelectionDialog(Window* parent_window, Vector const& selected_keymaps) : Dialog(parent_window) { auto widget = set_main_widget(); @@ -68,7 +68,7 @@ private: }); if (iterator_result.is_error()) { - GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Error on reading mapping file list: {}", iterator_result.error()), "Keyboard settings"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(nullptr, ByteString::formatted("Error on reading mapping file list: {}", iterator_result.error()), "Keyboard settings"sv, GUI::MessageBox::Type::Error); GUI::Application::the()->quit(-1); } @@ -78,7 +78,7 @@ private: m_keymaps_combobox = *widget->find_descendant_of_type_named("keymaps_combobox"); m_keymaps_combobox->set_only_allow_values_from_model(true); - m_keymaps_combobox->set_model(*GUI::ItemListModel::create(m_character_map_files)); + m_keymaps_combobox->set_model(*GUI::ItemListModel::create(m_character_map_files)); m_keymaps_combobox->set_selected_index(0); m_keymaps_combobox->on_change = [&](auto& keymap, auto) { @@ -97,8 +97,8 @@ private: } RefPtr m_keymaps_combobox; - Vector m_character_map_files; - DeprecatedString m_selected_keymap; + Vector m_character_map_files; + ByteString m_selected_keymap; }; class KeymapModel final : public GUI::Model { @@ -110,7 +110,7 @@ public: GUI::Variant data(GUI::ModelIndex const& index, GUI::ModelRole role) const override { - DeprecatedString const& data = m_data.at(index.row()); + ByteString const& data = m_data.at(index.row()); if (role == GUI::ModelRole::Font && data == m_active_keymap) return Gfx::FontDatabase::default_font().bold_variant(); @@ -123,30 +123,30 @@ public: invalidate(); } - void add_keymap(DeprecatedString const& keymap) + void add_keymap(ByteString const& keymap) { m_data.append(keymap); invalidate(); } - void set_active_keymap(DeprecatedString const& keymap) + void set_active_keymap(ByteString const& keymap) { m_active_keymap = keymap; invalidate(); } - DeprecatedString const& active_keymap() { return m_active_keymap; } + ByteString const& active_keymap() { return m_active_keymap; } - DeprecatedString const& keymap_at(size_t index) + ByteString const& keymap_at(size_t index) { return m_data[index]; } - Vector const& keymaps() const { return m_data; } + Vector const& keymaps() const { return m_data; } private: - Vector m_data; - DeprecatedString m_active_keymap; + Vector m_data; + ByteString m_active_keymap; }; ErrorOr> KeyboardSettingsWidget::try_create() @@ -165,7 +165,7 @@ ErrorOr KeyboardSettingsWidget::setup() auto json = TRY(JsonValue::from_string(keymap)); auto const& keymap_object = json.as_object(); VERIFY(keymap_object.has("keymap"sv)); - m_initial_active_keymap = keymap_object.get_deprecated_string("keymap"sv).value(); + m_initial_active_keymap = keymap_object.get_byte_string("keymap"sv).value(); dbgln("KeyboardSettings thinks the current keymap is: {}", m_initial_active_keymap); auto mapper_config(TRY(Core::ConfigFile::open("/etc/Keyboard.ini"))); @@ -265,7 +265,7 @@ ErrorOr KeyboardSettingsWidget::setup() m_caps_lock_checkbox = find_descendant_of_type_named("caps_lock_remapped_to_ctrl_checkbox"); auto caps_lock_is_remapped = read_caps_lock_to_ctrl_sys_variable(); if (caps_lock_is_remapped.is_error()) { - auto error_message = DeprecatedString::formatted("Could not determine if Caps Lock is remapped to Ctrl: {}", caps_lock_is_remapped.error()); + auto error_message = ByteString::formatted("Could not determine if Caps Lock is remapped to Ctrl: {}", caps_lock_is_remapped.error()); GUI::MessageBox::show_error(window(), error_message); } else { m_caps_lock_checkbox->set_checked(caps_lock_is_remapped.value()); @@ -305,9 +305,9 @@ void KeyboardSettingsWidget::apply_settings() write_caps_lock_to_ctrl_sys_variable(m_caps_lock_checkbox->is_checked()); } -void KeyboardSettingsWidget::set_keymaps(Vector const& keymaps, DeprecatedString const& active_keymap) +void KeyboardSettingsWidget::set_keymaps(Vector const& keymaps, ByteString const& active_keymap) { - auto keymaps_string = DeprecatedString::join(',', keymaps); + auto keymaps_string = ByteString::join(',', keymaps); GUI::Process::spawn_or_show_error(window(), "/bin/keymap"sv, Array { "-s", keymaps_string.characters(), "-m", active_keymap.characters() }); } @@ -316,7 +316,7 @@ void KeyboardSettingsWidget::write_caps_lock_to_ctrl_sys_variable(bool caps_lock if (getuid() != 0) return; - auto write_command = DeprecatedString::formatted("caps_lock_to_ctrl={}", caps_lock_to_ctrl ? "1" : "0"); + auto write_command = ByteString::formatted("caps_lock_to_ctrl={}", caps_lock_to_ctrl ? "1" : "0"); GUI::Process::spawn_or_show_error(window(), "/bin/sysctl"sv, Array { "-w", write_command.characters() }); } diff --git a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.h b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.h index 6281857ff0d..15eb7c4a7ed 100644 --- a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.h +++ b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.h @@ -29,14 +29,14 @@ private: KeyboardSettingsWidget() = default; ErrorOr setup(); - void set_keymaps(Vector const& keymaps, DeprecatedString const& active_keymap); + void set_keymaps(Vector const& keymaps, ByteString const& active_keymap); void write_caps_lock_to_ctrl_sys_variable(bool); ErrorOr read_caps_lock_to_ctrl_sys_variable(); - Vector m_initial_keymap_list; + Vector m_initial_keymap_list; - DeprecatedString m_initial_active_keymap; + ByteString m_initial_active_keymap; RefPtr m_selected_keymaps_listview; RefPtr m_active_keymap_label; diff --git a/Userland/Applications/Magnifier/main.cpp b/Userland/Applications/Magnifier/main.cpp index 7829b5dd115..1157e24df88 100644 --- a/Userland/Applications/Magnifier/main.cpp +++ b/Userland/Applications/Magnifier/main.cpp @@ -63,13 +63,13 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file_menu = window->add_menu("&File"_string); file_menu->add_action(GUI::CommonActions::make_save_as_action([&](auto&) { - AK::DeprecatedString filename = "file for saving"; + AK::ByteString filename = "file for saving"; auto do_save = [&]() -> ErrorOr { auto response = FileSystemAccessClient::Client::the().save_file(window, "Capture", "png"); if (response.is_error()) return {}; auto file = response.value().release_stream(); - auto path = AK::LexicalPath(response.value().filename().to_deprecated_string()); + auto path = AK::LexicalPath(response.value().filename().to_byte_string()); filename = path.basename(); auto encoded = TRY(dump_bitmap(magnifier->current_bitmap(), path.extension())); @@ -128,7 +128,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }; dialog->set_color_has_alpha_channel(true); if (dialog->exec() == GUI::Dialog::ExecResult::OK) { - Config::write_string("Magnifier"sv, "Grid"sv, "Color"sv, dialog->color().to_deprecated_string()); + Config::write_string("Magnifier"sv, "Grid"sv, "Color"sv, dialog->color().to_byte_string()); } }); { diff --git a/Userland/Applications/Mail/AccountHolder.cpp b/Userland/Applications/Mail/AccountHolder.cpp index cfd5a177543..e6ff75167e1 100644 --- a/Userland/Applications/Mail/AccountHolder.cpp +++ b/Userland/Applications/Mail/AccountHolder.cpp @@ -12,7 +12,7 @@ AccountHolder::AccountHolder() m_mailbox_tree_model = MailboxTreeModel::create(*this); } -void AccountHolder::add_account_with_name_and_mailboxes(DeprecatedString name, Vector const& mailboxes) +void AccountHolder::add_account_with_name_and_mailboxes(ByteString name, Vector const& mailboxes) { auto account = AccountNode::create(move(name)); diff --git a/Userland/Applications/Mail/AccountHolder.h b/Userland/Applications/Mail/AccountHolder.h index 4fa5bd44dc9..ea69facad72 100644 --- a/Userland/Applications/Mail/AccountHolder.h +++ b/Userland/Applications/Mail/AccountHolder.h @@ -8,7 +8,7 @@ #pragma once #include "MailboxTreeModel.h" -#include +#include #include #include @@ -21,7 +21,7 @@ class MailboxNode; class AccountNode final : public BaseNode { public: - static NonnullRefPtr create(DeprecatedString name) + static NonnullRefPtr create(ByteString name) { return adopt_ref(*new AccountNode(move(name))); } @@ -34,21 +34,21 @@ public: } Vector> const& mailboxes() const { return m_mailboxes; } - DeprecatedString const& name() const { return m_name; } + ByteString const& name() const { return m_name; } private: - explicit AccountNode(DeprecatedString name) + explicit AccountNode(ByteString name) : m_name(move(name)) { } - DeprecatedString m_name; + ByteString m_name; Vector> m_mailboxes; }; class MailboxNode final : public BaseNode { public: - static NonnullRefPtr create(AccountNode const& associated_account, IMAP::ListItem const& mailbox, DeprecatedString display_name) + static NonnullRefPtr create(AccountNode const& associated_account, IMAP::ListItem const& mailbox, ByteString display_name) { return adopt_ref(*new MailboxNode(associated_account, mailbox, move(display_name))); } @@ -56,8 +56,8 @@ public: virtual ~MailboxNode() override = default; AccountNode const& associated_account() const { return m_associated_account; } - DeprecatedString const& select_name() const { return m_mailbox.name; } - DeprecatedString const& display_name() const { return m_display_name; } + ByteString const& select_name() const { return m_mailbox.name; } + ByteString const& display_name() const { return m_display_name; } IMAP::ListItem const& mailbox() const { return m_mailbox; } bool has_parent() const { return m_parent; } @@ -69,7 +69,7 @@ public: void add_child(NonnullRefPtr child) { m_children.append(child); } private: - MailboxNode(AccountNode const& associated_account, IMAP::ListItem const& mailbox, DeprecatedString display_name) + MailboxNode(AccountNode const& associated_account, IMAP::ListItem const& mailbox, ByteString display_name) : m_associated_account(associated_account) , m_mailbox(mailbox) , m_display_name(move(display_name)) @@ -78,7 +78,7 @@ private: AccountNode const& m_associated_account; IMAP::ListItem m_mailbox; - DeprecatedString m_display_name; + ByteString m_display_name; Vector> m_children; RefPtr m_parent; @@ -93,7 +93,7 @@ public: return adopt_own(*new AccountHolder()); } - void add_account_with_name_and_mailboxes(DeprecatedString, Vector const&); + void add_account_with_name_and_mailboxes(ByteString, Vector const&); Vector> const& accounts() const { return m_accounts; } MailboxTreeModel& mailbox_tree_model() { return *m_mailbox_tree_model; } diff --git a/Userland/Applications/Mail/InboxModel.h b/Userland/Applications/Mail/InboxModel.h index 91a4899f730..bc6dc607671 100644 --- a/Userland/Applications/Mail/InboxModel.h +++ b/Userland/Applications/Mail/InboxModel.h @@ -12,9 +12,9 @@ struct InboxEntry { u32 sequence_number; - DeprecatedString date; - DeprecatedString from; - DeprecatedString subject; + ByteString date; + ByteString from; + ByteString subject; bool seen; }; diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp index 5ac793d4f4d..996de3277e8 100644 --- a/Userland/Applications/Mail/MailWidget.cpp +++ b/Userland/Applications/Mail/MailWidget.cpp @@ -47,7 +47,7 @@ MailWidget::MailWidget() if (!Desktop::Launcher::open(url)) { GUI::MessageBox::show( window(), - DeprecatedString::formatted("The link to '{}' could not be opened.", url), + ByteString::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error); } @@ -59,7 +59,7 @@ MailWidget::MailWidget() m_web_view->on_link_hover = [this](auto& url) { if (url.is_valid()) - m_statusbar->set_text(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors()); + m_statusbar->set_text(String::from_byte_string(url.to_byte_string()).release_value_but_fixme_should_propagate_errors()); else m_statusbar->set_text({}); }; @@ -72,7 +72,7 @@ MailWidget::MailWidget() m_link_context_menu_default_action = link_default_action; m_link_context_menu->add_separator(); m_link_context_menu->add_action(GUI::Action::create("&Copy URL", [this](auto&) { - GUI::Clipboard::the().set_plain_text(m_link_context_menu_url.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(m_link_context_menu_url.to_byte_string()); })); m_web_view->on_link_context_menu_request = [this](auto& url, auto screen_position) { @@ -86,7 +86,7 @@ MailWidget::MailWidget() GUI::Clipboard::the().set_bitmap(*m_image_context_menu_bitmap.bitmap()); })); m_image_context_menu->add_action(GUI::Action::create("Copy Image &URL", [this](auto&) { - GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_deprecated_string()); + GUI::Clipboard::the().set_plain_text(m_image_context_menu_url.to_byte_string()); })); m_image_context_menu->add_separator(); m_image_context_menu->add_action(GUI::Action::create("&Open Image in Browser", [this](auto&) { @@ -131,7 +131,7 @@ ErrorOr MailWidget::connect_and_login() m_statusbar->set_text(String::formatted("Connecting to {}:{}...", server, port).release_value_but_fixme_should_propagate_errors()); auto maybe_imap_client = tls ? IMAP::Client::connect_tls(server, port) : IMAP::Client::connect_plaintext(server, port); if (maybe_imap_client.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to connect to '{}:{}' over {}: {}", server, port, tls ? "TLS" : "Plaintext", maybe_imap_client.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to connect to '{}:{}' over {}: {}", server, port, tls ? "TLS" : "Plaintext", maybe_imap_client.error())); return false; } m_imap_client = maybe_imap_client.release_value(); @@ -144,7 +144,7 @@ ErrorOr MailWidget::connect_and_login() if (response.status() != IMAP::ResponseStatus::OK) { dbgln("Failed to login. The server says: '{}'", response.response_text()); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to login. The server says: '{}'", response.response_text())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to login. The server says: '{}'", response.response_text())); m_statusbar->set_text("Failed to log in"_string); return false; } @@ -154,7 +154,7 @@ ErrorOr MailWidget::connect_and_login() if (response.status() != IMAP::ResponseStatus::OK) { dbgln("Failed to retrieve mailboxes. The server says: '{}'", response.response_text()); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to retrieve mailboxes. The server says: '{}'", response.response_text())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to retrieve mailboxes. The server says: '{}'", response.response_text())); return false; } @@ -270,7 +270,7 @@ void MailWidget::selected_mailbox(GUI::ModelIndex const& index) if (response.status() != IMAP::ResponseStatus::OK) { dbgln("Failed to select mailbox. The server says: '{}'", response.response_text()); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to select mailbox. The server says: '{}'", response.response_text())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to select mailbox. The server says: '{}'", response.response_text())); return; } @@ -301,7 +301,7 @@ void MailWidget::selected_mailbox(GUI::ModelIndex const& index) if (fetch_response.status() != IMAP::ResponseStatus::OK) { dbgln("Failed to retrieve subject/from for e-mails. The server says: '{}'", response.response_text()); m_statusbar->set_text(String::formatted("[{}]: Failed to fetch messages :^(", mailbox.name).release_value_but_fixme_should_propagate_errors()); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to retrieve e-mails. The server says: '{}'", response.response_text())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to retrieve e-mails. The server says: '{}'", response.response_text())); return; } @@ -316,8 +316,8 @@ void MailWidget::selected_mailbox(GUI::ModelIndex const& index) auto seen = !response_data.flags().find_if([](StringView value) { return value.equals_ignoring_ascii_case("\\Seen"sv); }).is_end(); - DeprecatedString date = internal_date.to_deprecated_string(); - DeprecatedString subject = envelope.subject.is_empty() ? "(No subject)" : envelope.subject; + ByteString date = internal_date.to_byte_string(); + ByteString subject = envelope.subject.is_empty() ? "(No subject)" : envelope.subject; if (subject.contains("=?"sv) && subject.contains("?="sv)) { subject = MUST(IMAP::decode_rfc2047_encoded_words(subject)).span(); } @@ -347,7 +347,7 @@ void MailWidget::selected_mailbox(GUI::ModelIndex const& index) } } } - DeprecatedString from = sender_builder.to_deprecated_string(); + ByteString from = sender_builder.to_byte_string(); InboxEntry inbox_entry { sequence_number, date, from, subject, seen }; m_statusbar->set_text(String::formatted("[{}]: Loading entry {}", mailbox.name, ++i).release_value_but_fixme_should_propagate_errors()); @@ -385,12 +385,12 @@ void MailWidget::selected_email_to_load(GUI::ModelIndex const& index) if (fetch_response.status() != IMAP::ResponseStatus::OK) { dbgln("Failed to retrieve the body structure of the selected e-mail. The server says: '{}'", fetch_response.response_text()); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to retrieve the selected e-mail. The server says: '{}'", fetch_response.response_text())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to retrieve the selected e-mail. The server says: '{}'", fetch_response.response_text())); return; } Vector selected_alternative_position; - DeprecatedString selected_alternative_encoding; + ByteString selected_alternative_encoding; auto& response_data = fetch_response.data().fetch_data().last().get(); @@ -449,7 +449,7 @@ void MailWidget::selected_email_to_load(GUI::ModelIndex const& index) if (fetch_response.status() != IMAP::ResponseStatus::OK) { dbgln("Failed to retrieve the body of the selected e-mail. The server says: '{}'", fetch_response.response_text()); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to retrieve the selected e-mail. The server says: '{}'", fetch_response.response_text())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to retrieve the selected e-mail. The server says: '{}'", fetch_response.response_text())); return; } @@ -474,7 +474,7 @@ void MailWidget::selected_email_to_load(GUI::ModelIndex const& index) } auto& body_data = fetch_response_data.body_data(); - auto body_text_part_iterator = body_data.find_if([](Tuple& data) { + auto body_text_part_iterator = body_data.find_if([](Tuple& data) { const auto data_item = data.get<0>(); return data_item.section.has_value() && data_item.section->type == IMAP::FetchCommand::DataItem::SectionType::Parts; }); @@ -482,7 +482,7 @@ void MailWidget::selected_email_to_load(GUI::ModelIndex const& index) auto& encoded_data = body_text_part_iterator->get<1>(); - DeprecatedString decoded_data; + ByteString decoded_data; // FIXME: String uses char internally, so 8bit shouldn't be stored in it. // However, it works for now. @@ -496,7 +496,7 @@ void MailWidget::selected_email_to_load(GUI::ModelIndex const& index) decoded_data = IMAP::decode_quoted_printable(encoded_data).release_value_but_fixme_should_propagate_errors().span(); } else { dbgln("Mail: Unimplemented decoder for encoding: {}", selected_alternative_encoding); - GUI::MessageBox::show(window(), DeprecatedString::formatted("The e-mail encoding '{}' is currently unsupported.", selected_alternative_encoding), "Unsupported"sv, GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), ByteString::formatted("The e-mail encoding '{}' is currently unsupported.", selected_alternative_encoding), "Unsupported"sv, GUI::MessageBox::Type::Information); return; } diff --git a/Userland/Applications/MailSettings/MailSettingsWidget.cpp b/Userland/Applications/MailSettings/MailSettingsWidget.cpp index 37bb033cd70..db088591891 100644 --- a/Userland/Applications/MailSettings/MailSettingsWidget.cpp +++ b/Userland/Applications/MailSettings/MailSettingsWidget.cpp @@ -60,7 +60,7 @@ ErrorOr MailSettingsWidget::setup() m_port_combobox = *find_descendant_of_type_named("port_input"); m_port_combobox->set_text(Config::read_string("Mail"sv, "Connection"sv, "Port"sv, "993"sv)); m_port_combobox->set_only_allow_values_from_model(false); - m_port_combobox->set_model(*GUI::ItemListModel::create(m_common_ports)); + m_port_combobox->set_model(*GUI::ItemListModel::create(m_common_ports)); m_port_combobox->on_change = [&](auto, auto) { set_modified(true); }; diff --git a/Userland/Applications/MailSettings/MailSettingsWidget.h b/Userland/Applications/MailSettings/MailSettingsWidget.h index 4af6a9496a1..d87768cb9ee 100644 --- a/Userland/Applications/MailSettings/MailSettingsWidget.h +++ b/Userland/Applications/MailSettings/MailSettingsWidget.h @@ -24,11 +24,11 @@ private: MailSettingsWidget() = default; ErrorOr setup(); - DeprecatedString m_server; - DeprecatedString m_port; + ByteString m_server; + ByteString m_port; bool m_tls { false }; - DeprecatedString m_email; - Vector m_common_ports; + ByteString m_email; + Vector m_common_ports; RefPtr m_server_inputbox; RefPtr m_port_combobox; diff --git a/Userland/Applications/Maps/FavoritesPanel.cpp b/Userland/Applications/Maps/FavoritesPanel.cpp index c5bde8e74a4..7700ff14ac3 100644 --- a/Userland/Applications/Maps/FavoritesPanel.cpp +++ b/Userland/Applications/Maps/FavoritesPanel.cpp @@ -33,7 +33,7 @@ ErrorOr FavoritesPanel::setup() if (!index.is_valid()) return; auto& model = *m_favorites_list->model(); - on_selected_favorite_change({ MUST(String::from_deprecated_string(model.index(index.row(), 0).data().to_deprecated_string())), + on_selected_favorite_change({ MUST(String::from_byte_string(model.index(index.row(), 0).data().to_byte_string())), { model.index(index.row(), 1).data().as_double(), model.index(index.row(), 2).data().as_double() }, model.index(index.row(), 3).data().to_i32() }); @@ -63,15 +63,15 @@ void FavoritesPanel::load_favorites() { Vector favorites_fields; favorites_fields.empend("name", "Name"_string, Gfx::TextAlignment::CenterLeft, [](JsonObject const& object) -> GUI::Variant { - DeprecatedString name = object.get_deprecated_string("name"sv).release_value(); + ByteString name = object.get_byte_string("name"sv).release_value(); double latitude = object.get_double_with_precision_loss("latitude"sv).release_value(); double longitude = object.get_double_with_precision_loss("longitude"sv).release_value(); - return DeprecatedString::formatted("{}\n{:.5}, {:.5}", name, latitude, longitude); + return ByteString::formatted("{}\n{:.5}, {:.5}", name, latitude, longitude); }); favorites_fields.empend("latitude", "Latitude"_string, Gfx::TextAlignment::CenterLeft); favorites_fields.empend("longitude", "Longitude"_string, Gfx::TextAlignment::CenterLeft); favorites_fields.empend("zoom", "Zoom"_string, Gfx::TextAlignment::CenterLeft); - m_favorites_list->set_model(*GUI::JsonArrayModel::create(DeprecatedString::formatted("{}/MapsFavorites.json", Core::StandardPaths::config_directory()), move(favorites_fields))); + m_favorites_list->set_model(*GUI::JsonArrayModel::create(ByteString::formatted("{}/MapsFavorites.json", Core::StandardPaths::config_directory()), move(favorites_fields))); m_favorites_list->model()->invalidate(); favorites_changed(); } @@ -80,7 +80,7 @@ ErrorOr FavoritesPanel::add_favorite(Favorite const& favorite) { auto& model = *static_cast(m_favorites_list->model()); Vector favorite_json; - favorite_json.append(favorite.name.to_deprecated_string()); + favorite_json.append(favorite.name.to_byte_string()); favorite_json.append(favorite.latlng.latitude); favorite_json.append(favorite.latlng.longitude); favorite_json.append(favorite.zoom); @@ -109,7 +109,7 @@ ErrorOr FavoritesPanel::edit_favorite(int row) edit_dialog->set_main_widget(widget); auto& name_textbox = *widget->find_descendant_of_type_named("name_textbox"); - name_textbox.set_text(model.index(row, 0).data().to_deprecated_string().split('\n').at(0)); + name_textbox.set_text(model.index(row, 0).data().to_byte_string().split('\n').at(0)); name_textbox.set_focus(true); name_textbox.select_all(); @@ -144,7 +144,7 @@ void FavoritesPanel::favorites_changed() Vector favorites; for (int index = 0; index < model.row_count(); index++) - favorites.append({ MUST(String::from_deprecated_string(model.index(index, 0).data().to_deprecated_string())), + favorites.append({ MUST(String::from_byte_string(model.index(index, 0).data().to_byte_string())), { model.index(index, 1).data().as_double(), model.index(index, 2).data().as_double() }, model.index(index, 3).data().to_i32() }); diff --git a/Userland/Applications/Maps/MapWidget.cpp b/Userland/Applications/Maps/MapWidget.cpp index 2d642abc34e..70b8105db7c 100644 --- a/Userland/Applications/Maps/MapWidget.cpp +++ b/Userland/Applications/Maps/MapWidget.cpp @@ -73,12 +73,12 @@ MapWidget::MapWidget(Options const& options) { m_request_client = Protocol::RequestClient::try_create().release_value_but_fixme_should_propagate_errors(); if (options.attribution_enabled) { - auto attribution_text = options.attribution_text.value_or(MUST(String::from_deprecated_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionText"sv, Maps::default_tile_provider_attribution_text)))); + auto attribution_text = options.attribution_text.value_or(MUST(String::from_byte_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionText"sv, Maps::default_tile_provider_attribution_text)))); URL attribution_url = options.attribution_url.value_or(URL(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionUrl"sv, Maps::default_tile_provider_attribution_url))); add_panel({ attribution_text, Panel::Position::BottomRight, attribution_url, "attribution"_string }); } m_marker_image = Gfx::Bitmap::load_from_file("/res/graphics/maps/marker-blue.png"sv).release_value_but_fixme_should_propagate_errors(); - m_default_tile_provider = MUST(String::from_deprecated_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderUrlFormat"sv, Maps::default_tile_provider_url_format))); + m_default_tile_provider = MUST(String::from_byte_string(Config::read_string("Maps"sv, "MapWidget"sv, "TileProviderUrlFormat"sv, Maps::default_tile_provider_url_format))); } void MapWidget::set_zoom(int zoom) @@ -315,7 +315,7 @@ void MapWidget::process_tile_queue() auto tile_key = m_tile_queue.dequeue(); // Start HTTP GET request to load image - HashMap headers; + HashMap headers; headers.set("User-Agent", "SerenityOS Maps"); headers.set("Accept", "image/png"); URL url(MUST(String::formatted(m_tile_provider.value_or(m_default_tile_provider), tile_key.zoom, tile_key.x, tile_key.y))); diff --git a/Userland/Applications/Maps/SearchPanel.cpp b/Userland/Applications/Maps/SearchPanel.cpp index 881ebbe7992..79119eaef82 100644 --- a/Userland/Applications/Maps/SearchPanel.cpp +++ b/Userland/Applications/Maps/SearchPanel.cpp @@ -30,10 +30,10 @@ ErrorOr SearchPanel::setup() m_places_list->set_visible(false); m_search_textbox->on_return_pressed = [this]() { - search(MUST(String::from_deprecated_string(m_search_textbox->text()))); + search(MUST(String::from_byte_string(m_search_textbox->text()))); }; m_search_button->on_click = [this](unsigned) { - search(MUST(String::from_deprecated_string(m_search_textbox->text()))); + search(MUST(String::from_byte_string(m_search_textbox->text()))); }; m_places_list->set_item_height(m_places_list->font().preferred_line_height() * 2 + m_places_list->vertical_padding()); @@ -59,7 +59,7 @@ void SearchPanel::search(StringView query) m_start_container->set_visible(false); // Start HTTP GET request to load people.json - HashMap headers; + HashMap headers; headers.set("User-Agent", "SerenityOS Maps"); headers.set("Accept", "application/json"); URL url(MUST(String::formatted("https://nominatim.openstreetmap.org/search?q={}&format=json", AK::URL::percent_encode(query, AK::URL::PercentEncodeSet::Query)))); @@ -96,9 +96,9 @@ void SearchPanel::search(StringView query) // FIXME: Handle JSON parsing errors auto const& json_place = json_places.at(i).as_object(); - MapWidget::LatLng latlng = { json_place.get_deprecated_string("lat"sv).release_value().to_double().release_value(), - json_place.get_deprecated_string("lon"sv).release_value().to_double().release_value() }; - String name = MUST(String::formatted("{}\n{:.5}, {:.5}", json_place.get_deprecated_string("display_name"sv).release_value(), latlng.latitude, latlng.longitude)); + MapWidget::LatLng latlng = { json_place.get_byte_string("lat"sv).release_value().to_double().release_value(), + json_place.get_byte_string("lon"sv).release_value().to_double().release_value() }; + String name = MUST(String::formatted("{}\n{:.5}, {:.5}", json_place.get_byte_string("display_name"sv).release_value(), latlng.latitude, latlng.longitude)); // Calculate the right zoom level for bounding box auto const& json_boundingbox = json_place.get_array("boundingbox"sv); diff --git a/Userland/Applications/Maps/UsersMapWidget.cpp b/Userland/Applications/Maps/UsersMapWidget.cpp index dadb2469146..6fcbe62bf92 100644 --- a/Userland/Applications/Maps/UsersMapWidget.cpp +++ b/Userland/Applications/Maps/UsersMapWidget.cpp @@ -19,7 +19,7 @@ UsersMapWidget::UsersMapWidget(Options const& options) void UsersMapWidget::get_users() { // Start HTTP GET request to load people.json - HashMap headers; + HashMap headers; headers.set("User-Agent", "SerenityOS Maps"); headers.set("Accept", "application/json"); URL url("https://usermap.serenityos.org/people.json"); @@ -48,7 +48,7 @@ void UsersMapWidget::get_users() for (size_t i = 0; i < json_users.size(); i++) { auto const& json_user = json_users.at(i).as_object(); User user { - MUST(String::from_deprecated_string(json_user.get_deprecated_string("nick"sv).release_value())), + MUST(String::from_byte_string(json_user.get_byte_string("nick"sv).release_value())), { json_user.get_array("coordinates"sv).release_value().at(0).to_double(), json_user.get_array("coordinates"sv).release_value().at(1).to_double() }, json_user.has_bool("contributor"sv), diff --git a/Userland/Applications/Maps/main.cpp b/Userland/Applications/Maps/main.cpp index 941858adb2d..296821beaba 100644 --- a/Userland/Applications/Maps/main.cpp +++ b/Userland/Applications/Maps/main.cpp @@ -68,7 +68,7 @@ ErrorOr serenity_main(Main::Arguments arguments) map_widget.set_show_users(Config::read_bool("Maps"sv, "MapView"sv, "ShowUsers"sv, false)); // Panels - String init_panel_open_name = TRY(String::from_deprecated_string(Config::read_string("Maps"sv, "Panel"sv, "OpenName"sv, ""sv))); + String init_panel_open_name = TRY(String::from_byte_string(Config::read_string("Maps"sv, "Panel"sv, "OpenName"sv, ""sv))); int panel_width = Config::read_i32("Maps"sv, "Panel"sv, "Width"sv, INT_MIN); // Search panel diff --git a/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp b/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp index ec50f49640f..9d94d26a0b8 100644 --- a/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp +++ b/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp @@ -29,11 +29,11 @@ void MapsSettingsWidget::apply_settings() Config::remove_key("Maps"sv, "MapWidget"sv, "TileProviderAttributionText"sv); Config::remove_key("Maps"sv, "MapWidget"sv, "TileProviderAttributionUrl"sv); } else { - auto tile_provider_url_format = m_tile_provider_combobox->model()->index(m_tile_provider_combobox->selected_index(), 1).data().to_deprecated_string(); + auto tile_provider_url_format = m_tile_provider_combobox->model()->index(m_tile_provider_combobox->selected_index(), 1).data().to_byte_string(); Config::write_string("Maps"sv, "MapWidget"sv, "TileProviderUrlFormat"sv, tile_provider_url_format); - auto tile_provider_attribution_text = m_tile_provider_combobox->model()->index(m_tile_provider_combobox->selected_index(), 2).data().to_deprecated_string(); + auto tile_provider_attribution_text = m_tile_provider_combobox->model()->index(m_tile_provider_combobox->selected_index(), 2).data().to_byte_string(); Config::write_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionText"sv, tile_provider_attribution_text); - auto tile_provider_attribution_url = m_tile_provider_combobox->model()->index(m_tile_provider_combobox->selected_index(), 3).data().to_deprecated_string(); + auto tile_provider_attribution_url = m_tile_provider_combobox->model()->index(m_tile_provider_combobox->selected_index(), 3).data().to_byte_string(); Config::write_string("Maps"sv, "MapWidget"sv, "TileProviderAttributionUrl"sv, tile_provider_attribution_url); } } @@ -51,7 +51,7 @@ ErrorOr MapsSettingsWidget::setup() tile_provider_fields.empend("url_format", "URL format"_string, Gfx::TextAlignment::CenterLeft); tile_provider_fields.empend("attribution_text", "Attribution text"_string, Gfx::TextAlignment::CenterLeft); tile_provider_fields.empend("attribution_url", "Attribution URL"_string, Gfx::TextAlignment::CenterLeft); - auto tile_providers = GUI::JsonArrayModel::create(DeprecatedString::formatted("{}/MapsTileProviders.json", Core::StandardPaths::config_directory()), move(tile_provider_fields)); + auto tile_providers = GUI::JsonArrayModel::create(ByteString::formatted("{}/MapsTileProviders.json", Core::StandardPaths::config_directory()), move(tile_provider_fields)); tile_providers->invalidate(); Vector custom_tile_provider; @@ -71,8 +71,8 @@ ErrorOr MapsSettingsWidget::setup() m_custom_tile_provider_textbox->set_placeholder(Maps::default_tile_provider_url_format); m_custom_tile_provider_textbox->on_change = [&]() { set_modified(true); }; - m_tile_provider_combobox->on_change = [&](DeprecatedString const&, GUI::ModelIndex const& index) { - auto tile_provider_url_format = m_tile_provider_combobox->model()->index(index.row(), 1).data().to_deprecated_string(); + m_tile_provider_combobox->on_change = [&](ByteString const&, GUI::ModelIndex const& index) { + auto tile_provider_url_format = m_tile_provider_combobox->model()->index(index.row(), 1).data().to_byte_string(); m_is_custom_tile_provider = tile_provider_url_format.is_empty(); m_custom_tile_provider_group->set_enabled(m_is_custom_tile_provider); set_modified(true); @@ -86,7 +86,7 @@ void MapsSettingsWidget::set_tile_provider(StringView tile_provider_url_format) { bool found = false; for (int index = 0; index < m_tile_provider_combobox->model()->row_count(); index++) { - auto url_format = m_tile_provider_combobox->model()->index(index, 1).data().to_deprecated_string(); + auto url_format = m_tile_provider_combobox->model()->index(index, 1).data().to_byte_string(); if (url_format == tile_provider_url_format) { m_tile_provider_combobox->set_selected_index(index, GUI::AllowCallback::No); found = true; diff --git a/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp b/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp index f51142d333d..f46018b2c36 100644 --- a/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp +++ b/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp @@ -5,7 +5,7 @@ */ #include "HighlightPreviewWidget.h" -#include +#include #include #include #include @@ -22,7 +22,7 @@ HighlightPreviewWidget::HighlightPreviewWidget(Gfx::Palette const& palette) ErrorOr HighlightPreviewWidget::reload_cursor() { auto cursor_theme = GUI::ConnectionToWindowServer::the().get_cursor_theme(); - auto theme_path = DeprecatedString::formatted("/res/cursor-themes/{}/{}", cursor_theme, "Config.ini"); + auto theme_path = ByteString::formatted("/res/cursor-themes/{}/{}", cursor_theme, "Config.ini"); auto cursor_theme_config = TRY(Core::ConfigFile::open(theme_path)); auto load_bitmap = [](StringView path, StringView default_path) { auto maybe_bitmap = Gfx::Bitmap::load_from_file(path); @@ -31,7 +31,7 @@ ErrorOr HighlightPreviewWidget::reload_cursor() return Gfx::Bitmap::load_from_file(default_path); }; constexpr auto default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png"sv; - auto cursor_path = DeprecatedString::formatted("/res/cursor-themes/{}/{}", + auto cursor_path = ByteString::formatted("/res/cursor-themes/{}/{}", cursor_theme, cursor_theme_config->read_entry("Cursor", "Arrow")); m_cursor_bitmap = TRY(load_bitmap(cursor_path, default_cursor_path)); m_cursor_params = Gfx::CursorParams::parse_from_filename(cursor_path, m_cursor_bitmap->rect().center()).constrained(*m_cursor_bitmap); diff --git a/Userland/Applications/MouseSettings/ThemeWidget.cpp b/Userland/Applications/MouseSettings/ThemeWidget.cpp index c595f23fc58..137247c245a 100644 --- a/Userland/Applications/MouseSettings/ThemeWidget.cpp +++ b/Userland/Applications/MouseSettings/ThemeWidget.cpp @@ -51,7 +51,7 @@ void MouseCursorModel::invalidate() m_cursors.clear(); // FIXME: Propagate errors. - (void)Core::Directory::for_each_entry(DeprecatedString::formatted("/res/cursor-themes/{}", m_theme_name), Core::DirIterator::Flags::SkipDots, [&](auto const& entry, auto const& directory) -> ErrorOr { + (void)Core::Directory::for_each_entry(ByteString::formatted("/res/cursor-themes/{}", m_theme_name), Core::DirIterator::Flags::SkipDots, [&](auto const& entry, auto const& directory) -> ErrorOr { auto path = LexicalPath::join(directory.path().string(), entry.name); if (path.has_extension(".ini"sv)) return IterationDecision::Continue; @@ -89,7 +89,7 @@ void ThemeModel::invalidate() // FIXME: Propagate errors. (void)Core::Directory::for_each_entry("/res/cursor-themes"sv, Core::DirIterator::Flags::SkipDots, [&](auto const& entry, auto&) -> ErrorOr { - if (access(DeprecatedString::formatted("/res/cursor-themes/{}/Config.ini", entry.name).characters(), R_OK) == 0) + if (access(ByteString::formatted("/res/cursor-themes/{}/Config.ini", entry.name).characters(), R_OK) == 0) m_themes.append(entry.name); return IterationDecision::Continue; }); @@ -127,7 +127,7 @@ ErrorOr ThemeWidget::setup() m_mouse_cursor_model->change_theme(theme_name); m_theme_name_box = find_descendant_of_type_named("theme_name_box"); - m_theme_name_box->on_change = [this](DeprecatedString const& value, GUI::ModelIndex const&) { + m_theme_name_box->on_change = [this](ByteString const& value, GUI::ModelIndex const&) { m_mouse_cursor_model->change_theme(value); set_modified(true); }; diff --git a/Userland/Applications/MouseSettings/ThemeWidget.h b/Userland/Applications/MouseSettings/ThemeWidget.h index 2308745c7b0..5c17717f88c 100644 --- a/Userland/Applications/MouseSettings/ThemeWidget.h +++ b/Userland/Applications/MouseSettings/ThemeWidget.h @@ -29,7 +29,7 @@ public: virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override; virtual void invalidate() override; - void change_theme(DeprecatedString const& name) + void change_theme(ByteString const& name) { m_theme_name = name; invalidate(); @@ -40,13 +40,13 @@ private: struct Cursor { RefPtr bitmap; - DeprecatedString path; - DeprecatedString name; + ByteString path; + ByteString name; Gfx::CursorParams params; }; Vector m_cursors; - DeprecatedString m_theme_name; + ByteString m_theme_name; }; class ThemeModel final : public GUI::Model { @@ -59,7 +59,7 @@ public: virtual void invalidate() override; private: - Vector m_themes; + Vector m_themes; }; class ThemeWidget final : public GUI::SettingsWindow::Tab { diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp index e67b1a54702..b6d284f4e4e 100644 --- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp +++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp @@ -6,7 +6,7 @@ */ #include "NetworkSettingsWidget.h" -#include +#include #include #include #include @@ -78,7 +78,7 @@ ErrorOr NetworkSettingsWidget::setup() size_t index = 0; proc_net_adapters_json.as_array().for_each([&](auto& value) { auto& if_object = value.as_object(); - auto adapter_name = if_object.get_deprecated_string("name"sv).value(); + auto adapter_name = if_object.get_byte_string("name"sv).value(); if (adapter_name == "loop") return; @@ -106,8 +106,8 @@ ErrorOr NetworkSettingsWidget::setup() ::exit(1); } - m_adapters_combobox->set_model(GUI::ItemListModel::create(m_adapter_names)); - m_adapters_combobox->on_change = [this](DeprecatedString const& text, GUI::ModelIndex const&) { + m_adapters_combobox->set_model(GUI::ItemListModel::create(m_adapter_names)); + m_adapters_combobox->on_change = [this](ByteString const& text, GUI::ModelIndex const&) { on_switch_adapter(text); }; auto const& selected_adapter = selected_adapter_index; @@ -117,7 +117,7 @@ ErrorOr NetworkSettingsWidget::setup() return {}; } -void NetworkSettingsWidget::on_switch_adapter(DeprecatedString const& adapter) +void NetworkSettingsWidget::on_switch_adapter(ByteString const& adapter) { auto& adapter_data = m_network_adapters.get(adapter).value(); m_current_adapter_data = &adapter_data; @@ -198,7 +198,7 @@ ErrorOr> NetworkSettingsWidget::create_settings_object() adapter.set("Enabled", adapter_data.value.enabled); adapter.set("DHCP", adapter_data.value.dhcp); adapter.set("IPv4Address", adapter_data.value.ip_address); - adapter.set("IPv4Netmask", netmask.to_deprecated_string()); + adapter.set("IPv4Netmask", netmask.to_byte_string()); adapter.set("IPv4Gateway", adapter_data.value.default_gateway); json.set(adapter_data.key, move(adapter)); } @@ -206,7 +206,7 @@ ErrorOr> NetworkSettingsWidget::create_settings_object() return json; } -void NetworkSettingsWidget::switch_adapter(DeprecatedString const& adapter) +void NetworkSettingsWidget::switch_adapter(ByteString const& adapter) { m_adapters_combobox->set_text(adapter, GUI::AllowCallback::No); on_switch_adapter(adapter); diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h index 8123741dcbf..7b739e30db7 100644 --- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h +++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h @@ -19,7 +19,7 @@ public: static ErrorOr> create(); virtual void apply_settings() override; - void switch_adapter(DeprecatedString const& adapter); + void switch_adapter(ByteString const& adapter); protected: static ErrorOr> try_create(); @@ -31,18 +31,18 @@ private: struct NetworkAdapterData { bool enabled = false; bool dhcp = false; - DeprecatedString ip_address; + ByteString ip_address; int cidr = 0; - DeprecatedString default_gateway; + ByteString default_gateway; }; - void on_switch_adapter(DeprecatedString const& adapter); + void on_switch_adapter(ByteString const& adapter); void on_switch_enabled_or_dhcp(); ErrorOr apply_settings_impl(); ErrorOr> create_settings_object(); - HashMap m_network_adapters; - Vector m_adapter_names; + HashMap m_network_adapters; + Vector m_adapter_names; NetworkAdapterData* m_current_adapter_data = nullptr; RefPtr m_enabled_checkbox; diff --git a/Userland/Applications/PDFViewer/NumericInput.cpp b/Userland/Applications/PDFViewer/NumericInput.cpp index d3ee9e01c57..34df9e2c4e1 100644 --- a/Userland/Applications/PDFViewer/NumericInput.cpp +++ b/Userland/Applications/PDFViewer/NumericInput.cpp @@ -26,7 +26,7 @@ NumericInput::NumericInput() first = false; } - auto new_number_opt = builder.to_deprecated_string().to_int(); + auto new_number_opt = builder.to_byte_string().to_int(); if (!new_number_opt.has_value()) { m_needs_text_reset = true; return; @@ -34,7 +34,7 @@ NumericInput::NumericInput() m_needs_text_reset = false; } - set_text(builder.to_deprecated_string()); + set_text(builder.to_byte_string()); set_current_number(new_number_opt.value(), GUI::AllowCallback::No); }; @@ -70,7 +70,7 @@ void NumericInput::set_max_number(i32 number) void NumericInput::on_focus_lost() { if (m_needs_text_reset) { - set_text(DeprecatedString::number(m_current_number)); + set_text(ByteString::number(m_current_number)); m_needs_text_reset = false; } if (on_number_changed) @@ -83,7 +83,7 @@ void NumericInput::set_current_number(i32 number, GUI::AllowCallback allow_callb return; m_current_number = clamp(number, m_min_number, m_max_number); - set_text(DeprecatedString::number(m_current_number)); + set_text(ByteString::number(m_current_number)); if (on_number_changed && allow_callback == GUI::AllowCallback::Yes) on_number_changed(m_current_number); } diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index acaeb7b8f89..3c53d0e27d3 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -7,7 +7,7 @@ #include "PDFViewerWidget.h" #include -#include +#include #include #include #include @@ -38,7 +38,7 @@ class PagedErrorsModel : public GUI::Model { _Count }; - using PageErrors = AK::OrderedHashTable; + using PageErrors = AK::OrderedHashTable; using PagedErrors = HashMap; public: @@ -102,7 +102,7 @@ public: case Columns::Page: return m_pages_with_errors[index.row()] + 1; case Columns::Message: - return DeprecatedString::formatted("{} errors", error_count_in_page(index)); + return ByteString::formatted("{} errors", error_count_in_page(index)); default: VERIFY_NOT_REACHED(); } @@ -366,14 +366,14 @@ void PDFViewerWidget::open_file(StringView path, NonnullOwnPtr file) if (maybe_error.is_error()) { auto error = maybe_error.release_error(); warnln("{}", error.message()); - auto user_error_message = DeprecatedString::formatted("Failed to load the document. Error:\n{}.", error.message()); + auto user_error_message = ByteString::formatted("Failed to load the document. Error:\n{}.", error.message()); GUI::MessageBox::show_error(nullptr, user_error_message.view()); } } PDF::PDFErrorOr PDFViewerWidget::try_open_file(StringView path, NonnullOwnPtr file) { - window()->set_title(DeprecatedString::formatted("{} - PDF Viewer", path)); + window()->set_title(ByteString::formatted("{} - PDF Viewer", path)); m_buffer = TRY(file->read_until_eof()); auto document = TRY(PDF::Document::create(m_buffer)); diff --git a/Userland/Applications/PartitionEditor/PartitionModel.cpp b/Userland/Applications/PartitionEditor/PartitionModel.cpp index 6f8b53ae7a1..bbd0082081a 100644 --- a/Userland/Applications/PartitionEditor/PartitionModel.cpp +++ b/Userland/Applications/PartitionEditor/PartitionModel.cpp @@ -65,7 +65,7 @@ GUI::Variant PartitionModel::data(GUI::ModelIndex const& index, GUI::ModelRole r return {}; } -ErrorOr PartitionModel::set_device_path(DeprecatedString const& path) +ErrorOr PartitionModel::set_device_path(ByteString const& path) { auto strong_file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto weak_file = TRY(Core::File::adopt_fd(strong_file->fd(), Core::File::OpenMode::Read, Core::File::ShouldCloseFileDescriptor::No)); diff --git a/Userland/Applications/PartitionEditor/PartitionModel.h b/Userland/Applications/PartitionEditor/PartitionModel.h index bc3a1febe42..858f2a5fa98 100644 --- a/Userland/Applications/PartitionEditor/PartitionModel.h +++ b/Userland/Applications/PartitionEditor/PartitionModel.h @@ -31,7 +31,7 @@ public: virtual ErrorOr column_name(int) const override; virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override; - ErrorOr set_device_path(DeprecatedString const&); + ErrorOr set_device_path(ByteString const&); private: PartitionModel() = default; diff --git a/Userland/Applications/PartitionEditor/main.cpp b/Userland/Applications/PartitionEditor/main.cpp index 16fa493d85c..80f6cb9a929 100644 --- a/Userland/Applications/PartitionEditor/main.cpp +++ b/Userland/Applications/PartitionEditor/main.cpp @@ -17,9 +17,9 @@ #include #include -static Vector get_device_paths() +static Vector get_device_paths() { - auto device_paths = Vector(); + auto device_paths = Vector(); // FIXME: Propagate errors. (void)Core::Directory::for_each_entry("/dev"sv, Core::DirIterator::Flags::SkipParentAndBaseDir, [&](auto const& entry, auto const& directory) -> ErrorOr { auto full_path = LexicalPath::join(directory.path().string(), entry.name).string(); @@ -67,13 +67,13 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(partition_model->set_device_path(device_paths.first())); auto& device_combobox = *widget->find_descendant_of_type_named("device_combobox"); - device_combobox.set_model(GUI::ItemListModel::create(device_paths)); + device_combobox.set_model(GUI::ItemListModel::create(device_paths)); device_combobox.set_only_allow_values_from_model(true); device_combobox.set_selected_index(0); device_combobox.on_change = [&](auto const& path, auto const&) { auto result = partition_model->set_device_path(path); if (result.is_error()) - GUI::MessageBox::show_error(window, DeprecatedString::formatted("No partition table found for device {}", path)); + GUI::MessageBox::show_error(window, ByteString::formatted("No partition table found for device {}", path)); }; auto& partition_table_view = *widget->find_descendant_of_type_named("partition_table_view"); diff --git a/Userland/Applications/Piano/ExportProgressWindow.cpp b/Userland/Applications/Piano/ExportProgressWindow.cpp index 9664af7fcbe..8b40e28660b 100644 --- a/Userland/Applications/Piano/ExportProgressWindow.cpp +++ b/Userland/Applications/Piano/ExportProgressWindow.cpp @@ -5,7 +5,7 @@ */ #include "ExportProgressWindow.h" -#include +#include #include #include #include diff --git a/Userland/Applications/Piano/PlayerWidget.cpp b/Userland/Applications/Piano/PlayerWidget.cpp index 1eff90f3b84..f7b5a66fea5 100644 --- a/Userland/Applications/Piano/PlayerWidget.cpp +++ b/Userland/Applications/Piano/PlayerWidget.cpp @@ -50,7 +50,7 @@ ErrorOr PlayerWidget::initialize() m_track_dropdown = add(); m_track_dropdown->set_max_width(75); - m_track_dropdown->set_model(*GUI::ItemListModel::create(m_track_number_choices)); + m_track_dropdown->set_model(*GUI::ItemListModel::create(m_track_number_choices)); m_track_dropdown->set_only_allow_values_from_model(true); m_track_dropdown->set_model_column(0); m_track_dropdown->set_selected_index(0); @@ -117,7 +117,7 @@ void PlayerWidget::add_track() { m_track_manager.add_track(); auto latest_track_count = m_track_manager.track_count(); - auto latest_track_string = DeprecatedString::number(latest_track_count); + auto latest_track_string = ByteString::number(latest_track_count); m_track_number_choices.append(latest_track_string); m_track_dropdown->set_selected_index(latest_track_count - 1); } diff --git a/Userland/Applications/Piano/PlayerWidget.h b/Userland/Applications/Piano/PlayerWidget.h index 072484b4954..da2088c0dc2 100644 --- a/Userland/Applications/Piano/PlayerWidget.h +++ b/Userland/Applications/Piano/PlayerWidget.h @@ -31,7 +31,7 @@ private: TrackManager& m_track_manager; MainWidget& m_main_widget; AudioPlayerLoop& m_audio_loop; - Vector m_track_number_choices; + Vector m_track_number_choices; RefPtr m_play_icon; RefPtr m_pause_icon; diff --git a/Userland/Applications/Piano/ProcessorParameterWidget/Dropdown.h b/Userland/Applications/Piano/ProcessorParameterWidget/Dropdown.h index 0e4c25f6755..52aff71f483 100644 --- a/Userland/Applications/Piano/ProcessorParameterWidget/Dropdown.h +++ b/Userland/Applications/Piano/ProcessorParameterWidget/Dropdown.h @@ -20,12 +20,12 @@ class ProcessorParameterDropdown : public GUI::ComboBox { C_OBJECT(ProcessorParameterDropdown); public: - ProcessorParameterDropdown(DSP::ProcessorEnumParameter& parameter, Vector modes) + ProcessorParameterDropdown(DSP::ProcessorEnumParameter& parameter, Vector modes) : ComboBox() , m_parameter(parameter) , m_modes(move(modes)) { - auto model = GUI::ItemListModel>::create(m_modes); + auto model = GUI::ItemListModel>::create(m_modes); set_model(model); set_only_allow_values_from_model(true); set_model_column(0); @@ -55,5 +55,5 @@ public: private: DSP::ProcessorEnumParameter& m_parameter; - Vector m_modes; + Vector m_modes; }; diff --git a/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.cpp b/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.cpp index 16d7377b499..cd520316fbe 100644 --- a/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.cpp +++ b/Userland/Applications/Piano/ProcessorParameterWidget/ParameterWidget.cpp @@ -26,7 +26,7 @@ ProcessorParameterWidget::ProcessorParameterWidget(DSP::ProcessorParameter& raw_ case DSP::ParameterType::Enum: { // FIXME: We shouldn't do that, but the only user is the synth right now. auto& parameter = static_cast&>(raw_parameter); - auto enum_strings = Vector { "Sine", "Triangle", "Square", "Saw", "Noise" }; + auto enum_strings = Vector { "Sine", "Triangle", "Square", "Saw", "Noise" }; m_parameter_modifier = add>(parameter, move(enum_strings)); break; } diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp index 2da845aac2b..5ba2defb17b 100644 --- a/Userland/Applications/Piano/RollWidget.cpp +++ b/Userland/Applications/Piano/RollWidget.cpp @@ -163,7 +163,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft); note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0); if (note % notes_per_octave == 0) - painter.draw_text(note_name_rect, DeprecatedString::formatted("{}", note / notes_per_octave + 1), Gfx::TextAlignment::CenterLeft); + painter.draw_text(note_name_rect, ByteString::formatted("{}", note / notes_per_octave + 1), Gfx::TextAlignment::CenterLeft); } int x = m_roll_width * (static_cast(m_track_manager.transport()->time()) / roll_length); diff --git a/Userland/Applications/Piano/SamplerWidget.cpp b/Userland/Applications/Piano/SamplerWidget.cpp index 235402f3fe2..94f78148baa 100644 --- a/Userland/Applications/Piano/SamplerWidget.cpp +++ b/Userland/Applications/Piano/SamplerWidget.cpp @@ -52,11 +52,11 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager) m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus); m_open_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors()); m_open_button->on_click = [this](auto) { - Optional open_path = GUI::FilePicker::get_open_filepath(window()); + Optional open_path = GUI::FilePicker::get_open_filepath(window()); if (!open_path.has_value()) return; // TODO: We don't actually load the sample. - m_recorded_sample_name->set_text(String::from_deprecated_string(open_path.value()).release_value_but_fixme_should_propagate_errors()); + m_recorded_sample_name->set_text(String::from_byte_string(open_path.value()).release_value_but_fixme_should_propagate_errors()); m_wave_editor->update(); }; diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index 496e1fe6da6..4131c0259b4 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -36,7 +36,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TrackManager track_manager; Threading::MutexProtected wav_writer; - Optional save_path; + Optional save_path; Atomic need_to_write_wav = false; Atomic wav_percent_written = 0; @@ -65,11 +65,11 @@ ErrorOr serenity_main(Main::Arguments arguments) save_path = GUI::FilePicker::get_save_filepath(window, "Untitled", "wav"); if (!save_path.has_value()) return; - DeprecatedString error; + ByteString error; wav_writer.with_locked([&](auto& wav_writer) { auto error_or_void = wav_writer.set_file(save_path.value()); if (error_or_void.is_error()) - error = DeprecatedString::formatted("Failed to export WAV file: {}", error_or_void.error()); + error = ByteString::formatted("Failed to export WAV file: {}", error_or_void.error()); }); if (!error.is_empty()) { GUI::MessageBox::show_error(window, error); diff --git a/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp b/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp index 090fe6ae5d3..e23e65cae1e 100644 --- a/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp +++ b/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp @@ -121,7 +121,7 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window) Config::write_string("PixelPaint"sv, "NewImage"sv, "Name"sv, m_image_name); Config::write_i32("PixelPaint"sv, "NewImage"sv, "Width"sv, m_image_size.width()); Config::write_i32("PixelPaint"sv, "NewImage"sv, "Height"sv, m_image_size.height()); - Config::write_string("PixelPaint"sv, "NewImage"sv, "Background"sv, m_background_color.to_deprecated_string()); + Config::write_string("PixelPaint"sv, "NewImage"sv, "Background"sv, m_background_color.to_byte_string()); } done(ExecResult::OK); diff --git a/Userland/Applications/PixelPaint/CreateNewImageDialog.h b/Userland/Applications/PixelPaint/CreateNewImageDialog.h index a407a9e9d91..844f7d99515 100644 --- a/Userland/Applications/PixelPaint/CreateNewImageDialog.h +++ b/Userland/Applications/PixelPaint/CreateNewImageDialog.h @@ -16,13 +16,13 @@ class CreateNewImageDialog final : public GUI::Dialog { public: Gfx::IntSize image_size() const { return m_image_size; } - DeprecatedString const& image_name() const { return m_image_name; } + ByteString const& image_name() const { return m_image_name; } Gfx::Color background_color() const { return m_background_color; } private: CreateNewImageDialog(GUI::Window* parent_window); - DeprecatedString m_image_name; + ByteString m_image_name; Gfx::IntSize m_image_size; Gfx::Color m_background_color {}; diff --git a/Userland/Applications/PixelPaint/CreateNewLayerDialog.h b/Userland/Applications/PixelPaint/CreateNewLayerDialog.h index 1c600e2407e..0844bd3acaf 100644 --- a/Userland/Applications/PixelPaint/CreateNewLayerDialog.h +++ b/Userland/Applications/PixelPaint/CreateNewLayerDialog.h @@ -15,7 +15,7 @@ class CreateNewLayerDialog final : public GUI::Dialog { public: Gfx::IntSize layer_size() const { return m_layer_size; } - DeprecatedString const& layer_name() const { return m_layer_name; } + ByteString const& layer_name() const { return m_layer_name; } private: static constexpr StringView default_layer_name = "Layer"sv; @@ -23,7 +23,7 @@ private: CreateNewLayerDialog(Gfx::IntSize suggested_size, GUI::Window* parent_window); Gfx::IntSize m_layer_size; - DeprecatedString m_layer_name { default_layer_name }; + ByteString m_layer_name { default_layer_name }; RefPtr m_name_textbox; }; diff --git a/Userland/Applications/PixelPaint/EditGuideDialog.cpp b/Userland/Applications/PixelPaint/EditGuideDialog.cpp index 8fb8d5f368d..eb49d6d9408 100644 --- a/Userland/Applications/PixelPaint/EditGuideDialog.cpp +++ b/Userland/Applications/PixelPaint/EditGuideDialog.cpp @@ -13,7 +13,7 @@ namespace PixelPaint { -EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, DeprecatedString const& offset, Guide::Orientation orientation) +EditGuideDialog::EditGuideDialog(GUI::Window* parent_window, ByteString const& offset, Guide::Orientation orientation) : Dialog(parent_window) , m_offset(offset) , m_orientation(orientation) diff --git a/Userland/Applications/PixelPaint/EditGuideDialog.h b/Userland/Applications/PixelPaint/EditGuideDialog.h index bdc31f6124c..a32f0d07647 100644 --- a/Userland/Applications/PixelPaint/EditGuideDialog.h +++ b/Userland/Applications/PixelPaint/EditGuideDialog.h @@ -16,15 +16,15 @@ class EditGuideDialog final : public GUI::Dialog { C_OBJECT(EditGuideDialog); public: - DeprecatedString const offset() const { return m_offset; } + ByteString const offset() const { return m_offset; } Guide::Orientation orientation() const { return m_orientation; } Optional offset_as_pixel(ImageEditor const&); private: - EditGuideDialog(GUI::Window* parent_window, DeprecatedString const& offset = {}, Guide::Orientation orientation = Guide::Orientation::Unset); + EditGuideDialog(GUI::Window* parent_window, ByteString const& offset = {}, Guide::Orientation orientation = Guide::Orientation::Unset); - DeprecatedString m_offset; + ByteString m_offset; Guide::Orientation m_orientation; RefPtr m_offset_text_box; bool m_is_horizontal_checked { false }; diff --git a/Userland/Applications/PixelPaint/FilterTreeModel.h b/Userland/Applications/PixelPaint/FilterTreeModel.h index 4853472b916..9464b6e4b15 100644 --- a/Userland/Applications/PixelPaint/FilterTreeModel.h +++ b/Userland/Applications/PixelPaint/FilterTreeModel.h @@ -16,7 +16,7 @@ namespace PixelPaint { class FilterNode final : public GUI::TreeViewModel::Node { public: - FilterNode(DeprecatedString text, Optional icon, Node* parent_node, NonnullRefPtr filter) + FilterNode(ByteString text, Optional icon, Node* parent_node, NonnullRefPtr filter) : Node(move(text), move(icon), parent_node) , m_filter(move(filter)) { diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 1e90c5815d2..7d2b9de8f9b 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -54,7 +54,7 @@ ErrorOr> Image::decode_bitmap(ReadonlyBytes bitmap_da { // Spawn a new ImageDecoder service process and connect to it. auto client = TRY(ImageDecoderClient::Client::try_create()); - auto optional_mime_type = guessed_mime_type.map([](auto mime_type) { return mime_type.to_deprecated_string(); }); + auto optional_mime_type = guessed_mime_type.map([](auto mime_type) { return mime_type.to_byte_string(); }); // FIXME: Find a way to avoid the memory copying here. auto maybe_decoded_image = client->decode_image(bitmap_data, optional_mime_type); @@ -85,14 +85,14 @@ ErrorOr> Image::create_from_pixel_paint_json(JsonObject con auto layers_value = json.get_array("layers"sv).value(); for (auto& layer_value : layers_value.values()) { auto const& layer_object = layer_value.as_object(); - auto name = layer_object.get_deprecated_string("name"sv).value(); + auto name = layer_object.get_byte_string("name"sv).value(); - auto bitmap_base64_encoded = layer_object.get_deprecated_string("bitmap"sv).value(); + auto bitmap_base64_encoded = layer_object.get_byte_string("bitmap"sv).value(); auto bitmap_data = TRY(decode_base64(bitmap_base64_encoded)); auto bitmap = TRY(decode_bitmap(bitmap_data, {})); auto layer = TRY(Layer::create_with_bitmap(*image, move(bitmap), name)); - if (auto const& mask_object = layer_object.get_deprecated_string("mask"sv); mask_object.has_value()) { + if (auto const& mask_object = layer_object.get_byte_string("mask"sv); mask_object.has_value()) { auto mask_base64_encoded = mask_object.value(); auto mask_data = TRY(decode_base64(mask_base64_encoded)); auto mask = TRY(decode_bitmap(mask_data, {})); @@ -519,7 +519,7 @@ void Image::did_change_rect(Gfx::IntRect const& a_modified_rect) client->image_did_change_rect(modified_rect); } -ImageUndoCommand::ImageUndoCommand(Image& image, DeprecatedString action_text) +ImageUndoCommand::ImageUndoCommand(Image& image, ByteString action_text) : m_snapshot(image.take_snapshot().release_value_but_fixme_should_propagate_errors()) , m_image(image) , m_action_text(move(action_text)) diff --git a/Userland/Applications/PixelPaint/Image.h b/Userland/Applications/PixelPaint/Image.h index 001f597ac4e..736303343e0 100644 --- a/Userland/Applications/PixelPaint/Image.h +++ b/Userland/Applications/PixelPaint/Image.h @@ -136,16 +136,16 @@ private: class ImageUndoCommand : public GUI::Command { public: - ImageUndoCommand(Image&, DeprecatedString action_text); + ImageUndoCommand(Image&, ByteString action_text); virtual void undo() override; virtual void redo() override; - virtual DeprecatedString action_text() const override { return m_action_text; } + virtual ByteString action_text() const override { return m_action_text; } private: RefPtr m_snapshot; Image& m_image; - DeprecatedString m_action_text; + ByteString m_action_text; }; } diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 42c9e22193c..5d4c2d89863 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -34,7 +34,7 @@ ImageEditor::ImageEditor(NonnullRefPtr image) , m_gui_event_loop(Core::EventLoop::current()) { set_focus_policy(GUI::FocusPolicy::StrongFocus); - m_undo_stack.push(make(*m_image, DeprecatedString())); + m_undo_stack.push(make(*m_image, ByteString())); m_image->add_client(*this); m_image->selection().add_client(*this); set_original_rect(m_image->rect()); @@ -61,7 +61,7 @@ ImageEditor::~ImageEditor() m_image->remove_client(*this); } -void ImageEditor::did_complete_action(DeprecatedString action_text) +void ImageEditor::did_complete_action(ByteString action_text) { set_modified(move(action_text)); } @@ -110,13 +110,13 @@ void ImageEditor::set_title(String title) on_title_change(m_title); } -void ImageEditor::set_path(DeprecatedString path) +void ImageEditor::set_path(ByteString path) { m_path = move(path); - set_title(String::from_deprecated_string(LexicalPath::title(m_path)).release_value_but_fixme_should_propagate_errors()); + set_title(String::from_byte_string(LexicalPath::title(m_path)).release_value_but_fixme_should_propagate_errors()); } -void ImageEditor::set_modified(DeprecatedString action_text) +void ImageEditor::set_modified(ByteString action_text) { m_undo_stack.push(make(*m_image, move(action_text))); update_modified(); @@ -227,7 +227,7 @@ void ImageEditor::paint_event(GUI::PaintEvent& event) int const editor_x = content_to_frame_position({ x, 0 }).x(); painter.draw_line({ editor_x, 0 }, { editor_x, m_ruler_thickness }, ruler_fg_color); - painter.draw_text(Gfx::IntRect { { editor_x + 2, 0 }, { m_ruler_thickness, m_ruler_thickness - 2 } }, DeprecatedString::formatted("{}", x), painter.font(), Gfx::TextAlignment::CenterLeft, ruler_text_color); + painter.draw_text(Gfx::IntRect { { editor_x + 2, 0 }, { m_ruler_thickness, m_ruler_thickness - 2 } }, ByteString::formatted("{}", x), painter.font(), Gfx::TextAlignment::CenterLeft, ruler_text_color); } // Vertical ruler @@ -244,7 +244,7 @@ void ImageEditor::paint_event(GUI::PaintEvent& event) int const editor_y = content_to_frame_position({ 0, y }).y(); painter.draw_line({ 0, editor_y }, { m_ruler_thickness, editor_y }, ruler_fg_color); - painter.draw_text(Gfx::IntRect { { 0, editor_y - m_ruler_thickness }, { m_ruler_thickness, m_ruler_thickness } }, DeprecatedString::formatted("{}", y), painter.font(), Gfx::TextAlignment::BottomRight, ruler_text_color); + painter.draw_text(Gfx::IntRect { { 0, editor_y - m_ruler_thickness }, { m_ruler_thickness, m_ruler_thickness } }, ByteString::formatted("{}", y), painter.font(), Gfx::TextAlignment::BottomRight, ruler_text_color); } // Mouse position indicator @@ -360,7 +360,7 @@ void ImageEditor::set_status_info_to_color_at_mouse_position(Gfx::IntPoint posit if (!color.has_value()) return; - set_appended_status_info(DeprecatedString::formatted("R:{}, G:{}, B:{}, A:{} [{}]", color->red(), color->green(), color->blue(), color->alpha(), color->to_deprecated_string())); + set_appended_status_info(ByteString::formatted("R:{}, G:{}, B:{}, A:{} [{}]", color->red(), color->green(), color->blue(), color->alpha(), color->to_byte_string())); } void ImageEditor::set_editor_color_to_color_at_mouse_position(GUI::MouseEvent const& event, bool sample_all_layers = false) @@ -767,7 +767,7 @@ void ImageEditor::save_project() void ImageEditor::save_project_as() { - auto response = FileSystemAccessClient::Client::the().save_file(window(), m_title.to_deprecated_string(), "pp"); + auto response = FileSystemAccessClient::Client::the().save_file(window(), m_title.to_byte_string(), "pp"); if (response.is_error()) return; auto file = response.release_value(); @@ -776,7 +776,7 @@ void ImageEditor::save_project_as() GUI::MessageBox::show_error(window(), MUST(String::formatted("Could not save {}: {}", file.filename(), result.release_error()))); return; } - set_path(file.filename().to_deprecated_string()); + set_path(file.filename().to_byte_string()); set_loaded_from_image(false); set_unmodified(); } @@ -911,25 +911,25 @@ void ImageEditor::selection_did_change() update(); } -void ImageEditor::set_appended_status_info(DeprecatedString new_status_info) +void ImageEditor::set_appended_status_info(ByteString new_status_info) { m_appended_status_info = new_status_info; if (on_appended_status_info_change) on_appended_status_info_change(m_appended_status_info); } -DeprecatedString ImageEditor::generate_unique_layer_name(DeprecatedString const& original_layer_name) +ByteString ImageEditor::generate_unique_layer_name(ByteString const& original_layer_name) { constexpr StringView copy_string_view = " copy"sv; auto copy_suffix_index = original_layer_name.find_last(copy_string_view); if (!copy_suffix_index.has_value()) - return DeprecatedString::formatted("{}{}", original_layer_name, copy_string_view); + return ByteString::formatted("{}{}", original_layer_name, copy_string_view); auto after_copy_suffix_view = original_layer_name.substring_view(copy_suffix_index.value() + copy_string_view.length()); if (!after_copy_suffix_view.is_empty()) { auto after_copy_suffix_number = after_copy_suffix_view.trim_whitespace().to_int(); if (!after_copy_suffix_number.has_value()) - return DeprecatedString::formatted("{}{}", original_layer_name, copy_string_view); + return ByteString::formatted("{}{}", original_layer_name, copy_string_view); } auto layer_with_name_exists = [this](auto name) { @@ -948,7 +948,7 @@ DeprecatedString ImageEditor::generate_unique_layer_name(DeprecatedString const& new_layer_name.appendff("{}{} {}", base_layer_name, copy_string_view, ++duplicate_name_count); } while (layer_with_name_exists(new_layer_name.string_view())); - return new_layer_name.to_deprecated_string(); + return new_layer_name.to_byte_string(); } Gfx::IntRect ImageEditor::active_layer_visible_rect() diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 46843f59baa..34eda4c4c00 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -44,14 +44,14 @@ public: void set_active_tool(Tool*); void update_tool_cursor(); - void did_complete_action(DeprecatedString action_text); + void did_complete_action(ByteString action_text); bool undo(); bool redo(); auto& undo_stack() { return m_undo_stack; } - DeprecatedString const& path() const { return m_path; } - void set_path(DeprecatedString); + ByteString const& path() const { return m_path; } + void set_path(ByteString); String const& title() const { return m_title; } void set_title(String); @@ -122,13 +122,13 @@ public: void set_status_info_to_color_at_mouse_position(Gfx::IntPoint position, bool sample_all_layers); void set_editor_color_to_color_at_mouse_position(GUI::MouseEvent const& event, bool sample_all_layers); - void set_modified(DeprecatedString action_text); + void set_modified(ByteString action_text); void set_unmodified(); void update_modified(); - Function on_appended_status_info_change; - DeprecatedString appended_status_info() { return m_appended_status_info; } - void set_appended_status_info(DeprecatedString); - DeprecatedString generate_unique_layer_name(DeprecatedString const& original_layer_name); + Function on_appended_status_info_change; + ByteString appended_status_info() { return m_appended_status_info; } + void set_appended_status_info(ByteString); + ByteString generate_unique_layer_name(ByteString const& original_layer_name); private: explicit ImageEditor(NonnullRefPtr); @@ -170,7 +170,7 @@ private: RefPtr m_active_layer; GUI::UndoStack m_undo_stack; - DeprecatedString m_path; + ByteString m_path; String m_title; Vector> m_guides; @@ -202,7 +202,7 @@ private: void draw_marching_ants_pixel(Gfx::Painter&, int x, int y) const; Core::EventLoop& m_gui_event_loop; - DeprecatedString m_appended_status_info; + ByteString m_appended_status_info; }; } diff --git a/Userland/Applications/PixelPaint/ImageMasking.cpp b/Userland/Applications/PixelPaint/ImageMasking.cpp index ffc3264d268..36af4963b78 100644 --- a/Userland/Applications/PixelPaint/ImageMasking.cpp +++ b/Userland/Applications/PixelPaint/ImageMasking.cpp @@ -378,7 +378,7 @@ void ColorWheelWidget::paint_event(GUI::PaintEvent&) aa_painter.fill_circle({ 0, 0 }, (height() - 4) / 4, Color::from_hsv(hue(), 1, 1)); painter.restore(); - auto hue_text = DeprecatedString::formatted("hue: {:.0}", hue()); + auto hue_text = ByteString::formatted("hue: {:.0}", hue()); painter.draw_text(rect().translated(1, 1), hue_text, Gfx::TextAlignment::Center, Color::Black); painter.draw_text(rect(), hue_text, Gfx::TextAlignment::Center, Color::White); } diff --git a/Userland/Applications/PixelPaint/ImageProcessor.cpp b/Userland/Applications/PixelPaint/ImageProcessor.cpp index 6cbb6907c6a..3f3dff5fc13 100644 --- a/Userland/Applications/PixelPaint/ImageProcessor.cpp +++ b/Userland/Applications/PixelPaint/ImageProcessor.cpp @@ -31,7 +31,7 @@ void FilterApplicationCommand::execute() m_filter->m_editor->gui_event_loop().deferred_invoke([strong_this = NonnullRefPtr(*this)]() { strong_this->m_target_layer->did_modify_bitmap(strong_this->m_target_layer->rect()); - strong_this->m_filter->m_editor->did_complete_action(DeprecatedString::formatted("Filter {}", strong_this->m_filter->filter_name())); + strong_this->m_filter->m_editor->did_complete_action(ByteString::formatted("Filter {}", strong_this->m_filter->filter_name())); }); } diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index 4c4f803a427..358d1bb6c62 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -18,7 +18,7 @@ namespace PixelPaint { -ErrorOr> Layer::create_with_size(Image& image, Gfx::IntSize size, DeprecatedString name) +ErrorOr> Layer::create_with_size(Image& image, Gfx::IntSize size, ByteString name) { VERIFY(!size.is_empty()); @@ -29,7 +29,7 @@ ErrorOr> Layer::create_with_size(Image& image, Gfx::IntSize return adopt_nonnull_ref_or_enomem(new (nothrow) Layer(image, move(bitmap), move(name))); } -ErrorOr> Layer::create_with_bitmap(Image& image, NonnullRefPtr bitmap, DeprecatedString name) +ErrorOr> Layer::create_with_bitmap(Image& image, NonnullRefPtr bitmap, ByteString name) { VERIFY(!bitmap->size().is_empty()); @@ -64,7 +64,7 @@ ErrorOr> Layer::create_snapshot(Image& image, Layer const& return snapshot; } -Layer::Layer(Image& image, NonnullRefPtr bitmap, DeprecatedString name) +Layer::Layer(Image& image, NonnullRefPtr bitmap, ByteString name) : m_image(image) , m_name(move(name)) , m_content_bitmap(move(bitmap)) @@ -112,7 +112,7 @@ void Layer::set_opacity_percent(int opacity_percent) m_image.layer_did_modify_properties({}, *this); } -void Layer::set_name(DeprecatedString name) +void Layer::set_name(ByteString name) { if (m_name == name) return; @@ -486,7 +486,7 @@ Optional Layer::editing_mask_bounding_rect() const *max_content_y - *min_content_y + 1 }; } -ErrorOr> Layer::duplicate(DeprecatedString name) +ErrorOr> Layer::duplicate(ByteString name) { auto duplicated_layer = TRY(Layer::create_snapshot(m_image, *this)); duplicated_layer->m_name = move(name); diff --git a/Userland/Applications/PixelPaint/Layer.h b/Userland/Applications/PixelPaint/Layer.h index 75b86bf5027..aaccff395ce 100644 --- a/Userland/Applications/PixelPaint/Layer.h +++ b/Userland/Applications/PixelPaint/Layer.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include #include @@ -31,8 +31,8 @@ class Layer AK_MAKE_NONMOVABLE(Layer); public: - static ErrorOr> create_with_size(Image&, Gfx::IntSize, DeprecatedString name); - static ErrorOr> create_with_bitmap(Image&, NonnullRefPtr, DeprecatedString name); + static ErrorOr> create_with_size(Image&, Gfx::IntSize, ByteString name); + static ErrorOr> create_with_bitmap(Image&, NonnullRefPtr, ByteString name); static ErrorOr> create_snapshot(Image&, Layer const&); ~Layer() = default; @@ -68,8 +68,8 @@ public: Gfx::IntRect relative_rect() const { return { location(), size() }; } Gfx::IntRect rect() const { return { {}, size() }; } - DeprecatedString const& name() const { return m_name; } - void set_name(DeprecatedString); + ByteString const& name() const { return m_name; } + void set_name(ByteString); enum class NotifyClients { Yes, @@ -116,7 +116,7 @@ public: Gfx::Bitmap& currently_edited_bitmap(); - ErrorOr> duplicate(DeprecatedString name); + ErrorOr> duplicate(ByteString name); ALWAYS_INLINE Color modify_pixel_with_editing_mask(int x, int y, Color const& target_color, Color const& current_color) { @@ -134,11 +134,11 @@ public: void on_second_paint(ImageEditor&); private: - Layer(Image&, NonnullRefPtr, DeprecatedString name); + Layer(Image&, NonnullRefPtr, ByteString name); Image& m_image; - DeprecatedString m_name; + ByteString m_name; Gfx::IntPoint m_location; NonnullRefPtr m_content_bitmap; RefPtr m_scratch_edited_bitmap { nullptr }; diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index 29b35bc4d77..256d39e2f75 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -129,7 +129,7 @@ void MainWidget::image_editor_did_update_undo_stack() builder.append(' '); builder.append(suffix.value()); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; auto& undo_stack = image_editor->undo_stack(); @@ -141,7 +141,7 @@ void MainWidget::image_editor_did_update_undo_stack() } // Note: Update these together! v -static Vector const s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" }; +static Vector const s_suggested_zoom_levels { "25%", "50%", "100%", "200%", "300%", "400%", "800%", "1600%", "Fit to width", "Fit to height", "Fit entire image" }; static constexpr int s_zoom_level_fit_width = 8; static constexpr int s_zoom_level_fit_height = 9; static constexpr int s_zoom_level_fit_image = 10; @@ -174,7 +174,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto& editor = create_new_editor(*image); auto image_title = dialog->image_name().trim_whitespace(); - editor.set_title((image_title.is_empty() ? "Untitled"_string : String::from_deprecated_string(image_title)).release_value_but_fixme_should_propagate_errors()); + editor.set_title((image_title.is_empty() ? "Untitled"_string : String::from_byte_string(image_title)).release_value_but_fixme_should_propagate_errors()); editor.set_unmodified(); m_histogram_widget->set_image(image); @@ -205,7 +205,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto* editor = current_image_editor(); VERIFY(editor); editor->save_project_as(); - auto path_string = String::from_deprecated_string(editor->path()).release_value_but_fixme_should_propagate_errors(); + auto path_string = String::from_byte_string(editor->path()).release_value_but_fixme_should_propagate_errors(); GUI::Application::the()->set_most_recently_open_file(path_string); }); @@ -213,7 +213,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto* editor = current_image_editor(); VERIFY(editor); editor->save_project(); - auto path_string = String::from_deprecated_string(editor->path()).release_value_but_fixme_should_propagate_errors(); + auto path_string = String::from_byte_string(editor->path()).release_value_but_fixme_should_propagate_errors(); GUI::Application::the()->set_most_recently_open_file(path_string); }); @@ -230,7 +230,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) "As &BMP...", [&](auto&) { auto* editor = current_image_editor(); VERIFY(editor); - auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_deprecated_string(), "bmp"); + auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_byte_string(), "bmp"); if (response.is_error()) return; auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); @@ -245,7 +245,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto* editor = current_image_editor(); VERIFY(editor); // TODO: fix bmp on line below? - auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_deprecated_string(), "png"); + auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_byte_string(), "png"); if (response.is_error()) return; auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); @@ -259,7 +259,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) "As &QOI...", [&](auto&) { auto* editor = current_image_editor(); VERIFY(editor); - auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_deprecated_string(), "qoi"); + auto response = FileSystemAccessClient::Client::the().save_file(&window, editor->title().to_byte_string(), "qoi"); if (response.is_error()) return; auto result = editor->image().export_qoi_to_file(response.value().release_stream()); @@ -325,9 +325,9 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) return; } auto layer_rect = editor->active_layer()->relative_rect(); - HashMap layer_metadata; - layer_metadata.set("pixelpaint-layer-x", DeprecatedString::number(layer_rect.x())); - layer_metadata.set("pixelpaint-layer-y", DeprecatedString::number(layer_rect.y())); + HashMap layer_metadata; + layer_metadata.set("pixelpaint-layer-x", ByteString::number(layer_rect.x())); + layer_metadata.set("pixelpaint-layer-y", ByteString::number(layer_rect.y())); GUI::Clipboard::the().set_bitmap(*bitmap, layer_metadata); }); @@ -1192,8 +1192,8 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) m_zoom_combobox = toolbar.add(); m_zoom_combobox->set_max_width(75); - m_zoom_combobox->set_model(*GUI::ItemListModel::create(s_suggested_zoom_levels)); - m_zoom_combobox->on_change = [this](DeprecatedString const& value, GUI::ModelIndex const& index) { + m_zoom_combobox->set_model(*GUI::ItemListModel::create(s_suggested_zoom_levels)); + m_zoom_combobox->on_change = [this](ByteString const& value, GUI::ModelIndex const& index) { auto* editor = current_image_editor(); VERIFY(editor); @@ -1295,7 +1295,7 @@ void MainWidget::open_image(FileSystemAccessClient::File file) auto& image = *m_loader.release_image(); auto& editor = create_new_editor(image); editor.set_loaded_from_image(m_loader.is_raw_image()); - editor.set_path(file.filename().to_deprecated_string()); + editor.set_path(file.filename().to_byte_string()); editor.set_unmodified(); m_layer_list_widget->set_image(&image); GUI::Application::the()->set_most_recently_open_file(file.filename()); @@ -1415,7 +1415,7 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr image) }; image_editor.on_scale_change = Core::debounce(100, [this](float scale) { - m_zoom_combobox->set_text(DeprecatedString::formatted("{}%", roundf(scale * 100))); + m_zoom_combobox->set_text(ByteString::formatted("{}%", roundf(scale * 100))); current_image_editor()->update_tool_cursor(); }); @@ -1440,7 +1440,7 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr image) if (!value.is_object()) return; auto& json_object = value.as_object(); - auto orientation_value = json_object.get_deprecated_string("orientation"sv); + auto orientation_value = json_object.get_byte_string("orientation"sv); if (!orientation_value.has_value()) return; @@ -1502,10 +1502,10 @@ void MainWidget::update_window_modified() { window()->set_modified(m_tab_widget->is_any_tab_modified()); } -void MainWidget::update_status_bar(DeprecatedString appended_text) +void MainWidget::update_status_bar(ByteString appended_text) { StringBuilder builder = StringBuilder(); - builder.append(m_last_image_editor_mouse_position.to_deprecated_string()); + builder.append(m_last_image_editor_mouse_position.to_byte_string()); if (!appended_text.is_empty()) { builder.append(" "sv); builder.append(appended_text); diff --git a/Userland/Applications/PixelPaint/MainWidget.h b/Userland/Applications/PixelPaint/MainWidget.h index 46c6771693c..ccd4894ce39 100644 --- a/Userland/Applications/PixelPaint/MainWidget.h +++ b/Userland/Applications/PixelPaint/MainWidget.h @@ -62,7 +62,7 @@ private: virtual void drop_event(GUI::DropEvent&) override; void update_window_modified(); - void update_status_bar(DeprecatedString appended_text = DeprecatedString::empty()); + void update_status_bar(ByteString appended_text = ByteString::empty()); ProjectLoader m_loader; diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index ddbbab69b38..9bc76cd8ce8 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -240,7 +240,7 @@ ErrorOr> PaletteWidget::load_palette_file(NonnullOwnPtr> PaletteWidget::load_palette_path(DeprecatedString const& file_path) +ErrorOr> PaletteWidget::load_palette_path(ByteString const& file_path) { auto file = TRY(Core::File::open(file_path, Core::File::OpenMode::Read)); return load_palette_file(move(file)); @@ -249,7 +249,7 @@ ErrorOr> PaletteWidget::load_palette_path(DeprecatedString const& ErrorOr PaletteWidget::save_palette_file(Vector palette, NonnullOwnPtr file) { for (auto& color : palette) { - TRY(file->write_until_depleted(color.to_deprecated_string_without_alpha().bytes())); + TRY(file->write_until_depleted(color.to_byte_string_without_alpha().bytes())); TRY(file->write_until_depleted({ "\n", 1 })); } return {}; diff --git a/Userland/Applications/PixelPaint/PaletteWidget.h b/Userland/Applications/PixelPaint/PaletteWidget.h index 362c29f5180..7825290fe07 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.h +++ b/Userland/Applications/PixelPaint/PaletteWidget.h @@ -32,7 +32,7 @@ public: Vector colors(); static ErrorOr> load_palette_file(NonnullOwnPtr); - static ErrorOr> load_palette_path(DeprecatedString const&); + static ErrorOr> load_palette_path(ByteString const&); static ErrorOr save_palette_file(Vector, NonnullOwnPtr); static Vector fallback_colors(); diff --git a/Userland/Applications/PixelPaint/ToolboxWidget.cpp b/Userland/Applications/PixelPaint/ToolboxWidget.cpp index a4161282509..03dd21469e9 100644 --- a/Userland/Applications/PixelPaint/ToolboxWidget.cpp +++ b/Userland/Applications/PixelPaint/ToolboxWidget.cpp @@ -52,7 +52,7 @@ ToolboxWidget::ToolboxWidget() void ToolboxWidget::setup_tools() { auto add_tool = [&](StringView icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr tool, bool is_default_tool = false) { - auto action = GUI::Action::create_checkable(tool->tool_name(), shortcut, Gfx::Bitmap::load_from_file(DeprecatedString::formatted("/res/icons/pixelpaint/{}.png", icon_name)).release_value_but_fixme_should_propagate_errors(), + auto action = GUI::Action::create_checkable(tool->tool_name(), shortcut, Gfx::Bitmap::load_from_file(ByteString::formatted("/res/icons/pixelpaint/{}.png", icon_name)).release_value_but_fixme_should_propagate_errors(), [this, tool = tool.ptr()](auto& action) { if (action.is_checked()) { on_tool_selection(tool); diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp index 32dc1b04fb9..0a296ed5ee6 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp @@ -140,7 +140,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event) return; auto dialog = EditGuideDialog::construct( editor()->window(), - DeprecatedString::formatted("{}", m_context_menu_guide->offset()), + ByteString::formatted("{}", m_context_menu_guide->offset()), m_context_menu_guide->orientation()); if (dialog->exec() != GUI::Dialog::ExecResult::OK) return; diff --git a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp index d622aa587d3..5f79fc9a2d9 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.cpp @@ -209,7 +209,7 @@ NonnullRefPtr RectangleSelectTool::get_properties_widget() auto& mode_combo = mode_container.add(); mode_combo.set_only_allow_values_from_model(true); - mode_combo.set_model(*GUI::ItemListModel::create(m_merge_mode_names)); + mode_combo.set_model(*GUI::ItemListModel::create(m_merge_mode_names)); mode_combo.set_selected_index((int)m_merge_mode); mode_combo.on_change = [this](auto&&, GUI::ModelIndex const& index) { VERIFY(index.row() >= 0); diff --git a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h index 0392f3f4697..6cc94fec107 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h +++ b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h @@ -40,7 +40,7 @@ private: }; RefPtr m_properties_widget; - Vector m_merge_mode_names {}; + Vector m_merge_mode_names {}; Selection::MergeMode m_merge_mode { Selection::MergeMode::Set }; float m_edge_feathering { 0.0f }; bool m_selecting { false }; diff --git a/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp b/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp index 1ba18e7a3e9..02bb870970e 100644 --- a/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/WandSelectTool.cpp @@ -122,7 +122,7 @@ NonnullRefPtr WandSelectTool::get_properties_widget() auto& mode_combo = mode_container.add(); mode_combo.set_only_allow_values_from_model(true); - mode_combo.set_model(*GUI::ItemListModel::create(m_merge_mode_names)); + mode_combo.set_model(*GUI::ItemListModel::create(m_merge_mode_names)); mode_combo.set_selected_index((int)m_merge_mode); mode_combo.on_change = [this](auto&&, GUI::ModelIndex const& index) { VERIFY(index.row() >= 0); diff --git a/Userland/Applications/PixelPaint/Tools/WandSelectTool.h b/Userland/Applications/PixelPaint/Tools/WandSelectTool.h index dd67eb00c72..beb9e9961fa 100644 --- a/Userland/Applications/PixelPaint/Tools/WandSelectTool.h +++ b/Userland/Applications/PixelPaint/Tools/WandSelectTool.h @@ -31,7 +31,7 @@ private: int m_threshold { 0 }; RefPtr m_properties_widget; - Vector m_merge_mode_names {}; + Vector m_merge_mode_names {}; Selection::MergeMode m_merge_mode { Selection::MergeMode::Set }; }; diff --git a/Userland/Applications/Presenter/Presentation.cpp b/Userland/Applications/Presenter/Presentation.cpp index 7b53b02571f..73efdc46962 100644 --- a/Userland/Applications/Presenter/Presentation.cpp +++ b/Userland/Applications/Presenter/Presentation.cpp @@ -11,13 +11,13 @@ #include #include -Presentation::Presentation(Gfx::IntSize normative_size, HashMap metadata) +Presentation::Presentation(Gfx::IntSize normative_size, HashMap metadata) : m_normative_size(normative_size) , m_metadata(move(metadata)) { } -NonnullOwnPtr Presentation::construct(Gfx::IntSize normative_size, HashMap metadata) +NonnullOwnPtr Presentation::construct(Gfx::IntSize normative_size, HashMap metadata) { return NonnullOwnPtr(NonnullOwnPtr::Adopt, *new Presentation(normative_size, move(metadata))); } @@ -128,12 +128,12 @@ ErrorOr> Presentation::load_from_file(StringView fil return presentation; } -HashMap Presentation::parse_metadata(JsonObject const& metadata_object) +HashMap Presentation::parse_metadata(JsonObject const& metadata_object) { - HashMap metadata; + HashMap metadata; metadata_object.for_each_member([&](auto const& key, auto const& value) { - metadata.set(key, value.to_deprecated_string()); + metadata.set(key, value.to_byte_string()); }); return metadata; @@ -142,7 +142,7 @@ HashMap Presentation::parse_metadata(JsonObj ErrorOr Presentation::parse_presentation_size(JsonObject const& metadata_object) { auto const& maybe_width = metadata_object.get("width"sv); - auto const& maybe_aspect = metadata_object.get_deprecated_string("aspect"sv); + auto const& maybe_aspect = metadata_object.get_byte_string("aspect"sv); if (!maybe_width.has_value() || !maybe_width->is_number() || !maybe_aspect.has_value()) return Error::from_string_view("Width or aspect in incorrect format"sv); @@ -164,14 +164,14 @@ ErrorOr Presentation::parse_presentation_size(JsonObject const& me }; } -ErrorOr Presentation::render() +ErrorOr Presentation::render() { HTMLElement main_element; main_element.tag_name = "main"sv; for (size_t i = 0; i < m_slides.size(); ++i) { HTMLElement slide_div; slide_div.tag_name = "div"sv; - TRY(slide_div.attributes.try_set("id"sv, DeprecatedString::formatted("slide{}", i))); + TRY(slide_div.attributes.try_set("id"sv, ByteString::formatted("slide{}", i))); TRY(slide_div.attributes.try_set("class"sv, "slide hidden"sv)); auto& slide = m_slides[i]; TRY(slide_div.children.try_append(TRY(slide.render(*this)))); @@ -214,5 +214,5 @@ ErrorOr Presentation::render() )"sv)); TRY(main_element.serialize(builder)); TRY(builder.try_append(""sv)); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } diff --git a/Userland/Applications/Presenter/Presentation.h b/Userland/Applications/Presenter/Presentation.h index 47cb07441bf..91fbca84233 100644 --- a/Userland/Applications/Presenter/Presentation.h +++ b/Userland/Applications/Presenter/Presentation.h @@ -8,7 +8,7 @@ #pragma once #include "Slide.h" -#include +#include #include #include #include @@ -38,21 +38,21 @@ public: void previous_frame(); void go_to_first_slide(); - ErrorOr render(); + ErrorOr render(); private: - static HashMap parse_metadata(JsonObject const& metadata_object); + static HashMap parse_metadata(JsonObject const& metadata_object); static ErrorOr parse_presentation_size(JsonObject const& metadata_object); - Presentation(Gfx::IntSize normative_size, HashMap metadata); - static NonnullOwnPtr construct(Gfx::IntSize normative_size, HashMap metadata); + Presentation(Gfx::IntSize normative_size, HashMap metadata); + static NonnullOwnPtr construct(Gfx::IntSize normative_size, HashMap metadata); void append_slide(Slide slide); Vector m_slides {}; // This is not a pixel size, but an abstract size used by the slide objects for relative positioning. Gfx::IntSize m_normative_size; - HashMap m_metadata; + HashMap m_metadata; Checked m_current_slide { 0 }; Checked m_current_frame_in_slide { 0 }; diff --git a/Userland/Applications/Presenter/PresenterWidget.cpp b/Userland/Applications/Presenter/PresenterWidget.cpp index acffb9a7b94..7118b66f6e9 100644 --- a/Userland/Applications/Presenter/PresenterWidget.cpp +++ b/Userland/Applications/Presenter/PresenterWidget.cpp @@ -125,7 +125,7 @@ ErrorOr PresenterWidget::initialize_menubar() void PresenterWidget::update_web_view() { - m_web_view->run_javascript(DeprecatedString::formatted("goto({}, {})", m_current_presentation->current_slide_number(), m_current_presentation->current_frame_in_slide_number())); + m_web_view->run_javascript(ByteString::formatted("goto({}, {})", m_current_presentation->current_slide_number(), m_current_presentation->current_frame_in_slide_number())); } void PresenterWidget::update_slides_actions() @@ -147,10 +147,10 @@ void PresenterWidget::set_file(StringView file_name) { auto presentation = Presentation::load_from_file(file_name); if (presentation.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("The presentation \"{}\" could not be loaded.\n{}", file_name, presentation.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("The presentation \"{}\" could not be loaded.\n{}", file_name, presentation.error())); } else { m_current_presentation = presentation.release_value(); - window()->set_title(DeprecatedString::formatted(title_template, m_current_presentation->title(), m_current_presentation->author())); + window()->set_title(ByteString::formatted(title_template, m_current_presentation->title(), m_current_presentation->author())); set_min_size(m_current_presentation->normative_size()); m_web_view->load_html(MUST(m_current_presentation->render())); update_slides_actions(); diff --git a/Userland/Applications/Presenter/Slide.cpp b/Userland/Applications/Presenter/Slide.cpp index b9b8e092136..db6684efd97 100644 --- a/Userland/Applications/Presenter/Slide.cpp +++ b/Userland/Applications/Presenter/Slide.cpp @@ -9,7 +9,7 @@ #include "Presentation.h" #include -Slide::Slide(unsigned frame_count, Vector> slide_objects, DeprecatedString title) +Slide::Slide(unsigned frame_count, Vector> slide_objects, ByteString title) : m_frame_count(move(frame_count)) , m_slide_objects(move(slide_objects)) , m_title(move(title)) @@ -19,7 +19,7 @@ Slide::Slide(unsigned frame_count, Vector> slide_obje ErrorOr Slide::parse_slide(JsonObject const& slide_json, unsigned slide_index) { // FIXME: Use the text with the "title" role for a title, if there is no title given. - auto title = slide_json.get_deprecated_string("title"sv).value_or("Untitled slide"); + auto title = slide_json.get_byte_string("title"sv).value_or("Untitled slide"); auto frame_count = slide_json.get_u32("frame_count"sv).value_or(1); auto maybe_slide_objects = slide_json.get_array("objects"sv); if (!maybe_slide_objects.has_value()) diff --git a/Userland/Applications/Presenter/Slide.h b/Userland/Applications/Presenter/Slide.h index 864cd4e4ec6..3baf5a420c2 100644 --- a/Userland/Applications/Presenter/Slide.h +++ b/Userland/Applications/Presenter/Slide.h @@ -8,7 +8,7 @@ #pragma once #include "SlideObject.h" -#include +#include #include // A single slide of a presentation. @@ -22,9 +22,9 @@ public: ErrorOr render(Presentation const&) const; private: - Slide(unsigned frame_count, Vector> slide_objects, DeprecatedString title); + Slide(unsigned frame_count, Vector> slide_objects, ByteString title); unsigned m_frame_count; Vector> m_slide_objects; - DeprecatedString m_title; + ByteString m_title; }; diff --git a/Userland/Applications/Presenter/SlideObject.cpp b/Userland/Applications/Presenter/SlideObject.cpp index 6576b5be880..3cf837ac60d 100644 --- a/Userland/Applications/Presenter/SlideObject.cpp +++ b/Userland/Applications/Presenter/SlideObject.cpp @@ -11,16 +11,16 @@ #include #include -static DeprecatedString to_css_length(float design_value, Presentation const& presentation) +static ByteString to_css_length(float design_value, Presentation const& presentation) { float length_in_vw = design_value / static_cast(presentation.normative_size().width()) * 100.0f; - return DeprecatedString::formatted("{}vw", length_in_vw); + return ByteString::formatted("{}vw", length_in_vw); } ErrorOr> SlideObject::parse_slide_object(JsonObject const& slide_object_json, unsigned slide_index) { auto frame = slide_object_json.get_u32("frame"sv).value_or(0); - auto maybe_type = slide_object_json.get_deprecated_string("type"sv); + auto maybe_type = slide_object_json.get_byte_string("type"sv); if (!maybe_type.has_value()) return Error::from_string_view("Slide object must have a type"sv); @@ -58,7 +58,7 @@ void SlideObject::set_property(StringView name, JsonValue value) void GraphicsObject::set_property(StringView name, JsonValue value) { if (name == "color"sv) { - if (auto color = Gfx::Color::from_string(value.to_deprecated_string()); color.has_value()) { + if (auto color = Gfx::Color::from_string(value.to_byte_string()); color.has_value()) { m_color = color.release_value(); } } @@ -68,15 +68,15 @@ void GraphicsObject::set_property(StringView name, JsonValue value) void Text::set_property(StringView name, JsonValue value) { if (name == "text"sv) { - m_text = value.to_deprecated_string(); + m_text = value.to_byte_string(); } else if (name == "font"sv) { - m_font_family = value.to_deprecated_string(); + m_font_family = value.to_byte_string(); } else if (name == "font-weight"sv) { - m_font_weight = Gfx::name_to_weight(value.to_deprecated_string()); + m_font_weight = Gfx::name_to_weight(value.to_byte_string()); } else if (name == "font-size"sv) { m_font_size_in_pt = value.to_float(); } else if (name == "text-alignment"sv) { - m_text_align = value.to_deprecated_string(); + m_text_align = value.to_byte_string(); } GraphicsObject::set_property(name, move(value)); } @@ -84,11 +84,11 @@ void Text::set_property(StringView name, JsonValue value) void Image::set_property(StringView name, JsonValue value) { if (name == "path"sv) { - m_src = value.to_deprecated_string(); + m_src = value.to_byte_string(); } else if (name == "scaling-mode"sv) { - if (value.to_deprecated_string() == "nearest-neighbor"sv) + if (value.to_byte_string() == "nearest-neighbor"sv) m_image_rendering = "crisp-edges"sv; - else if (value.to_deprecated_string() == "smooth-pixels"sv) + else if (value.to_byte_string() == "smooth-pixels"sv) m_image_rendering = "pixelated"sv; } SlideObject::set_property(name, move(value)); @@ -98,11 +98,11 @@ ErrorOr Text::render(Presentation const& presentation) const { HTMLElement div; div.tag_name = "div"sv; - TRY(div.attributes.try_set("class"sv, DeprecatedString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index))); - div.style.set("color"sv, m_color.to_deprecated_string()); - div.style.set("font-family"sv, DeprecatedString::formatted("'{}'", m_font_family)); + TRY(div.attributes.try_set("class"sv, ByteString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index))); + div.style.set("color"sv, m_color.to_byte_string()); + div.style.set("font-family"sv, ByteString::formatted("'{}'", m_font_family)); div.style.set("font-size"sv, to_css_length(m_font_size_in_pt * 1.33333333f, presentation)); - div.style.set("font-weight"sv, DeprecatedString::number(m_font_weight)); + div.style.set("font-weight"sv, ByteString::number(m_font_weight)); div.style.set("text-align"sv, m_text_align); div.style.set("white-space"sv, "pre-wrap"sv); div.style.set("width"sv, to_css_length(m_rect.width(), presentation)); @@ -118,7 +118,7 @@ ErrorOr Image::render(Presentation const& presentation) const { HTMLElement img; img.tag_name = "img"sv; - img.attributes.set("src"sv, URL::create_with_file_scheme(m_src).to_deprecated_string()); + img.attributes.set("src"sv, URL::create_with_file_scheme(m_src).to_byte_string()); img.style.set("image-rendering"sv, m_image_rendering); if (m_rect.width() > m_rect.height()) img.style.set("height"sv, "100%"sv); @@ -127,7 +127,7 @@ ErrorOr Image::render(Presentation const& presentation) const HTMLElement image_wrapper; image_wrapper.tag_name = "div"sv; - TRY(image_wrapper.attributes.try_set("class"sv, DeprecatedString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index))); + TRY(image_wrapper.attributes.try_set("class"sv, ByteString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index))); image_wrapper.children.append(move(img)); image_wrapper.style.set("position"sv, "absolute"sv); image_wrapper.style.set("left"sv, to_css_length(m_rect.left(), presentation)); diff --git a/Userland/Applications/Presenter/SlideObject.h b/Userland/Applications/Presenter/SlideObject.h index 1936f84d466..cd12416e417 100644 --- a/Userland/Applications/Presenter/SlideObject.h +++ b/Userland/Applications/Presenter/SlideObject.h @@ -14,9 +14,9 @@ class Presentation; struct HTMLElement { StringView tag_name; - HashMap attributes; - HashMap style; - DeprecatedString inner_text; + HashMap attributes; + HashMap style; + ByteString inner_text; Vector children; ErrorOr serialize(StringBuilder&) const; @@ -44,7 +44,7 @@ protected: unsigned m_frame_index; unsigned m_slide_index; - HashMap m_properties; + HashMap m_properties; Gfx::IntRect m_rect; }; @@ -76,9 +76,9 @@ private: virtual ErrorOr render(Presentation const&) const override; virtual void set_property(StringView name, JsonValue) override; - DeprecatedString m_text; - DeprecatedString m_font_family; - DeprecatedString m_text_align; + ByteString m_text; + ByteString m_font_family; + ByteString m_text_align; float m_font_size_in_pt { 18 }; unsigned m_font_weight { Gfx::FontWeight::Regular }; }; @@ -92,7 +92,7 @@ public: virtual ~Image() = default; private: - DeprecatedString m_src; + ByteString m_src; StringView m_image_rendering; virtual ErrorOr render(Presentation const&) const override; diff --git a/Userland/Applications/Presenter/main.cpp b/Userland/Applications/Presenter/main.cpp index 9526276caaa..d49fc9b303c 100644 --- a/Userland/Applications/Presenter/main.cpp +++ b/Userland/Applications/Presenter/main.cpp @@ -18,7 +18,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // rpath is required to load .presenter files, unix, sendfd and recvfd are required to talk to WindowServer and WebContent. TRY(Core::System::pledge("stdio rpath unix sendfd recvfd")); - DeprecatedString file_to_load; + ByteString file_to_load; Core::ArgsParser argument_parser; argument_parser.add_positional_argument(file_to_load, "Presentation to load", "file", Core::ArgsParser::Required::No); argument_parser.parse(arguments); diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index de3ab1c3a28..2b8246bff53 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -28,7 +28,7 @@ RunWindow::RunWindow() : m_path_history() - , m_path_history_model(GUI::ItemListModel::create(m_path_history)) + , m_path_history_model(GUI::ItemListModel::create(m_path_history)) { // FIXME: Handle failure to load history somehow. (void)load_history(); @@ -65,7 +65,7 @@ RunWindow::RunWindow() m_browse_button = *find_descendant_of_type_named("browse_button"); m_browse_button->on_click = [this](auto) { - Optional path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), false, GUI::Dialog::ScreenPosition::Center); + Optional path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), false, GUI::Dialog::ScreenPosition::Center); if (path.has_value()) m_path_combo_box->set_text(path.value().view()); }; @@ -95,7 +95,7 @@ void RunWindow::do_run() if (run_via_launch(run_input) || run_as_command(run_input)) { // Remove any existing history entry, prepend the successful run string to history and save. - m_path_history.remove_all_matching([&](DeprecatedString v) { return v == run_input; }); + m_path_history.remove_all_matching([&](ByteString v) { return v == run_input; }); m_path_history.prepend(run_input); // FIXME: Handle failure to save history somehow. (void)save_history(); @@ -109,7 +109,7 @@ void RunWindow::do_run() show(); } -bool RunWindow::run_as_command(DeprecatedString const& run_input) +bool RunWindow::run_as_command(ByteString const& run_input) { // TODO: Query and use the user's preferred shell. auto maybe_child_pid = Core::Process::spawn("/bin/Shell"sv, Array { "-c", run_input.characters() }, {}, Core::Process::KeepAsChild::Yes); @@ -136,7 +136,7 @@ bool RunWindow::run_as_command(DeprecatedString const& run_input) return true; } -bool RunWindow::run_via_launch(DeprecatedString const& run_input) +bool RunWindow::run_via_launch(ByteString const& run_input) { auto url = URL::create_with_url_or_path(run_input); @@ -147,7 +147,7 @@ bool RunWindow::run_via_launch(DeprecatedString const& run_input) warnln("Failed to launch '{}': {}", file_path, real_path_or_error.error()); return false; } - url = URL::create_with_url_or_path(real_path_or_error.release_value().to_deprecated_string()); + url = URL::create_with_url_or_path(real_path_or_error.release_value().to_byte_string()); } if (!Desktop::Launcher::open(url)) { @@ -160,9 +160,9 @@ bool RunWindow::run_via_launch(DeprecatedString const& run_input) return true; } -DeprecatedString RunWindow::history_file_path() +ByteString RunWindow::history_file_path() { - return LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", Core::StandardPaths::config_directory(), "RunHistory.txt")); + return LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", Core::StandardPaths::config_directory(), "RunHistory.txt")); } ErrorOr RunWindow::load_history() @@ -186,7 +186,7 @@ ErrorOr RunWindow::save_history() // Write the first 25 items of history for (int i = 0; i < min(static_cast(m_path_history.size()), 25); i++) - TRY(file->write_until_depleted(DeprecatedString::formatted("{}\n", m_path_history[i]).bytes())); + TRY(file->write_until_depleted(ByteString::formatted("{}\n", m_path_history[i]).bytes())); return {}; } diff --git a/Userland/Applications/Run/RunWindow.h b/Userland/Applications/Run/RunWindow.h index 28694073936..9c3076ce1b4 100644 --- a/Userland/Applications/Run/RunWindow.h +++ b/Userland/Applications/Run/RunWindow.h @@ -24,15 +24,15 @@ private: RunWindow(); void do_run(); - bool run_as_command(DeprecatedString const& run_input); - bool run_via_launch(DeprecatedString const& run_input); + bool run_as_command(ByteString const& run_input); + bool run_via_launch(ByteString const& run_input); - DeprecatedString history_file_path(); + ByteString history_file_path(); ErrorOr load_history(); ErrorOr save_history(); - Vector m_path_history; - NonnullRefPtr> m_path_history_model; + Vector m_path_history; + NonnullRefPtr> m_path_history_model; RefPtr m_icon_image_widget; RefPtr m_ok_button; diff --git a/Userland/Applications/Settings/main.cpp b/Userland/Applications/Settings/main.cpp index c53a052f383..1e1e9433367 100644 --- a/Userland/Applications/Settings/main.cpp +++ b/Userland/Applications/Settings/main.cpp @@ -55,7 +55,7 @@ public: return app->icon(); if (role == GUI::ModelRole::Display) { - DeprecatedString name; + ByteString name; if (app->name().ends_with(" Settings"sv)) name = app->name().substring(0, app->name().length() - " Settings"sv.length()); @@ -115,7 +115,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto requires_root = model->data(index, static_cast(SettingsAppsModelCustomRole::RequiresRoot)).as_bool(); auto launch_origin_rect = icon_view.to_widget_rect(icon_view.content_rect(index)).translated(icon_view.screen_relative_rect().location()); - setenv("__libgui_launch_origin_rect", DeprecatedString::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1); + setenv("__libgui_launch_origin_rect", ByteString::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1); if (requires_root) GUI::Process::spawn_or_show_error(window, "/bin/Escalator"sv, Array { executable }); @@ -133,7 +133,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto& app = *(NonnullRefPtr*)index.internal_data(); - statusbar.set_text(String::from_deprecated_string(app->description()).release_value_but_fixme_should_propagate_errors()); + statusbar.set_text(String::from_byte_string(app->description()).release_value_but_fixme_should_propagate_errors()); }; window->set_icon(app_icon.bitmap_for_size(16)); diff --git a/Userland/Applications/SoundPlayer/M3UParser.cpp b/Userland/Applications/SoundPlayer/M3UParser.cpp index a5778592ebd..65c15c9feb0 100644 --- a/Userland/Applications/SoundPlayer/M3UParser.cpp +++ b/Userland/Applications/SoundPlayer/M3UParser.cpp @@ -20,10 +20,10 @@ NonnullOwnPtr M3UParser::from_file(StringView path) auto file_result = Core::File::open(path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); auto contents = file_result->read_until_eof().release_value_but_fixme_should_propagate_errors(); auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive); - return from_memory(DeprecatedString { contents, NoChomp }, use_utf8); + return from_memory(ByteString { contents, NoChomp }, use_utf8); } -NonnullOwnPtr M3UParser::from_memory(DeprecatedString const& m3u_contents, bool utf8) +NonnullOwnPtr M3UParser::from_memory(ByteString const& m3u_contents, bool utf8) { auto parser = make(); VERIFY(!m3u_contents.is_empty() && !m3u_contents.is_whitespace()); diff --git a/Userland/Applications/SoundPlayer/M3UParser.h b/Userland/Applications/SoundPlayer/M3UParser.h index 39e33e79db8..4bfc8381121 100644 --- a/Userland/Applications/SoundPlayer/M3UParser.h +++ b/Userland/Applications/SoundPlayer/M3UParser.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -15,35 +15,35 @@ // Extended M3U fields (de facto standard) struct M3UExtendedInfo { Optional track_length_in_seconds; - Optional track_display_title; - Optional group_name; - Optional album_title; - Optional album_artist; - Optional album_genre; + Optional track_display_title; + Optional group_name; + Optional album_title; + Optional album_artist; + Optional album_genre; Optional file_size_in_bytes; Optional embedded_mp3; - Optional cover_path; + Optional cover_path; }; struct M3UEntry { - DeprecatedString path; + ByteString path; Optional extended_info; }; class M3UParser { public: static NonnullOwnPtr from_file(StringView path); - static NonnullOwnPtr from_memory(DeprecatedString const& m3u_contents, bool utf8); + static NonnullOwnPtr from_memory(ByteString const& m3u_contents, bool utf8); NonnullOwnPtr> parse(bool include_extended_info); - Optional& get_playlist_title_metadata() { return m_parsed_playlist_title; } + Optional& get_playlist_title_metadata() { return m_parsed_playlist_title; } M3UParser(); private: - DeprecatedString m_m3u_raw_data; - DeprecatedString m_playlist_path; + ByteString m_m3u_raw_data; + ByteString m_playlist_path; bool m_use_utf8; - Optional m_parsed_playlist_title; + Optional m_parsed_playlist_title; }; diff --git a/Userland/Applications/SoundPlayer/Player.cpp b/Userland/Applications/SoundPlayer/Player.cpp index 3ff8c2ae891..1017de350e6 100644 --- a/Userland/Applications/SoundPlayer/Player.cpp +++ b/Userland/Applications/SoundPlayer/Player.cpp @@ -38,7 +38,7 @@ Player::Player(Audio::ConnectionToServer& audio_client_connection) }; } -void Player::play_file_path(DeprecatedString const& path) +void Player::play_file_path(ByteString const& path) { if (!FileSystem::exists(path)) { audio_load_error(path, "File does not exist"sv); @@ -66,7 +66,7 @@ void Player::play_file_path(DeprecatedString const& path) play(); } -bool Player::is_playlist(DeprecatedString const& path) +bool Player::is_playlist(ByteString const& path) { return (path.ends_with(".m3u"sv, AK::CaseSensitivity::CaseInsensitive) || path.ends_with(".m3u8"sv, AK::CaseSensitivity::CaseInsensitive)); diff --git a/Userland/Applications/SoundPlayer/Player.h b/Userland/Applications/SoundPlayer/Player.h index f0b27655337..f3cab748edf 100644 --- a/Userland/Applications/SoundPlayer/Player.h +++ b/Userland/Applications/SoundPlayer/Player.h @@ -35,12 +35,12 @@ public: explicit Player(Audio::ConnectionToServer& audio_client_connection); virtual ~Player() = default; - void play_file_path(DeprecatedString const& path); - bool is_playlist(DeprecatedString const& path); + void play_file_path(ByteString const& path); + bool is_playlist(ByteString const& path); Playlist& playlist() { return m_playlist; } PlaybackManager const& playback_manager() const { return m_playback_manager; } - DeprecatedString const& loaded_filename() const { return m_loaded_filename; } + ByteString const& loaded_filename() const { return m_loaded_filename; } PlayState play_state() const { return m_play_state; } void set_play_state(PlayState); @@ -98,7 +98,7 @@ private: Audio::ConnectionToServer& m_audio_client_connection; PlaybackManager m_playback_manager; - DeprecatedString m_loaded_filename; + ByteString m_loaded_filename; double m_volume { 0 }; bool m_muted { false }; }; diff --git a/Userland/Applications/SoundPlayer/Playlist.cpp b/Userland/Applications/SoundPlayer/Playlist.cpp index 6e841291eda..5454e853229 100644 --- a/Userland/Applications/SoundPlayer/Playlist.cpp +++ b/Userland/Applications/SoundPlayer/Playlist.cpp @@ -36,7 +36,7 @@ void Playlist::try_fill_missing_info(Vector& entries, StringView path) for (auto& entry : entries) { if (!LexicalPath { entry.path }.is_absolute()) - entry.path = DeprecatedString::formatted("{}/{}", playlist_path.dirname(), entry.path); + entry.path = ByteString::formatted("{}/{}", playlist_path.dirname(), entry.path); if (!entry.extended_info->file_size_in_bytes.has_value()) { auto size = FileSystem::size(entry.path); diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidget.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidget.cpp index 1ead9c70d4a..d30e53a8314 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidget.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidget.cpp @@ -11,7 +11,7 @@ #include "M3UParser.h" #include "PlaybackManager.h" #include "SampleWidget.h" -#include +#include #include #include #include @@ -250,17 +250,17 @@ void SoundPlayerWidget::time_elapsed(int seconds) void SoundPlayerWidget::file_name_changed(StringView name) { m_visualization->start_new_file(name); - DeprecatedString title = name; + ByteString title = name; if (playback_manager().loader()) { auto const& metadata = playback_manager().loader()->metadata(); if (auto artists_or_error = metadata.all_artists(" / "_string); !artists_or_error.is_error() && artists_or_error.value().has_value() && metadata.title.has_value()) { - title = DeprecatedString::formatted("{} – {}", metadata.title.value(), artists_or_error.release_value().release_value()); + title = ByteString::formatted("{} – {}", metadata.title.value(), artists_or_error.release_value().release_value()); } else if (metadata.title.has_value()) { - title = metadata.title.value().to_deprecated_string(); + title = metadata.title.value().to_byte_string(); } } - m_window.set_title(DeprecatedString::formatted("{} — Sound Player", title)); + m_window.set_title(ByteString::formatted("{} — Sound Player", title)); } void SoundPlayerWidget::total_samples_changed(int total_samples) @@ -286,7 +286,7 @@ void SoundPlayerWidget::volume_changed(double volume) void SoundPlayerWidget::playlist_loaded(StringView path, bool loaded) { if (!loaded) { - GUI::MessageBox::show(&m_window, DeprecatedString::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(&m_window, ByteString::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist"sv, GUI::MessageBox::Type::Error); return; } set_playlist_visible(true); @@ -295,6 +295,6 @@ void SoundPlayerWidget::playlist_loaded(StringView path, bool loaded) void SoundPlayerWidget::audio_load_error(StringView path, StringView error_string) { - GUI::MessageBox::show(&m_window, DeprecatedString::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error"sv : error_string), + GUI::MessageBox::show(&m_window, ByteString::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error"sv : error_string), "Filetype error"sv, GUI::MessageBox::Type::Error); } diff --git a/Userland/Applications/SoundPlayer/main.cpp b/Userland/Applications/SoundPlayer/main.cpp index 35d394302e2..83206096d1e 100644 --- a/Userland/Applications/SoundPlayer/main.cpp +++ b/Userland/Applications/SoundPlayer/main.cpp @@ -62,7 +62,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file_menu = window->add_menu("&File"_string); file_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) { - Optional path = GUI::FilePicker::get_open_filepath(window); + Optional path = GUI::FilePicker::get_open_filepath(window); if (path.has_value()) { player->play_file_path(path.value()); } diff --git a/Userland/Applications/SpaceAnalyzer/Tree.cpp b/Userland/Applications/SpaceAnalyzer/Tree.cpp index 39edea37723..2e010f7f0fb 100644 --- a/Userland/Applications/SpaceAnalyzer/Tree.cpp +++ b/Userland/Applications/SpaceAnalyzer/Tree.cpp @@ -40,19 +40,19 @@ void TreeNode::sort_children_by_area() const } struct QueueEntry { - QueueEntry(DeprecatedString path, TreeNode* node) + QueueEntry(ByteString path, TreeNode* node) : path(move(path)) , node(node) {}; - DeprecatedString path; + ByteString path; TreeNode* node { nullptr }; }; -static MountInfo* find_mount_for_path(DeprecatedString path, Vector& mounts) +static MountInfo* find_mount_for_path(ByteString path, Vector& mounts) { MountInfo* result = nullptr; size_t length = 0; for (auto& mount_info : mounts) { - DeprecatedString& mount_point = mount_info.mount_point; + ByteString& mount_point = mount_info.mount_point; if (path.starts_with(mount_point)) { if (!result || mount_point.length() > length) { result = &mount_info; @@ -81,7 +81,7 @@ HashMap TreeNode::populate_filesize_tree(Vector& mounts, Fu StringBuilder builder = StringBuilder(); builder.append(m_name); builder.append('/'); - MountInfo* root_mount_info = find_mount_for_path(builder.to_deprecated_string(), mounts); + MountInfo* root_mount_info = find_mount_for_path(builder.to_byte_string(), mounts); if (!root_mount_info) { return error_accumulator; } @@ -92,7 +92,7 @@ HashMap TreeNode::populate_filesize_tree(Vector& mounts, Fu builder.append(queue_entry.path); builder.append('/'); - MountInfo* mount_info = find_mount_for_path(builder.to_deprecated_string(), mounts); + MountInfo* mount_info = find_mount_for_path(builder.to_byte_string(), mounts); if (!mount_info || (mount_info != root_mount_info && mount_info->source != root_mount_info->source)) { continue; } @@ -123,7 +123,7 @@ HashMap TreeNode::populate_filesize_tree(Vector& mounts, Fu } else { auto st = st_or_error.release_value(); if (S_ISDIR(st.st_mode)) { - queue.enqueue(QueueEntry(builder.to_deprecated_string(), &child)); + queue.enqueue(QueueEntry(builder.to_byte_string(), &child)); } else { child.m_area = st.st_size; } @@ -137,7 +137,7 @@ HashMap TreeNode::populate_filesize_tree(Vector& mounts, Fu return error_accumulator; } -Optional TreeNode::child_with_name(DeprecatedString name) const +Optional TreeNode::child_with_name(ByteString name) const { for (auto& child : *m_children) { if (child.name() == name) diff --git a/Userland/Applications/SpaceAnalyzer/Tree.h b/Userland/Applications/SpaceAnalyzer/Tree.h index 663f2614342..34e0913a782 100644 --- a/Userland/Applications/SpaceAnalyzer/Tree.h +++ b/Userland/Applications/SpaceAnalyzer/Tree.h @@ -6,22 +6,22 @@ #pragma once -#include +#include #include #include #include struct MountInfo { - DeprecatedString mount_point; - DeprecatedString source; + ByteString mount_point; + ByteString source; }; class TreeNode final { public: - TreeNode(DeprecatedString name) + TreeNode(ByteString name) : m_name(move(name)) {}; - DeprecatedString name() const { return m_name; } + ByteString name() const { return m_name; } i64 area() const { return m_area; } size_t num_children() const { @@ -31,21 +31,21 @@ public: return 0; } TreeNode const& child_at(size_t i) const { return m_children->at(i); } - Optional child_with_name(DeprecatedString name) const; + Optional child_with_name(ByteString name) const; void sort_children_by_area() const; HashMap populate_filesize_tree(Vector& mounts, Function on_progress); private: long long int update_totals(); - DeprecatedString m_name; + ByteString m_name; i64 m_area { 0 }; OwnPtr> m_children; }; class Tree { public: - static ErrorOr> create(DeprecatedString root_name) + static ErrorOr> create(ByteString root_name) { return adopt_nonnull_own_or_enomem(new (nothrow) Tree(move(root_name))); } @@ -57,7 +57,7 @@ public: } private: - Tree(DeprecatedString root_name) + Tree(ByteString root_name) : m_root(move(root_name)) {}; TreeNode m_root; }; diff --git a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp index cf9f632d416..3679d2ba6af 100644 --- a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp +++ b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp @@ -9,7 +9,7 @@ #include "ProgressWindow.h" #include "Tree.h" #include -#include +#include #include #include #include @@ -97,7 +97,7 @@ void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, TreeNode const& node text_rect.take_from_top(font().presentation_size() + 1); painter.draw_text(text_rect, human_readable_size(node.area()), font(), Gfx::TextAlignment::TopLeft, Color::Black); } else { - painter.draw_text(text_rect, DeprecatedString::formatted("{} - {}", node.name(), human_readable_size(node.area())), font(), Gfx::TextAlignment::TopLeft, Color::Black); + painter.draw_text(text_rect, ByteString::formatted("{} - {}", node.name(), human_readable_size(node.area())), font(), Gfx::TextAlignment::TopLeft, Color::Black); } painter.clear_clip_rect(); } @@ -261,13 +261,13 @@ void TreeMapWidget::paint_event(GUI::PaintEvent& event) } } -Vector TreeMapWidget::path_to_position(Gfx::IntPoint position) +Vector TreeMapWidget::path_to_position(Gfx::IntPoint position) { TreeNode const* node = path_node(m_viewpoint); if (!node) { return {}; } - Vector path; + Vector path; lay_out_children(*node, frame_inner_rect(), m_viewpoint, [&](TreeNode const& node, int, Gfx::IntRect const& rect, Gfx::IntRect const&, int, HasLabel, IsRemainder is_remainder) { if (is_remainder == IsRemainder::No && rect.contains(position)) { path.append(node.name()); @@ -381,8 +381,8 @@ static ErrorOr fill_mounts(Vector& output) TRY(json.as_array().try_for_each([&output](JsonValue const& value) -> ErrorOr { auto& filesystem_object = value.as_object(); MountInfo mount_info; - mount_info.mount_point = filesystem_object.get_deprecated_string("mount_point"sv).value_or({}); - mount_info.source = filesystem_object.get_deprecated_string("source"sv).value_or("none"); + mount_info.mount_point = filesystem_object.get_byte_string("mount_point"sv).value_or({}); + mount_info.source = filesystem_object.get_byte_string("source"sv).value_or("none"); TRY(output.try_append(mount_info)); return {}; })); @@ -420,7 +420,7 @@ ErrorOr TreeMapWidget::analyze(GUI::Statusbar& statusbar) builder.append({ error, strlen(error) }); builder.append(" ("sv); int value = errors.get(key).value(); - builder.append(DeprecatedString::number(value)); + builder.append(ByteString::number(value)); if (value == 1) { builder.append(" time"sv); } else { diff --git a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h index bfed7cfe855..6131e839264 100644 --- a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h +++ b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.h @@ -7,7 +7,7 @@ #pragma once #include "Tree.h" -#include +#include #include #include @@ -50,11 +50,11 @@ private: template void lay_out_children(TreeNode const&, Gfx::IntRect const&, int depth, Function); void paint_cell_frame(GUI::Painter&, TreeNode const&, Gfx::IntRect const&, Gfx::IntRect const&, int depth, HasLabel has_label) const; - Vector path_to_position(Gfx::IntPoint); + Vector path_to_position(Gfx::IntPoint); void recalculate_path_for_new_tree(); OwnPtr m_tree; - Vector m_path_segments; + Vector m_path_segments; size_t m_viewpoint { 0 }; // Current position within m_path_segments. void const* m_selected_node_cache; }; diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index abc94565a32..4959e5be30c 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -28,7 +28,7 @@ static auto const APP_NAME = "Space Analyzer"_string; -static DeprecatedString get_absolute_path_to_selected_node(SpaceAnalyzer::TreeMapWidget const& tree_map_widget, bool include_last_node = true) +static ByteString get_absolute_path_to_selected_node(SpaceAnalyzer::TreeMapWidget const& tree_map_widget, bool include_last_node = true) { StringBuilder path_builder; for (size_t k = 0; k < tree_map_widget.path_size() - (include_last_node ? 0 : 1); k++) { @@ -38,7 +38,7 @@ static DeprecatedString get_absolute_path_to_selected_node(SpaceAnalyzer::TreeMa TreeNode const* node = tree_map_widget.path_node(k); path_builder.append(node->name()); } - return path_builder.to_deprecated_string(); + return path_builder.to_byte_string(); } ErrorOr serenity_main(Main::Arguments arguments) @@ -72,7 +72,7 @@ ErrorOr serenity_main(Main::Arguments arguments) file_menu->add_action(GUI::Action::create("&Analyze", { KeyCode::Key_F5 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { // FIXME: Just modify the tree in memory instead of traversing the entire file system if (auto result = tree_map_widget.analyze(statusbar); result.is_error()) { - GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error())); + GUI::MessageBox::show_error(window, ByteString::formatted("{}", result.error())); } })); file_menu->add_separator(); @@ -104,7 +104,7 @@ ErrorOr serenity_main(Main::Arguments arguments) GUI::Clipboard::the().set_plain_text(get_absolute_path_to_selected_node(tree_map_widget)); }); auto delete_action = GUI::CommonActions::make_delete_action([&](auto&) { - DeprecatedString selected_node_path = get_absolute_path_to_selected_node(tree_map_widget); + ByteString selected_node_path = get_absolute_path_to_selected_node(tree_map_widget); bool try_again = true; while (try_again) { try_again = false; @@ -112,7 +112,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto deletion_result = FileSystem::remove(selected_node_path, FileSystem::RecursionMode::Allowed); if (deletion_result.is_error()) { auto retry_message_result = GUI::MessageBox::show(window, - DeprecatedString::formatted("Failed to delete \"{}\": {}. Retry?", + ByteString::formatted("Failed to delete \"{}\": {}. Retry?", selected_node_path, deletion_result.error()), "Deletion failed"sv, @@ -123,7 +123,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } } else { GUI::MessageBox::show(window, - DeprecatedString::formatted("Successfully deleted \"{}\".", selected_node_path), + ByteString::formatted("Successfully deleted \"{}\".", selected_node_path), "Deletion completed"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OK); @@ -131,7 +131,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } if (auto result = tree_map_widget.analyze(statusbar); result.is_error()) { - GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error())); + GUI::MessageBox::show_error(window, ByteString::formatted("{}", result.error())); } }); @@ -165,14 +165,14 @@ ErrorOr serenity_main(Main::Arguments arguments) // Sneakily set the window title here, while the StringBuilder holds the right amount of the path. if (k == tree_map_widget.viewpoint()) - window->set_title(DeprecatedString::formatted("{} - SpaceAnalyzer", builder.string_view())); + window->set_title(ByteString::formatted("{} - SpaceAnalyzer", builder.string_view())); breadcrumbbar.append_segment(node->name(), GUI::FileIconProvider::icon_for_path(builder.string_view()).bitmap_for_size(16), builder.string_view(), MUST(builder.to_string())); } breadcrumbbar.set_selected_segment(tree_map_widget.viewpoint()); }; tree_map_widget.on_context_menu_request = [&](const GUI::ContextMenuEvent& event) { - DeprecatedString selected_node_path = get_absolute_path_to_selected_node(tree_map_widget); + ByteString selected_node_path = get_absolute_path_to_selected_node(tree_map_widget); if (selected_node_path.is_empty()) return; delete_action->set_enabled(FileSystem::can_delete_or_move(selected_node_path)); diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp index ea630d9e90d..d54ad3175b7 100644 --- a/Userland/Applications/Spreadsheet/Cell.cpp +++ b/Userland/Applications/Spreadsheet/Cell.cpp @@ -12,7 +12,7 @@ namespace Spreadsheet { -void Cell::set_data(DeprecatedString new_data) +void Cell::set_data(ByteString new_data) { // If we are a formula, we do not save the beginning '=', if the new_data is "" we can simply change our kind if (m_kind == Formula && m_data.is_empty() && new_data.is_empty()) { @@ -43,7 +43,7 @@ void Cell::set_data(JS::Value new_data) StringBuilder builder; builder.append(new_data.to_string_without_side_effects()); - m_data = builder.to_deprecated_string(); + m_data = builder.to_byte_string(); m_evaluated_data = move(new_data); } @@ -86,7 +86,7 @@ CellType const& Cell::type() const return *CellType::get_by_name("Identity"sv); } -JS::ThrowCompletionOr Cell::typed_display() const +JS::ThrowCompletionOr Cell::typed_display() const { return type().display(const_cast(*this), m_type_metadata); } @@ -163,13 +163,13 @@ JS::Value Cell::js_data() return JS::PrimitiveString::create(vm, m_data); } -DeprecatedString Cell::source() const +ByteString Cell::source() const { StringBuilder builder; if (m_kind == Formula) builder.append('='); builder.append(m_data); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } // FIXME: Find a better way to figure out dependencies diff --git a/Userland/Applications/Spreadsheet/Cell.h b/Userland/Applications/Spreadsheet/Cell.h index 34456f09a73..d7072f59529 100644 --- a/Userland/Applications/Spreadsheet/Cell.h +++ b/Userland/Applications/Spreadsheet/Cell.h @@ -11,7 +11,7 @@ #include "Forward.h" #include "JSIntegration.h" #include "Position.h" -#include +#include #include #include #include @@ -24,7 +24,7 @@ struct Cell : public Weakable { Formula, }; - Cell(DeprecatedString data, Position position, WeakPtr sheet) + Cell(ByteString data, Position position, WeakPtr sheet) : m_dirty(false) , m_data(move(data)) , m_kind(LiteralString) @@ -33,7 +33,7 @@ struct Cell : public Weakable { { } - Cell(DeprecatedString source, JS::Value&& cell_value, Position position, WeakPtr sheet) + Cell(ByteString source, JS::Value&& cell_value, Position position, WeakPtr sheet) : m_dirty(false) , m_data(move(source)) , m_evaluated_data(move(cell_value)) @@ -45,7 +45,7 @@ struct Cell : public Weakable { void reference_from(Cell*); - void set_data(DeprecatedString new_data); + void set_data(ByteString new_data); void set_data(JS::Value new_data); bool dirty() const { return m_dirty; } void clear_dirty() { m_dirty = false; } @@ -55,7 +55,7 @@ struct Cell : public Weakable { if (!m_name_for_javascript.is_empty()) return m_name_for_javascript; - m_name_for_javascript = DeprecatedString::formatted("cell {}", m_position.to_cell_identifier(sheet)); + m_name_for_javascript = ByteString::formatted("cell {}", m_position.to_cell_identifier(sheet)); return m_name_for_javascript; } @@ -67,7 +67,7 @@ struct Cell : public Weakable { return m_thrown_value; } - DeprecatedString const& data() const { return m_data; } + ByteString const& data() const { return m_data; } const JS::Value& evaluated_data() const { return m_evaluated_data; } Kind kind() const { return m_kind; } Vector> const& referencing_cells() const { return m_referencing_cells; } @@ -95,14 +95,14 @@ struct Cell : public Weakable { m_conditional_formats = move(fmts); } - JS::ThrowCompletionOr typed_display() const; + JS::ThrowCompletionOr typed_display() const; JS::ThrowCompletionOr typed_js_data() const; CellType const& type() const; CellTypeMetadata const& type_metadata() const { return m_type_metadata; } CellTypeMetadata& type_metadata() { return m_type_metadata; } - DeprecatedString source() const; + ByteString source() const; JS::Value js_data(); @@ -117,7 +117,7 @@ struct Cell : public Weakable { private: bool m_dirty { false }; bool m_evaluated_externally { false }; - DeprecatedString m_data; + ByteString m_data; JS::Value m_evaluated_data; JS::Value m_thrown_value; Kind m_kind { LiteralString }; @@ -126,7 +126,7 @@ private: CellType const* m_type { nullptr }; CellTypeMetadata m_type_metadata; Position m_position; - mutable DeprecatedString m_name_for_javascript; + mutable ByteString m_name_for_javascript; Vector m_conditional_formats; Format m_evaluated_formats; diff --git a/Userland/Applications/Spreadsheet/CellType/Date.cpp b/Userland/Applications/Spreadsheet/CellType/Date.cpp index 085acaf46d5..d74898db339 100644 --- a/Userland/Applications/Spreadsheet/CellType/Date.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Date.cpp @@ -17,12 +17,12 @@ DateCell::DateCell() { } -JS::ThrowCompletionOr DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const +JS::ThrowCompletionOr DateCell::display(Cell& cell, CellTypeMetadata const& metadata) const { - return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr { + return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr { auto& vm = cell.sheet().global_object().vm(); auto timestamp = TRY(js_value(cell, metadata)); - auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(vm))).to_deprecated_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S"sv : metadata.format.view()); + auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(vm))).to_byte_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S"sv : metadata.format.view()); if (metadata.length >= 0) return string.substring(0, metadata.length); diff --git a/Userland/Applications/Spreadsheet/CellType/Date.h b/Userland/Applications/Spreadsheet/CellType/Date.h index 61258e4eb63..72ab9888238 100644 --- a/Userland/Applications/Spreadsheet/CellType/Date.h +++ b/Userland/Applications/Spreadsheet/CellType/Date.h @@ -16,7 +16,7 @@ class DateCell : public CellType { public: DateCell(); virtual ~DateCell() override = default; - virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; virtual JS::ThrowCompletionOr js_value(Cell&, CellTypeMetadata const&) const override; virtual String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/Format.cpp b/Userland/Applications/Spreadsheet/CellType/Format.cpp index 663aa2173de..431254d6f5f 100644 --- a/Userland/Applications/Spreadsheet/CellType/Format.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Format.cpp @@ -5,7 +5,7 @@ */ #include "Format.h" -#include +#include #include #include @@ -37,13 +37,13 @@ struct PrintfImpl : public PrintfImplementation::PrintfImpl(putch, nullptr, format, value); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } diff --git a/Userland/Applications/Spreadsheet/CellType/Format.h b/Userland/Applications/Spreadsheet/CellType/Format.h index 1429692e008..b9776a27e04 100644 --- a/Userland/Applications/Spreadsheet/CellType/Format.h +++ b/Userland/Applications/Spreadsheet/CellType/Format.h @@ -10,6 +10,6 @@ namespace Spreadsheet { -DeprecatedString format_double(char const* format, double value); +ByteString format_double(char const* format, double value); } diff --git a/Userland/Applications/Spreadsheet/CellType/Identity.cpp b/Userland/Applications/Spreadsheet/CellType/Identity.cpp index 203c0401208..1d7c9820525 100644 --- a/Userland/Applications/Spreadsheet/CellType/Identity.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Identity.cpp @@ -15,14 +15,14 @@ IdentityCell::IdentityCell() { } -JS::ThrowCompletionOr IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const +JS::ThrowCompletionOr IdentityCell::display(Cell& cell, CellTypeMetadata const& metadata) const { auto& vm = cell.sheet().global_object().vm(); auto data = cell.js_data(); if (!metadata.format.is_empty()) data = TRY(cell.sheet().evaluate(metadata.format, &cell)); - return data.to_deprecated_string(vm); + return data.to_byte_string(vm); } JS::ThrowCompletionOr IdentityCell::js_value(Cell& cell, CellTypeMetadata const&) const diff --git a/Userland/Applications/Spreadsheet/CellType/Identity.h b/Userland/Applications/Spreadsheet/CellType/Identity.h index a3c7dbe9a34..fcfd3707c46 100644 --- a/Userland/Applications/Spreadsheet/CellType/Identity.h +++ b/Userland/Applications/Spreadsheet/CellType/Identity.h @@ -15,7 +15,7 @@ class IdentityCell : public CellType { public: IdentityCell(); virtual ~IdentityCell() override = default; - virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; virtual JS::ThrowCompletionOr js_value(Cell&, CellTypeMetadata const&) const override; virtual String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp index 92bbe1971e9..ed85b9c8604 100644 --- a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp @@ -18,14 +18,14 @@ NumericCell::NumericCell() { } -JS::ThrowCompletionOr NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const +JS::ThrowCompletionOr NumericCell::display(Cell& cell, CellTypeMetadata const& metadata) const { - return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr { + return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr { auto& vm = cell.sheet().global_object().vm(); auto value = TRY(js_value(cell, metadata)); - DeprecatedString string; + ByteString string; if (metadata.format.is_empty()) - string = TRY(value.to_deprecated_string(vm)); + string = TRY(value.to_byte_string(vm)); else string = format_double(metadata.format.characters(), TRY(value.to_double(vm))); diff --git a/Userland/Applications/Spreadsheet/CellType/Numeric.h b/Userland/Applications/Spreadsheet/CellType/Numeric.h index 4a6672c8162..c8480ea9d5c 100644 --- a/Userland/Applications/Spreadsheet/CellType/Numeric.h +++ b/Userland/Applications/Spreadsheet/CellType/Numeric.h @@ -26,7 +26,7 @@ class NumericCell : public CellType { public: NumericCell(); virtual ~NumericCell() override = default; - virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; virtual JS::ThrowCompletionOr js_value(Cell&, CellTypeMetadata const&) const override; virtual String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/String.cpp b/Userland/Applications/Spreadsheet/CellType/String.cpp index 379ac5215cb..c0a9ff67bf4 100644 --- a/Userland/Applications/Spreadsheet/CellType/String.cpp +++ b/Userland/Applications/Spreadsheet/CellType/String.cpp @@ -15,10 +15,10 @@ StringCell::StringCell() { } -JS::ThrowCompletionOr StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const +JS::ThrowCompletionOr StringCell::display(Cell& cell, CellTypeMetadata const& metadata) const { auto& vm = cell.sheet().global_object().vm(); - auto string = TRY(cell.js_data().to_deprecated_string(vm)); + auto string = TRY(cell.js_data().to_byte_string(vm)); if (metadata.length >= 0) return string.substring(0, metadata.length); diff --git a/Userland/Applications/Spreadsheet/CellType/String.h b/Userland/Applications/Spreadsheet/CellType/String.h index 28b145c4478..7512207b431 100644 --- a/Userland/Applications/Spreadsheet/CellType/String.h +++ b/Userland/Applications/Spreadsheet/CellType/String.h @@ -15,7 +15,7 @@ class StringCell : public CellType { public: StringCell(); virtual ~StringCell() override = default; - virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; + virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const override; virtual JS::ThrowCompletionOr js_value(Cell&, CellTypeMetadata const&) const override; virtual String metadata_hint(MetadataName) const override; }; diff --git a/Userland/Applications/Spreadsheet/CellType/Type.cpp b/Userland/Applications/Spreadsheet/CellType/Type.cpp index 259cf9f001d..903b0bb3046 100644 --- a/Userland/Applications/Spreadsheet/CellType/Type.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Type.cpp @@ -12,7 +12,7 @@ #include #include -static HashMap s_cell_types; +static HashMap s_cell_types; static Spreadsheet::StringCell s_string_cell; static Spreadsheet::NumericCell s_numeric_cell; static Spreadsheet::IdentityCell s_identity_cell; diff --git a/Userland/Applications/Spreadsheet/CellType/Type.h b/Userland/Applications/Spreadsheet/CellType/Type.h index 5badeae308f..deefb6f9d89 100644 --- a/Userland/Applications/Spreadsheet/CellType/Type.h +++ b/Userland/Applications/Spreadsheet/CellType/Type.h @@ -8,7 +8,7 @@ #include "../ConditionalFormatting.h" #include "../Forward.h" -#include +#include #include #include #include @@ -18,7 +18,7 @@ namespace Spreadsheet { struct CellTypeMetadata { int length { -1 }; - DeprecatedString format; + ByteString format; Gfx::TextAlignment alignment { Gfx::TextAlignment::CenterRight }; Format static_format; }; @@ -35,18 +35,18 @@ public: static CellType const* get_by_name(StringView); static Vector names(); - virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const = 0; + virtual JS::ThrowCompletionOr display(Cell&, CellTypeMetadata const&) const = 0; virtual JS::ThrowCompletionOr js_value(Cell&, CellTypeMetadata const&) const = 0; virtual String metadata_hint(MetadataName) const { return {}; } virtual ~CellType() = default; - DeprecatedString const& name() const { return m_name; } + ByteString const& name() const { return m_name; } protected: CellType(StringView name); private: - DeprecatedString m_name; + ByteString m_name; }; } diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp index 3027f00addd..1ce5344ecd4 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.cpp +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.cpp @@ -61,9 +61,9 @@ CellTypeDialog::CellTypeDialog(Vector const& positions, Sheet& sheet, ok_button.on_click = [&](auto) { done(ExecResult::OK); }; } -Vector const g_horizontal_alignments { "Left", "Center", "Right" }; -Vector const g_vertical_alignments { "Top", "Center", "Bottom" }; -Vector g_types; +Vector const g_horizontal_alignments { "Left", "Center", "Right" }; +Vector const g_vertical_alignments { "Top", "Center", "Bottom" }; +Vector g_types; constexpr static CellTypeDialog::VerticalAlignment vertical_alignment_from(Gfx::TextAlignment alignment) { @@ -142,7 +142,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector const& po right_side.set_fixed_width(170); auto& type_list = left_side.add(); - type_list.set_model(*GUI::ItemListModel::create(g_types)); + type_list.set_model(*GUI::ItemListModel::create(g_types)); type_list.set_should_hide_unnecessary_scrollbars(true); type_list.on_selection_change = [&] { const auto& index = type_list.selection().first(); @@ -188,7 +188,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector const& po checkbox.on_checked = [&](auto checked) { editor.set_enabled(checked); if (!checked) - m_format = DeprecatedString::empty(); + m_format = ByteString::empty(); editor.set_text(m_format); }; editor.on_change = [&] { @@ -213,7 +213,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector const& po auto& horizontal_combobox = alignment_tab.add(); horizontal_combobox.set_only_allow_values_from_model(true); - horizontal_combobox.set_model(*GUI::ItemListModel::create(g_horizontal_alignments)); + horizontal_combobox.set_model(*GUI::ItemListModel::create(g_horizontal_alignments)); horizontal_combobox.set_selected_index((int)m_horizontal_alignment); horizontal_combobox.on_change = [&](auto&, const GUI::ModelIndex& index) { switch (index.row()) { @@ -244,7 +244,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, Vector const& po auto& vertical_combobox = alignment_tab.add(); vertical_combobox.set_only_allow_values_from_model(true); - vertical_combobox.set_model(*GUI::ItemListModel::create(g_vertical_alignments)); + vertical_combobox.set_model(*GUI::ItemListModel::create(g_vertical_alignments)); vertical_combobox.set_selected_index((int)m_vertical_alignment); vertical_combobox.on_change = [&](auto&, const GUI::ModelIndex& index) { switch (index.row()) { diff --git a/Userland/Applications/Spreadsheet/CellTypeDialog.h b/Userland/Applications/Spreadsheet/CellTypeDialog.h index 9171e27e9c4..8060924485a 100644 --- a/Userland/Applications/Spreadsheet/CellTypeDialog.h +++ b/Userland/Applications/Spreadsheet/CellTypeDialog.h @@ -39,7 +39,7 @@ private: CellType const* m_type { nullptr }; int m_length { -1 }; - DeprecatedString m_format; + ByteString m_format; HorizontalAlignment m_horizontal_alignment { HorizontalAlignment::Right }; VerticalAlignment m_vertical_alignment { VerticalAlignment::Center }; Format m_static_format; diff --git a/Userland/Applications/Spreadsheet/ConditionalFormatting.h b/Userland/Applications/Spreadsheet/ConditionalFormatting.h index d6e324d91dc..02ae9cd8554 100644 --- a/Userland/Applications/Spreadsheet/ConditionalFormatting.h +++ b/Userland/Applications/Spreadsheet/ConditionalFormatting.h @@ -7,7 +7,7 @@ #pragma once #include "Forward.h" -#include +#include #include #include @@ -19,7 +19,7 @@ struct Format { }; struct ConditionalFormat : public Format { - DeprecatedString condition; + ByteString condition; }; enum class FormatType { diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp index cc84d1618e1..66f566078b9 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp @@ -7,7 +7,7 @@ #include "ExportDialog.h" #include "Spreadsheet.h" #include "Workbook.h" -#include +#include #include #include #include @@ -59,7 +59,7 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet) m_data_preview_text_editor->set_should_hide_unnecessary_scrollbars(true); - m_quote_escape_combo_box->set_model(GUI::ItemListModel::create(m_quote_escape_items)); + m_quote_escape_combo_box->set_model(GUI::ItemListModel::create(m_quote_escape_items)); // By default, use commas, double quotes with repeat, disable headers, and quote only the fields that require quoting. m_delimiter_comma_radio->set_checked(true); @@ -91,7 +91,7 @@ CSVExportDialogPage::CSVExportDialogPage(Sheet const& sheet) auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> ErrorOr { - auto delimiter = TRY([this]() -> ErrorOr { + auto delimiter = TRY([this]() -> ErrorOr { if (m_delimiter_other_radio->is_checked()) { if (m_delimiter_other_text_box->text().is_empty()) return Error::from_string_literal("Delimiter unset"); @@ -108,7 +108,7 @@ auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> Error return Error::from_string_literal("Delimiter unset"); }()); - auto quote = TRY([this]() -> ErrorOr { + auto quote = TRY([this]() -> ErrorOr { if (m_quote_other_radio->is_checked()) { if (m_quote_other_text_box->text().is_empty()) return Error::from_string_literal("Quote separator unset"); @@ -140,7 +140,7 @@ auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> Error }; auto behaviors = Writer::default_behaviors(); - Vector empty_headers; + Vector empty_headers; auto* headers = &empty_headers; if (should_export_headers) { @@ -153,7 +153,7 @@ auto CSVExportDialogPage::generate(Stream& stream, GenerationType type) -> Error switch (type) { case GenerationType::Normal: - TRY((Writer::XSV>::generate(stream, m_data, move(traits), *headers, behaviors))); + TRY((Writer::XSV>::generate(stream, m_data, move(traits), *headers, behaviors))); break; case GenerationType::Preview: TRY((Writer::XSV::generate_preview(stream, m_data, move(traits), *headers, behaviors))); @@ -176,10 +176,10 @@ void CSVExportDialogPage::update_preview() return {}; }(); if (maybe_error.is_error()) - m_data_preview_text_editor->set_text(DeprecatedString::formatted("Cannot update preview: {}", maybe_error.error())); + m_data_preview_text_editor->set_text(ByteString::formatted("Cannot update preview: {}", maybe_error.error())); } -ErrorOr ExportDialog::make_and_run_for(StringView mime, Core::File& file, DeprecatedString filename, Workbook& workbook) +ErrorOr ExportDialog::make_and_run_for(StringView mime, Core::File& file, ByteString filename, Workbook& workbook) { auto wizard = TRY(GUI::WizardDialog::create(GUI::Application::the()->active_window())); wizard->set_title("File Export Wizard"); @@ -205,7 +205,7 @@ ErrorOr ExportDialog::make_and_run_for(StringView mime, Core::File& file, for (auto& sheet : workbook.sheets()) array.must_append(sheet->to_json()); - auto file_content = array.to_deprecated_string(); + auto file_content = array.to_byte_string(); return file.write_until_depleted(file_content.bytes()); }; @@ -223,11 +223,11 @@ ErrorOr ExportDialog::make_and_run_for(StringView mime, Core::File& file, TRY(page->body_widget().load_from_gml(select_format_page_gml)); auto format_combo_box = page->body_widget().find_descendant_of_type_named("select_format_page_format_combo_box"); - Vector supported_formats { + Vector supported_formats { "CSV (text/csv)", "Spreadsheet Worksheet", }; - format_combo_box->set_model(GUI::ItemListModel::create(supported_formats)); + format_combo_box->set_model(GUI::ItemListModel::create(supported_formats)); wizard->push_page(page); diff --git a/Userland/Applications/Spreadsheet/ExportDialog.h b/Userland/Applications/Spreadsheet/ExportDialog.h index bdef59826b6..56424a8c69d 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.h +++ b/Userland/Applications/Spreadsheet/ExportDialog.h @@ -33,8 +33,8 @@ protected: void update_preview(); private: - Vector> m_data; - Vector m_headers; + Vector> m_data; + Vector m_headers; RefPtr m_page; RefPtr m_delimiter_comma_radio; RefPtr m_delimiter_semicolon_radio; @@ -50,7 +50,7 @@ private: RefPtr m_export_header_check_box; RefPtr m_quote_all_fields_check_box; RefPtr m_data_preview_text_editor; - Vector m_quote_escape_items { + Vector m_quote_escape_items { // Note: Keep in sync with Writer::WriterTraits::QuoteEscape. "Repeat", "Backslash", @@ -58,7 +58,7 @@ private: }; struct ExportDialog { - static ErrorOr make_and_run_for(StringView mime, Core::File&, DeprecatedString filename, Workbook&); + static ErrorOr make_and_run_for(StringView mime, Core::File&, ByteString filename, Workbook&); }; } diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp index 04d5519d99f..833b3f7c402 100644 --- a/Userland/Applications/Spreadsheet/HelpWindow.cpp +++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp @@ -38,7 +38,7 @@ public: return {}; } - DeprecatedString key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; } + ByteString key(const GUI::ModelIndex& index) const { return m_keys[index.row()]; } void set_from(JsonObject const& object) { @@ -55,7 +55,7 @@ private: { } - Vector m_keys; + Vector m_keys; }; RefPtr HelpWindow::s_the { nullptr }; @@ -90,7 +90,7 @@ HelpWindow::HelpWindow(GUI::Window* parent) auto entry = LexicalPath::basename(example_path); auto doc_option = m_docs.get_object(entry); if (!doc_option.has_value()) { - GUI::MessageBox::show_error(this, DeprecatedString::formatted("No documentation entry found for '{}'", example_path)); + GUI::MessageBox::show_error(this, ByteString::formatted("No documentation entry found for '{}'", example_path)); return; } auto& doc = doc_option.value(); @@ -98,13 +98,13 @@ HelpWindow::HelpWindow(GUI::Window* parent) auto maybe_example_data = doc.get_object("example_data"sv); if (!maybe_example_data.has_value()) { - GUI::MessageBox::show_error(this, DeprecatedString::formatted("No example data found for '{}'", example_path)); + GUI::MessageBox::show_error(this, ByteString::formatted("No example data found for '{}'", example_path)); return; } auto& example_data = maybe_example_data.value(); if (!example_data.has_object(name)) { - GUI::MessageBox::show_error(this, DeprecatedString::formatted("Example '{}' not found for '{}'", name, example_path)); + GUI::MessageBox::show_error(this, ByteString::formatted("Example '{}' not found for '{}'", name, example_path)); return; } auto& value = example_data.get_object(name).value(); @@ -112,13 +112,13 @@ HelpWindow::HelpWindow(GUI::Window* parent) auto window = GUI::Window::construct(this); window->resize(size()); window->set_icon(icon()); - window->set_title(DeprecatedString::formatted("Spreadsheet Help - Example {} for {}", name, entry)); + window->set_title(ByteString::formatted("Spreadsheet Help - Example {} for {}", name, entry)); window->on_close = [window = window.ptr()] { window->remove_from_parent(); }; auto widget = window->set_main_widget(window, Vector> {}, false); auto sheet = Sheet::from_json(value, widget->workbook()); if (!sheet) { - GUI::MessageBox::show_error(this, DeprecatedString::formatted("Corrupted example '{}' in '{}'", name, example_path)); + GUI::MessageBox::show_error(this, ByteString::formatted("Corrupted example '{}' in '{}'", name, example_path)); return; } @@ -141,17 +141,17 @@ HelpWindow::HelpWindow(GUI::Window* parent) }; } -DeprecatedString HelpWindow::render(StringView key) +ByteString HelpWindow::render(StringView key) { VERIFY(m_docs.has_object(key)); auto& doc = m_docs.get_object(key).value(); - auto name = doc.get_deprecated_string("name"sv).value_or({}); + auto name = doc.get_byte_string("name"sv).value_or({}); auto argc = doc.get_u32("argc"sv).value_or(0); VERIFY(doc.has_array("argnames"sv)); auto& argnames = doc.get_array("argnames"sv).value(); - auto docstring = doc.get_deprecated_string("doc"sv).value_or({}); + auto docstring = doc.get_byte_string("doc"sv).value_or({}); StringBuilder markdown_builder; @@ -166,7 +166,7 @@ DeprecatedString HelpWindow::render(StringView key) markdown_builder.append("No required arguments.\n"sv); for (size_t i = 0; i < argc; ++i) - markdown_builder.appendff("- `{}`\n", argnames.at(i).to_deprecated_string()); + markdown_builder.appendff("- `{}`\n", argnames.at(i).to_byte_string()); if (argc > 0) markdown_builder.append("\n"sv); @@ -175,7 +175,7 @@ DeprecatedString HelpWindow::render(StringView key) auto opt_count = argnames.size() - argc; markdown_builder.appendff("{} optional argument(s):\n", opt_count); for (size_t i = argc; i < (size_t)argnames.size(); ++i) - markdown_builder.appendff("- `{}`\n", argnames.at(i).to_deprecated_string()); + markdown_builder.appendff("- `{}`\n", argnames.at(i).to_byte_string()); markdown_builder.append("\n"sv); } @@ -188,8 +188,8 @@ DeprecatedString HelpWindow::render(StringView key) VERIFY(examples.has_value()); markdown_builder.append("# EXAMPLES\n"sv); examples->for_each_member([&](auto& text, auto& description_value) { - dbgln("```js\n{}\n```\n\n- {}\n", text, description_value.to_deprecated_string()); - markdown_builder.appendff("```js\n{}\n```\n\n- {}\n", text, description_value.to_deprecated_string()); + dbgln("```js\n{}\n```\n\n- {}\n", text, description_value.to_byte_string()); + markdown_builder.appendff("```js\n{}\n```\n\n- {}\n", text, description_value.to_byte_string()); }); } diff --git a/Userland/Applications/Spreadsheet/HelpWindow.h b/Userland/Applications/Spreadsheet/HelpWindow.h index 41eb9360630..fe2b8765b09 100644 --- a/Userland/Applications/Spreadsheet/HelpWindow.h +++ b/Userland/Applications/Spreadsheet/HelpWindow.h @@ -32,7 +32,7 @@ public: private: static RefPtr s_the; - DeprecatedString render(StringView key); + ByteString render(StringView key); HelpWindow(GUI::Window* parent = nullptr); JsonObject m_docs; diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp index fe2074b76b6..d37a3c47222 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp @@ -53,7 +53,7 @@ CSVImportDialogPage::CSVImportDialogPage(StringView csv) m_data_preview_error_label = m_page->body_widget().find_descendant_of_type_named("data_preview_error_label"); m_data_preview_widget = m_page->body_widget().find_descendant_of_type_named("data_preview_widget"); - m_quote_escape_combo_box->set_model(GUI::ItemListModel::create(m_quote_escape_items)); + m_quote_escape_combo_box->set_model(GUI::ItemListModel::create(m_quote_escape_items)); // By default, use commas, double quotes with repeat, and disable headers. m_delimiter_comma_radio->set_checked(true); @@ -86,8 +86,8 @@ CSVImportDialogPage::CSVImportDialogPage(StringView csv) auto CSVImportDialogPage::make_reader() -> Optional { - DeprecatedString delimiter; - DeprecatedString quote; + ByteString delimiter; + ByteString quote; Reader::ParserTraits::QuoteEscape quote_escape; // Delimiter @@ -169,7 +169,7 @@ void CSVImportDialogPage::update_preview() Vector headers; for (auto const& header : reader.headers()) - headers.append(String::from_deprecated_string(header).release_value_but_fixme_should_propagate_errors()); + headers.append(String::from_byte_string(header).release_value_but_fixme_should_propagate_errors()); m_data_preview_table_view->set_model( GUI::ItemListModel>::create(reader, headers, min(8ul, reader.size()))); @@ -177,16 +177,16 @@ void CSVImportDialogPage::update_preview() m_data_preview_table_view->update(); } -ErrorOr>, DeprecatedString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook) +ErrorOr>, ByteString> ImportDialog::make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook& workbook) { auto wizard = GUI::WizardDialog::create(&parent).release_value_but_fixme_should_propagate_errors(); wizard->set_title("File Import Wizard"); wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16)); - auto import_xsv = [&]() -> ErrorOr>, DeprecatedString> { + auto import_xsv = [&]() -> ErrorOr>, ByteString> { auto contents_or_error = file.read_until_eof(); if (contents_or_error.is_error()) - return DeprecatedString::formatted("{}", contents_or_error.release_error()); + return ByteString::formatted("{}", contents_or_error.release_error()); CSVImportDialogPage page { contents_or_error.value() }; wizard->replace_page(page.page()); auto result = wizard->exec(); @@ -199,7 +199,7 @@ ErrorOr>, DeprecatedString> ImportDialog::make_and_r if (reader.has_value()) { reader->parse(); if (reader.value().has_error()) - return DeprecatedString::formatted("CSV Import failed: {}", reader.value().error_string()); + return ByteString::formatted("CSV Import failed: {}", reader.value().error_string()); auto sheet = Sheet::from_xsv(reader.value(), workbook); if (sheet) @@ -209,20 +209,20 @@ ErrorOr>, DeprecatedString> ImportDialog::make_and_r return sheets; } - return DeprecatedString { "CSV Import was cancelled" }; + return ByteString { "CSV Import was cancelled" }; }; - auto import_worksheet = [&]() -> ErrorOr>, DeprecatedString> { + auto import_worksheet = [&]() -> ErrorOr>, ByteString> { auto contents_or_error = file.read_until_eof(); if (contents_or_error.is_error()) - return DeprecatedString::formatted("{}", contents_or_error.release_error()); + return ByteString::formatted("{}", contents_or_error.release_error()); auto json_value_option = JsonParser(contents_or_error.release_value()).parse(); if (json_value_option.is_error()) - return DeprecatedString::formatted("Failed to parse {}", filename); + return ByteString::formatted("Failed to parse {}", filename); auto& json_value = json_value_option.value(); if (!json_value.is_array()) - return DeprecatedString::formatted("Did not find a spreadsheet in {}", filename); + return ByteString::formatted("Did not find a spreadsheet in {}", filename); Vector> sheets; @@ -247,7 +247,7 @@ ErrorOr>, DeprecatedString> ImportDialog::make_and_r } else { auto page = GUI::WizardPage::create( "Import File Format"sv, - DeprecatedString::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(filename.to_deprecated_string()))) + ByteString::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(filename.to_byte_string()))) .release_value_but_fixme_should_propagate_errors(); page->on_next_page = [] { return nullptr; }; @@ -255,16 +255,16 @@ ErrorOr>, DeprecatedString> ImportDialog::make_and_r page->body_widget().load_from_gml(select_format_page_gml).release_value_but_fixme_should_propagate_errors(); auto format_combo_box = page->body_widget().find_descendant_of_type_named("select_format_page_format_combo_box"); - Vector supported_formats { + Vector supported_formats { "CSV (text/csv)", "Spreadsheet Worksheet", }; - format_combo_box->set_model(GUI::ItemListModel::create(supported_formats)); + format_combo_box->set_model(GUI::ItemListModel::create(supported_formats)); wizard->push_page(page); if (wizard->exec() != GUI::Dialog::ExecResult::OK) - return DeprecatedString { "Import was cancelled" }; + return ByteString { "Import was cancelled" }; if (format_combo_box->selected_index() == 0) return import_xsv(); diff --git a/Userland/Applications/Spreadsheet/ImportDialog.h b/Userland/Applications/Spreadsheet/ImportDialog.h index 6b883e47aef..f9e6c00bcc4 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.h +++ b/Userland/Applications/Spreadsheet/ImportDialog.h @@ -47,7 +47,7 @@ private: RefPtr m_data_preview_table_view; RefPtr m_data_preview_error_label; RefPtr m_data_preview_widget; - Vector m_quote_escape_items { + Vector m_quote_escape_items { // Note: Keep in sync with Reader::ParserTraits::QuoteEscape. "Repeat", "Backslash", @@ -55,7 +55,7 @@ private: }; struct ImportDialog { - static ErrorOr>, DeprecatedString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&); + static ErrorOr>, ByteString> make_and_run_for(GUI::Window& parent, StringView mime, String const& filename, Core::File& file, Workbook&); }; } diff --git a/Userland/Applications/Spreadsheet/JSIntegration.cpp b/Userland/Applications/Spreadsheet/JSIntegration.cpp index 2cf362ede21..37fb98db489 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.cpp +++ b/Userland/Applications/Spreadsheet/JSIntegration.cpp @@ -197,7 +197,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents) auto name_value = vm.argument(0); if (!name_value.is_string()) return vm.throw_completion("Expected a String argument to get_real_cell_contents()"sv); - auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().deprecated_string()); + auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().byte_string()); if (!position.has_value()) return vm.throw_completion("Invalid cell name"sv); @@ -206,7 +206,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_real_cell_contents) return JS::js_undefined(); if (cell->kind() == Spreadsheet::Cell::Kind::Formula) - return JS::PrimitiveString::create(vm, DeprecatedString::formatted("={}", cell->data())); + return JS::PrimitiveString::create(vm, ByteString::formatted("={}", cell->data())); return JS::PrimitiveString::create(vm, cell->data()); } @@ -226,7 +226,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents) auto name_value = vm.argument(0); if (!name_value.is_string()) return vm.throw_completion("Expected the first argument of set_real_cell_contents() to be a String"sv); - auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().deprecated_string()); + auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().byte_string()); if (!position.has_value()) return vm.throw_completion("Invalid cell name"sv); @@ -235,7 +235,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::set_real_cell_contents) return vm.throw_completion("Expected the second argument of set_real_cell_contents() to be a String"sv); auto& cell = sheet_object.m_sheet.ensure(position.value()); - auto new_contents = new_contents_value.as_string().deprecated_string(); + auto new_contents = new_contents_value.as_string().byte_string(); cell.set_data(new_contents); return JS::js_null(); } @@ -256,7 +256,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::parse_cell_name) auto name_value = vm.argument(0); if (!name_value.is_string()) return vm.throw_completion("Expected a String argument to parse_cell_name()"sv); - auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().deprecated_string()); + auto position = sheet_object.m_sheet.parse_cell_name(name_value.as_string().byte_string()); if (!position.has_value()) return JS::js_undefined(); @@ -302,7 +302,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_index) if (!column_name.is_string()) return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "String"); - auto column_name_str = column_name.as_string().deprecated_string(); + auto column_name_str = column_name.as_string().byte_string(); auto this_object = TRY(vm.this_value().to_object(vm)); @@ -327,7 +327,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::column_arithmetic) if (!column_name.is_string()) return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "String"); - auto column_name_str = column_name.as_string().deprecated_string(); + auto column_name_str = column_name.as_string().byte_string(); auto offset = TRY(vm.argument(1).to_number(vm)); auto offset_number = static_cast(offset.as_double()); @@ -355,7 +355,7 @@ JS_DEFINE_NATIVE_FUNCTION(SheetGlobalObject::get_column_bound) if (!column_name.is_string()) return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "String"); - auto column_name_str = column_name.as_string().deprecated_string(); + auto column_name_str = column_name.as_string().byte_string(); auto this_object = TRY(vm.this_value().to_object(vm)); if (!is(*this_object)) @@ -407,7 +407,7 @@ JS_DEFINE_NATIVE_FUNCTION(WorkbookObject::sheet) auto& workbook = workbook_object.m_workbook; if (name_value.is_string()) { - auto name = name_value.as_string().deprecated_string(); + auto name = name_value.as_string().byte_string(); for (auto& sheet : workbook.sheets()) { if (sheet->name() == name) return JS::Value(&sheet->global_object()); diff --git a/Userland/Applications/Spreadsheet/JSIntegration.h b/Userland/Applications/Spreadsheet/JSIntegration.h index 7122e160e27..d52922c39f4 100644 --- a/Userland/Applications/Spreadsheet/JSIntegration.h +++ b/Userland/Applications/Spreadsheet/JSIntegration.h @@ -14,7 +14,7 @@ namespace Spreadsheet { struct FunctionAndArgumentIndex { - DeprecatedString function_name; + ByteString function_name; size_t argument_index { 0 }; }; Optional get_function_and_argument_index(StringView source); diff --git a/Userland/Applications/Spreadsheet/Position.h b/Userland/Applications/Spreadsheet/Position.h index f798640a121..2c7d4feae0f 100644 --- a/Userland/Applications/Spreadsheet/Position.h +++ b/Userland/Applications/Spreadsheet/Position.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -37,7 +37,7 @@ struct Position { return row == other.row && column == other.column; } - DeprecatedString to_cell_identifier(Sheet const& sheet) const; + ByteString to_cell_identifier(Sheet const& sheet) const; URL to_url(Sheet const& sheet) const; size_t column { 0 }; diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.cpp b/Userland/Applications/Spreadsheet/Readers/XSV.cpp index 92e692f654f..9b8289cbd76 100644 --- a/Userland/Applications/Spreadsheet/Readers/XSV.cpp +++ b/Userland/Applications/Spreadsheet/Readers/XSV.cpp @@ -25,9 +25,9 @@ void XSV::set_error(ReadError error) m_error = error; } -Vector XSV::headers() const +Vector XSV::headers() const { - Vector headers; + Vector headers; if (has_explicit_headers()) { for (auto& field : m_names) headers.append(field.is_string_view ? field.as_string_view : field.as_string.view()); @@ -37,7 +37,7 @@ Vector XSV::headers() const return headers; for ([[maybe_unused]] auto& field : m_rows.first()) - headers.append(DeprecatedString::empty()); + headers.append(ByteString::empty()); } return headers; @@ -240,7 +240,7 @@ XSV::Field XSV::read_one_quoted_field() set_error(ReadError::QuoteFailure); if (is_copy) - return { {}, builder.to_deprecated_string(), false }; + return { {}, builder.to_byte_string(), false }; return { m_source.substring_view(start, end - start), {}, true }; } diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.h b/Userland/Applications/Spreadsheet/Readers/XSV.h index 31d08865a31..7dc3c275fd6 100644 --- a/Userland/Applications/Spreadsheet/Readers/XSV.h +++ b/Userland/Applications/Spreadsheet/Readers/XSV.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -31,8 +31,8 @@ ParserBehavior operator&(ParserBehavior left, ParserBehavior right); ParserBehavior operator|(ParserBehavior left, ParserBehavior right); struct ParserTraits { - DeprecatedString separator; - DeprecatedString quote { "\"" }; + ByteString separator; + ByteString quote { "\"" }; enum QuoteEscape { Repeat, Backslash, @@ -73,7 +73,7 @@ public: void parse(); bool has_error() const { return m_error != ReadError::None; } ReadError error() const { return m_error; } - DeprecatedString error_string() const + ByteString error_string() const { switch (m_error) { #define E(x, y) \ @@ -87,7 +87,7 @@ public: } size_t size() const { return m_rows.size(); } - Vector headers() const; + Vector headers() const; [[nodiscard]] bool has_explicit_headers() const { return (static_cast(m_behaviors) & static_cast(ParserBehavior::ReadHeaders)) != 0; } class Row { @@ -185,7 +185,7 @@ public: private: struct Field { StringView as_string_view; - DeprecatedString as_string; // This member only used if the parser couldn't use the original source verbatim. + ByteString as_string; // This member only used if the parser couldn't use the original source verbatim. bool is_string_view { true }; bool operator==(StringView other) const diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 71680df5953..fceeeee9d23 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -61,7 +61,7 @@ Sheet::Sheet(Workbook& workbook) warnln("Spreadsheet: Failed to parse runtime code"); for (auto& error : script_or_error.error()) { // FIXME: This doesn't print hints anymore - warnln("SyntaxError: {}", error.to_deprecated_string()); + warnln("SyntaxError: {}", error.to_byte_string()); } } else { auto result = vm.bytecode_interpreter().run(script_or_error.value()); @@ -109,9 +109,9 @@ static Optional convert_from_string(StringView str, unsigned base = 26, return value - 1; } -DeprecatedString Sheet::add_column() +ByteString Sheet::add_column() { - auto next_column = DeprecatedString::bijective_base_from(m_columns.size()); + auto next_column = ByteString::bijective_base_from(m_columns.size()); m_columns.append(next_column); return next_column; } @@ -224,7 +224,7 @@ Optional Sheet::column_index(StringView column_name) const return index; } -Optional Sheet::column_arithmetic(StringView column_name, int offset) +Optional Sheet::column_arithmetic(StringView column_name, int offset) { auto maybe_index = column_index(column_name); if (!maybe_index.has_value()) @@ -255,17 +255,17 @@ Cell* Sheet::from_url(const URL& url) Optional Sheet::position_from_url(const URL& url) const { if (!url.is_valid()) { - dbgln("Invalid url: {}", url.to_deprecated_string()); + dbgln("Invalid url: {}", url.to_byte_string()); return {}; } if (url.scheme() != "spreadsheet" || url.host() != "cell"_string) { - dbgln("Bad url: {}", url.to_deprecated_string()); + dbgln("Bad url: {}", url.to_byte_string()); return {}; } // FIXME: Figure out a way to do this cross-process. - VERIFY(url.serialize_path() == DeprecatedString::formatted("/{}", getpid())); + VERIFY(url.serialize_path() == ByteString::formatted("/{}", getpid())); return parse_cell_name(url.fragment().value_or(String {})); } @@ -372,7 +372,7 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) auto sheet = adopt_ref(*new Sheet(workbook)); auto rows = object.get_u32("rows"sv).value_or(default_row_count); auto columns = object.get_array("columns"sv); - auto name = object.get_deprecated_string("name"sv).value_or("Sheet"); + auto name = object.get_byte_string("name"sv).value_or("Sheet"); if (object.has("cells"sv) && !object.has_object("cells"sv)) return {}; @@ -398,9 +398,9 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) auto& parse_function = json.as_object().get_without_side_effects("parse").as_function(); auto read_format = [](auto& format, auto const& obj) { - if (auto value = obj.get_deprecated_string("foreground_color"sv); value.has_value()) + if (auto value = obj.get_byte_string("foreground_color"sv); value.has_value()) format.foreground_color = Color::from_string(*value); - if (auto value = obj.get_deprecated_string("background_color"sv); value.has_value()) + if (auto value = obj.get_byte_string("background_color"sv); value.has_value()) format.background_color = Color::from_string(*value); }; @@ -412,26 +412,26 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) auto position = position_option.value(); auto& obj = value.as_object(); - auto kind = obj.get_deprecated_string("kind"sv).value_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula; + auto kind = obj.get_byte_string("kind"sv).value_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula; OwnPtr cell; switch (kind) { case Cell::LiteralString: - cell = make(obj.get_deprecated_string("value"sv).value_or({}), position, *sheet); + cell = make(obj.get_byte_string("value"sv).value_or({}), position, *sheet); break; case Cell::Formula: { auto& vm = sheet->vm(); - auto value_or_error = JS::call(vm, parse_function, json, JS::PrimitiveString::create(vm, obj.get_deprecated_string("value"sv).value_or({}))); + auto value_or_error = JS::call(vm, parse_function, json, JS::PrimitiveString::create(vm, obj.get_byte_string("value"sv).value_or({}))); if (value_or_error.is_error()) { warnln("Failed to load previous value for cell {}, leaving as undefined", position.to_cell_identifier(sheet)); value_or_error = JS::js_undefined(); } - cell = make(obj.get_deprecated_string("source"sv).value_or({}), value_or_error.release_value(), position, *sheet); + cell = make(obj.get_byte_string("source"sv).value_or({}), value_or_error.release_value(), position, *sheet); break; } } - auto type_name = obj.has("type"sv) ? obj.get_deprecated_string("type"sv).value_or({}) : "Numeric"; + auto type_name = obj.has("type"sv) ? obj.get_byte_string("type"sv).value_or({}) : "Numeric"; cell->set_type(type_name); auto type_meta = obj.get_object("type_metadata"sv); @@ -440,9 +440,9 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) auto meta = cell->type_metadata(); if (auto value = meta_obj.get_i32("length"sv); value.has_value()) meta.length = value.value(); - if (auto value = meta_obj.get_deprecated_string("format"sv); value.has_value()) + if (auto value = meta_obj.get_byte_string("format"sv); value.has_value()) meta.format = value.value(); - if (auto value = meta_obj.get_deprecated_string("alignment"sv); value.has_value()) { + if (auto value = meta_obj.get_byte_string("alignment"sv); value.has_value()) { auto alignment = Gfx::text_alignment_from_string(*value); if (alignment.has_value()) meta.alignment = alignment.value(); @@ -460,7 +460,7 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) return IterationDecision::Continue; auto& fmt_obj = fmt_val.as_object(); - auto fmt_cond = fmt_obj.get_deprecated_string("condition"sv).value_or({}); + auto fmt_cond = fmt_obj.get_byte_string("condition"sv).value_or({}); if (fmt_cond.is_empty()) return IterationDecision::Continue; @@ -513,7 +513,7 @@ Position Sheet::written_data_bounds(Optional column_index) const bool Sheet::columns_are_standard() const { for (size_t i = 0; i < m_columns.size(); ++i) { - if (m_columns[i] != DeprecatedString::bijective_base_from(i)) + if (m_columns[i] != ByteString::bijective_base_from(i)) return false; } @@ -527,9 +527,9 @@ JsonObject Sheet::to_json() const auto save_format = [](auto const& format, auto& obj) { if (format.foreground_color.has_value()) - obj.set("foreground_color", format.foreground_color.value().to_deprecated_string()); + obj.set("foreground_color", format.foreground_color.value().to_byte_string()); if (format.background_color.has_value()) - obj.set("background_color", format.background_color.value().to_deprecated_string()); + obj.set("background_color", format.background_color.value().to_byte_string()); }; auto bottom_right = written_data_bounds(); @@ -547,7 +547,7 @@ JsonObject Sheet::to_json() const StringBuilder builder; builder.append(column(it.key.column)); builder.appendff("{}", it.key.row); - auto key = builder.to_deprecated_string(); + auto key = builder.to_byte_string(); JsonObject data; data.set("kind", it.value->kind() == Cell::Kind::Formula ? "Formula" : "LiteralString"); @@ -556,7 +556,7 @@ JsonObject Sheet::to_json() const auto json = realm().global_object().get_without_side_effects("JSON"); auto stringified_or_error = JS::call(vm(), json.as_object().get_without_side_effects("stringify").as_function(), json, it.value->evaluated_data()); VERIFY(!stringified_or_error.is_error()); - data.set("value", stringified_or_error.release_value().to_string_without_side_effects().to_deprecated_string()); + data.set("value", stringified_or_error.release_value().to_string_without_side_effects().to_byte_string()); } else { data.set("value", it.value->data()); } @@ -599,9 +599,9 @@ JsonObject Sheet::to_json() const return object; } -Vector> Sheet::to_xsv() const +Vector> Sheet::to_xsv() const { - Vector> data; + Vector> data; auto bottom_right = written_data_bounds(); @@ -609,7 +609,7 @@ Vector> Sheet::to_xsv() const size_t column_count = m_columns.size(); if (columns_are_standard()) { column_count = bottom_right.column + 1; - Vector cols; + Vector cols; for (size_t i = 0; i < column_count; ++i) cols.append(m_columns[i]); data.append(move(cols)); @@ -618,7 +618,7 @@ Vector> Sheet::to_xsv() const } for (size_t i = 0; i <= bottom_right.row; ++i) { - Vector row; + Vector row; row.resize(column_count); for (size_t j = 0; j < column_count; ++j) { auto cell = at({ j, i }); @@ -646,7 +646,7 @@ RefPtr Sheet::from_xsv(Reader::XSV const& xsv, Workbook& workbook) } else { sheet->m_columns.ensure_capacity(cols.size()); for (size_t i = 0; i < cols.size(); ++i) - sheet->m_columns.append(DeprecatedString::bijective_base_from(i)); + sheet->m_columns.append(ByteString::bijective_base_from(i)); } for (size_t i = 0; i < max(rows, Sheet::default_row_count); ++i) sheet->add_row(); @@ -706,7 +706,7 @@ JsonObject Sheet::gather_documentation() const return m_cached_documentation.value(); } -DeprecatedString Sheet::generate_inline_documentation_for(StringView function, size_t argument_index) +ByteString Sheet::generate_inline_documentation_for(StringView function, size_t argument_index) { if (!m_cached_documentation.has_value()) gather_documentation(); @@ -714,13 +714,13 @@ DeprecatedString Sheet::generate_inline_documentation_for(StringView function, s auto& docs = m_cached_documentation.value(); auto entry = docs.get_object(function); if (!entry.has_value()) - return DeprecatedString::formatted("{}(...???{})", function, argument_index); + return ByteString::formatted("{}(...???{})", function, argument_index); auto& entry_object = entry.value(); size_t argc = entry_object.get_integer("argc"sv).value_or(0); auto argnames_value = entry_object.get_array("argnames"sv); if (!argnames_value.has_value()) - return DeprecatedString::formatted("{}(...{}???{})", function, argc, argument_index); + return ByteString::formatted("{}(...{}???{})", function, argc, argument_index); auto& argnames = argnames_value.value(); StringBuilder builder; builder.appendff("{}(", function); @@ -731,7 +731,7 @@ DeprecatedString Sheet::generate_inline_documentation_for(StringView function, s builder.append('<'); else if (i >= argc) builder.append('['); - builder.append(argnames[i].to_deprecated_string()); + builder.append(argnames[i].to_byte_string()); if (i == argument_index) builder.append('>'); else if (i >= argc) @@ -739,12 +739,12 @@ DeprecatedString Sheet::generate_inline_documentation_for(StringView function, s } builder.append(')'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString Position::to_cell_identifier(Sheet const& sheet) const +ByteString Position::to_cell_identifier(Sheet const& sheet) const { - return DeprecatedString::formatted("{}{}", sheet.column(column), row); + return ByteString::formatted("{}{}", sheet.column(column), row); } URL Position::to_url(Sheet const& sheet) const @@ -752,12 +752,12 @@ URL Position::to_url(Sheet const& sheet) const URL url; url.set_scheme("spreadsheet"_string); url.set_host("cell"_string); - url.set_paths({ DeprecatedString::number(getpid()) }); - url.set_fragment(String::from_deprecated_string(to_cell_identifier(sheet)).release_value()); + url.set_paths({ ByteString::number(getpid()) }); + url.set_fragment(String::from_byte_string(to_cell_identifier(sheet)).release_value()); return url; } -CellChange::CellChange(Cell& cell, DeprecatedString const& previous_data) +CellChange::CellChange(Cell& cell, ByteString const& previous_data) : m_cell(cell) , m_previous_data(previous_data) { diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.h b/Userland/Applications/Spreadsheet/Spreadsheet.h index 28e4bad61af..72d6a4fec31 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.h +++ b/Userland/Applications/Spreadsheet/Spreadsheet.h @@ -9,7 +9,7 @@ #include "Cell.h" #include "Forward.h" #include "Readers/XSV.h" -#include +#include #include #include #include @@ -23,7 +23,7 @@ namespace Spreadsheet { class CellChange { public: - CellChange(Cell&, DeprecatedString const&); + CellChange(Cell&, ByteString const&); CellChange(Cell&, CellTypeMetadata const&); auto& cell() { return m_cell; } @@ -34,8 +34,8 @@ public: private: Cell& m_cell; - DeprecatedString m_previous_data; - DeprecatedString m_new_data; + ByteString m_previous_data; + ByteString m_new_data; CellTypeMetadata m_previous_type_metadata; CellTypeMetadata m_new_type_metadata; }; @@ -51,7 +51,7 @@ public: Optional parse_cell_name(StringView) const; Optional column_index(StringView column_name) const; - Optional column_arithmetic(StringView column_name, int offset); + Optional column_arithmetic(StringView column_name, int offset); Cell* from_url(const URL&); Cell const* from_url(const URL& url) const { return const_cast(this)->from_url(url); } @@ -64,10 +64,10 @@ public: JsonObject to_json() const; static RefPtr from_json(JsonObject const&, Workbook&); - Vector> to_xsv() const; + Vector> to_xsv() const; static RefPtr from_xsv(Reader::XSV const&, Workbook&); - DeprecatedString const& name() const { return m_name; } + ByteString const& name() const { return m_name; } void set_name(StringView name) { m_name = name; } JsonObject gather_documentation() const; @@ -89,17 +89,17 @@ public: if (auto cell = at(position)) return *cell; - m_cells.set(position, make(DeprecatedString::empty(), position, *this)); + m_cells.set(position, make(ByteString::empty(), position, *this)); return *at(position); } size_t add_row(); - DeprecatedString add_column(); + ByteString add_column(); size_t row_count() const { return m_rows; } size_t column_count() const { return m_columns.size(); } - Vector const& columns() const { return m_columns; } - DeprecatedString const& column(size_t index) + Vector const& columns() const { return m_columns; } + ByteString const& column(size_t index) { for (size_t i = column_count(); i < index; ++i) add_column(); @@ -107,7 +107,7 @@ public: VERIFY(column_count() > index); return m_columns[index]; } - DeprecatedString const& column(size_t index) const + ByteString const& column(size_t index) const { VERIFY(column_count() > index); return m_columns[index]; @@ -145,7 +145,7 @@ public: bool columns_are_standard() const; - DeprecatedString generate_inline_documentation_for(StringView function, size_t argument_index); + ByteString generate_inline_documentation_for(StringView function, size_t argument_index); JS::Realm& realm() const { return *m_root_execution_context->realm; } JS::VM& vm() const { return realm().vm(); } @@ -154,8 +154,8 @@ private: explicit Sheet(Workbook&); explicit Sheet(StringView name, Workbook&); - DeprecatedString m_name; - Vector m_columns; + ByteString m_name; + Vector m_columns; size_t m_rows { 0 }; HashMap> m_cells; HashTable m_selected_cells; diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index b7e330cdcbc..f1c17af961d 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -21,9 +21,9 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) if (role == GUI::ModelRole::Display) { auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); if (!cell) - return DeprecatedString::empty(); + return ByteString::empty(); - Function to_deprecated_string_as_exception = [&](JS::Value value) { + Function to_byte_string_as_exception = [&](JS::Value value) { auto& vm = cell->sheet().global_object().vm(); StringBuilder builder; builder.append("Error: "sv); @@ -31,37 +31,37 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) auto& object = value.as_object(); if (is(object)) { auto message = object.get_without_side_effects("message"); - auto error = message.to_deprecated_string(vm); + auto error = message.to_byte_string(vm); if (error.is_throw_completion()) builder.append(message.to_string_without_side_effects()); else builder.append(error.release_value()); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } - auto error_message = value.to_deprecated_string(vm); + auto error_message = value.to_byte_string(vm); if (error_message.is_throw_completion()) - return to_deprecated_string_as_exception(*error_message.release_error().value()); + return to_byte_string_as_exception(*error_message.release_error().value()); builder.append(error_message.release_value()); - return builder.to_deprecated_string(); + return builder.to_byte_string(); }; if (cell->kind() == Spreadsheet::Cell::Formula) { if (auto opt_throw_value = cell->thrown_value(); opt_throw_value.has_value()) - return to_deprecated_string_as_exception(*opt_throw_value); + return to_byte_string_as_exception(*opt_throw_value); } auto display = cell->typed_display(); if (display.is_error()) - return to_deprecated_string_as_exception(*display.release_error().value()); + return to_byte_string_as_exception(*display.release_error().value()); return display.release_value(); } if (role == GUI::ModelRole::MimeData) - return Position { (size_t)index.column(), (size_t)index.row() }.to_url(m_sheet).to_deprecated_string(); + return Position { (size_t)index.column(), (size_t)index.row() }.to_url(m_sheet).to_byte_string(); if (role == GUI::ModelRole::TextAlignment) { auto const* cell = m_sheet->at({ (size_t)index.column(), (size_t)index.row() }); @@ -131,7 +131,7 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) builder.appendff(" in cell '{}', at line {}, column {}\n", frame.source_range().filename().substring_view(5), frame.source_range().start.line, frame.source_range().start.column); } } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } return {}; @@ -154,8 +154,8 @@ RefPtr SheetModel::mime_data(const GUI::ModelSelection& selectio Position cursor_position { (size_t)cursor->column(), (size_t)cursor->row() }; auto mime_data_buffer = mime_data->data("text/x-spreadsheet-data"sv); - auto new_data = DeprecatedString::formatted("{}\n{}", - cursor_position.to_url(m_sheet).to_deprecated_string(), + auto new_data = ByteString::formatted("{}\n{}", + cursor_position.to_url(m_sheet).to_byte_string(), StringView(mime_data_buffer)); mime_data->set_data("text/x-spreadsheet-data"_string, new_data.to_byte_buffer()); @@ -167,7 +167,7 @@ ErrorOr SheetModel::column_name(int index) const if (index < 0) return String {}; - return TRY(String::from_deprecated_string(m_sheet->column(index))); + return TRY(String::from_byte_string(m_sheet->column(index))); } bool SheetModel::is_editable(const GUI::ModelIndex& index) const @@ -185,7 +185,7 @@ void SheetModel::set_data(const GUI::ModelIndex& index, const GUI::Variant& valu auto& cell = m_sheet->ensure({ (size_t)index.column(), (size_t)index.row() }); auto previous_data = cell.data(); - cell.set_data(value.to_deprecated_string()); + cell.set_data(value.to_byte_string()); if (on_cell_data_change) on_cell_data_change(cell, previous_data); did_update(UpdateFlag::DontInvalidateIndices); @@ -202,7 +202,7 @@ CellsUndoCommand::CellsUndoCommand(Vector cell_changes) m_cell_changes = cell_changes; } -CellsUndoCommand::CellsUndoCommand(Cell& cell, DeprecatedString const& previous_data) +CellsUndoCommand::CellsUndoCommand(Cell& cell, ByteString const& previous_data) { m_cell_changes.append(CellChange(cell, previous_data)); } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.h b/Userland/Applications/Spreadsheet/SpreadsheetModel.h index 9a876e23cce..49267320703 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.h @@ -34,7 +34,7 @@ public: void update(); - Function on_cell_data_change; + Function on_cell_data_change; Function)> on_cells_data_change; private: @@ -48,7 +48,7 @@ private: class CellsUndoCommand : public GUI::Command { public: - CellsUndoCommand(Cell&, DeprecatedString const&); + CellsUndoCommand(Cell&, ByteString const&); CellsUndoCommand(Vector); virtual void undo() override; diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index a9210ce9ab8..dd3855d27b1 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -80,7 +80,7 @@ void InfinitelyScrollableTableView::mousemove_event(GUI::MouseEvent& event) if (!is_dragging()) { auto tooltip = model->data(index, static_cast(SheetModel::Role::Tooltip)); if (tooltip.is_string()) { - set_tooltip(MUST(String::from_deprecated_string(tooltip.as_string()))); + set_tooltip(MUST(String::from_byte_string(tooltip.as_string()))); show_or_hide_tooltip(); } else { set_tooltip({}); @@ -495,7 +495,7 @@ void SpreadsheetView::TableCellPainter::paint(GUI::Painter& painter, Gfx::IntRec auto text_color = index.data(GUI::ModelRole::ForegroundColor).to_color(palette.color(m_table_view.foreground_role())); auto data = index.data(); auto text_alignment = index.data(GUI::ModelRole::TextAlignment).to_text_alignment(Gfx::TextAlignment::CenterRight); - painter.draw_text(rect, data.to_deprecated_string(), m_table_view.font_for_index(index), text_alignment, text_color, Gfx::TextElision::Right); + painter.draw_text(rect, data.to_byte_string(), m_table_view.font_for_index(index), text_alignment, text_color, Gfx::TextElision::Right); } } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index e88d52b5969..49293336155 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -99,7 +99,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vectorsheet_if_available(); VERIFY(sheet_ptr); // How did we get here without a sheet? auto& sheet = *sheet_ptr; - String new_name = String::from_deprecated_string(sheet.name()).release_value_but_fixme_should_propagate_errors(); + String new_name = String::from_byte_string(sheet.name()).release_value_but_fixme_should_propagate_errors(); if (GUI::InputBox::show(window(), new_name, {}, "Rename Sheet"sv, GUI::InputType::NonemptyText, "Name"sv) == GUI::Dialog::ExecResult::OK) { sheet.set_name(new_name); sheet.update(); @@ -166,7 +166,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, Vectorset_rect(m_cell_value_editor->screen_relative_rect().translated(0, m_cell_value_editor->height() + 7).inflated(6, 6)); } -void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mime_type) +void SpreadsheetWidget::clipboard_content_did_change(ByteString const& mime_type) { if (auto* sheet = current_worksheet_if_available()) m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"sv)); @@ -345,7 +345,7 @@ void SpreadsheetWidget::clipboard_content_did_change(DeprecatedString const& mim void SpreadsheetWidget::setup_tabs(Vector> new_sheets) { for (auto& sheet : new_sheets) { - auto& new_view = m_tab_widget->add_tab(String::from_deprecated_string(sheet->name()).release_value_but_fixme_should_propagate_errors(), sheet); + auto& new_view = m_tab_widget->add_tab(String::from_byte_string(sheet->name()).release_value_but_fixme_should_propagate_errors(), sheet); new_view.model()->on_cell_data_change = [&](auto& cell, auto& previous_data) { undo_stack().push(make(cell, previous_data)); window()->set_modified(true); @@ -372,7 +372,7 @@ void SpreadsheetWidget::setup_tabs(Vector> new_sheets) if (selection.size() == 1) { auto& position = selection.first(); - m_current_cell_label->set_text(String::from_deprecated_string(position.to_cell_identifier(sheet)).release_value_but_fixme_should_propagate_errors()); + m_current_cell_label->set_text(String::from_byte_string(position.to_cell_identifier(sheet)).release_value_but_fixme_should_propagate_errors()); auto& cell = sheet.ensure(position); m_cell_value_editor->on_change = nullptr; @@ -467,7 +467,7 @@ void SpreadsheetWidget::try_generate_tip_for_input_expression(StringView source, if (text.is_empty()) { m_inline_documentation_window->hide(); } else { - m_inline_documentation_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors()); + m_inline_documentation_label->set_text(String::from_byte_string(text).release_value_but_fixme_should_propagate_errors()); m_inline_documentation_window->show(); } } @@ -564,7 +564,7 @@ void SpreadsheetWidget::save(String const& filename, Core::File& file) { auto result = m_workbook->write_to_file(filename, file); if (result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Cannot save file: {}", result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Cannot save file: {}", result.error())); return; } undo_stack().set_current_unmodified(); @@ -666,7 +666,7 @@ void SpreadsheetWidget::update_window_title() builder.append(current_filename()); builder.append("[*] - Spreadsheet"sv); - window()->set_title(builder.to_deprecated_string()); + window()->set_title(builder.to_byte_string()); } void SpreadsheetWidget::clipboard_action(bool is_cut) @@ -689,17 +689,17 @@ void SpreadsheetWidget::clipboard_action(bool is_cut) auto cursor = current_selection_cursor(); if (cursor) { Spreadsheet::Position position { (size_t)cursor->column(), (size_t)cursor->row() }; - url_builder.append(position.to_url(worksheet).to_deprecated_string()); + url_builder.append(position.to_url(worksheet).to_byte_string()); url_builder.append('\n'); } for (auto& cell : cells) { if (first && !cursor) { - url_builder.append(cell.to_url(worksheet).to_deprecated_string()); + url_builder.append(cell.to_url(worksheet).to_byte_string()); url_builder.append('\n'); } - url_builder.append(cell.to_url(worksheet).to_deprecated_string()); + url_builder.append(cell.to_url(worksheet).to_byte_string()); url_builder.append('\n'); auto cell_data = worksheet.at(cell); @@ -709,9 +709,9 @@ void SpreadsheetWidget::clipboard_action(bool is_cut) text_builder.append(cell_data->data()); first = false; } - HashMap metadata; - metadata.set("text/x-spreadsheet-data", url_builder.to_deprecated_string()); - dbgln(url_builder.to_deprecated_string()); + HashMap metadata; + metadata.set("text/x-spreadsheet-data", url_builder.to_byte_string()); + dbgln(url_builder.to_byte_string()); GUI::Clipboard::the().set_data(text_builder.string_view().bytes(), "text/plain", move(metadata)); } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h index 856789c8af9..d99ac857d28 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.h @@ -29,7 +29,7 @@ public: void add_sheet(); void add_sheet(NonnullRefPtr&&); - DeprecatedString const& current_filename() const { return m_workbook->current_filename(); } + ByteString const& current_filename() const { return m_workbook->current_filename(); } SpreadsheetView* current_view() { return static_cast(m_tab_widget->active_widget()); } Sheet* current_worksheet_if_available() { return current_view() ? current_view()->sheet_if_available() : nullptr; } void update_window_title(); @@ -57,7 +57,7 @@ private: virtual void resize_event(GUI::ResizeEvent&) override; // ^GUI::Clipboard::ClipboardClient - virtual void clipboard_content_did_change(DeprecatedString const& mime_type) override; + virtual void clipboard_content_did_change(ByteString const& mime_type) override; explicit SpreadsheetWidget(GUI::Window& window, Vector>&& sheets = {}, bool should_add_sheet_if_empty = true); diff --git a/Userland/Applications/Spreadsheet/Workbook.cpp b/Userland/Applications/Spreadsheet/Workbook.cpp index 1706afd72ae..f2c8b40fe5a 100644 --- a/Userland/Applications/Spreadsheet/Workbook.cpp +++ b/Userland/Applications/Spreadsheet/Workbook.cpp @@ -41,7 +41,7 @@ Workbook::Workbook(Vector>&& sheets, GUI::Window& parent_wi m_vm->set_dynamic_imports_allowed(true); } -bool Workbook::set_filename(DeprecatedString const& filename) +bool Workbook::set_filename(ByteString const& filename) { if (m_current_filename == filename) return false; @@ -50,14 +50,14 @@ bool Workbook::set_filename(DeprecatedString const& filename) return true; } -ErrorOr Workbook::open_file(String const& filename, Core::File& file) +ErrorOr Workbook::open_file(String const& filename, Core::File& file) { auto mime = Core::guess_mime_type_based_on_filename(filename); // Make an import dialog, we might need to import it. m_sheets = TRY(ImportDialog::make_and_run_for(m_parent_window, mime, filename, file, *this)); - set_filename(filename.to_deprecated_string()); + set_filename(filename.to_byte_string()); return {}; } @@ -67,14 +67,14 @@ ErrorOr Workbook::write_to_file(String const& filename, Core::File& stream auto mime = Core::guess_mime_type_based_on_filename(filename); // Make an export dialog, we might need to import it. - TRY(ExportDialog::make_and_run_for(mime, stream, filename.to_deprecated_string(), *this)); + TRY(ExportDialog::make_and_run_for(mime, stream, filename.to_byte_string(), *this)); - set_filename(filename.to_deprecated_string()); + set_filename(filename.to_byte_string()); set_dirty(false); return {}; } -ErrorOr Workbook::import_file(String const& filename, Core::File& file) +ErrorOr Workbook::import_file(String const& filename, Core::File& file) { auto mime = Core::guess_mime_type_based_on_filename(filename); diff --git a/Userland/Applications/Spreadsheet/Workbook.h b/Userland/Applications/Spreadsheet/Workbook.h index 864eba764a6..70dbb47d97f 100644 --- a/Userland/Applications/Spreadsheet/Workbook.h +++ b/Userland/Applications/Spreadsheet/Workbook.h @@ -15,13 +15,13 @@ class Workbook { public: Workbook(Vector>&& sheets, GUI::Window& parent_window); - ErrorOr open_file(String const& filename, Core::File&); + ErrorOr open_file(String const& filename, Core::File&); ErrorOr write_to_file(String const& filename, Core::File&); - ErrorOr import_file(String const& filename, Core::File&); + ErrorOr import_file(String const& filename, Core::File&); - DeprecatedString const& current_filename() const { return m_current_filename; } - bool set_filename(DeprecatedString const& filename); + ByteString const& current_filename() const { return m_current_filename; } + bool set_filename(ByteString const& filename); bool dirty() { return m_dirty; } void set_dirty(bool dirty) { m_dirty = dirty; } @@ -50,7 +50,7 @@ private: NonnullOwnPtr m_main_execution_context; GUI::Window& m_parent_window; - DeprecatedString m_current_filename; + ByteString m_current_filename; bool m_dirty { false }; }; diff --git a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp index 8b09cf579d4..d57dc1768aa 100644 --- a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp +++ b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp @@ -52,7 +52,7 @@ TEST_CASE(can_write_with_header) TEST_CASE(can_write_with_different_behaviors) { - Vector> data = { + Vector> data = { { "Well", "Hello\"", "Friends" }, { "We\"ll", "Hello,", " Friends" }, }; diff --git a/Userland/Applications/Spreadsheet/Writers/XSV.h b/Userland/Applications/Spreadsheet/Writers/XSV.h index 2ea61a0e207..5b13b468a64 100644 --- a/Userland/Applications/Spreadsheet/Writers/XSV.h +++ b/Userland/Applications/Spreadsheet/Writers/XSV.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -26,8 +26,8 @@ enum class WriterBehavior : u32 { AK_ENUM_BITWISE_OPERATORS(WriterBehavior); struct WriterTraits { - DeprecatedString separator; - DeprecatedString quote { "\"" }; + ByteString separator; + ByteString quote { "\"" }; enum QuoteEscape { Repeat, Backslash, @@ -121,7 +121,7 @@ private: template ErrorOr write_entry(T&& entry) { - auto string = DeprecatedString::formatted("{}", FormatIfSupported(entry)); + auto string = ByteString::formatted("{}", FormatIfSupported(entry)); auto safe_to_write_normally = !has_flag(m_behaviors, WriterBehavior::QuoteAll) && !string.contains('\n') diff --git a/Userland/Applications/SystemMonitor/GraphWidget.h b/Userland/Applications/SystemMonitor/GraphWidget.h index e8831343703..67eeef3a98b 100644 --- a/Userland/Applications/SystemMonitor/GraphWidget.h +++ b/Userland/Applications/SystemMonitor/GraphWidget.h @@ -26,7 +26,7 @@ public: struct ValueFormat { Gfx::ColorRole graph_color_role { Gfx::ColorRole::Base }; Color text_shadow_color { Color::Transparent }; - Function text_formatter; + Function text_formatter; }; void set_value_format(size_t index, ValueFormat&& format) { diff --git a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp index 8d6c6246e6b..e5543b55f02 100644 --- a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -71,7 +71,7 @@ void MemoryStatsWidget::set_graph_widget(GraphWidget& graph) m_graph = &graph; } -void MemoryStatsWidget::set_graph_widget_via_name(DeprecatedString name) +void MemoryStatsWidget::set_graph_widget_via_name(ByteString name) { m_graph_widget_name = move(name); if (!m_graph_widget_name.is_empty()) { @@ -87,7 +87,7 @@ void MemoryStatsWidget::set_graph_widget_via_name(DeprecatedString name) } } -DeprecatedString MemoryStatsWidget::graph_widget_name() +ByteString MemoryStatsWidget::graph_widget_name() { if (m_graph) return m_graph->name(); diff --git a/Userland/Applications/SystemMonitor/MemoryStatsWidget.h b/Userland/Applications/SystemMonitor/MemoryStatsWidget.h index 3305aaf0d8d..52d67f8ab3a 100644 --- a/Userland/Applications/SystemMonitor/MemoryStatsWidget.h +++ b/Userland/Applications/SystemMonitor/MemoryStatsWidget.h @@ -22,8 +22,8 @@ public: void set_graph_widget(GraphWidget& graph); - void set_graph_widget_via_name(DeprecatedString name); - DeprecatedString graph_widget_name(); + void set_graph_widget_via_name(ByteString name); + ByteString graph_widget_name(); void refresh(); @@ -33,7 +33,7 @@ private: GraphWidget* m_graph; // Is null if we have a valid graph - DeprecatedString m_graph_widget_name {}; + ByteString m_graph_widget_name {}; RefPtr m_physical_pages_label; RefPtr m_physical_pages_committed_label; RefPtr m_kmalloc_space_label; diff --git a/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp index bb42d61450f..bfdf4dcd353 100644 --- a/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp +++ b/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp @@ -48,22 +48,22 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() if (!object.get_bool("link_up"sv).value_or(false)) return *m_network_link_down_bitmap; else - return object.get_deprecated_string("ipv4_address"sv).value_or("").is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap; + return object.get_byte_string("ipv4_address"sv).value_or("").is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap; }); net_adapters_fields.empend("name", "Name"_string, Gfx::TextAlignment::CenterLeft); net_adapters_fields.empend("class_name", "Class"_string, Gfx::TextAlignment::CenterLeft); net_adapters_fields.empend("mac_address", "MAC"_string, Gfx::TextAlignment::CenterLeft); net_adapters_fields.empend("Link status"_string, Gfx::TextAlignment::CenterLeft, - [](JsonObject const& object) -> DeprecatedString { + [](JsonObject const& object) -> ByteString { if (!object.get_bool("link_up"sv).value_or(false)) return "Down"; - return DeprecatedString::formatted("{} Mb/s {}-duplex", object.get_i32("link_speed"sv).value_or(0), + return ByteString::formatted("{} Mb/s {}-duplex", object.get_i32("link_speed"sv).value_or(0), object.get_bool("link_full_duplex"sv).value_or(false) ? "full"sv : "half"sv); }); net_adapters_fields.empend("IPv4"_string, Gfx::TextAlignment::CenterLeft, - [](JsonObject const& object) -> DeprecatedString { - return object.get_deprecated_string("ipv4_address"sv).value_or(""sv); + [](JsonObject const& object) -> ByteString { + return object.get_byte_string("ipv4_address"sv).value_or(""sv); }); net_adapters_fields.empend("packets_in", "Pkt In"_string, Gfx::TextAlignment::CenterRight); net_adapters_fields.empend("packets_out", "Pkt Out"_string, Gfx::TextAlignment::CenterRight); diff --git a/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp b/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp index 7d50edc8d13..162d9b13d53 100644 --- a/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp @@ -53,7 +53,7 @@ void ProcessFileDescriptorMapWidget::set_pid(pid_t pid) if (m_pid == pid) return; m_pid = pid; - m_model->set_json_path(DeprecatedString::formatted("/proc/{}/fds", m_pid)); + m_model->set_json_path(ByteString::formatted("/proc/{}/fds", m_pid)); } } diff --git a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index d787760df7d..1e4bd47addc 100644 --- a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -25,7 +25,7 @@ public: virtual void paint(GUI::Painter& painter, Gfx::IntRect const& a_rect, Gfx::Palette const&, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); - auto pagemap = index.data(GUI::ModelRole::Custom).to_deprecated_string(); + auto pagemap = index.data(GUI::ModelRole::Custom).to_byte_string(); float scale_factor = (float)pagemap.length() / (float)rect.width(); @@ -58,7 +58,7 @@ ErrorOr> ProcessMemoryMapWidget::try_creat Vector pid_vm_fields; TRY(pid_vm_fields.try_empend( "Address"_string, Gfx::TextAlignment::CenterLeft, - [](auto& object) { return DeprecatedString::formatted("{:p}", object.get_u64("address"sv).value_or(0)); }, + [](auto& object) { return ByteString::formatted("{:p}", object.get_u64("address"sv).value_or(0)); }, [](auto& object) { return object.get_u64("address"sv).value_or(0); })); TRY(pid_vm_fields.try_empend("size", "Size"_string, Gfx::TextAlignment::CenterRight)); TRY(pid_vm_fields.try_empend("amount_resident", "Resident"_string, Gfx::TextAlignment::CenterRight)); @@ -77,10 +77,10 @@ ErrorOr> ProcessMemoryMapWidget::try_creat builder.append('C'); if (object.get_bool("stack"sv).value_or(false)) builder.append('T'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); })); TRY(pid_vm_fields.try_empend("VMObject type"_string, Gfx::TextAlignment::CenterLeft, [](auto& object) { - auto type = object.get_deprecated_string("vmobject"sv).value_or({}); + auto type = object.get_byte_string("vmobject"sv).value_or({}); if (type.ends_with("VMObject"sv)) type = type.substring(0, type.length() - 8); return type; @@ -99,7 +99,7 @@ ErrorOr> ProcessMemoryMapWidget::try_creat return GUI::Variant(0); }, [](JsonObject const& object) { - auto pagemap = object.get_deprecated_string("pagemap"sv).value_or({}); + auto pagemap = object.get_byte_string("pagemap"sv).value_or({}); return pagemap; })); TRY(pid_vm_fields.try_empend("cow_pages", "# CoW"_string, Gfx::TextAlignment::CenterRight)); @@ -121,7 +121,7 @@ void ProcessMemoryMapWidget::set_pid(pid_t pid) if (m_pid == pid) return; m_pid = pid; - m_json_model->set_json_path(DeprecatedString::formatted("/proc/{}/vm", pid)); + m_json_model->set_json_path(ByteString::formatted("/proc/{}/vm", pid)); } void ProcessMemoryMapWidget::refresh() diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp index 45a5bc8055b..ea2dc96b69f 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.cpp +++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp @@ -288,12 +288,12 @@ GUI::Variant ProcessModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol case Column::PurgeableNonvolatile: return human_readable_size(thread.current_state.amount_purgeable_nonvolatile); case Column::CPU: - return DeprecatedString::formatted("{:.2}", thread.current_state.cpu_percent); + return ByteString::formatted("{:.2}", thread.current_state.cpu_percent); case Column::Processor: return thread.current_state.cpu; case Column::Name: if (thread.current_state.kernel) - return DeprecatedString::formatted("{} (*)", thread.current_state.name); + return ByteString::formatted("{} (*)", thread.current_state.name); return thread.current_state.name; case Column::Command: return thread.current_state.command.visit([](String const& cmdline) { return cmdline; }, [](auto const&) { return ""_string; }); diff --git a/Userland/Applications/SystemMonitor/ProcessModel.h b/Userland/Applications/SystemMonitor/ProcessModel.h index 9f6a9f9d7f1..f6c95f1ad73 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.h +++ b/Userland/Applications/SystemMonitor/ProcessModel.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -110,14 +110,14 @@ private: u64 time_user { 0 }; u64 time_kernel { 0 }; bool kernel { false }; - DeprecatedString executable { "" }; - DeprecatedString name { "" }; + ByteString executable { "" }; + ByteString name { "" }; Variant command { EmptyCommand::NotInitialized }; uid_t uid { 0 }; - DeprecatedString state { "" }; - DeprecatedString user { "" }; - DeprecatedString pledge { "" }; - DeprecatedString veil { "" }; + ByteString state { "" }; + ByteString user { "" }; + ByteString pledge { "" }; + ByteString veil { "" }; u32 cpu { 0 }; u32 priority { 0 }; size_t amount_virtual { 0 }; diff --git a/Userland/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp b/Userland/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp index bef2f50fdd4..8ffe69514a5 100644 --- a/Userland/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp @@ -36,7 +36,7 @@ void ProcessUnveiledPathsWidget::set_pid(pid_t pid) if (m_pid == pid) return; m_pid = pid; - m_model->set_json_path(DeprecatedString::formatted("/proc/{}/unveil", m_pid)); + m_model->set_json_path(ByteString::formatted("/proc/{}/unveil", m_pid)); } } diff --git a/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp b/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp index 4e3c2210c84..9df72c865b9 100644 --- a/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp +++ b/Userland/Applications/SystemMonitor/ThreadStackWidget.cpp @@ -49,7 +49,7 @@ public: auto& symbol = m_symbols[model_index.row()]; switch (model_index.column()) { case Column::Address: - return DeprecatedString::formatted("{:p}", symbol.address); + return ByteString::formatted("{:p}", symbol.address); case Column::Object: return symbol.object; case Column::Symbol: diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index c39b89952b7..16835ab1d6f 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -75,7 +75,7 @@ public: auto percentage = index.data(GUI::ModelRole::Custom).to_i32(); auto data = index.data(); - DeprecatedString text; + ByteString text; if (data.is_string()) text = data.as_string(); Gfx::StylePainter::paint_progressbar(painter, rect, palette, 0, 100, percentage, text); @@ -133,7 +133,7 @@ public: size_builder.append(' '); size_builder.append(human_readable_size(object.get_u64("total_block_count"sv).value_or(0) * object.get_u64("block_size"sv).value_or(0))); size_builder.append(' '); - return size_builder.to_deprecated_string(); + return size_builder.to_byte_string(); }, [](JsonObject const& object) { return object.get_u64("total_block_count"sv).value_or(0) * object.get_u64("block_size"sv).value_or(0); @@ -194,8 +194,8 @@ public: check(MS_AXALLOWED, "axallowed"sv); check(MS_NOREGULAR, "noregular"sv); if (builder.string_view().is_empty()) - return DeprecatedString("defaults"); - return builder.to_deprecated_string(); + return ByteString("defaults"); + return builder.to_byte_string(); }); df_fields.empend("free_block_count", "Free blocks"_string, Gfx::TextAlignment::CenterRight); df_fields.empend("total_block_count", "Total blocks"_string, Gfx::TextAlignment::CenterRight); @@ -342,11 +342,11 @@ ErrorOr serenity_main(Main::Arguments arguments) return pid_index.data().to_i32(); }; - auto selected_name = [&](ProcessModel::Column column) -> DeprecatedString { + auto selected_name = [&](ProcessModel::Column column) -> ByteString { if (process_table_view.selection().is_empty()) return {}; auto pid_index = process_table_view.model()->index(process_table_view.selection().first().row(), column, process_table_view.selection().first().parent()); - return pid_index.data().to_deprecated_string(); + return pid_index.data().to_byte_string(); }; auto kill_action = GUI::Action::create( @@ -354,7 +354,7 @@ ErrorOr serenity_main(Main::Arguments arguments) pid_t pid = selected_id(ProcessModel::Column::PID); if (pid == -1) return; - auto rc = GUI::MessageBox::show(window, DeprecatedString::formatted("Do you really want to kill \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto rc = GUI::MessageBox::show(window, ByteString::formatted("Do you really want to kill \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (rc == GUI::Dialog::ExecResult::Yes) kill(pid, SIGKILL); }, @@ -365,7 +365,7 @@ ErrorOr serenity_main(Main::Arguments arguments) pid_t pid = selected_id(ProcessModel::Column::PID); if (pid == -1) return; - auto rc = GUI::MessageBox::show(window, DeprecatedString::formatted("Do you really want to stop \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto rc = GUI::MessageBox::show(window, ByteString::formatted("Do you really want to stop \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (rc == GUI::Dialog::ExecResult::Yes) kill(pid, SIGSTOP); }, @@ -385,7 +385,7 @@ ErrorOr serenity_main(Main::Arguments arguments) pid_t pid = selected_id(ProcessModel::Column::PID); if (pid == -1) return; - auto pid_string = DeprecatedString::number(pid); + auto pid_string = ByteString::number(pid); GUI::Process::spawn_or_show_error(window, "/bin/Profiler"sv, Array { "--pid", pid_string.characters() }); }, &process_table_view); @@ -395,7 +395,7 @@ ErrorOr serenity_main(Main::Arguments arguments) pid_t pid = selected_id(ProcessModel::Column::PID); if (pid == -1) return; - auto pid_string = DeprecatedString::number(pid); + auto pid_string = ByteString::number(pid); GUI::Process::spawn_or_show_error(window, "/bin/HackStudio"sv, Array { "--pid", pid_string.characters() }); }, &process_table_view); @@ -452,7 +452,7 @@ ErrorOr serenity_main(Main::Arguments arguments) frequency_action_group.set_exclusive(true); auto make_frequency_action = [&](int seconds) -> ErrorOr { - auto action = GUI::Action::create_checkable(DeprecatedString::formatted("&{} Sec", seconds), [&refresh_timer, seconds](auto&) { + auto action = GUI::Action::create_checkable(ByteString::formatted("&{} Sec", seconds), [&refresh_timer, seconds](auto&) { Config::write_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, seconds); refresh_timer.restart(seconds * 1000); }); @@ -526,7 +526,7 @@ ErrorOr> build_process_window(pid_t pid) { auto window = GUI::Window::construct(); window->resize(480, 360); - window->set_title(DeprecatedString::formatted("PID {} - System Monitor", pid)); + window->set_title(ByteString::formatted("PID {} - System Monitor", pid)); auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-system-monitor"sv)); window->set_icon(app_icon.bitmap_for_size(16)); @@ -548,7 +548,7 @@ ErrorOr> build_process_window(pid_t pid) main_widget->find_descendant_of_type_named("process_icon")->set_bitmap(icon_data.as_icon().bitmap_for_size(32)); } - main_widget->find_descendant_of_type_named("process_name")->set_text(TRY(String::formatted("{} (PID {})", process_index.sibling_at_column(ProcessModel::Column::Name).data().to_deprecated_string(), pid))); + main_widget->find_descendant_of_type_named("process_name")->set_text(TRY(String::formatted("{} (PID {})", process_index.sibling_at_column(ProcessModel::Column::Name).data().to_byte_string(), pid))); main_widget->find_descendant_of_type_named("process_state")->set_pid(pid); main_widget->find_descendant_of_type_named("open_files")->set_pid(pid); @@ -587,13 +587,13 @@ ErrorOr build_performance_tab(GUI::Widget& graphs_container) cpu_graph.set_value_format(0, { .graph_color_role = ColorRole::SyntaxPreprocessorStatement, .text_formatter = [](u64 value) { - return DeprecatedString::formatted("Total: {}%", value); + return ByteString::formatted("Total: {}%", value); }, }); cpu_graph.set_value_format(1, { .graph_color_role = ColorRole::SyntaxPreprocessorValue, .text_formatter = [](u64 value) { - return DeprecatedString::formatted("Kernel: {}%", value); + return ByteString::formatted("Kernel: {}%", value); }, }); cpu_graphs.append(cpu_graph); @@ -613,19 +613,19 @@ ErrorOr build_performance_tab(GUI::Widget& graphs_container) memory_graph.set_value_format(0, { .graph_color_role = ColorRole::SyntaxComment, .text_formatter = [](u64 bytes) { - return DeprecatedString::formatted("Committed: {}", human_readable_size(bytes)); + return ByteString::formatted("Committed: {}", human_readable_size(bytes)); }, }); memory_graph.set_value_format(1, { .graph_color_role = ColorRole::SyntaxPreprocessorStatement, .text_formatter = [](u64 bytes) { - return DeprecatedString::formatted("Allocated: {}", human_readable_size(bytes)); + return ByteString::formatted("Allocated: {}", human_readable_size(bytes)); }, }); memory_graph.set_value_format(2, { .graph_color_role = ColorRole::SyntaxPreprocessorValue, .text_formatter = [](u64 bytes) { - return DeprecatedString::formatted("Kernel heap: {}", human_readable_size(bytes)); + return ByteString::formatted("Kernel heap: {}", human_readable_size(bytes)); }, }); return {}; diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index e3431431623..58b7f947c70 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -139,7 +139,7 @@ static ErrorOr utmp_update(StringView tty, pid_t pid, bool create) static ErrorOr run_command(StringView command, bool keep_open) { - auto shell = TRY(String::from_deprecated_string(TRY(Core::Account::self(Core::Account::Read::PasswdOnly)).shell())); + auto shell = TRY(String::from_byte_string(TRY(Core::Account::self(Core::Account::Read::PasswdOnly)).shell())); if (shell.is_empty()) shell = "/bin/Shell"_string; diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp index 13480df6423..bcfb6404c69 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp @@ -236,7 +236,7 @@ VT::TerminalWidget::BellMode TerminalSettingsMainWidget::parse_bell(StringView b VERIFY_NOT_REACHED(); } -DeprecatedString TerminalSettingsMainWidget::stringify_bell(VT::TerminalWidget::BellMode bell_mode) +ByteString TerminalSettingsMainWidget::stringify_bell(VT::TerminalWidget::BellMode bell_mode) { if (bell_mode == VT::TerminalWidget::BellMode::AudibleBeep) return "AudibleBeep"; diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h index e752f72bf01..df0be97d1ce 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.h @@ -27,7 +27,7 @@ private: void write_back_settings() const; static VT::TerminalWidget::BellMode parse_bell(StringView bell_string); - static DeprecatedString stringify_bell(VT::TerminalWidget::BellMode bell_mode); + static ByteString stringify_bell(VT::TerminalWidget::BellMode bell_mode); VT::TerminalWidget::BellMode m_bell_mode { VT::TerminalWidget::BellMode::Disabled }; bool m_confirm_close { true }; @@ -51,7 +51,7 @@ private: RefPtr m_font; float m_opacity; - DeprecatedString m_color_scheme; + ByteString m_color_scheme; VT::CursorShape m_cursor_shape { VT::CursorShape::Block }; bool m_cursor_is_blinking_set { true }; size_t m_max_history_size; @@ -59,7 +59,7 @@ private: RefPtr m_original_font; float m_original_opacity; - DeprecatedString m_original_color_scheme; + ByteString m_original_color_scheme; VT::CursorShape m_original_cursor_shape; bool m_original_cursor_is_blinking_set; size_t m_original_max_history_size; diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index b256d6662db..e6d0adeeee0 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -127,7 +127,7 @@ MainWidget::MainWidget() m_editor->insert_at_cursor_or_replace_selection(substitute); } else { GUI::MessageBox::show(window(), - DeprecatedString::formatted("Not found: \"{}\"", needle), + ByteString::formatted("Not found: \"{}\"", needle), "Not found"sv, GUI::MessageBox::Type::Information); } @@ -152,7 +152,7 @@ MainWidget::MainWidget() } } else { GUI::MessageBox::show(window(), - DeprecatedString::formatted("Not found: \"{}\"", needle), + ByteString::formatted("Not found: \"{}\"", needle), "Not found"sv, GUI::MessageBox::Type::Information); } @@ -346,7 +346,7 @@ WebView::OutOfProcessWebView& MainWidget::ensure_web_view() m_page_view = web_view_container.add(); m_page_view->on_link_hover = [this](auto& url) { if (url.is_valid()) - m_statusbar->set_text(String::from_deprecated_string(url.to_deprecated_string()).release_value_but_fixme_should_propagate_errors()); + m_statusbar->set_text(String::from_byte_string(url.to_byte_string()).release_value_but_fixme_should_propagate_errors()); else update_statusbar(); }; @@ -354,7 +354,7 @@ WebView::OutOfProcessWebView& MainWidget::ensure_web_view() if (!Desktop::Launcher::open(url)) { GUI::MessageBox::show( window(), - DeprecatedString::formatted("The link to '{}' could not be opened.", url), + ByteString::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error); } @@ -791,7 +791,7 @@ void MainWidget::update_title() else builder.append(m_path); builder.append("[*] - Text Editor"sv); - window()->set_title(builder.to_deprecated_string()); + window()->set_title(builder.to_byte_string()); } ErrorOr MainWidget::read_file(String const& filename, Core::File& file) @@ -803,7 +803,7 @@ ErrorOr MainWidget::read_file(String const& filename, Core::File& file) return {}; } -void MainWidget::open_nonexistent_file(DeprecatedString const& path) +void MainWidget::open_nonexistent_file(ByteString const& path) { m_editor->set_text({}); set_path(path); @@ -928,11 +928,11 @@ void MainWidget::update_statusbar() StringBuilder builder; if (m_editor->has_selection()) { - DeprecatedString selected_text = m_editor->selected_text(); + ByteString selected_text = m_editor->selected_text(); auto word_count = m_editor->number_of_selected_words(); builder.appendff("{:'d} {} ({:'d} {}) selected", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word"); } else { - DeprecatedString text = m_editor->text(); + ByteString text = m_editor->text(); auto word_count = m_editor->number_of_words(); builder.appendff("{:'d} {} ({:'d} {})", text.length(), text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word"); } @@ -959,7 +959,7 @@ void MainWidget::find_text(GUI::TextEditor::SearchDirection direction, ShowMessa if (!result.is_valid() && show_message == ShowMessageIfNoResults::Yes) { GUI::MessageBox::show(window(), - DeprecatedString::formatted("Not found: \"{}\"", needle), + ByteString::formatted("Not found: \"{}\"", needle), "Not found"sv, GUI::MessageBox::Type::Information); } diff --git a/Userland/Applications/TextEditor/MainWidget.h b/Userland/Applications/TextEditor/MainWidget.h index 0e338d7e925..38c8b5c265d 100644 --- a/Userland/Applications/TextEditor/MainWidget.h +++ b/Userland/Applications/TextEditor/MainWidget.h @@ -26,7 +26,7 @@ class MainWidget final : public GUI::Widget { public: virtual ~MainWidget() override = default; ErrorOr read_file(String const& filename, Core::File&); - void open_nonexistent_file(DeprecatedString const& path); + void open_nonexistent_file(ByteString const& path); bool request_close(); GUI::TextEditor& editor() { return *m_editor; } @@ -64,9 +64,9 @@ private: void find_text(GUI::TextEditor::SearchDirection, ShowMessageIfNoResults); RefPtr m_editor; - DeprecatedString m_path; - DeprecatedString m_name; - DeprecatedString m_extension; + ByteString m_path; + ByteString m_name; + ByteString m_extension; RefPtr m_new_action; RefPtr m_open_action; RefPtr m_save_action; diff --git a/Userland/Applications/TextEditor/main.cpp b/Userland/Applications/TextEditor/main.cpp index b2a491d7f07..a57a08e5248 100644 --- a/Userland/Applications/TextEditor/main.cpp +++ b/Userland/Applications/TextEditor/main.cpp @@ -79,11 +79,11 @@ ErrorOr serenity_main(Main::Arguments arguments) FileArgument parsed_argument(filename); FileSystemAccessClient::Client::the().set_silence_errors(FileSystemAccessClient::ErrorFlag::NoEntries); - auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, parsed_argument.filename().to_deprecated_string()); + auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, parsed_argument.filename().to_byte_string()); if (response.is_error()) { if (response.error().code() == ENOENT) - text_widget->open_nonexistent_file(parsed_argument.filename().to_deprecated_string()); + text_widget->open_nonexistent_file(parsed_argument.filename().to_byte_string()); } else { TRY(text_widget->read_file(response.value().filename(), response.value().stream())); text_widget->editor().set_cursor_and_focus_line(parsed_argument.line().value_or(1) - 1, parsed_argument.column().value_or(0)); diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index 3743fa8484b..ea40d5ad933 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -259,7 +259,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) return; auto load_from_file_result = load_from_file(response.value().filename(), response.value().release_stream()); if (load_from_file_result.is_error()) { - GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); + GUI::MessageBox::show_error(&window, ByteString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); return; } })); @@ -295,7 +295,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) return; auto load_from_file_result = load_from_file(response.value().filename(), response.value().release_stream()); if (load_from_file_result.is_error()) { - GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); + GUI::MessageBox::show_error(&window, ByteString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); return; } }); @@ -316,7 +316,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) void MainWidget::update_title() { - window()->set_title(DeprecatedString::formatted("{}[*] - Theme Editor", m_path.value_or("Untitled"))); + window()->set_title(ByteString::formatted("{}[*] - Theme Editor", m_path.value_or("Untitled"))); } GUI::Window::CloseRequestDecision MainWidget::request_close() @@ -338,7 +338,7 @@ GUI::Window::CloseRequestDecision MainWidget::request_close() return GUI::Window::CloseRequestDecision::StayOpen; } -void MainWidget::set_path(DeprecatedString path) +void MainWidget::set_path(ByteString path) { m_path = path; update_title(); @@ -346,13 +346,13 @@ void MainWidget::set_path(DeprecatedString path) void MainWidget::save_to_file(String const& filename, NonnullOwnPtr file) { - auto theme = Core::ConfigFile::open(filename.to_deprecated_string(), move(file)).release_value_but_fixme_should_propagate_errors(); + auto theme = Core::ConfigFile::open(filename.to_byte_string(), move(file)).release_value_but_fixme_should_propagate_errors(); #define __ENUMERATE_ALIGNMENT_ROLE(role) theme->write_entry("Alignments", to_string(Gfx::AlignmentRole::role), to_string(m_current_palette.alignment(Gfx::AlignmentRole::role))); ENUMERATE_ALIGNMENT_ROLES(__ENUMERATE_ALIGNMENT_ROLE) #undef __ENUMERATE_ALIGNMENT_ROLE -#define __ENUMERATE_COLOR_ROLE(role) theme->write_entry("Colors", to_string(Gfx::ColorRole::role), m_current_palette.color(Gfx::ColorRole::role).to_deprecated_string()); +#define __ENUMERATE_COLOR_ROLE(role) theme->write_entry("Colors", to_string(Gfx::ColorRole::role), m_current_palette.color(Gfx::ColorRole::role).to_byte_string()); ENUMERATE_COLOR_ROLES(__ENUMERATE_COLOR_ROLE) #undef __ENUMERATE_COLOR_ROLE @@ -370,10 +370,10 @@ void MainWidget::save_to_file(String const& filename, NonnullOwnPtr auto sync_result = theme->sync(); if (sync_result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save theme file: {}", sync_result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save theme file: {}", sync_result.error())); } else { m_last_modified_time = MonotonicTime::now(); - set_path(filename.to_deprecated_string()); + set_path(filename.to_byte_string()); window()->set_modified(false); GUI::Application::the()->set_most_recently_open_file(filename); } @@ -597,7 +597,7 @@ void MainWidget::set_metric(Gfx::MetricRole role, int value) set_palette(preview_palette); } -void MainWidget::set_path(Gfx::PathRole role, DeprecatedString value) +void MainWidget::set_path(Gfx::PathRole role, ByteString value) { auto preview_palette = m_current_palette; preview_palette.set_path(role, value); @@ -615,7 +615,7 @@ void MainWidget::set_palette(Gfx::Palette palette) void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI::TextBox& path_input, PathPickerTarget path_picker_target) { bool open_folder = path_picker_target == PathPickerTarget::Folder; - auto window_title = DeprecatedString::formatted(open_folder ? "Select {} folder"sv : "Select {} file"sv, property_display_name); + auto window_title = ByteString::formatted(open_folder ? "Select {} folder"sv : "Select {} file"sv, property_display_name); auto target_path = path_input.text(); if (FileSystem::exists(target_path)) { if (!FileSystem::is_directory(target_path)) @@ -631,13 +631,13 @@ void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI:: ErrorOr MainWidget::load_from_file(String const& filename, NonnullOwnPtr file) { - auto config_file = TRY(Core::ConfigFile::open(filename.to_deprecated_string(), move(file))); + auto config_file = TRY(Core::ConfigFile::open(filename.to_byte_string(), move(file))); auto theme = TRY(Gfx::load_system_theme(config_file)); VERIFY(theme.is_valid()); auto new_palette = Gfx::Palette(Gfx::PaletteImpl::create_with_anonymous_buffer(theme)); set_palette(move(new_palette)); - set_path(filename.to_deprecated_string()); + set_path(filename.to_byte_string()); #define __ENUMERATE_ALIGNMENT_ROLE(role) \ if (auto alignment_input = m_alignment_inputs[to_underlying(Gfx::AlignmentRole::role)]) \ @@ -704,7 +704,7 @@ void MainWidget::drop_event(GUI::DropEvent& event) auto load_from_file_result = load_from_file(response.value().filename(), response.value().release_stream()); if (load_from_file_result.is_error()) - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Can't open file named {}: {}", response.value().filename(), load_from_file_result.error())); } } diff --git a/Userland/Applications/ThemeEditor/MainWidget.h b/Userland/Applications/ThemeEditor/MainWidget.h index e86c946d45f..b394fe8d619 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.h +++ b/Userland/Applications/ThemeEditor/MainWidget.h @@ -52,7 +52,7 @@ private: AlignmentModel() = default; struct AlignmentValue { - DeprecatedString title; + ByteString title; Gfx::TextAlignment setting_value; }; Vector m_alignments { @@ -67,7 +67,7 @@ struct Property { }; struct PropertyGroup { - DeprecatedString title; + ByteString title; Vector properties; }; @@ -96,7 +96,7 @@ private: void save_to_file(String const& filename, NonnullOwnPtr file); ErrorOr encode(); - void set_path(DeprecatedString); + void set_path(ByteString); void build_override_controls(); @@ -105,7 +105,7 @@ private: void set_color(Gfx::ColorRole, Gfx::Color); void set_flag(Gfx::FlagRole, bool); void set_metric(Gfx::MetricRole, int); - void set_path(Gfx::PathRole, DeprecatedString); + void set_path(Gfx::PathRole, ByteString); void set_palette(Gfx::Palette); @@ -123,7 +123,7 @@ private: RefPtr m_theme_override_apply; RefPtr m_theme_override_reset; - Optional m_path; + Optional m_path; Gfx::Palette m_current_palette; MonotonicTime m_last_modified_time { MonotonicTime::now() }; diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index facff62fc7a..abaec1a6df4 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -57,11 +57,11 @@ ErrorOr serenity_main(Main::Arguments arguments) // Note: This is deferred to ensure that the window has already popped and any error dialog boxes would show up correctly. app->event_loop().deferred_invoke( [&window, &path, &main_widget]() { - auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path.value().to_deprecated_string()); + auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(window, path.value().to_byte_string()); if (!response.is_error()) { auto load_from_file_result = main_widget->load_from_file(response.value().filename(), response.value().release_stream()); if (load_from_file_result.is_error()) - GUI::MessageBox::show_error(window, DeprecatedString::formatted("Loading theme from file has failed: {}", load_from_file_result.error())); + GUI::MessageBox::show_error(window, ByteString::formatted("Loading theme from file has failed: {}", load_from_file_result.error())); } }); } diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index 4cf4d423997..7862fbed189 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -237,7 +237,7 @@ void VideoPlayerWidget::on_decoding_error(Video::DecoderError const& error) break; } - GUI::MessageBox::show(window(), DeprecatedString::formatted(text_format, error.string_literal()), "Video Player encountered an error"sv); + GUI::MessageBox::show(window(), ByteString::formatted(text_format, error.string_literal()), "Video Player encountered an error"sv); } void VideoPlayerWidget::update_seek_slider_max() @@ -352,7 +352,7 @@ void VideoPlayerWidget::update_title() } string_builder.append("[*] - Video Player"sv); - window()->set_title(string_builder.to_deprecated_string()); + window()->set_title(string_builder.to_byte_string()); } Video::PlaybackManager::SeekMode VideoPlayerWidget::seek_mode() diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp index e7dd7372b92..cdb3d718b54 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.cpp +++ b/Userland/Applications/Welcome/WelcomeWidget.cpp @@ -37,7 +37,7 @@ ErrorOr WelcomeWidget::create_widgets() m_web_view = find_descendant_of_type_named("web_view"); m_web_view->use_native_user_style_sheet(); auto path = TRY(String::formatted("{}/README.md", Core::StandardPaths::home_directory())); - m_web_view->load(URL::create_with_file_scheme(path.to_deprecated_string())); + m_web_view->load(URL::create_with_file_scheme(path.to_byte_string())); m_tip_label = find_descendant_of_type_named("tip_label"); m_tip_frame = find_descendant_of_type_named("tip_frame"); diff --git a/Userland/Demos/Mandelbrot/Mandelbrot.cpp b/Userland/Demos/Mandelbrot/Mandelbrot.cpp index 7b1f88473ee..0c03720e46b 100644 --- a/Userland/Demos/Mandelbrot/Mandelbrot.cpp +++ b/Userland/Demos/Mandelbrot/Mandelbrot.cpp @@ -217,7 +217,7 @@ enum class ImageType { class Mandelbrot : public GUI::Frame { C_OBJECT(Mandelbrot) - ErrorOr export_image(DeprecatedString const& export_path, ImageType image_type); + ErrorOr export_image(ByteString const& export_path, ImageType image_type); enum class Zoom { In, @@ -366,7 +366,7 @@ void Mandelbrot::resize_event(GUI::ResizeEvent& event) m_set.resize(event.size()); } -ErrorOr Mandelbrot::export_image(DeprecatedString const& export_path, ImageType image_type) +ErrorOr Mandelbrot::export_image(ByteString const& export_path, ImageType image_type) { m_set.resize(Gfx::IntSize { 1920, 1080 }); ByteBuffer encoded_data; @@ -386,7 +386,7 @@ ErrorOr Mandelbrot::export_image(DeprecatedString const& export_path, Imag m_set.resize(size()); auto file = fopen(export_path.characters(), "wb"); if (!file) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not open '{}' for writing.", export_path), "Mandelbrot"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Could not open '{}' for writing.", export_path), "Mandelbrot"sv, GUI::MessageBox::Type::Error); return {}; } fwrite(encoded_data.data(), 1, encoded_data.size(), file); @@ -419,27 +419,27 @@ ErrorOr serenity_main(Main::Arguments arguments) export_submenu->add_action(GUI::Action::create("As &BMP...", [&](GUI::Action&) { - Optional export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "bmp"); + Optional export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "bmp"); if (!export_path.has_value()) return; if (auto result = mandelbrot->export_image(export_path.value(), ImageType::BMP); result.is_error()) - GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error())); + GUI::MessageBox::show_error(window, ByteString::formatted("{}", result.error())); })); export_submenu->add_action(GUI::Action::create("As &PNG...", { Mod_Ctrl | Mod_Shift, Key_S }, [&](GUI::Action&) { - Optional export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png"); + Optional export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "png"); if (!export_path.has_value()) return; if (auto result = mandelbrot->export_image(export_path.value(), ImageType::PNG); result.is_error()) - GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error())); + GUI::MessageBox::show_error(window, ByteString::formatted("{}", result.error())); })); export_submenu->add_action(GUI::Action::create("As &QOI...", [&](GUI::Action&) { - Optional export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "qoi"); + Optional export_path = GUI::FilePicker::get_save_filepath(window, "untitled", "qoi"); if (!export_path.has_value()) return; if (auto result = mandelbrot->export_image(export_path.value(), ImageType::QOI); result.is_error()) - GUI::MessageBox::show_error(window, DeprecatedString::formatted("{}", result.error())); + GUI::MessageBox::show_error(window, ByteString::formatted("{}", result.error())); })); export_submenu->set_icon(TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"sv))); diff --git a/Userland/Demos/ModelGallery/BasicModel.cpp b/Userland/Demos/ModelGallery/BasicModel.cpp index fe70c7133fb..10645907f61 100644 --- a/Userland/Demos/ModelGallery/BasicModel.cpp +++ b/Userland/Demos/ModelGallery/BasicModel.cpp @@ -50,7 +50,7 @@ GUI::ModelIndex BasicModel::index(int row, int column, GUI::ModelIndex const& pa return create_index(row, column); } -void BasicModel::add_item(DeprecatedString const& item) +void BasicModel::add_item(ByteString const& item) { begin_insert_rows({}, m_items.size(), m_items.size()); m_items.append(item); diff --git a/Userland/Demos/ModelGallery/BasicModel.h b/Userland/Demos/ModelGallery/BasicModel.h index 6fdd896b24d..5b059d27560 100644 --- a/Userland/Demos/ModelGallery/BasicModel.h +++ b/Userland/Demos/ModelGallery/BasicModel.h @@ -29,7 +29,7 @@ public: Function on_invalidate; - void add_item(DeprecatedString const& item); + void add_item(ByteString const& item); void remove_item(GUI::ModelIndex const&); private: @@ -37,5 +37,5 @@ private: { } - Vector m_items; + Vector m_items; }; diff --git a/Userland/Demos/WidgetGallery/DemoWizardDialog.h b/Userland/Demos/WidgetGallery/DemoWizardDialog.h index daaa86faaa7..cb7ca08563b 100644 --- a/Userland/Demos/WidgetGallery/DemoWizardDialog.h +++ b/Userland/Demos/WidgetGallery/DemoWizardDialog.h @@ -17,7 +17,7 @@ class DemoWizardDialog : public GUI::WizardDialog { C_OBJECT(DemoWizardDialog); public: - DeprecatedString page_1_location() { return m_page_1_location_text_box->get_text(); } + ByteString page_1_location() { return m_page_1_location_text_box->get_text(); } private: DemoWizardDialog(GUI::Window* parent_window); diff --git a/Userland/Demos/WidgetGallery/GalleryModels.h b/Userland/Demos/WidgetGallery/GalleryModels.h index 20d4d403a34..0d14c47034e 100644 --- a/Userland/Demos/WidgetGallery/GalleryModels.h +++ b/Userland/Demos/WidgetGallery/GalleryModels.h @@ -60,7 +60,7 @@ public: { m_cursors.clear(); - Core::DirIterator iterator(DeprecatedString::formatted("/res/cursor-themes/{}", GUI::ConnectionToWindowServer::the().get_cursor_theme()), Core::DirIterator::Flags::SkipDots); + Core::DirIterator iterator(ByteString::formatted("/res/cursor-themes/{}", GUI::ConnectionToWindowServer::the().get_cursor_theme()), Core::DirIterator::Flags::SkipDots); while (iterator.has_next()) { auto path = iterator.next_full_path(); @@ -90,8 +90,8 @@ private: struct Cursor { RefPtr bitmap; - DeprecatedString path; - DeprecatedString name; + ByteString path; + ByteString name; Gfx::CursorParams params; }; @@ -194,7 +194,7 @@ private: struct IconSet { RefPtr big_icon; RefPtr little_icon; - DeprecatedString name; + ByteString name; }; Vector m_icon_sets; diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index dc19983d6fa..edc9b9a9977 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -53,7 +53,7 @@ GalleryWidget::GalleryWidget() m_frame_shapes.append("Sunken Panel"); m_frame_shape_combobox = basics_tab.find_descendant_of_type_named("frame_style_combobox"); - m_frame_shape_combobox->set_model(*GUI::ItemListModel::create(m_frame_shapes)); + m_frame_shape_combobox->set_model(*GUI::ItemListModel::create(m_frame_shapes)); m_frame_shape_combobox->on_change = [&](auto&, auto const& index) { m_label_frame->set_frame_style(static_cast(index.row())); @@ -61,7 +61,7 @@ GalleryWidget::GalleryWidget() }; m_frame_shape_combobox->on_return_pressed = [&]() { - m_enabled_label->set_text(String::from_deprecated_string(m_frame_shape_combobox->text()).release_value_but_fixme_should_propagate_errors()); + m_enabled_label->set_text(String::from_byte_string(m_frame_shape_combobox->text()).release_value_but_fixme_should_propagate_errors()); }; m_button_icons.append(Gfx::Bitmap::load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors()); @@ -141,7 +141,7 @@ GalleryWidget::GalleryWidget() m_msgbox_buttons.append("Yes No Cancel"); m_msgbox_icon_combobox = basics_tab.find_descendant_of_type_named("msgbox_icon_combobox"); - m_msgbox_icon_combobox->set_model(*GUI::ItemListModel::create(m_msgbox_icons)); + m_msgbox_icon_combobox->set_model(*GUI::ItemListModel::create(m_msgbox_icons)); m_msgbox_icon_combobox->set_selected_index(0); m_msgbox_icon_combobox->on_change = [&](auto&, auto const& index) { @@ -149,7 +149,7 @@ GalleryWidget::GalleryWidget() }; m_msgbox_buttons_combobox = basics_tab.find_descendant_of_type_named("msgbox_buttons_combobox"); - m_msgbox_buttons_combobox->set_model(*GUI::ItemListModel::create(m_msgbox_buttons)); + m_msgbox_buttons_combobox->set_model(*GUI::ItemListModel::create(m_msgbox_buttons)); m_msgbox_buttons_combobox->set_selected_index(0); m_msgbox_buttons_combobox->on_change = [&](auto&, auto const& index) { @@ -260,20 +260,20 @@ GalleryWidget::GalleryWidget() " _||_-\n" }; - m_wizard_output->set_text(DeprecatedString::formatted("{}{}", serenityos_ascii, wizard_ascii)); + m_wizard_output->set_text(ByteString::formatted("{}{}", serenityos_ascii, wizard_ascii)); m_wizard_button->on_click = [&](auto) { StringBuilder sb; sb.append(m_wizard_output->get_text()); sb.append("\nWizard started."sv); - m_wizard_output->set_text(sb.to_deprecated_string()); + m_wizard_output->set_text(sb.to_byte_string()); auto wizard = DemoWizardDialog::try_create(window()).release_value_but_fixme_should_propagate_errors(); auto result = wizard->exec(); - sb.append(DeprecatedString::formatted("\nWizard execution complete.\nDialog ExecResult code: {}", to_underlying(result))); + sb.append(ByteString::formatted("\nWizard execution complete.\nDialog ExecResult code: {}", to_underlying(result))); if (result == GUI::Dialog::ExecResult::OK) - sb.append(DeprecatedString::formatted(" (ExecResult::OK)\n'Installation' location: \"{}\"", wizard->page_1_location())); + sb.append(ByteString::formatted(" (ExecResult::OK)\n'Installation' location: \"{}\"", wizard->page_1_location())); m_wizard_output->set_text(sb.string_view()); }; diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.h b/Userland/Demos/WidgetGallery/GalleryWidget.h index 89322d0ab05..d94c9f1d9c5 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.h +++ b/Userland/Demos/WidgetGallery/GalleryWidget.h @@ -61,9 +61,9 @@ private: RefPtr m_opacity_value_slider; RefPtr m_opacity_imagewidget; - Vector m_frame_shapes; - Vector m_msgbox_icons; - Vector m_msgbox_buttons; + Vector m_frame_shapes; + Vector m_msgbox_icons; + Vector m_msgbox_buttons; Vector> m_button_icons; GUI::MessageBox::Type m_msgbox_type; diff --git a/Userland/DevTools/GMLPlayground/MainWidget.cpp b/Userland/DevTools/GMLPlayground/MainWidget.cpp index 5645008ada8..19fb338ff09 100644 --- a/Userland/DevTools/GMLPlayground/MainWidget.cpp +++ b/Userland/DevTools/GMLPlayground/MainWidget.cpp @@ -36,19 +36,19 @@ class UnregisteredWidget final : public GUI::Widget { C_OBJECT(UnregisteredWidget); private: - UnregisteredWidget(DeprecatedString const& class_name); + UnregisteredWidget(ByteString const& class_name); virtual void paint_event(GUI::PaintEvent& event) override; - DeprecatedString m_text; + ByteString m_text; }; -UnregisteredWidget::UnregisteredWidget(DeprecatedString const& class_name) +UnregisteredWidget::UnregisteredWidget(ByteString const& class_name) { StringBuilder builder; builder.append(class_name); builder.append("\nnot registered"sv); - m_text = builder.to_deprecated_string(); + m_text = builder.to_byte_string(); } void UnregisteredWidget::paint_event(GUI::PaintEvent& event) @@ -114,7 +114,7 @@ MainWidget::MainWidget() void MainWidget::update_title() { - window()->set_title(DeprecatedString::formatted("{}[*] - GML Playground", m_file_path.is_empty() ? "Untitled"sv : m_file_path.view())); + window()->set_title(ByteString::formatted("{}[*] - GML Playground", m_file_path.is_empty() ? "Untitled"sv : m_file_path.view())); } void MainWidget::load_file(FileSystemAccessClient::File file) @@ -126,7 +126,7 @@ void MainWidget::load_file(FileSystemAccessClient::File file) m_editor->set_text(buffer_or_error.release_value()); m_editor->set_focus(true); - m_file_path = file.filename().to_deprecated_string(); + m_file_path = file.filename().to_byte_string(); update_title(); GUI::Application::the()->set_most_recently_open_file(file.filename()); @@ -144,10 +144,10 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto file = response.value().release_stream(); if (auto result = m_editor->write_to_file(*file); result.is_error()) { - GUI::MessageBox::show(&window, DeprecatedString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(&window, ByteString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error); return; } - m_file_path = response.value().filename().to_deprecated_string(); + m_file_path = response.value().filename().to_byte_string(); update_title(); GUI::Application::the()->set_most_recently_open_file(response.value().filename()); @@ -164,7 +164,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) auto file = response.value().release_stream(); if (auto result = m_editor->write_to_file(*file); result.is_error()) { - GUI::MessageBox::show(&window, DeprecatedString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(&window, ByteString::formatted("Unable to save file: {}\n"sv, result.release_error()), "Error"sv, GUI::MessageBox::Type::Error); return; } update_title(); @@ -225,7 +225,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) } else { GUI::MessageBox::show( &window, - DeprecatedString::formatted("GML could not be formatted: {}", formatted_gml_or_error.error()), + ByteString::formatted("GML could not be formatted: {}", formatted_gml_or_error.error()), "Error"sv, GUI::MessageBox::Type::Error); } diff --git a/Userland/DevTools/GMLPlayground/MainWidget.h b/Userland/DevTools/GMLPlayground/MainWidget.h index a333855101b..7d2bb4df5da 100644 --- a/Userland/DevTools/GMLPlayground/MainWidget.h +++ b/Userland/DevTools/GMLPlayground/MainWidget.h @@ -51,5 +51,5 @@ private: RefPtr m_view_window_action; GUI::Icon m_icon; - DeprecatedString m_file_path; + ByteString m_file_path; }; diff --git a/Userland/DevTools/HackStudio/AutoCompleteResponse.h b/Userland/DevTools/HackStudio/AutoCompleteResponse.h index 216d040f79d..ca4cb4c8f97 100644 --- a/Userland/DevTools/HackStudio/AutoCompleteResponse.h +++ b/Userland/DevTools/HackStudio/AutoCompleteResponse.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -29,10 +29,10 @@ inline ErrorOr encode(Encoder& encoder, CodeComprehension::AutocompleteRes template<> inline ErrorOr decode(Decoder& decoder) { - auto completion = TRY(decoder.decode()); + auto completion = TRY(decoder.decode()); auto partial_input_length = TRY(decoder.decode()); auto language = TRY(decoder.decode()); - auto display_text = TRY(decoder.decode()); + auto display_text = TRY(decoder.decode()); auto hide_autocomplete_after_applying = TRY(decoder.decode()); return CodeComprehension::AutocompleteResultEntry { move(completion), partial_input_length, language, move(display_text), hide_autocomplete_after_applying }; @@ -50,7 +50,7 @@ inline ErrorOr encode(Encoder& encoder, CodeComprehension::ProjectLocation template<> inline ErrorOr decode(Decoder& decoder) { - auto file = TRY(decoder.decode()); + auto file = TRY(decoder.decode()); auto line = TRY(decoder.decode()); auto column = TRY(decoder.decode()); @@ -70,10 +70,10 @@ inline ErrorOr encode(Encoder& encoder, CodeComprehension::Declaration con template<> inline ErrorOr decode(Decoder& decoder) { - auto name = TRY(decoder.decode()); + auto name = TRY(decoder.decode()); auto position = TRY(decoder.decode()); auto type = TRY(decoder.decode()); - auto scope = TRY(decoder.decode()); + auto scope = TRY(decoder.decode()); return CodeComprehension::Declaration { move(name), position, type, move(scope) }; } @@ -91,8 +91,8 @@ inline ErrorOr encode(Encoder& encoder, CodeComprehension::TodoEntry const template<> inline ErrorOr decode(Decoder& decoder) { - auto content = TRY(decoder.decode()); - auto filename = TRY(decoder.decode()); + auto content = TRY(decoder.decode()); + auto filename = TRY(decoder.decode()); auto line = TRY(decoder.decode()); auto column = TRY(decoder.decode()); diff --git a/Userland/DevTools/HackStudio/CodeDocument.cpp b/Userland/DevTools/HackStudio/CodeDocument.cpp index c4caef00242..1cbec9969fe 100644 --- a/Userland/DevTools/HackStudio/CodeDocument.cpp +++ b/Userland/DevTools/HackStudio/CodeDocument.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -NonnullRefPtr CodeDocument::create(DeprecatedString const& file_path, Client* client) +NonnullRefPtr CodeDocument::create(ByteString const& file_path, Client* client) { return adopt_ref(*new CodeDocument(file_path, client)); } @@ -19,7 +19,7 @@ NonnullRefPtr CodeDocument::create(Client* client) return adopt_ref(*new CodeDocument(client)); } -CodeDocument::CodeDocument(DeprecatedString const& file_path, Client* client) +CodeDocument::CodeDocument(ByteString const& file_path, Client* client) : TextDocument(client) , m_file_path(file_path) { diff --git a/Userland/DevTools/HackStudio/CodeDocument.h b/Userland/DevTools/HackStudio/CodeDocument.h index 045d3a5d82d..e9004811e11 100644 --- a/Userland/DevTools/HackStudio/CodeDocument.h +++ b/Userland/DevTools/HackStudio/CodeDocument.h @@ -18,7 +18,7 @@ class Editor; class CodeDocument final : public GUI::TextDocument { public: virtual ~CodeDocument() override = default; - static NonnullRefPtr create(DeprecatedString const& file_path, Client* client = nullptr); + static NonnullRefPtr create(ByteString const& file_path, Client* client = nullptr); static NonnullRefPtr create(Client* client = nullptr); Vector const& breakpoint_lines() const { return m_breakpoint_lines; } @@ -26,7 +26,7 @@ public: Optional execution_position() const { return m_execution_position; } void set_execution_position(size_t line) { m_execution_position = line; } void clear_execution_position() { m_execution_position.clear(); } - DeprecatedString const& file_path() const { return m_file_path; } + ByteString const& file_path() const { return m_file_path; } Optional const& language() const { return m_language; } enum class DiffType { @@ -39,10 +39,10 @@ public: void set_line_differences(Badge, Vector); private: - explicit CodeDocument(DeprecatedString const& file_path, Client* client = nullptr); + explicit CodeDocument(ByteString const& file_path, Client* client = nullptr); explicit CodeDocument(Client* client = nullptr); - DeprecatedString m_file_path; + ByteString m_file_path; Optional m_language; Vector m_breakpoint_lines; Optional m_execution_position; diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp index c6835f0e7ae..cc2d7439253 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp @@ -46,7 +46,7 @@ Vector BacktraceModel::create_backtrace(Debug::Proces // We need to go back to the 'call' instruction to get accurate source position information. if (frame_index > 0) --current_instruction; - DeprecatedString name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address); + ByteString name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address); if (name.is_empty()) { dbgln("BacktraceModel: couldn't find containing function for address: {:p} (library={})", current_instruction, lib->name); name = ""; diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h index 56e9b5e30db..e3770b47a78 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.h @@ -34,7 +34,7 @@ public: virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override; struct FrameInfo { - DeprecatedString function_name; + ByteString function_name; FlatPtr instruction_address { 0 }; FlatPtr frame_base { 0 }; Optional m_source_position; diff --git a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h index 99be9747930..b57fa473e14 100644 --- a/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h +++ b/Userland/DevTools/HackStudio/Debugger/BreakpointCallback.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -17,5 +17,5 @@ enum class BreakpointChange { Removed, }; -using BreakpointChangeCallback = Function; +using BreakpointChangeCallback = Function; } diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp index 57a91318a86..2a5a193fcec 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp @@ -18,7 +18,7 @@ Debugger& Debugger::the() } void Debugger::initialize( - DeprecatedString source_root, + ByteString source_root, Function on_stop_callback, Function on_continue_callback, Function on_exit_callback, @@ -33,7 +33,7 @@ bool Debugger::is_initialized() } Debugger::Debugger( - DeprecatedString source_root, + ByteString source_root, Function on_stop_callback, Function on_continue_callback, Function on_exit_callback, @@ -48,7 +48,7 @@ Debugger::Debugger( pthread_cond_init(&m_ui_action_cond, nullptr); } -void Debugger::on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type) +void Debugger::on_breakpoint_change(ByteString const& file, size_t line, BreakpointChange change_type) { auto position = create_source_position(file, line); @@ -80,7 +80,7 @@ void Debugger::on_breakpoint_change(DeprecatedString const& file, size_t line, B } } -bool Debugger::set_execution_position(DeprecatedString const& file, size_t line) +bool Debugger::set_execution_position(ByteString const& file, size_t line) { auto position = create_source_position(file, line); auto session = Debugger::the().session(); @@ -95,11 +95,11 @@ bool Debugger::set_execution_position(DeprecatedString const& file, size_t line) return true; } -Debug::DebugInfo::SourcePosition Debugger::create_source_position(DeprecatedString const& file, size_t line) +Debug::DebugInfo::SourcePosition Debugger::create_source_position(ByteString const& file, size_t line) { if (file.starts_with('/')) return { file, line + 1 }; - return { LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_source_root, file)), line + 1 }; + return { LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", m_source_root, file)), line + 1 }; } intptr_t Debugger::start_static() diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.h b/Userland/DevTools/HackStudio/Debugger/Debugger.h index 656d2983c40..c6b833b005c 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.h +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.h @@ -26,7 +26,7 @@ public: }; static void initialize( - DeprecatedString source_root, + ByteString source_root, Function on_stop_callback, Function on_continue_callback, Function on_exit_callback, @@ -34,11 +34,11 @@ public: static bool is_initialized(); - void on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type); - bool set_execution_position(DeprecatedString const& file, size_t line); + void on_breakpoint_change(ByteString const& file, size_t line, BreakpointChange change_type); + bool set_execution_position(ByteString const& file, size_t line); - void set_executable_path(DeprecatedString const& path) { m_executable_path = path; } - void set_source_root(DeprecatedString const& source_root) { m_source_root = source_root; } + void set_executable_path(ByteString const& path) { m_executable_path = path; } + void set_source_root(ByteString const& source_root) { m_source_root = source_root; } void set_pid_to_attach(pid_t pid) { m_pid_to_attach = pid; } Debug::DebugSession* session() { return m_debug_session.ptr(); } @@ -94,13 +94,13 @@ private: }; explicit Debugger( - DeprecatedString source_root, + ByteString source_root, Function on_stop_callback, Function on_continue_callback, Function on_exit_callback, Function on_initialization_progress); - Debug::DebugInfo::SourcePosition create_source_position(DeprecatedString const& file, size_t line); + Debug::DebugInfo::SourcePosition create_source_position(ByteString const& file, size_t line); void start(); int debugger_loop(Debug::DebugSession::DesiredInitialDebugeeState); @@ -118,7 +118,7 @@ private: CreateDebugSessionResult create_debug_session(); OwnPtr m_debug_session; - DeprecatedString m_source_root; + ByteString m_source_root; DebuggingState m_state; pthread_mutex_t m_ui_action_mutex {}; @@ -127,7 +127,7 @@ private: Vector m_breakpoints; - DeprecatedString m_executable_path; + ByteString m_executable_path; Optional m_pid_to_attach; Function m_on_stopped_callback; diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp index 956a133c8ea..cadb7141dc7 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp @@ -60,7 +60,7 @@ DisassemblyModel::DisassemblyModel(Debug::DebugSession const& debug_session, Ptr if (!insn.has_value()) break; FlatPtr address_in_profiled_program = symbol.value().value() + offset_into_symbol; - auto disassembly = insn.value().to_deprecated_string(address_in_profiled_program, &symbol_provider); + auto disassembly = insn.value().to_byte_string(address_in_profiled_program, &symbol_provider); StringView instruction_bytes = view.substring_view(offset_into_symbol, insn.value().length()); m_instructions.append({ insn.value(), disassembly, instruction_bytes, address_in_profiled_program }); @@ -93,12 +93,12 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole if (role == GUI::ModelRole::Display) { if (index.column() == Column::Address) - return DeprecatedString::formatted("{:p}", insn.address); + return ByteString::formatted("{:p}", insn.address); if (index.column() == Column::InstructionBytes) { StringBuilder builder; for (auto ch : insn.bytes) builder.appendff("{:02x} ", static_cast(ch)); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } if (index.column() == Column::Disassembly) return insn.disassembly; diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h index 33ee35777d4..c6239e02162 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.h @@ -22,7 +22,7 @@ namespace HackStudio { struct InstructionData { X86::Instruction insn; - DeprecatedString disassembly; + ByteString disassembly; StringView bytes; FlatPtr address { 0 }; }; diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp index 0139a485997..9382a23d76a 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp @@ -49,7 +49,7 @@ void DisassemblyWidget::update_state(Debug::DebugSession const& debug_session, P return; auto containing_function = lib->debug_info->get_containing_function(regs.ip() - lib->base_address); if (containing_function.has_value()) - m_function_name_label->set_text(String::from_deprecated_string(containing_function.value().name).release_value_but_fixme_should_propagate_errors()); + m_function_name_label->set_text(String::from_byte_string(containing_function.value().name).release_value_but_fixme_should_propagate_errors()); else m_function_name_label->set_text(""_string); show_disassembly(); @@ -73,7 +73,7 @@ void DisassemblyWidget::show_disassembly() m_unavailable_disassembly_widget->set_visible(false); } -void DisassemblyWidget::hide_disassembly(DeprecatedString const& reason) +void DisassemblyWidget::hide_disassembly(ByteString const& reason) { m_top_container->set_visible(false); m_disassembly_view->set_visible(false); diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h index d695e600c63..61277660164 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyWidget.h @@ -21,18 +21,18 @@ class UnavailableDisassemblyWidget final : public GUI::Frame { public: virtual ~UnavailableDisassemblyWidget() override { } - DeprecatedString const& reason() const { return m_reason; } - void set_reason(DeprecatedString const& text) { m_reason = text; } + ByteString const& reason() const { return m_reason; } + void set_reason(ByteString const& text) { m_reason = text; } private: - UnavailableDisassemblyWidget(DeprecatedString const& reason) + UnavailableDisassemblyWidget(ByteString const& reason) : m_reason(reason) { } virtual void paint_event(GUI::PaintEvent& event) override; - DeprecatedString m_reason; + ByteString m_reason; }; class DisassemblyWidget final : public GUI::Widget { @@ -47,7 +47,7 @@ private: DisassemblyWidget(); void show_disassembly(); - void hide_disassembly(DeprecatedString const&); + void hide_disassembly(ByteString const&); RefPtr m_top_container; RefPtr m_disassembly_view; diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp b/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp index 1b09445d90b..127f0248710 100644 --- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.cpp @@ -118,7 +118,7 @@ GUI::Variant RegistersModel::data(const GUI::ModelIndex& index, GUI::ModelRole r if (index.column() == Column::Register) return reg.name; if (index.column() == Column::Value) - return DeprecatedString::formatted("{:p}", reg.value); + return ByteString::formatted("{:p}", reg.value); return {}; } return {}; diff --git a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h index 0d4505b2ea8..b9d347c81fe 100644 --- a/Userland/DevTools/HackStudio/Debugger/RegistersModel.h +++ b/Userland/DevTools/HackStudio/Debugger/RegistersModel.h @@ -14,7 +14,7 @@ namespace HackStudio { struct RegisterData { - DeprecatedString name; + ByteString name; FlatPtr value; bool changed { false }; }; diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp index 2ea9d5eb197..8b5d22516a7 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -55,7 +55,7 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const return node->members.size(); } -static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable) +static ByteString variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable) { if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address) return "N/A"; @@ -69,20 +69,20 @@ static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo return enumerator->constant_data.as_u32 == enumerator_value; }); if (it.is_end()) - return DeprecatedString::formatted("Unknown ({})", value.value()); - return DeprecatedString::formatted("{}::{}", variable.type_name, (*it)->name); + return ByteString::formatted("Unknown ({})", value.value()); + return ByteString::formatted("{}::{}", variable.type_name, (*it)->name); } if (variable.type_name == "int") { auto value = Debugger::the().session()->peek(variable_address); VERIFY(value.has_value()); - return DeprecatedString::formatted("{}", static_cast(value.value())); + return ByteString::formatted("{}", static_cast(value.value())); } if (variable.type_name == "char") { auto value = Debugger::the().session()->peek(variable_address); VERIFY(value.has_value()); - return DeprecatedString::formatted("'{0:c}'", (char)value.value()); + return ByteString::formatted("'{0:c}'", (char)value.value()); } if (variable.type_name == "bool") { @@ -91,13 +91,13 @@ static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo return (value.value() & 1) ? "true" : "false"; } - return DeprecatedString::formatted("type: {} @ {:p}, ", variable.type_name, variable_address); + return ByteString::formatted("type: {} @ {:p}, ", variable.type_name, variable_address); } static Optional string_to_variable_value(StringView string_value, Debug::DebugInfo::VariableInfo const& variable) { if (variable.is_enum_type()) { - auto prefix_string = DeprecatedString::formatted("{}::", variable.type_name); + auto prefix_string = ByteString::formatted("{}::", variable.type_name); auto string_to_use = string_value; if (string_value.starts_with(prefix_string)) string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length()); @@ -143,7 +143,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView GUI::MessageBox::show( parent_window, - DeprecatedString::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name), + ByteString::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name), "Set value failed"sv, GUI::MessageBox::Type::Error); } @@ -154,7 +154,7 @@ GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole r switch (role) { case GUI::ModelRole::Display: { auto value_as_string = variable_value_as_string(*variable); - return DeprecatedString::formatted("{}: {}", variable->name, value_as_string); + return ByteString::formatted("{}: {}", variable->name, value_as_string); } case GUI::ModelRole::Icon: return m_variable_icon; diff --git a/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.h b/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.h index 1d3d0e321fb..20145d16190 100644 --- a/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.h +++ b/Userland/DevTools/HackStudio/Dialogs/Git/GitCommitDialog.h @@ -15,7 +15,7 @@ namespace HackStudio { -using OnCommitCallback = Function; +using OnCommitCallback = Function; class GitCommitDialog final : public GUI::Dialog { C_OBJECT(GitCommitDialog); diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index e55d35e22e3..dbf2643fbd7 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -89,7 +89,7 @@ NewProjectDialog::NewProjectDialog(GUI::Window* parent) m_browse_button = *find_descendant_of_type_named("browse_button"); m_browse_button->on_click = [this](auto) { - Optional path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), true); + Optional path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), true); if (path.has_value()) m_create_in_input->set_text(path.value().view()); }; @@ -113,7 +113,7 @@ void NewProjectDialog::update_dialog() m_input_valid = true; if (project_template) { - m_description_label->set_text(String::from_deprecated_string(project_template->description()).release_value_but_fixme_should_propagate_errors()); + m_description_label->set_text(String::from_byte_string(project_template->description()).release_value_but_fixme_should_propagate_errors()); } else { m_description_label->set_text("Select a project template to continue."_string); m_input_valid = false; @@ -122,7 +122,7 @@ void NewProjectDialog::update_dialog() auto maybe_project_path = get_project_full_path(); if (maybe_project_path.has_value()) { - m_full_path_label->set_text(String::from_deprecated_string(maybe_project_path.value()).release_value_but_fixme_should_propagate_errors()); + m_full_path_label->set_text(String::from_byte_string(maybe_project_path.value()).release_value_but_fixme_should_propagate_errors()); } else { m_full_path_label->set_text("Invalid name or creation directory."_string); m_input_valid = false; @@ -131,7 +131,7 @@ void NewProjectDialog::update_dialog() m_ok_button->set_enabled(m_input_valid); } -Optional NewProjectDialog::get_available_project_name() +Optional NewProjectDialog::get_available_project_name() { auto create_in = m_create_in_input->text(); auto chosen_name = m_name_input->text(); @@ -148,16 +148,16 @@ Optional NewProjectDialog::get_available_project_name() for (int i = 0; i < 1000; i++) { auto candidate = (i == 0) ? chosen_name - : DeprecatedString::formatted("{}-{}", chosen_name, i); + : ByteString::formatted("{}-{}", chosen_name, i); - if (!FileSystem::exists(DeprecatedString::formatted("{}/{}", create_in, candidate))) + if (!FileSystem::exists(ByteString::formatted("{}/{}", create_in, candidate))) return candidate; } return {}; } -Optional NewProjectDialog::get_project_full_path() +Optional NewProjectDialog::get_project_full_path() { // Do not permit forward-slashes in project names if (m_name_input->text().contains('/')) @@ -189,13 +189,13 @@ void NewProjectDialog::do_create_project() auto create_in = m_create_in_input->text(); if (!FileSystem::exists(create_in) || !FileSystem::is_directory(create_in)) { - auto result = GUI::MessageBox::show(this, DeprecatedString::formatted("The directory \"{}\" does not exist yet, would you like to create it?", create_in), "New Project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto result = GUI::MessageBox::show(this, ByteString::formatted("The directory \"{}\" does not exist yet, would you like to create it?", create_in), "New Project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (result != GUI::MessageBox::ExecResult::Yes) return; auto created = Core::Directory::create(maybe_project_full_path.value(), Core::Directory::CreateDirectories::Yes); if (created.is_error()) { - GUI::MessageBox::show_error(this, DeprecatedString::formatted("Could not create directory \"{}\"", create_in)); + GUI::MessageBox::show_error(this, ByteString::formatted("Could not create directory \"{}\"", create_in)); return; } } @@ -206,7 +206,7 @@ void NewProjectDialog::do_create_project() m_created_project_path = maybe_project_full_path.value(); done(ExecResult::OK); } else { - GUI::MessageBox::show_error(this, DeprecatedString::formatted("Could not create project: {}", creation_result.error())); + GUI::MessageBox::show_error(this, ByteString::formatted("Could not create project: {}", creation_result.error())); } } diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h index ec74124210e..14219682e3e 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.h @@ -24,15 +24,15 @@ class NewProjectDialog : public GUI::Dialog { public: static ExecResult show(GUI::Window* parent_window); - Optional created_project_path() const { return m_created_project_path; } + Optional created_project_path() const { return m_created_project_path; } private: NewProjectDialog(GUI::Window* parent); virtual ~NewProjectDialog() override = default; void update_dialog(); - Optional get_available_project_name(); - Optional get_project_full_path(); + Optional get_available_project_name(); + Optional get_project_full_path(); void do_create_project(); @@ -53,7 +53,7 @@ private: RefPtr m_cancel_button; RefPtr m_browse_button; - Optional m_created_project_path; + Optional m_created_project_path; }; } diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 6c782c27026..3de246e535b 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -163,9 +163,9 @@ void Editor::paint_event(GUI::PaintEvent& event) } } -static HashMap& man_paths() +static HashMap& man_paths() { - static HashMap paths; + static HashMap paths; if (paths.is_empty()) { auto json = Config::read_string("HackStudio"sv, "Global"sv, "DocumentationSearchPaths"sv); AK::JsonParser parser(json); @@ -194,7 +194,7 @@ static HashMap& man_paths() return paths; } -void Editor::show_documentation_tooltip_if_available(DeprecatedString const& hovered_token, Gfx::IntPoint screen_location) +void Editor::show_documentation_tooltip_if_available(ByteString const& hovered_token, Gfx::IntPoint screen_location) { auto it = man_paths().find(hovered_token); if (it == man_paths().end()) { @@ -384,11 +384,11 @@ void Editor::leave_event(Core::Event& event) GUI::TextEditor::leave_event(event); } -static HashMap& include_paths() +static HashMap& include_paths() { - static HashMap paths; + static HashMap paths; - auto add_directory = [](DeprecatedString base, Optional recursive, auto handle_directory) -> void { + auto add_directory = [](ByteString base, Optional recursive, auto handle_directory) -> void { Core::DirIterator it(recursive.value_or(base), Core::DirIterator::Flags::SkipDots); while (it.has_next()) { auto path = it.next_full_path(); @@ -412,7 +412,7 @@ static HashMap& include_paths() return paths; } -void Editor::navigate_to_include_if_available(DeprecatedString path) +void Editor::navigate_to_include_if_available(ByteString path) { auto it = include_paths().find(path); if (it == include_paths().end()) { @@ -587,7 +587,7 @@ void Editor::on_identifier_click(const GUI::TextDocumentSpan& span) if (!m_language_client) return; - m_language_client->on_declaration_found = [](DeprecatedString const& file, size_t line, size_t column) { + m_language_client->on_declaration_found = [](ByteString const& file, size_t line, size_t column) { HackStudio::open_file(file, line, column); }; m_language_client->search_declaration(code_document().file_path(), span.range.start().line(), span.range.start().column()); @@ -704,7 +704,7 @@ void Editor::handle_function_parameters_hint_request() if (!m_language_client) return; - m_language_client->on_function_parameters_hint_result = [this](Vector const& params, size_t argument_index) { + m_language_client->on_function_parameters_hint_result = [this](Vector const& params, size_t argument_index) { dbgln("on_function_parameters_hint_result"); StringBuilder html; @@ -722,7 +722,7 @@ void Editor::handle_function_parameters_hint_request() } html.append(""sv); - s_tooltip_page_view->load_html(html.to_deprecated_string()); + s_tooltip_page_view->load_html(html.to_byte_string()); auto cursor_rect = current_editor().cursor_content_rect().location().translated(screen_relative_rect().location()); diff --git a/Userland/DevTools/HackStudio/Editor.h b/Userland/DevTools/HackStudio/Editor.h index 2d6aa5dafa5..e1461dac6d7 100644 --- a/Userland/DevTools/HackStudio/Editor.h +++ b/Userland/DevTools/HackStudio/Editor.h @@ -28,7 +28,7 @@ public: virtual ~Editor() override = default; - Function on_open; + Function on_open; EditorWrapper& wrapper(); EditorWrapper const& wrapper() const; @@ -72,8 +72,8 @@ private: virtual void leave_event(Core::Event&) override; virtual void keydown_event(GUI::KeyEvent&) override; - void show_documentation_tooltip_if_available(DeprecatedString const&, Gfx::IntPoint screen_location); - void navigate_to_include_if_available(DeprecatedString); + void show_documentation_tooltip_if_available(ByteString const&, Gfx::IntPoint screen_location); + void navigate_to_include_if_available(ByteString); void on_navigatable_link_click(const GUI::TextDocumentSpan&); void on_identifier_click(const GUI::TextDocumentSpan&); @@ -111,7 +111,7 @@ private: explicit Editor(); - DeprecatedString m_last_parsed_token; + ByteString m_last_parsed_token; GUI::TextPosition m_previous_text_position { 0, 0 }; bool m_hovering_editor { false }; bool m_hovering_clickable { false }; diff --git a/Userland/DevTools/HackStudio/EditorWrapper.cpp b/Userland/DevTools/HackStudio/EditorWrapper.cpp index 82edf5e7d86..9077b415371 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.cpp +++ b/Userland/DevTools/HackStudio/EditorWrapper.cpp @@ -34,7 +34,7 @@ EditorWrapper::EditorWrapper() set_current_editor_wrapper(this); }; - m_editor->on_open = [](DeprecatedString const& path) { + m_editor->on_open = [](ByteString const& path) { open_file(path); }; @@ -64,7 +64,7 @@ void EditorWrapper::set_mode_non_displayable() editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"sv); } -void EditorWrapper::set_filename(DeprecatedString const& filename) +void EditorWrapper::set_filename(ByteString const& filename) { m_filename = filename; update_title(); @@ -75,7 +75,7 @@ bool EditorWrapper::save() { if (filename().is_empty()) { auto file_picker_action = GUI::CommonActions::make_save_as_action([&](auto&) { - Optional save_path = GUI::FilePicker::get_save_filepath(window(), "file"sv, "txt"sv, project_root().value()); + Optional save_path = GUI::FilePicker::get_save_filepath(window(), "file"sv, "txt"sv, project_root().value()); if (save_path.has_value()) set_filename(save_path.value()); }); @@ -99,7 +99,7 @@ void EditorWrapper::update_diff() } } -void EditorWrapper::set_project_root(DeprecatedString const& project_root) +void EditorWrapper::set_project_root(ByteString const& project_root) { m_project_root = project_root; auto result = GitRepo::try_to_create(*m_project_root); @@ -126,7 +126,7 @@ void EditorWrapper::update_title() if (editor().document().is_modified()) title.append(" (*)"sv); - m_filename_title = title.to_deprecated_string(); + m_filename_title = title.to_byte_string(); } void EditorWrapper::set_debug_mode(bool enabled) diff --git a/Userland/DevTools/HackStudio/EditorWrapper.h b/Userland/DevTools/HackStudio/EditorWrapper.h index 30f97a4c8f6..fcbe23d523c 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.h +++ b/Userland/DevTools/HackStudio/EditorWrapper.h @@ -37,12 +37,12 @@ public: void set_mode_displayable(); void set_mode_non_displayable(); void set_debug_mode(bool); - void set_filename(DeprecatedString const&); - DeprecatedString const& filename() const { return m_filename; } - DeprecatedString const& filename_title() const { return m_filename_title; } + void set_filename(ByteString const&); + ByteString const& filename() const { return m_filename; } + ByteString const& filename_title() const { return m_filename_title; } - Optional const& project_root() const { return m_project_root; } - void set_project_root(DeprecatedString const& project_root); + Optional const& project_root() const { return m_project_root; } + void set_project_root(ByteString const& project_root); GitRepo const* git_repo() const { return m_git_repo; } @@ -59,11 +59,11 @@ private: void update_title(); - DeprecatedString m_filename; - DeprecatedString m_filename_title; + ByteString m_filename; + ByteString m_filename_title; RefPtr m_editor; - Optional m_project_root; + Optional m_project_root; RefPtr m_git_repo; Vector m_hunks; }; diff --git a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp index f8977c9b5b7..c123e6ea040 100644 --- a/Userland/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/Userland/DevTools/HackStudio/FindInFilesWidget.cpp @@ -17,9 +17,9 @@ namespace HackStudio { struct Match { - DeprecatedString filename; + ByteString filename; GUI::TextRange range; - DeprecatedString text; + ByteString text; }; class SearchResultsModel final : public GUI::Model { @@ -105,7 +105,7 @@ static RefPtr find_in_files(StringView text) builder.append(file.document().text_in_range(range)); builder.append(0x02); builder.append(right_part); - matches.append({ file.name(), range, builder.to_deprecated_string() }); + matches.append({ file.name(), range, builder.to_byte_string() }); } }); diff --git a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp index 5198a05e2e3..94e3e180545 100644 --- a/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp +++ b/Userland/DevTools/HackStudio/GMLPreviewWidget.cpp @@ -10,13 +10,13 @@ namespace HackStudio { -GMLPreviewWidget::GMLPreviewWidget(DeprecatedString const& gml_content) +GMLPreviewWidget::GMLPreviewWidget(ByteString const& gml_content) { set_layout(); load_gml(gml_content); } -void GMLPreviewWidget::load_gml(DeprecatedString const& gml) +void GMLPreviewWidget::load_gml(ByteString const& gml) { remove_all_children(); diff --git a/Userland/DevTools/HackStudio/GMLPreviewWidget.h b/Userland/DevTools/HackStudio/GMLPreviewWidget.h index 77419c502e0..17646b0fbc0 100644 --- a/Userland/DevTools/HackStudio/GMLPreviewWidget.h +++ b/Userland/DevTools/HackStudio/GMLPreviewWidget.h @@ -14,10 +14,10 @@ namespace HackStudio { class GMLPreviewWidget final : public GUI::Widget { C_OBJECT(GMLPreviewWidget) public: - void load_gml(DeprecatedString const&); + void load_gml(ByteString const&); private: - explicit GMLPreviewWidget(DeprecatedString const&); + explicit GMLPreviewWidget(ByteString const&); }; } diff --git a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp index 5fd11ef3fe8..7e5e0e53b18 100644 --- a/Userland/DevTools/HackStudio/Git/DiffViewer.cpp +++ b/Userland/DevTools/HackStudio/Git/DiffViewer.cpp @@ -135,7 +135,7 @@ Gfx::IntRect DiffViewer::separator_rect() const frame_inner_rect().height() }; } -void DiffViewer::set_content(DeprecatedString const& original, DeprecatedString const& diff) +void DiffViewer::set_content(ByteString const& original, ByteString const& diff) { m_original_lines = split_to_lines(original); m_hunks = Diff::parse_hunks(diff).release_value_but_fixme_should_propagate_errors(); @@ -151,7 +151,7 @@ DiffViewer::DiffViewer() setup_properties(); } -DiffViewer::DiffViewer(DeprecatedString const& original, DeprecatedString const& diff) +DiffViewer::DiffViewer(ByteString const& original, ByteString const& diff) : m_original_lines(split_to_lines(original)) , m_hunks(Diff::parse_hunks(diff).release_value_but_fixme_should_propagate_errors()) { @@ -165,10 +165,10 @@ void DiffViewer::setup_properties() set_foreground_role(ColorRole::BaseText); } -Vector DiffViewer::split_to_lines(DeprecatedString const& text) +Vector DiffViewer::split_to_lines(ByteString const& text) { // NOTE: This is slightly different than text.split('\n') - Vector lines; + Vector lines; size_t next_line_start_index = 0; for (size_t i = 0; i < text.length(); ++i) { if (text[i] == '\n') { diff --git a/Userland/DevTools/HackStudio/Git/DiffViewer.h b/Userland/DevTools/HackStudio/Git/DiffViewer.h index 24a9283373b..827c7397ea7 100644 --- a/Userland/DevTools/HackStudio/Git/DiffViewer.h +++ b/Userland/DevTools/HackStudio/Git/DiffViewer.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -18,10 +18,10 @@ class DiffViewer final : public GUI::AbstractScrollableWidget { public: virtual ~DiffViewer() override = default; - void set_content(DeprecatedString const& original, DeprecatedString const& diff); + void set_content(ByteString const& original, ByteString const& diff); private: - DiffViewer(DeprecatedString const& original, DeprecatedString const& diff); + DiffViewer(ByteString const& original, ByteString const& diff); DiffViewer(); void setup_properties(); @@ -45,7 +45,7 @@ private: void draw_line(GUI::Painter&, StringView line, size_t y_offset, LinePosition, LineType); - static Vector split_to_lines(DeprecatedString const& text); + static Vector split_to_lines(ByteString const& text); static Gfx::Color red_background(); static Gfx::Color green_background(); @@ -55,7 +55,7 @@ private: Gfx::IntRect separator_rect() const; - Vector m_original_lines; + Vector m_original_lines; Vector m_hunks; }; } diff --git a/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp b/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp index 4897c7f1027..7311d874b16 100644 --- a/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp +++ b/Userland/DevTools/HackStudio/Git/GitFilesModel.cpp @@ -8,12 +8,12 @@ namespace HackStudio { -NonnullRefPtr GitFilesModel::create(Vector&& files) +NonnullRefPtr GitFilesModel::create(Vector&& files) { return adopt_ref(*new GitFilesModel(move(files))); } -GitFilesModel::GitFilesModel(Vector&& files) +GitFilesModel::GitFilesModel(Vector&& files) : m_files(move(files)) { } diff --git a/Userland/DevTools/HackStudio/Git/GitFilesModel.h b/Userland/DevTools/HackStudio/Git/GitFilesModel.h index 98921f40d9d..3a91bcb1b54 100644 --- a/Userland/DevTools/HackStudio/Git/GitFilesModel.h +++ b/Userland/DevTools/HackStudio/Git/GitFilesModel.h @@ -14,7 +14,7 @@ namespace HackStudio { class GitFilesModel final : public GUI::Model { public: - static NonnullRefPtr create(Vector&& files); + static NonnullRefPtr create(Vector&& files); virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_files.size(); } virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; } @@ -26,7 +26,7 @@ public: virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override; private: - explicit GitFilesModel(Vector&& files); - Vector m_files; + explicit GitFilesModel(Vector&& files); + Vector m_files; }; } diff --git a/Userland/DevTools/HackStudio/Git/GitFilesView.cpp b/Userland/DevTools/HackStudio/Git/GitFilesView.cpp index d09fd5d4739..bff70cee402 100644 --- a/Userland/DevTools/HackStudio/Git/GitFilesView.cpp +++ b/Userland/DevTools/HackStudio/Git/GitFilesView.cpp @@ -54,7 +54,7 @@ void GitFilesView::mousedown_event(GUI::MouseEvent& event) auto data = model()->index(item_index, model_column()).data(); VERIFY(data.is_string()); - m_action_callback(data.to_deprecated_string()); + m_action_callback(data.to_byte_string()); } }; diff --git a/Userland/DevTools/HackStudio/Git/GitFilesView.h b/Userland/DevTools/HackStudio/Git/GitFilesView.h index bdc82be6060..c60e076ef64 100644 --- a/Userland/DevTools/HackStudio/Git/GitFilesView.h +++ b/Userland/DevTools/HackStudio/Git/GitFilesView.h @@ -13,7 +13,7 @@ namespace HackStudio { // A "GitFileAction" is either the staging or the unstaging of a file. -using GitFileActionCallback = Function; +using GitFileActionCallback = Function; class GitFilesView : public GUI::ListView { C_OBJECT(GitFilesView) diff --git a/Userland/DevTools/HackStudio/Git/GitRepo.cpp b/Userland/DevTools/HackStudio/Git/GitRepo.cpp index 7b3b0e9ba1e..34ec2e2904e 100644 --- a/Userland/DevTools/HackStudio/Git/GitRepo.cpp +++ b/Userland/DevTools/HackStudio/Git/GitRepo.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -GitRepo::CreateResult GitRepo::try_to_create(DeprecatedString const& repository_root) +GitRepo::CreateResult GitRepo::try_to_create(ByteString const& repository_root) { if (!git_is_installed()) { return { CreateResult::Type::GitProgramNotFound, nullptr }; @@ -21,7 +21,7 @@ GitRepo::CreateResult GitRepo::try_to_create(DeprecatedString const& repository_ return { CreateResult::Type::Success, adopt_ref(*new GitRepo(repository_root)) }; } -RefPtr GitRepo::initialize_repository(DeprecatedString const& repository_root) +RefPtr GitRepo::initialize_repository(ByteString const& repository_root) { auto res = command_wrapper({ "init" }, repository_root); if (!res.has_value()) @@ -31,7 +31,7 @@ RefPtr GitRepo::initialize_repository(DeprecatedString const& repositor return adopt_ref(*new GitRepo(repository_root)); } -Vector GitRepo::unstaged_files() const +Vector GitRepo::unstaged_files() const { auto modified = modified_files(); auto untracked = untracked_files(); @@ -39,7 +39,7 @@ Vector GitRepo::unstaged_files() const return modified; } // -Vector GitRepo::staged_files() const +Vector GitRepo::staged_files() const { auto raw_result = command({ "diff", "--cached", "--name-only" }); if (!raw_result.has_value()) @@ -47,7 +47,7 @@ Vector GitRepo::staged_files() const return parse_files_list(*raw_result); } -Vector GitRepo::modified_files() const +Vector GitRepo::modified_files() const { auto raw_result = command({ "ls-files", "--modified", "--exclude-standard" }); if (!raw_result.has_value()) @@ -55,7 +55,7 @@ Vector GitRepo::modified_files() const return parse_files_list(*raw_result); } -Vector GitRepo::untracked_files() const +Vector GitRepo::untracked_files() const { auto raw_result = command({ "ls-files", "--others", "--exclude-standard" }); if (!raw_result.has_value()) @@ -63,27 +63,27 @@ Vector GitRepo::untracked_files() const return parse_files_list(*raw_result); } -Vector GitRepo::parse_files_list(DeprecatedString const& raw_result) +Vector GitRepo::parse_files_list(ByteString const& raw_result) { auto lines = raw_result.split('\n'); - Vector files; + Vector files; for (auto const& line : lines) { files.empend(line); } return files; } -Optional GitRepo::command(Vector const& command_parts) const +Optional GitRepo::command(Vector const& command_parts) const { return command_wrapper(command_parts, m_repository_root); } -Optional GitRepo::command_wrapper(Vector const& command_parts, DeprecatedString const& chdir) +Optional GitRepo::command_wrapper(Vector const& command_parts, ByteString const& chdir) { auto const result = Core::command("git", command_parts, LexicalPath(chdir)); if (result.is_error() || result.value().exit_code != 0) return {}; - return DeprecatedString(result.value().output.bytes()); + return ByteString(result.value().output.bytes()); } bool GitRepo::git_is_installed() @@ -91,37 +91,37 @@ bool GitRepo::git_is_installed() return command_wrapper({ "--help" }, "/").has_value(); } -bool GitRepo::git_repo_exists(DeprecatedString const& repo_root) +bool GitRepo::git_repo_exists(ByteString const& repo_root) { return command_wrapper({ "status" }, repo_root).has_value(); } -bool GitRepo::stage(DeprecatedString const& file) +bool GitRepo::stage(ByteString const& file) { return command({ "add", file }).has_value(); } -bool GitRepo::unstage(DeprecatedString const& file) +bool GitRepo::unstage(ByteString const& file) { return command({ "reset", "HEAD", "--", file }).has_value(); } -bool GitRepo::commit(DeprecatedString const& message) +bool GitRepo::commit(ByteString const& message) { return command({ "commit", "-m", message }).has_value(); } -Optional GitRepo::original_file_content(DeprecatedString const& file) const +Optional GitRepo::original_file_content(ByteString const& file) const { - return command({ "show", DeprecatedString::formatted("HEAD:{}", file) }); + return command({ "show", ByteString::formatted("HEAD:{}", file) }); } -Optional GitRepo::unstaged_diff(DeprecatedString const& file) const +Optional GitRepo::unstaged_diff(ByteString const& file) const { return command({ "diff", "-U0", file.characters() }); } -bool GitRepo::is_tracked(DeprecatedString const& file) const +bool GitRepo::is_tracked(ByteString const& file) const { auto res = command({ "ls-files", file }); if (!res.has_value()) diff --git a/Userland/DevTools/HackStudio/Git/GitRepo.h b/Userland/DevTools/HackStudio/Git/GitRepo.h index e4598359ca1..ec04f96ad19 100644 --- a/Userland/DevTools/HackStudio/Git/GitRepo.h +++ b/Userland/DevTools/HackStudio/Git/GitRepo.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -28,37 +28,37 @@ public: RefPtr repo; }; - static CreateResult try_to_create(DeprecatedString const& repository_root); - static RefPtr initialize_repository(DeprecatedString const& repository_root); + static CreateResult try_to_create(ByteString const& repository_root); + static RefPtr initialize_repository(ByteString const& repository_root); - bool stage(DeprecatedString const& file); - bool unstage(DeprecatedString const& file); - bool commit(DeprecatedString const& message); - bool is_tracked(DeprecatedString const& file) const; + bool stage(ByteString const& file); + bool unstage(ByteString const& file); + bool commit(ByteString const& message); + bool is_tracked(ByteString const& file) const; - Vector unstaged_files() const; - Vector staged_files() const; - Optional original_file_content(DeprecatedString const& file) const; - Optional unstaged_diff(DeprecatedString const& file) const; + Vector unstaged_files() const; + Vector staged_files() const; + Optional original_file_content(ByteString const& file) const; + Optional unstaged_diff(ByteString const& file) const; private: static bool git_is_installed(); - static bool git_repo_exists(DeprecatedString const& repo_root); + static bool git_repo_exists(ByteString const& repo_root); - static Optional command_wrapper(Vector const& command_parts, DeprecatedString const& chdir); - static Vector parse_files_list(DeprecatedString const&); + static Optional command_wrapper(Vector const& command_parts, ByteString const& chdir); + static Vector parse_files_list(ByteString const&); - explicit GitRepo(DeprecatedString const& repository_root) + explicit GitRepo(ByteString const& repository_root) : m_repository_root(repository_root) { } - Vector modified_files() const; - Vector untracked_files() const; + Vector modified_files() const; + Vector untracked_files() const; - Optional command(Vector const& command_parts) const; + Optional command(Vector const& command_parts) const; - DeprecatedString m_repository_root; + ByteString m_repository_root; }; } diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 6d95dd4b39b..02d853f7c50 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -118,7 +118,7 @@ void GitWidget::refresh() m_staged_files->set_model(GitFilesModel::create(m_git_repo->staged_files())); } -void GitWidget::stage_file(DeprecatedString const& file) +void GitWidget::stage_file(ByteString const& file) { dbgln("staging: {}", file); bool rc = m_git_repo->stage(file); @@ -126,7 +126,7 @@ void GitWidget::stage_file(DeprecatedString const& file) refresh(); } -void GitWidget::unstage_file(DeprecatedString const& file) +void GitWidget::unstage_file(ByteString const& file) { dbgln("unstaging: {}", file); bool rc = m_git_repo->unstage(file); @@ -154,7 +154,7 @@ void GitWidget::set_view_diff_callback(ViewDiffCallback callback) m_view_diff_callback = move(callback); } -void GitWidget::show_diff(DeprecatedString const& file_path) +void GitWidget::show_diff(ByteString const& file_path) { if (!m_git_repo->is_tracked(file_path)) { auto file = Core::File::open(file_path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); @@ -168,7 +168,7 @@ void GitWidget::show_diff(DeprecatedString const& file_path) m_view_diff_callback(original_content.value(), diff.value()); } -void GitWidget::change_repo(DeprecatedString const& repo_root) +void GitWidget::change_repo(ByteString const& repo_root) { m_repo_root = repo_root; m_git_repo = nullptr; diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.h b/Userland/DevTools/HackStudio/Git/GitWidget.h index 5240662bef1..18c1e4860a9 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.h +++ b/Userland/DevTools/HackStudio/Git/GitWidget.h @@ -14,7 +14,7 @@ namespace HackStudio { -using ViewDiffCallback = Function; +using ViewDiffCallback = Function; class GitWidget final : public GUI::Widget { C_OBJECT(GitWidget) @@ -24,19 +24,19 @@ public: void refresh(); void set_view_diff_callback(ViewDiffCallback callback); bool initialized() const { return !m_git_repo.is_null(); } - void change_repo(DeprecatedString const& repo_root); + void change_repo(ByteString const& repo_root); private: explicit GitWidget(); bool initialize(); bool initialize_if_needed(); - void stage_file(DeprecatedString const&); - void unstage_file(DeprecatedString const&); + void stage_file(ByteString const&); + void unstage_file(ByteString const&); void commit(); - void show_diff(DeprecatedString const&); + void show_diff(ByteString const&); - DeprecatedString m_repo_root; + ByteString m_repo_root; RefPtr m_unstaged_files; RefPtr m_staged_files; RefPtr m_git_repo; diff --git a/Userland/DevTools/HackStudio/HackStudio.h b/Userland/DevTools/HackStudio/HackStudio.h index 0dfabeec757..6923981e8fe 100644 --- a/Userland/DevTools/HackStudio/HackStudio.h +++ b/Userland/DevTools/HackStudio/HackStudio.h @@ -9,17 +9,17 @@ #include "EditorWrapper.h" #include "LanguageClients/ConnectionsToServer.h" #include "Project.h" -#include +#include #include namespace HackStudio { GUI::TextEditor& current_editor(); -void open_file(DeprecatedString const&); +void open_file(ByteString const&); RefPtr current_editor_wrapper(); -void open_file(DeprecatedString const&, size_t line, size_t column); +void open_file(ByteString const&, size_t line, size_t column); Project& project(); -DeprecatedString currently_open_file(); +ByteString currently_open_file(); void set_current_editor_wrapper(RefPtr); void update_editor_window_title(); void for_each_open_file(Function); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index bd587422d65..4f1c859ee9d 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -80,7 +80,7 @@ namespace HackStudio { -ErrorOr> HackStudioWidget::create(DeprecatedString path_to_project) +ErrorOr> HackStudioWidget::create(ByteString path_to_project) { auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) HackStudioWidget)); @@ -174,7 +174,7 @@ ErrorOr> HackStudioWidget::create(DeprecatedStri return; if (event.event_path.starts_with(widget->project().root_path())) { - DeprecatedString relative_path = LexicalPath::relative_path(event.event_path, widget->project().root_path()); + ByteString relative_path = LexicalPath::relative_path(event.event_path, widget->project().root_path()); widget->handle_external_file_deletion(relative_path); } else { widget->handle_external_file_deletion(event.event_path); @@ -213,7 +213,7 @@ void HackStudioWidget::on_action_tab_change() } } -Vector HackStudioWidget::read_recent_projects() +Vector HackStudioWidget::read_recent_projects() { auto json = Config::read_string("HackStudio"sv, "Global"sv, "RecentProjects"sv); AK::JsonParser parser(json); @@ -225,7 +225,7 @@ Vector HackStudioWidget::read_recent_projects() if (!value.is_array()) return {}; - Vector paths; + Vector paths; for (auto& json_value : value.as_array().values()) { if (!json_value.is_string()) return {}; @@ -235,7 +235,7 @@ Vector HackStudioWidget::read_recent_projects() return paths; } -void HackStudioWidget::open_project(DeprecatedString const& root_path) +void HackStudioWidget::open_project(ByteString const& root_path) { if (warn_unsaved_changes("There are unsaved changes, do you want to save before closing current project?") == ContinueDecision::No) return; @@ -280,20 +280,20 @@ void HackStudioWidget::open_project(DeprecatedString const& root_path) if (recent_projects.size() > recent_projects_history_size) recent_projects.shrink(recent_projects_history_size); - Config::write_string("HackStudio"sv, "Global"sv, "RecentProjects"sv, JsonArray(recent_projects).to_deprecated_string()); + Config::write_string("HackStudio"sv, "Global"sv, "RecentProjects"sv, JsonArray(recent_projects).to_byte_string()); update_recent_projects_submenu(); } -Vector HackStudioWidget::selected_file_paths() const +Vector HackStudioWidget::selected_file_paths() const { - Vector files; + Vector files; m_project_tree_view->selection().for_each_index([&](const GUI::ModelIndex& index) { - DeprecatedString sub_path = index.data().as_string(); + ByteString sub_path = index.data().as_string(); GUI::ModelIndex parent_or_invalid = index.parent(); while (parent_or_invalid.is_valid()) { - sub_path = DeprecatedString::formatted("{}/{}", parent_or_invalid.data().as_string(), sub_path); + sub_path = ByteString::formatted("{}/{}", parent_or_invalid.data().as_string(), sub_path); parent_or_invalid = parent_or_invalid.parent(); } @@ -303,9 +303,9 @@ Vector HackStudioWidget::selected_file_paths() const return files; } -bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t line, size_t column) +bool HackStudioWidget::open_file(ByteString const& full_filename, size_t line, size_t column) { - DeprecatedString filename = full_filename; + ByteString filename = full_filename; if (full_filename.starts_with(project().root_path())) { filename = LexicalPath::relative_path(full_filename, project().root_path()); } @@ -371,7 +371,7 @@ bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t l set_edit_mode(EditMode::Text); - DeprecatedString relative_file_path = filename; + ByteString relative_file_path = filename; if (filename.starts_with(m_project->root_path())) relative_file_path = filename.substring(m_project->root_path().length() + 1); @@ -390,16 +390,16 @@ bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t l return true; } -void HackStudioWidget::close_file_in_all_editors(DeprecatedString const& filename) +void HackStudioWidget::close_file_in_all_editors(ByteString const& filename) { m_open_files.remove(filename); m_open_files_vector.remove_all_matching( - [&filename](DeprecatedString const& element) { return element == filename; }); + [&filename](ByteString const& element) { return element == filename; }); for (auto& editor_wrapper : m_all_editor_wrappers) { Editor& editor = editor_wrapper->editor(); - DeprecatedString editor_file_path = editor.code_document().file_path(); - DeprecatedString relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path()); + ByteString editor_file_path = editor.code_document().file_path(); + ByteString relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path()); if (relative_editor_file_path == filename) { if (m_open_files_vector.is_empty()) { @@ -515,7 +515,7 @@ ErrorOr> HackStudioWidget::create_project_tree_view_con return project_tree_view_context_menu; } -ErrorOr> HackStudioWidget::create_new_file_action(DeprecatedString const& label, DeprecatedString const& icon, DeprecatedString const& extension) +ErrorOr> HackStudioWidget::create_new_file_action(ByteString const& label, ByteString const& icon, ByteString const& extension) { auto icon_no_shadow = TRY(Gfx::Bitmap::load_from_file(icon)); return GUI::Action::create(label, icon_no_shadow, [this, extension](const GUI::Action&) { @@ -523,34 +523,34 @@ ErrorOr> HackStudioWidget::create_new_file_action(Dep if (GUI::InputBox::show(window(), filename, "Enter a name:"sv, "New File"sv) != GUI::InputBox::ExecResult::OK) return; - if (!extension.is_empty() && !AK::StringUtils::ends_with(filename, DeprecatedString::formatted(".{}", extension), CaseSensitivity::CaseSensitive)) { + if (!extension.is_empty() && !AK::StringUtils::ends_with(filename, ByteString::formatted(".{}", extension), CaseSensitivity::CaseSensitive)) { filename = String::formatted("{}.{}", filename, extension).release_value_but_fixme_should_propagate_errors(); } auto path_to_selected = selected_file_paths(); - DeprecatedString filepath; + ByteString filepath; if (!path_to_selected.is_empty()) { VERIFY(FileSystem::exists(path_to_selected.first())); LexicalPath selected(path_to_selected.first()); - DeprecatedString dir_path; + ByteString dir_path; if (FileSystem::is_directory(selected.string())) dir_path = selected.string(); else dir_path = selected.dirname(); - filepath = DeprecatedString::formatted("{}/", dir_path); + filepath = ByteString::formatted("{}/", dir_path); } - filepath = DeprecatedString::formatted("{}{}", filepath, filename); + filepath = ByteString::formatted("{}{}", filepath, filename); auto file_or_error = Core::File::open(filepath, Core::File::OpenMode::Write | Core::File::OpenMode::MustBeNew); if (file_or_error.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to create '{}': {}", filepath, file_or_error.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to create '{}': {}", filepath, file_or_error.error())); return; } open_file(filepath); @@ -570,7 +570,7 @@ ErrorOr> HackStudioWidget::create_new_directory_actio if (!path_to_selected.is_empty()) { LexicalPath selected(path_to_selected.first()); - DeprecatedString dir_path; + ByteString dir_path; if (FileSystem::is_directory(selected.string())) dir_path = selected.string(); @@ -580,7 +580,7 @@ ErrorOr> HackStudioWidget::create_new_directory_actio directory_name = String::formatted("{}/{}", dir_path, directory_name).release_value_but_fixme_should_propagate_errors(); } - auto formatted_dir_name = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_project->model().root_path(), directory_name)); + auto formatted_dir_name = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", m_project->model().root_path(), directory_name)); int rc = mkdir(formatted_dir_name.characters(), 0755); if (rc < 0) { GUI::MessageBox::show(window(), "Failed to create new directory"sv, "Error"sv, GUI::MessageBox::Type::Error); @@ -620,7 +620,7 @@ NonnullRefPtr HackStudioWidget::create_copy_relative_path_action() auto copy_relative_path_action = GUI::Action::create("Copy &Relative Path", [this](const GUI::Action&) { auto paths = selected_file_paths(); VERIFY(!paths.is_empty()); - auto paths_string = DeprecatedString::join('\n', paths); + auto paths_string = ByteString::join('\n', paths); GUI::Clipboard::the().set_plain_text(paths_string); }); copy_relative_path_action->set_enabled(true); @@ -634,10 +634,10 @@ NonnullRefPtr HackStudioWidget::create_copy_full_path_action() auto copy_full_path_action = GUI::Action::create("Copy &Full Path", [this](const GUI::Action&) { auto paths = selected_file_paths(); VERIFY(!paths.is_empty()); - Vector full_paths; + Vector full_paths; for (auto& path : paths) full_paths.append(get_absolute_path(path)); - auto paths_string = DeprecatedString::join('\n', full_paths); + auto paths_string = ByteString::join('\n', full_paths); GUI::Clipboard::the().set_plain_text(paths_string); }); copy_full_path_action->set_enabled(true); @@ -653,12 +653,12 @@ NonnullRefPtr HackStudioWidget::create_delete_action() if (files.is_empty()) return; - DeprecatedString message; + ByteString message; if (files.size() == 1) { LexicalPath file(files[0]); - message = DeprecatedString::formatted("Really remove \"{}\" from disk?", file.basename()); + message = ByteString::formatted("Really remove \"{}\" from disk?", file.basename()); } else { - message = DeprecatedString::formatted("Really remove \"{}\" files from disk?", files.size()); + message = ByteString::formatted("Really remove \"{}\" files from disk?", files.size()); } auto result = GUI::MessageBox::show(window(), @@ -673,7 +673,7 @@ NonnullRefPtr HackStudioWidget::create_delete_action() struct stat st; if (lstat(file.characters(), &st) < 0) { GUI::MessageBox::show(window(), - DeprecatedString::formatted("lstat ({}) failed: {}", file, strerror(errno)), + ByteString::formatted("lstat ({}) failed: {}", file, strerror(errno)), "Removal Failed"sv, GUI::MessageBox::Type::Error); break; @@ -684,12 +684,12 @@ NonnullRefPtr HackStudioWidget::create_delete_action() auto& error = result.error(); if (is_directory) { GUI::MessageBox::show(window(), - DeprecatedString::formatted("Removing directory \"{}\" from the project failed: {}", file, error), + ByteString::formatted("Removing directory \"{}\" from the project failed: {}", file, error), "Removal Failed"sv, GUI::MessageBox::Type::Error); } else { GUI::MessageBox::show(window(), - DeprecatedString::formatted("Removing file \"{}\" from the project failed: {}", file, error), + ByteString::formatted("Removing file \"{}\" from the project failed: {}", file, error), "Removal Failed"sv, GUI::MessageBox::Type::Error); } @@ -908,7 +908,7 @@ NonnullRefPtr HackStudioWidget::create_save_as_action() LexicalPath const old_path(old_filename); auto suggested_path = FileSystem::absolute_path(old_path.string()).release_value_but_fixme_should_propagate_errors(); - Optional save_path = GUI::FilePicker::get_save_filepath(window(), + Optional save_path = GUI::FilePicker::get_save_filepath(window(), old_filename.is_empty() ? "Untitled"sv : old_path.title(), old_filename.is_empty() ? "txt"sv : old_path.extension(), suggested_path); @@ -916,7 +916,7 @@ NonnullRefPtr HackStudioWidget::create_save_as_action() return; } - DeprecatedString const relative_file_path = LexicalPath::relative_path(save_path.value(), m_project->root_path()); + ByteString const relative_file_path = LexicalPath::relative_path(save_path.value(), m_project->root_path()); if (current_editor_wrapper().filename().is_empty()) { current_editor_wrapper().set_filename(relative_file_path); } else { @@ -1009,7 +1009,7 @@ ErrorOr> HackStudioWidget::create_debug_action() auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"sv)); return GUI::Action::create("&Debug", icon, [this](auto&) { if (!FileSystem::exists(get_project_executable_path())) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error); return; } if (Debugger::the().session()) { @@ -1104,7 +1104,7 @@ void HackStudioWidget::initialize_debugger() }); } -DeprecatedString HackStudioWidget::get_full_path_of_serenity_source(DeprecatedString const& file) +ByteString HackStudioWidget::get_full_path_of_serenity_source(ByteString const& file) { auto path_parts = LexicalPath(file).parts(); while (!path_parts.is_empty() && path_parts[0] == "..") { @@ -1114,10 +1114,10 @@ DeprecatedString HackStudioWidget::get_full_path_of_serenity_source(DeprecatedSt relative_path_builder.join('/', path_parts); constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity"; LexicalPath serenity_sources_base(SERENITY_LIBS_PREFIX); - return DeprecatedString::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_deprecated_string()); + return ByteString::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_byte_string()); } -DeprecatedString HackStudioWidget::get_absolute_path(DeprecatedString const& path) const +ByteString HackStudioWidget::get_absolute_path(ByteString const& path) const { // TODO: We can probably do a more specific condition here, something like // "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))" @@ -1127,9 +1127,9 @@ DeprecatedString HackStudioWidget::get_absolute_path(DeprecatedString const& pat return m_project->to_absolute_path(path); } -RefPtr HackStudioWidget::get_editor_of_file(DeprecatedString const& filename) +RefPtr HackStudioWidget::get_editor_of_file(ByteString const& filename) { - DeprecatedString file_path = filename; + ByteString file_path = filename; if (filename.starts_with("../"sv)) { file_path = get_full_path_of_serenity_source(filename); @@ -1140,19 +1140,19 @@ RefPtr HackStudioWidget::get_editor_of_file(DeprecatedString cons return current_editor_wrapper(); } -DeprecatedString HackStudioWidget::get_project_executable_path() const +ByteString HackStudioWidget::get_project_executable_path() const { // FIXME: Dumb heuristic ahead! // e.g /my/project => /my/project/project // TODO: Perhaps a Makefile rule for getting the value of $(PROGRAM) would be better? - return DeprecatedString::formatted("{}/{}", m_project->root_path(), LexicalPath::basename(m_project->root_path())); + return ByteString::formatted("{}/{}", m_project->root_path(), LexicalPath::basename(m_project->root_path())); } void HackStudioWidget::build() { auto result = m_project_builder->build(active_file()); if (result.is_error()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("{}", result.error()), "Build Failed"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("{}", result.error()), "Build Failed"sv, GUI::MessageBox::Type::Error); m_build_action->set_enabled(true); m_stop_action->set_enabled(false); } else { @@ -1164,7 +1164,7 @@ void HackStudioWidget::run() { auto result = m_project_builder->run(active_file()); if (result.is_error()) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("{}", result.error()), "Run Failed"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), ByteString::formatted("{}", result.error()), "Run Failed"sv, GUI::MessageBox::Type::Error); m_run_action->set_enabled(true); m_stop_action->set_enabled(false); } else { @@ -1202,7 +1202,7 @@ void HackStudioWidget::set_current_editor_wrapper(RefPtr editor_w update_statusbar(); } -void HackStudioWidget::file_renamed(DeprecatedString const& old_name, DeprecatedString const& new_name) +void HackStudioWidget::file_renamed(ByteString const& old_name, ByteString const& new_name) { auto editor_or_none = m_all_editor_wrappers.first_matching([&old_name](auto const& editor) { return editor->filename() == old_name; @@ -1272,11 +1272,11 @@ void HackStudioWidget::configure_project_tree_view() void HackStudioWidget::create_open_files_view(GUI::Widget& parent) { m_open_files_view = parent.add(); - auto open_files_model = GUI::ItemListModel::create(m_open_files_vector); + auto open_files_model = GUI::ItemListModel::create(m_open_files_vector); m_open_files_view->set_model(open_files_model); m_open_files_view->on_activation = [this](auto& index) { - open_file(index.data().to_deprecated_string()); + open_file(index.data().to_byte_string()); }; } @@ -1638,7 +1638,7 @@ void HackStudioWidget::update_statusbar() { StringBuilder builder; if (current_editor().has_selection()) { - DeprecatedString selected_text = current_editor().selected_text(); + ByteString selected_text = current_editor().selected_text(); auto word_count = current_editor().number_of_selected_words(); builder.appendff("Selected: {:'d} {} ({:'d} {})", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word"); } @@ -1648,7 +1648,7 @@ void HackStudioWidget::update_statusbar() m_statusbar->set_text(2, String::formatted("Ln {:'d} Col {:'d}", current_editor().cursor().line() + 1, current_editor().cursor().column()).release_value_but_fixme_should_propagate_errors()); } -void HackStudioWidget::handle_external_file_deletion(DeprecatedString const& filepath) +void HackStudioWidget::handle_external_file_deletion(ByteString const& filepath) { close_file_in_all_editors(filepath); } @@ -1686,7 +1686,7 @@ HackStudioWidget::~HackStudioWidget() stop_debugger_if_running(); } -HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(DeprecatedString const& prompt) +HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(ByteString const& prompt) { if (!any_document_is_dirty()) return ContinueDecision::Yes; @@ -1747,13 +1747,13 @@ void HackStudioWidget::update_toolbar_actions() void HackStudioWidget::update_window_title() { - window()->set_title(DeprecatedString::formatted("{} - {} - Hack Studio", m_current_editor_wrapper->filename_title(), m_project->name())); + window()->set_title(ByteString::formatted("{} - {} - Hack Studio", m_current_editor_wrapper->filename_title(), m_project->name())); window()->set_modified(any_document_is_dirty()); } void HackStudioWidget::update_current_editor_title() { - current_editor_tab_widget().set_tab_title(current_editor_wrapper(), String::from_deprecated_string(current_editor_wrapper().filename_title()).release_value_but_fixme_should_propagate_errors()); + current_editor_tab_widget().set_tab_title(current_editor_wrapper(), String::from_byte_string(current_editor_wrapper().filename_title()).release_value_but_fixme_should_propagate_errors()); } void HackStudioWidget::on_cursor_change() @@ -1831,13 +1831,13 @@ ErrorOr> HackStudioWidget::create_open_project_config auto parent_directory = LexicalPath::dirname(Project::config_file_path); auto absolute_config_file_path = LexicalPath::absolute_path(m_project->root_path(), Project::config_file_path); - DeprecatedString formatted_error_string_holder; + ByteString formatted_error_string_holder; auto save_configuration_or_error = [&]() -> ErrorOr { if (FileSystem::exists(absolute_config_file_path)) return {}; if (FileSystem::exists(parent_directory) && !FileSystem::is_directory(parent_directory)) { - formatted_error_string_holder = DeprecatedString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory); + formatted_error_string_holder = ByteString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory); return Error::from_string_view(formatted_error_string_holder.view()); } @@ -1854,7 +1854,7 @@ ErrorOr> HackStudioWidget::create_open_project_config return {}; }(); if (save_configuration_or_error.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Saving configuration failed: {}.", save_configuration_or_error.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Saving configuration failed: {}.", save_configuration_or_error.error())); return; } diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index f31694c293d..0a92dbb6fef 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -37,11 +37,11 @@ class HackStudioWidget : public GUI::Widget { C_OBJECT_ABSTRACT(HackStudioWidget) public: - static ErrorOr> create(DeprecatedString path_to_project); + static ErrorOr> create(ByteString path_to_project); virtual ~HackStudioWidget() override; - bool open_file(DeprecatedString const& filename, size_t line = 0, size_t column = 0); - void close_file_in_all_editors(DeprecatedString const& filename); + bool open_file(ByteString const& filename, size_t line = 0, size_t column = 0); + void close_file_in_all_editors(ByteString const& filename); void update_actions(); Project& project(); @@ -55,7 +55,7 @@ public: GUI::TabWidget& current_editor_tab_widget(); GUI::TabWidget const& current_editor_tab_widget() const; - DeprecatedString const& active_file() const { return m_current_editor_wrapper->filename(); } + ByteString const& active_file() const { return m_current_editor_wrapper->filename(); } ErrorOr initialize_menubar(GUI::Window&); Locator& locator() @@ -68,7 +68,7 @@ public: No, Yes }; - ContinueDecision warn_unsaved_changes(DeprecatedString const& prompt); + ContinueDecision warn_unsaved_changes(ByteString const& prompt); enum class Mode { Code, @@ -80,7 +80,7 @@ public: void for_each_open_file(Function); bool semantic_syntax_highlighting_is_enabled() const; - static Vector read_recent_projects(); + static Vector read_recent_projects(); void update_current_editor_title(); void update_window_title(); @@ -88,11 +88,11 @@ public: private: static constexpr size_t recent_projects_history_size = 15; - static DeprecatedString get_full_path_of_serenity_source(DeprecatedString const& file); - DeprecatedString get_absolute_path(DeprecatedString const&) const; - Vector selected_file_paths() const; + static ByteString get_full_path_of_serenity_source(ByteString const& file); + ByteString get_absolute_path(ByteString const&) const; + Vector selected_file_paths() const; - void open_project(DeprecatedString const& root_path); + void open_project(ByteString const& root_path); enum class EditMode { Text, @@ -102,7 +102,7 @@ private: void set_edit_mode(EditMode); ErrorOr> create_project_tree_view_context_menu(); - ErrorOr> create_new_file_action(DeprecatedString const& label, DeprecatedString const& icon, DeprecatedString const& extension); + ErrorOr> create_new_file_action(ByteString const& label, ByteString const& icon, ByteString const& extension); ErrorOr> create_new_directory_action(); ErrorOr> create_open_selected_action(); NonnullRefPtr create_delete_action(); @@ -133,15 +133,15 @@ private: void add_new_editor_tab_widget(GUI::Widget& parent); void add_new_editor(GUI::TabWidget& parent); - RefPtr get_editor_of_file(DeprecatedString const& filename); - DeprecatedString get_project_executable_path() const; + RefPtr get_editor_of_file(ByteString const& filename); + ByteString get_project_executable_path() const; void on_action_tab_change(); void reveal_action_tab(GUI::Widget&); void initialize_debugger(); void update_statusbar(); - void handle_external_file_deletion(DeprecatedString const& filepath); + void handle_external_file_deletion(ByteString const& filepath); void stop_debugger_if_running(); void close_current_project(); @@ -167,11 +167,11 @@ private: void update_tree_view(); void update_toolbar_actions(); void on_cursor_change(); - void file_renamed(DeprecatedString const& old_name, DeprecatedString const& new_name); + void file_renamed(ByteString const& old_name, ByteString const& new_name); bool save_file_changes(); struct ProjectLocation { - DeprecatedString filename; + ByteString filename; size_t line { 0 }; size_t column { 0 }; }; @@ -184,9 +184,9 @@ private: Vector> m_all_editor_tab_widgets; RefPtr m_current_editor_tab_widget; - HashMap> m_open_files; + HashMap> m_open_files; RefPtr m_file_watcher; - Vector m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers + Vector m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers OwnPtr m_project; diff --git a/Userland/DevTools/HackStudio/LanguageClient.cpp b/Userland/DevTools/HackStudio/LanguageClient.cpp index a28eb13318d..54c4f9593ad 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.cpp +++ b/Userland/DevTools/HackStudio/LanguageClient.cpp @@ -8,7 +8,7 @@ #include "HackStudio.h" #include "ProjectDeclarations.h" #include "ToDoEntries.h" -#include +#include #include #include @@ -32,7 +32,7 @@ void ConnectionToServer::declaration_location(CodeComprehension::ProjectLocation m_current_language_client->declaration_found(location.file, location.line, location.column); } -void ConnectionToServer::parameters_hint_result(Vector const& params, int argument_index) +void ConnectionToServer::parameters_hint_result(Vector const& params, int argument_index) { if (!m_current_language_client) { dbgln("Language Server connection has no attached language client"); @@ -60,35 +60,35 @@ void ConnectionToServer::die() m_wrapper->on_crash(); } -void LanguageClient::open_file(DeprecatedString const& path, int fd) +void LanguageClient::open_file(ByteString const& path, int fd) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_opened(path, fd); } -void LanguageClient::set_file_content(DeprecatedString const& path, DeprecatedString const& content) +void LanguageClient::set_file_content(ByteString const& path, ByteString const& content) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_set_file_content(path, content); } -void LanguageClient::insert_text(DeprecatedString const& path, DeprecatedString const& text, size_t line, size_t column) +void LanguageClient::insert_text(ByteString const& path, ByteString const& text, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_edit_insert_text(path, text, line, column); } -void LanguageClient::remove_text(DeprecatedString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column) +void LanguageClient::remove_text(ByteString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column) { if (!m_connection_wrapper.connection()) return; m_connection_wrapper.connection()->async_file_edit_remove_text(path, from_line, from_column, to_line, to_column); } -void LanguageClient::request_autocomplete(DeprecatedString const& path, size_t cursor_line, size_t cursor_column) +void LanguageClient::request_autocomplete(ByteString const& path, size_t cursor_line, size_t cursor_column) { if (!m_connection_wrapper.connection()) return; @@ -118,19 +118,19 @@ bool LanguageClient::is_active_client() const return m_connection_wrapper.connection()->active_client() == this; } -HashMap> ConnectionToServerInstances::s_instance_for_language; +HashMap> ConnectionToServerInstances::s_instance_for_language; -void ConnectionToServer::declarations_in_document(DeprecatedString const& filename, Vector const& declarations) +void ConnectionToServer::declarations_in_document(ByteString const& filename, Vector const& declarations) { ProjectDeclarations::the().set_declared_symbols(filename, declarations); } -void ConnectionToServer::todo_entries_in_document(DeprecatedString const& filename, Vector const& todo_entries) +void ConnectionToServer::todo_entries_in_document(ByteString const& filename, Vector const& todo_entries) { ToDoEntries::the().set_entries(filename, move(todo_entries)); } -void LanguageClient::search_declaration(DeprecatedString const& path, size_t line, size_t column) +void LanguageClient::search_declaration(ByteString const& path, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; @@ -138,7 +138,7 @@ void LanguageClient::search_declaration(DeprecatedString const& path, size_t lin m_connection_wrapper.connection()->async_find_declaration(CodeComprehension::ProjectLocation { path, line, column }); } -void LanguageClient::get_parameters_hint(DeprecatedString const& path, size_t line, size_t column) +void LanguageClient::get_parameters_hint(ByteString const& path, size_t line, size_t column) { if (!m_connection_wrapper.connection()) return; @@ -146,7 +146,7 @@ void LanguageClient::get_parameters_hint(DeprecatedString const& path, size_t li m_connection_wrapper.connection()->async_get_parameters_hint(CodeComprehension::ProjectLocation { path, line, column }); } -void LanguageClient::get_tokens_info(DeprecatedString const& filename) +void LanguageClient::get_tokens_info(ByteString const& filename) { if (!m_connection_wrapper.connection()) return; @@ -154,7 +154,7 @@ void LanguageClient::get_tokens_info(DeprecatedString const& filename) m_connection_wrapper.connection()->async_get_tokens_info(filename); } -void LanguageClient::declaration_found(DeprecatedString const& file, size_t line, size_t column) const +void LanguageClient::declaration_found(ByteString const& file, size_t line, size_t column) const { if (!on_declaration_found) { dbgln("on_declaration_found callback is not set"); @@ -163,7 +163,7 @@ void LanguageClient::declaration_found(DeprecatedString const& file, size_t line on_declaration_found(file, line, column); } -void LanguageClient::parameters_hint_result(Vector const& params, size_t argument_index) const +void LanguageClient::parameters_hint_result(Vector const& params, size_t argument_index) const { if (!on_function_parameters_hint_result) { dbgln("on_function_parameters_hint_result callback is not set"); @@ -172,17 +172,17 @@ void LanguageClient::parameters_hint_result(Vector const& para on_function_parameters_hint_result(params, argument_index); } -void ConnectionToServerInstances::set_instance_for_language(DeprecatedString const& language_name, NonnullOwnPtr&& connection_wrapper) +void ConnectionToServerInstances::set_instance_for_language(ByteString const& language_name, NonnullOwnPtr&& connection_wrapper) { s_instance_for_language.set(language_name, move(connection_wrapper)); } -void ConnectionToServerInstances::remove_instance_for_language(DeprecatedString const& language_name) +void ConnectionToServerInstances::remove_instance_for_language(ByteString const& language_name) { s_instance_for_language.remove(language_name); } -ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(DeprecatedString const& language_name) +ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(ByteString const& language_name) { if (auto instance = s_instance_for_language.get(language_name); instance.has_value()) { return const_cast(instance.value()); @@ -225,7 +225,7 @@ void ConnectionToServerWrapper::show_crash_notification() const notification->show(); } -ConnectionToServerWrapper::ConnectionToServerWrapper(DeprecatedString const& language_name, Function()> connection_creator) +ConnectionToServerWrapper::ConnectionToServerWrapper(ByteString const& language_name, Function()> connection_creator) : m_language(Syntax::language_from_name(language_name).value()) , m_connection_creator(move(connection_creator)) { diff --git a/Userland/DevTools/HackStudio/LanguageClient.h b/Userland/DevTools/HackStudio/LanguageClient.h index a1d5fa15ed7..b2f1dcb573a 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.h +++ b/Userland/DevTools/HackStudio/LanguageClient.h @@ -31,7 +31,7 @@ class ConnectionToServer friend class ConnectionToServerWrapper; public: - ConnectionToServer(NonnullOwnPtr socket, DeprecatedString const& project_path) + ConnectionToServer(NonnullOwnPtr socket, ByteString const& project_path) : IPC::ConnectionToServer(*this, move(socket)) { m_project_path = project_path; @@ -39,7 +39,7 @@ public: } WeakPtr language_client() { return m_current_language_client; } - DeprecatedString const& project_path() const { return m_project_path; } + ByteString const& project_path() const { return m_project_path; } virtual void die() override; @@ -48,13 +48,13 @@ public: protected: virtual void auto_complete_suggestions(Vector const&) override; virtual void declaration_location(CodeComprehension::ProjectLocation const&) override; - virtual void declarations_in_document(DeprecatedString const&, Vector const&) override; - virtual void todo_entries_in_document(DeprecatedString const&, Vector const&) override; - virtual void parameters_hint_result(Vector const&, int index) override; + virtual void declarations_in_document(ByteString const&, Vector const&) override; + virtual void todo_entries_in_document(ByteString const&, Vector const&) override; + virtual void parameters_hint_result(Vector const&, int index) override; virtual void tokens_info_result(Vector const&) override; void set_wrapper(ConnectionToServerWrapper& wrapper) { m_wrapper = &wrapper; } - DeprecatedString m_project_path; + ByteString m_project_path; WeakPtr m_current_language_client; ConnectionToServerWrapper* m_wrapper { nullptr }; }; @@ -63,11 +63,11 @@ class ConnectionToServerWrapper { AK_MAKE_NONCOPYABLE(ConnectionToServerWrapper); public: - explicit ConnectionToServerWrapper(DeprecatedString const& language_name, Function()> connection_creator); + explicit ConnectionToServerWrapper(ByteString const& language_name, Function()> connection_creator); ~ConnectionToServerWrapper() = default; template - static ConnectionToServerWrapper& get_or_create(DeprecatedString const& project_path); + static ConnectionToServerWrapper& get_or_create(ByteString const& project_path); Syntax::Language language() const { return m_language; } ConnectionToServer* connection(); @@ -93,13 +93,13 @@ private: class ConnectionToServerInstances { public: - static void set_instance_for_language(DeprecatedString const& language_name, NonnullOwnPtr&& connection_wrapper); - static void remove_instance_for_language(DeprecatedString const& language_name); + static void set_instance_for_language(ByteString const& language_name, NonnullOwnPtr&& connection_wrapper); + static void remove_instance_for_language(ByteString const& language_name); - static ConnectionToServerWrapper* get_instance_wrapper(DeprecatedString const& language_name); + static ConnectionToServerWrapper* get_instance_wrapper(ByteString const& language_name); private: - static HashMap> s_instance_for_language; + static HashMap> s_instance_for_language; }; class LanguageClient : public Weakable { @@ -128,23 +128,23 @@ public: Syntax::Language language() const { return m_connection_wrapper.language(); } void set_active_client(); bool is_active_client() const; - virtual void open_file(DeprecatedString const& path, int fd); - virtual void set_file_content(DeprecatedString const& path, DeprecatedString const& content); - virtual void insert_text(DeprecatedString const& path, DeprecatedString const& text, size_t line, size_t column); - virtual void remove_text(DeprecatedString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column); - virtual void request_autocomplete(DeprecatedString const& path, size_t cursor_line, size_t cursor_column); - virtual void search_declaration(DeprecatedString const& path, size_t line, size_t column); - virtual void get_parameters_hint(DeprecatedString const& path, size_t line, size_t column); - virtual void get_tokens_info(DeprecatedString const& filename); + virtual void open_file(ByteString const& path, int fd); + virtual void set_file_content(ByteString const& path, ByteString const& content); + virtual void insert_text(ByteString const& path, ByteString const& text, size_t line, size_t column); + virtual void remove_text(ByteString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column); + virtual void request_autocomplete(ByteString const& path, size_t cursor_line, size_t cursor_column); + virtual void search_declaration(ByteString const& path, size_t line, size_t column); + virtual void get_parameters_hint(ByteString const& path, size_t line, size_t column); + virtual void get_tokens_info(ByteString const& filename); void provide_autocomplete_suggestions(Vector const&) const; - void declaration_found(DeprecatedString const& file, size_t line, size_t column) const; - void parameters_hint_result(Vector const& params, size_t argument_index) const; + void declaration_found(ByteString const& file, size_t line, size_t column) const; + void parameters_hint_result(Vector const& params, size_t argument_index) const; // Callbacks that get called when the result of a language server query is ready Function)> on_autocomplete_suggestions; - Function on_declaration_found; - Function const&, size_t)> on_function_parameters_hint_result; + Function on_declaration_found; + Function const&, size_t)> on_function_parameters_hint_result; Function const&)> on_tokens_info_result; private: @@ -153,13 +153,13 @@ private: }; template -static inline NonnullOwnPtr get_language_client(DeprecatedString const& project_path) +static inline NonnullOwnPtr get_language_client(ByteString const& project_path) { return make(ConnectionToServerWrapper::get_or_create(project_path)); } template -ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(DeprecatedString const& project_path) +ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(ByteString const& project_path) { auto* wrapper = ConnectionToServerInstances::get_instance_wrapper(LanguageServerType::language_name()); if (wrapper) diff --git a/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h b/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h index 34335169140..a511f5e7387 100644 --- a/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h +++ b/Userland/DevTools/HackStudio/LanguageClients/ConnectionsToServer.h @@ -12,22 +12,22 @@ #include #include -#define LANGUAGE_CLIENT(language_name_, socket_name) \ - namespace language_name_ { \ - class ConnectionToServer final : public HackStudio::ConnectionToServer { \ - IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/session/%sid/portal/language/" socket_name) \ - public: \ - static char const* language_name() \ - { \ - return #language_name_; \ - } \ - \ - private: \ - ConnectionToServer(NonnullOwnPtr socket, DeprecatedString const& project_path) \ - : HackStudio::ConnectionToServer(move(socket), project_path) \ - { \ - } \ - }; \ +#define LANGUAGE_CLIENT(language_name_, socket_name) \ + namespace language_name_ { \ + class ConnectionToServer final : public HackStudio::ConnectionToServer { \ + IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/session/%sid/portal/language/" socket_name) \ + public: \ + static char const* language_name() \ + { \ + return #language_name_; \ + } \ + \ + private: \ + ConnectionToServer(NonnullOwnPtr socket, ByteString const& project_path) \ + : HackStudio::ConnectionToServer(move(socket), project_path) \ + { \ + } \ + }; \ } namespace LanguageClients { diff --git a/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.cpp b/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.cpp index fa3d664e27c..878b7ed7ec2 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.cpp @@ -26,7 +26,7 @@ void ConnectionFromClient::die() exit(0); } -void ConnectionFromClient::greet(DeprecatedString const& project_root) +void ConnectionFromClient::greet(ByteString const& project_root) { m_filedb.set_project_root(project_root); if (unveil(project_root.characters(), "r") < 0) { @@ -39,7 +39,7 @@ void ConnectionFromClient::greet(DeprecatedString const& project_root) } } -void ConnectionFromClient::file_opened(DeprecatedString const& filename, IPC::File const& file) +void ConnectionFromClient::file_opened(ByteString const& filename, IPC::File const& file) { if (m_filedb.is_open(filename)) { return; @@ -48,7 +48,7 @@ void ConnectionFromClient::file_opened(DeprecatedString const& filename, IPC::Fi m_autocomplete_engine->file_opened(filename); } -void ConnectionFromClient::file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& text, i32 start_line, i32 start_column) +void ConnectionFromClient::file_edit_insert_text(ByteString const& filename, ByteString const& text, i32 start_line, i32 start_column) { dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", filename); dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", text); @@ -57,7 +57,7 @@ void ConnectionFromClient::file_edit_insert_text(DeprecatedString const& filenam m_autocomplete_engine->on_edit(filename); } -void ConnectionFromClient::file_edit_remove_text(DeprecatedString const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) +void ConnectionFromClient::file_edit_remove_text(ByteString const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) { dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", filename); dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", start_line, start_column, end_line, end_column); @@ -80,7 +80,7 @@ void ConnectionFromClient::auto_complete_suggestions(CodeComprehension::ProjectL async_auto_complete_suggestions(move(suggestions)); } -void ConnectionFromClient::set_file_content(DeprecatedString const& filename, DeprecatedString const& content) +void ConnectionFromClient::set_file_content(ByteString const& filename, ByteString const& content) { dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", filename); auto document = m_filedb.get_document(filename); @@ -139,7 +139,7 @@ void ConnectionFromClient::get_parameters_hint(CodeComprehension::ProjectLocatio async_parameters_hint_result(params->params, params->current_index); } -void ConnectionFromClient::get_tokens_info(DeprecatedString const& filename) +void ConnectionFromClient::get_tokens_info(ByteString const& filename) { dbgln_if(LANGUAGE_SERVER_DEBUG, "GetTokenInfo: {}", filename); auto document = m_filedb.get_document(filename); diff --git a/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.h b/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.h index 59affb06c20..9498e929100 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.h +++ b/Userland/DevTools/HackStudio/LanguageServers/ConnectionFromClient.h @@ -27,15 +27,15 @@ public: virtual void die() override; protected: - virtual void greet(DeprecatedString const&) override; - virtual void file_opened(DeprecatedString const&, IPC::File const&) override; - virtual void file_edit_insert_text(DeprecatedString const&, DeprecatedString const&, i32, i32) override; - virtual void file_edit_remove_text(DeprecatedString const&, i32, i32, i32, i32) override; - virtual void set_file_content(DeprecatedString const&, DeprecatedString const&) override; + virtual void greet(ByteString const&) override; + virtual void file_opened(ByteString const&, IPC::File const&) override; + virtual void file_edit_insert_text(ByteString const&, ByteString const&, i32, i32) override; + virtual void file_edit_remove_text(ByteString const&, i32, i32, i32, i32) override; + virtual void set_file_content(ByteString const&, ByteString const&) override; virtual void auto_complete_suggestions(CodeComprehension::ProjectLocation const&) override; virtual void find_declaration(CodeComprehension::ProjectLocation const&) override; virtual void get_parameters_hint(CodeComprehension::ProjectLocation const&) override; - virtual void get_tokens_info(DeprecatedString const&) override; + virtual void get_tokens_info(ByteString const&) override; FileDB m_filedb; OwnPtr m_autocomplete_engine; diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h index 360788c91ae..1b7671e6e3f 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/ConnectionFromClient.h @@ -19,10 +19,10 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = adopt_own(*new CodeComprehension::Cpp::CppComprehensionEngine(m_filedb)); - m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector&& declarations) { async_declarations_in_document(filename, move(declarations)); }; - m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector&& todo_entries) { + m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector&& todo_entries) { async_todo_entries_in_document(filename, move(todo_entries)); }; } diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp index 5bfb6448c89..831abe43c7d 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.cpp @@ -13,7 +13,7 @@ namespace LanguageServers { -RefPtr FileDB::get_document(DeprecatedString const& filename) const +RefPtr FileDB::get_document(ByteString const& filename) const { auto absolute_path = to_absolute_path(filename); auto document_optional = m_open_files.get(absolute_path); @@ -23,7 +23,7 @@ RefPtr FileDB::get_document(DeprecatedString const& fil return *document_optional.value(); } -RefPtr FileDB::get_document(DeprecatedString const& filename) +RefPtr FileDB::get_document(ByteString const& filename) { auto document = reinterpret_cast(this)->get_document(filename); if (document.is_null()) @@ -31,7 +31,7 @@ RefPtr FileDB::get_document(DeprecatedString const& filename) return adopt_ref(*const_cast(document.leak_ref())); } -Optional FileDB::get_or_read_from_filesystem(StringView filename) const +Optional FileDB::get_or_read_from_filesystem(StringView filename) const { auto absolute_path = to_absolute_path(filename); auto document = get_document(absolute_path); @@ -46,12 +46,12 @@ Optional FileDB::get_or_read_from_filesystem(StringView filena return document_or_error.value()->text(); } -bool FileDB::is_open(DeprecatedString const& filename) const +bool FileDB::is_open(ByteString const& filename) const { return m_open_files.contains(to_absolute_path(filename)); } -bool FileDB::add(DeprecatedString const& filename, int fd) +bool FileDB::add(ByteString const& filename, int fd) { auto document_or_error = create_from_fd(fd); if (document_or_error.is_error()) { @@ -63,17 +63,17 @@ bool FileDB::add(DeprecatedString const& filename, int fd) return true; } -DeprecatedString FileDB::to_absolute_path(DeprecatedString const& filename) const +ByteString FileDB::to_absolute_path(ByteString const& filename) const { if (LexicalPath { filename }.is_absolute()) { return filename; } if (!m_project_root.has_value()) return filename; - return LexicalPath { DeprecatedString::formatted("{}/{}", *m_project_root, filename) }.string(); + return LexicalPath { ByteString::formatted("{}/{}", *m_project_root, filename) }.string(); } -ErrorOr> FileDB::create_from_filesystem(DeprecatedString const& filename) const +ErrorOr> FileDB::create_from_filesystem(ByteString const& filename) const { auto file = TRY(Core::File::open(to_absolute_path(filename), Core::File::OpenMode::Read)); return create_from_file(move(file)); @@ -110,7 +110,7 @@ ErrorOr> FileDB::create_from_file(NonnullOwnPtr return document; } -void FileDB::on_file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& inserted_text, size_t start_line, size_t start_column) +void FileDB::on_file_edit_insert_text(ByteString const& filename, ByteString const& inserted_text, size_t start_line, size_t start_column) { VERIFY(is_open(filename)); auto document = get_document(filename); @@ -121,7 +121,7 @@ void FileDB::on_file_edit_insert_text(DeprecatedString const& filename, Deprecat dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text()); } -void FileDB::on_file_edit_remove_text(DeprecatedString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column) +void FileDB::on_file_edit_remove_text(ByteString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column) { // TODO: If file is not open - need to get its contents // Otherwise- somehow verify that respawned language server is synced with all file contents @@ -138,7 +138,7 @@ void FileDB::on_file_edit_remove_text(DeprecatedString const& filename, size_t s dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text()); } -RefPtr FileDB::create_with_content(DeprecatedString const& content) +RefPtr FileDB::create_with_content(ByteString const& content) { StringView content_view(content); auto document = GUI::TextDocument::create(&s_default_document_client); @@ -146,7 +146,7 @@ RefPtr FileDB::create_with_content(DeprecatedString const& co return document; } -bool FileDB::add(DeprecatedString const& filename, DeprecatedString const& content) +bool FileDB::add(ByteString const& filename, ByteString const& content) { auto document = create_with_content(content); if (!document) { diff --git a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h index 35b743306d0..96221e6fdfa 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/FileDB.h +++ b/Userland/DevTools/HackStudio/LanguageServers/FileDB.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -17,28 +17,28 @@ namespace LanguageServers { class FileDB final : public CodeComprehension::FileDB { public: FileDB() = default; - virtual Optional get_or_read_from_filesystem(StringView filename) const override; + virtual Optional get_or_read_from_filesystem(StringView filename) const override; - RefPtr get_document(DeprecatedString const& filename) const; - RefPtr get_document(DeprecatedString const& filename); + RefPtr get_document(ByteString const& filename) const; + RefPtr get_document(ByteString const& filename); - bool add(DeprecatedString const& filename, int fd); - bool add(DeprecatedString const& filename, DeprecatedString const& content); + bool add(ByteString const& filename, int fd); + bool add(ByteString const& filename, ByteString const& content); - void on_file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& inserted_text, size_t start_line, size_t start_column); - void on_file_edit_remove_text(DeprecatedString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column); - DeprecatedString to_absolute_path(DeprecatedString const& filename) const; - bool is_open(DeprecatedString const& filename) const; + void on_file_edit_insert_text(ByteString const& filename, ByteString const& inserted_text, size_t start_line, size_t start_column); + void on_file_edit_remove_text(ByteString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column); + ByteString to_absolute_path(ByteString const& filename) const; + bool is_open(ByteString const& filename) const; private: - ErrorOr> create_from_filesystem(DeprecatedString const& filename) const; + ErrorOr> create_from_filesystem(ByteString const& filename) const; ErrorOr> create_from_fd(int fd) const; ErrorOr> create_from_file(NonnullOwnPtr) const; - static RefPtr create_with_content(DeprecatedString const&); + static RefPtr create_with_content(ByteString const&); private: - HashMap> m_open_files; - Optional m_project_root; + HashMap> m_open_files; + Optional m_project_root; }; } diff --git a/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc b/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc index 68f724762fc..f20fd2e7ccf 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc +++ b/Userland/DevTools/HackStudio/LanguageServers/LanguageClient.ipc @@ -2,8 +2,8 @@ endpoint LanguageClient { auto_complete_suggestions(Vector suggestions) =| declaration_location(CodeComprehension::ProjectLocation location) =| - declarations_in_document(DeprecatedString filename, Vector declarations) =| - todo_entries_in_document(DeprecatedString filename, Vector todo_entries) =| - parameters_hint_result(Vector params, int current_index) =| + declarations_in_document(ByteString filename, Vector declarations) =| + todo_entries_in_document(ByteString filename, Vector todo_entries) =| + parameters_hint_result(Vector params, int current_index) =| tokens_info_result(Vector tokens_info) =| } diff --git a/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc b/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc index 23dfe681b9e..5f4b7b45e42 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc +++ b/Userland/DevTools/HackStudio/LanguageServers/LanguageServer.ipc @@ -1,15 +1,15 @@ endpoint LanguageServer { - greet(DeprecatedString project_root) =| + greet(ByteString project_root) =| - file_opened(DeprecatedString filename, IPC::File file) =| - file_edit_insert_text(DeprecatedString filename, DeprecatedString text, i32 start_line, i32 start_column) =| - file_edit_remove_text(DeprecatedString filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =| - set_file_content(DeprecatedString filename, DeprecatedString content) =| + file_opened(ByteString filename, IPC::File file) =| + file_edit_insert_text(ByteString filename, ByteString text, i32 start_line, i32 start_column) =| + file_edit_remove_text(ByteString filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =| + set_file_content(ByteString filename, ByteString content) =| auto_complete_suggestions(CodeComprehension::ProjectLocation location) =| find_declaration(CodeComprehension::ProjectLocation location) =| get_parameters_hint(CodeComprehension::ProjectLocation location) =| - get_tokens_info(DeprecatedString filename) =| + get_tokens_info(ByteString filename) =| } diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h b/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h index 44a0f1a30c4..aab13a056bf 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/ConnectionFromClient.h @@ -20,10 +20,10 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = make(m_filedb); - m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector&& declarations) { async_declarations_in_document(filename, move(declarations)); }; - m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector&& todo_entries) { + m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector&& todo_entries) { async_todo_entries_in_document(filename, move(todo_entries)); }; } diff --git a/Userland/DevTools/HackStudio/Locator.cpp b/Userland/DevTools/HackStudio/Locator.cpp index 582bc2ff0a1..54b031949f9 100644 --- a/Userland/DevTools/HackStudio/Locator.cpp +++ b/Userland/DevTools/HackStudio/Locator.cpp @@ -21,13 +21,13 @@ namespace HackStudio { class LocatorSuggestionModel final : public GUI::Model { public: struct Suggestion { - static Suggestion create_filename(DeprecatedString const& filename); + static Suggestion create_filename(ByteString const& filename); static Suggestion create_symbol_declaration(CodeComprehension::Declaration const&); bool is_filename() const { return as_filename.has_value(); } bool is_symbol_declaration() const { return as_symbol_declaration.has_value(); } - Optional as_filename; + Optional as_filename; Optional as_symbol_declaration; }; @@ -62,7 +62,7 @@ public: if (index.column() == Column::Name) { if (!suggestion.as_symbol_declaration.value().scope.is_empty()) return suggestion.as_symbol_declaration.value().name; - return DeprecatedString::formatted("{}::{}", suggestion.as_symbol_declaration.value().scope, suggestion.as_symbol_declaration.value().name); + return ByteString::formatted("{}::{}", suggestion.as_symbol_declaration.value().scope, suggestion.as_symbol_declaration.value().name); } if (index.column() == Column::Filename) return suggestion.as_symbol_declaration.value().position.file; @@ -82,7 +82,7 @@ private: Vector m_suggestions; }; -LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(DeprecatedString const& filename) +LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(ByteString const& filename) { LocatorSuggestionModel::Suggestion s; s.as_filename = filename; diff --git a/Userland/DevTools/HackStudio/Project.cpp b/Userland/DevTools/HackStudio/Project.cpp index 1358958cc2a..3bde5faa804 100644 --- a/Userland/DevTools/HackStudio/Project.cpp +++ b/Userland/DevTools/HackStudio/Project.cpp @@ -10,13 +10,13 @@ namespace HackStudio { -Project::Project(DeprecatedString const& root_path) +Project::Project(ByteString const& root_path) : m_root_path(root_path) { m_model = GUI::FileSystemModel::create(root_path, GUI::FileSystemModel::Mode::FilesAndDirectories); } -OwnPtr Project::open_with_root_path(DeprecatedString const& root_path) +OwnPtr Project::open_with_root_path(ByteString const& root_path) { if (!FileSystem::is_directory(root_path)) return {}; @@ -45,18 +45,18 @@ void Project::for_each_text_file(Function callback) co }); } -NonnullRefPtr Project::create_file(DeprecatedString const& path) const +NonnullRefPtr Project::create_file(ByteString const& path) const { auto full_path = to_absolute_path(path); return ProjectFile::construct_with_name(full_path); } -DeprecatedString Project::to_absolute_path(DeprecatedString const& path) const +ByteString Project::to_absolute_path(ByteString const& path) const { if (LexicalPath { path }.is_absolute()) { return path; } - return LexicalPath { DeprecatedString::formatted("{}/{}", m_root_path, path) }.string(); + return LexicalPath { ByteString::formatted("{}/{}", m_root_path, path) }.string(); } bool Project::project_is_serenity() const diff --git a/Userland/DevTools/HackStudio/Project.h b/Userland/DevTools/HackStudio/Project.h index 62522a8626c..f0698b91143 100644 --- a/Userland/DevTools/HackStudio/Project.h +++ b/Userland/DevTools/HackStudio/Project.h @@ -20,28 +20,28 @@ class Project { AK_MAKE_NONMOVABLE(Project); public: - static OwnPtr open_with_root_path(DeprecatedString const& root_path); + static OwnPtr open_with_root_path(ByteString const& root_path); GUI::FileSystemModel& model() { return *m_model; } const GUI::FileSystemModel& model() const { return *m_model; } - DeprecatedString name() const { return LexicalPath::basename(m_root_path); } - DeprecatedString root_path() const { return m_root_path; } + ByteString name() const { return LexicalPath::basename(m_root_path); } + ByteString root_path() const { return m_root_path; } - NonnullRefPtr create_file(DeprecatedString const& path) const; + NonnullRefPtr create_file(ByteString const& path) const; void for_each_text_file(Function) const; - DeprecatedString to_absolute_path(DeprecatedString const&) const; + ByteString to_absolute_path(ByteString const&) const; bool project_is_serenity() const; static constexpr auto config_file_path = ".hackstudio/config.json"sv; NonnullOwnPtr config() const; private: - explicit Project(DeprecatedString const& root_path); + explicit Project(ByteString const& root_path); RefPtr m_model; - DeprecatedString m_root_path; + ByteString m_root_path; }; } diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp index ae8e3e019c3..cf39e50f153 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp +++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp @@ -35,7 +35,7 @@ ErrorOr ProjectBuilder::build(StringView active_file) return Error::from_string_literal("no active file"); if (active_file.ends_with(".js"sv)) { - TRY(m_terminal->run_command(DeprecatedString::formatted("js -A {}", active_file))); + TRY(m_terminal->run_command(ByteString::formatted("js -A {}", active_file))); return {}; } @@ -61,7 +61,7 @@ ErrorOr ProjectBuilder::run(StringView active_file) return Error::from_string_literal("no active file"); if (active_file.ends_with(".js"sv)) { - TRY(m_terminal->run_command(DeprecatedString::formatted("js {}", active_file))); + TRY(m_terminal->run_command(ByteString::formatted("js {}", active_file))); return {}; } @@ -105,11 +105,11 @@ ErrorOr ProjectBuilder::update_active_file(StringView active_file) ErrorOr ProjectBuilder::build_serenity_component() { TRY(verify_make_is_installed()); - TRY(m_terminal->run_command(DeprecatedString::formatted("make {}", m_serenity_component_name), build_directory(), TerminalWrapper::WaitForExit::Yes, "Make failed"sv)); + TRY(m_terminal->run_command(ByteString::formatted("make {}", m_serenity_component_name), build_directory(), TerminalWrapper::WaitForExit::Yes, "Make failed"sv)); return {}; } -ErrorOr ProjectBuilder::component_name(StringView cmake_file_path) +ErrorOr ProjectBuilder::component_name(StringView cmake_file_path) { auto file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Read)); auto content = TRY(file->read_until_eof()); @@ -119,7 +119,7 @@ ErrorOr ProjectBuilder::component_name(StringView cmake_file_p if (!component_name.search(StringView { content }, result)) return Error::from_string_literal("component not found"); - return DeprecatedString { result.capture_group_matches.at(0).at(0).view.string_view() }; + return ByteString { result.capture_group_matches.at(0).at(0).view.string_view() }; } ErrorOr ProjectBuilder::initialize_build_directory() @@ -137,15 +137,15 @@ ErrorOr ProjectBuilder::initialize_build_directory() auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::File::OpenMode::Write)); TRY(cmake_file->write_until_depleted(generate_cmake_file_content().bytes())); - TRY(m_terminal->run_command(DeprecatedString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}" - " -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF", + TRY(m_terminal->run_command(ByteString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}" + " -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF", m_project_root, cmake_file_path), build_directory(), TerminalWrapper::WaitForExit::Yes, "CMake error"sv)); return {}; } -Optional ProjectBuilder::find_cmake_file_for(StringView file_path) const +Optional ProjectBuilder::find_cmake_file_for(StringView file_path) const { auto directory = LexicalPath::dirname(file_path); while (!directory.is_empty()) { @@ -157,7 +157,7 @@ Optional ProjectBuilder::find_cmake_file_for(StringView file_p return {}; } -DeprecatedString ProjectBuilder::generate_cmake_file_content() const +ByteString ProjectBuilder::generate_cmake_file_content() const { StringBuilder builder; builder.appendff("add_subdirectory({})\n", LexicalPath::dirname(m_serenity_component_cmake_file)); @@ -174,20 +174,20 @@ DeprecatedString ProjectBuilder::generate_cmake_file_content() const // all of their direct dependencies in the CMakeLists file. // For example, a target may directly use LibGFX but only specify LibGUI as a dependency (which in turn depends on LibGFX). // In this example, if we don't specify the dependencies of LibGUI in the CMake file, linking will fail because of undefined LibGFX symbols. - builder.appendff("target_link_libraries({} INTERFACE {})\n", library.key, DeprecatedString::join(' ', library.value->dependencies)); + builder.appendff("target_link_libraries({} INTERFACE {})\n", library.key, ByteString::join(' ', library.value->dependencies)); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -HashMap> ProjectBuilder::get_defined_libraries() +HashMap> ProjectBuilder::get_defined_libraries() { - HashMap> libraries; + HashMap> libraries; - for_each_library_definition([&libraries](DeprecatedString name, DeprecatedString path) { + for_each_library_definition([&libraries](ByteString name, ByteString path) { libraries.set(name, make(move(path))); }); - for_each_library_dependencies([&libraries](DeprecatedString name, Vector const& dependencies) { + for_each_library_dependencies([&libraries](ByteString name, Vector const& dependencies) { auto library = libraries.get(name); if (!library.has_value()) return; @@ -199,9 +199,9 @@ HashMap> ProjectBui return libraries; } -void ProjectBuilder::for_each_library_definition(Function func) +void ProjectBuilder::for_each_library_definition(Function func) { - Vector arguments = { "-c", "find Userland -name CMakeLists.txt | xargs grep serenity_lib" }; + Vector arguments = { "-c", "find Userland -name CMakeLists.txt | xargs grep serenity_lib" }; auto res = Core::command("/bin/sh", arguments, {}); if (res.is_error()) { warnln("{}", res.error()); @@ -218,7 +218,7 @@ void ProjectBuilder::for_each_library_definition(Function)> func) +void ProjectBuilder::for_each_library_dependencies(Function)> func) { - Vector arguments = { "-c", "find Userland/Libraries -name CMakeLists.txt | xargs grep target_link_libraries" }; + Vector arguments = { "-c", "find Userland/Libraries -name CMakeLists.txt | xargs grep target_link_libraries" }; auto res = Core::command("/bin/sh", arguments, {}); if (res.is_error()) { warnln("{}", res.error()); @@ -267,7 +267,7 @@ ErrorOr ProjectBuilder::verify_make_is_installed() return Error::from_string_literal("Make port is not installed"); } -DeprecatedString ProjectBuilder::build_directory() const +ByteString ProjectBuilder::build_directory() const { return LexicalPath::join(m_project_root, "Build"sv).string(); } diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.h b/Userland/DevTools/HackStudio/ProjectBuilder.h index c579202e1b7..194f38d5d7a 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.h +++ b/Userland/DevTools/HackStudio/ProjectBuilder.h @@ -32,27 +32,27 @@ private: ErrorOr build_serenity_component(); ErrorOr run_serenity_component(); ErrorOr initialize_build_directory(); - Optional find_cmake_file_for(StringView file_path) const; - DeprecatedString generate_cmake_file_content() const; + Optional find_cmake_file_for(StringView file_path) const; + ByteString generate_cmake_file_content() const; ErrorOr update_active_file(StringView active_file); - DeprecatedString build_directory() const; + ByteString build_directory() const; struct LibraryInfo { - DeprecatedString path; - Vector dependencies {}; + ByteString path; + Vector dependencies {}; }; - static HashMap> get_defined_libraries(); - static void for_each_library_definition(Function); - static void for_each_library_dependencies(Function)>); - static ErrorOr component_name(StringView cmake_file_path); + static HashMap> get_defined_libraries(); + static void for_each_library_definition(Function); + static void for_each_library_dependencies(Function)>); + static ErrorOr component_name(StringView cmake_file_path); static ErrorOr verify_cmake_is_installed(); static ErrorOr verify_make_is_installed(); - DeprecatedString m_project_root; + ByteString m_project_root; Project const& m_project; NonnullRefPtr m_terminal; IsSerenityRepo m_is_serenity { IsSerenityRepo::No }; - DeprecatedString m_serenity_component_cmake_file; - DeprecatedString m_serenity_component_name; + ByteString m_serenity_component_cmake_file; + ByteString m_serenity_component_name; }; } diff --git a/Userland/DevTools/HackStudio/ProjectConfig.cpp b/Userland/DevTools/HackStudio/ProjectConfig.cpp index 9687e36daff..746b5c4938d 100644 --- a/Userland/DevTools/HackStudio/ProjectConfig.cpp +++ b/Userland/DevTools/HackStudio/ProjectConfig.cpp @@ -15,7 +15,7 @@ ProjectConfig::ProjectConfig(JsonObject config) { } -ErrorOr> ProjectConfig::try_load_project_config(DeprecatedString path) +ErrorOr> ProjectConfig::try_load_project_config(ByteString path) { auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto file_contents = TRY(file->read_until_eof()); @@ -33,9 +33,9 @@ NonnullOwnPtr ProjectConfig::create_empty() return adopt_own(*new ProjectConfig(empty)); } -Optional ProjectConfig::read_key(DeprecatedString key_name) const +Optional ProjectConfig::read_key(ByteString key_name) const { - return m_config.get_deprecated_string(key_name); + return m_config.get_byte_string(key_name); } } diff --git a/Userland/DevTools/HackStudio/ProjectConfig.h b/Userland/DevTools/HackStudio/ProjectConfig.h index 20019aa6a98..30ee7d2ffcd 100644 --- a/Userland/DevTools/HackStudio/ProjectConfig.h +++ b/Userland/DevTools/HackStudio/ProjectConfig.h @@ -16,16 +16,16 @@ namespace HackStudio { class ProjectConfig { public: - static ErrorOr> try_load_project_config(DeprecatedString path); + static ErrorOr> try_load_project_config(ByteString path); static NonnullOwnPtr create_empty(); ProjectConfig(JsonObject); - Optional build_command() const { return read_key("build_command"); } - Optional run_command() const { return read_key("run_command"); } + Optional build_command() const { return read_key("build_command"); } + Optional run_command() const { return read_key("run_command"); } private: - Optional read_key(DeprecatedString key_name) const; + Optional read_key(ByteString key_name) const; JsonObject m_config; }; diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp index dff6118a079..b4adce4f7b0 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp @@ -11,7 +11,7 @@ HackStudio::ProjectDeclarations& HackStudio::ProjectDeclarations::the() static ProjectDeclarations s_instance; return s_instance; } -void HackStudio::ProjectDeclarations::set_declared_symbols(DeprecatedString const& filename, Vector const& declarations) +void HackStudio::ProjectDeclarations::set_declared_symbols(ByteString const& filename, Vector const& declarations) { m_document_to_declarations.set(filename, declarations); if (on_update) diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.h b/Userland/DevTools/HackStudio/ProjectDeclarations.h index ee1e6f53de9..d356cfd33ef 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.h +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -23,7 +23,7 @@ public: template void for_each_declared_symbol(Func); - void set_declared_symbols(DeprecatedString const& filename, Vector const&); + void set_declared_symbols(ByteString const& filename, Vector const&); static Optional get_icon_for(CodeComprehension::DeclarationType); @@ -31,7 +31,7 @@ public: private: ProjectDeclarations() = default; - HashMap> m_document_to_declarations; + HashMap> m_document_to_declarations; }; template diff --git a/Userland/DevTools/HackStudio/ProjectFile.cpp b/Userland/DevTools/HackStudio/ProjectFile.cpp index 35fba436b09..98ab665c475 100644 --- a/Userland/DevTools/HackStudio/ProjectFile.cpp +++ b/Userland/DevTools/HackStudio/ProjectFile.cpp @@ -9,7 +9,7 @@ namespace HackStudio { -ProjectFile::ProjectFile(DeprecatedString const& name) +ProjectFile::ProjectFile(ByteString const& name) : m_name(name) { } diff --git a/Userland/DevTools/HackStudio/ProjectFile.h b/Userland/DevTools/HackStudio/ProjectFile.h index b4e38eca73d..d8fd6e10a0b 100644 --- a/Userland/DevTools/HackStudio/ProjectFile.h +++ b/Userland/DevTools/HackStudio/ProjectFile.h @@ -8,7 +8,7 @@ #include "CodeDocument.h" #include -#include +#include #include #include @@ -16,12 +16,12 @@ namespace HackStudio { class ProjectFile : public RefCounted { public: - static NonnullRefPtr construct_with_name(DeprecatedString const& name) + static NonnullRefPtr construct_with_name(ByteString const& name) { return adopt_ref(*new ProjectFile(name)); } - DeprecatedString const& name() const { return m_name; } + ByteString const& name() const { return m_name; } bool could_render_text() const { return m_could_render_text; } GUI::TextDocument& document() const; @@ -33,10 +33,10 @@ public: void horizontal_scroll_value(int); private: - explicit ProjectFile(DeprecatedString const& name); + explicit ProjectFile(ByteString const& name); void create_document_if_needed() const; - DeprecatedString m_name; + ByteString m_name; mutable RefPtr m_document; mutable bool m_could_render_text { false }; int m_vertical_scroll_value { 0 }; diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index 9ba02a85f43..415329b8b30 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -5,7 +5,7 @@ */ #include "ProjectTemplate.h" -#include +#include #include #include #include @@ -19,7 +19,7 @@ namespace HackStudio { -ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority) +ProjectTemplate::ProjectTemplate(ByteString const& id, ByteString const& name, ByteString const& description, const GUI::Icon& icon, int priority) : m_id(id) , m_name(name) , m_description(description) @@ -28,7 +28,7 @@ ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString co { } -RefPtr ProjectTemplate::load_from_manifest(DeprecatedString const& manifest_path) +RefPtr ProjectTemplate::load_from_manifest(ByteString const& manifest_path) { auto maybe_config = Core::ConfigFile::open(manifest_path); if (maybe_config.is_error()) @@ -50,7 +50,7 @@ RefPtr ProjectTemplate::load_from_manifest(DeprecatedString con // Fallback to a generic executable icon if one isn't found auto icon = GUI::Icon::default_icon("filetype-executable"sv); - auto bitmap_path_32 = DeprecatedString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x")); + auto bitmap_path_32 = ByteString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x")); if (FileSystem::exists(bitmap_path_32)) { auto bitmap_or_error = Gfx::Bitmap::load_from_file(bitmap_path_32); @@ -61,11 +61,11 @@ RefPtr ProjectTemplate::load_from_manifest(DeprecatedString con return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority)); } -Result ProjectTemplate::create_project(DeprecatedString const& name, DeprecatedString const& path) +Result ProjectTemplate::create_project(ByteString const& name, ByteString const& path) { // Check if a file or directory already exists at the project path if (FileSystem::exists(path)) - return DeprecatedString("File or directory already exists at specified location."); + return ByteString("File or directory already exists at specified location."); dbgln("Creating project at path '{}' with name '{}'", path, name); @@ -75,19 +75,19 @@ Result ProjectTemplate::create_project(DeprecatedString auto result = FileSystem::copy_file_or_directory(path, content_path()); dbgln("Copying {} -> {}", content_path(), path); if (result.is_error()) - return DeprecatedString::formatted("Failed to copy template contents. Error code: {}", static_cast(result.error())); + return ByteString::formatted("Failed to copy template contents. Error code: {}", static_cast(result.error())); } else { dbgln("No template content directory found for '{}', creating an empty directory for the project.", m_id); int rc; if ((rc = mkdir(path.characters(), 0755)) < 0) { - return DeprecatedString::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc); + return ByteString::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc); } } // Check for an executable post-create script in $TEMPLATES_DIR/$ID.postcreate, // and run it with the path and name - auto postcreate_script_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}.postcreate", templates_path(), m_id)); + auto postcreate_script_path = LexicalPath::canonicalized_path(ByteString::formatted("{}/{}.postcreate", templates_path(), m_id)); struct stat postcreate_st; int result = stat(postcreate_script_path.characters(), &postcreate_st); if (result == 0 && (postcreate_st.st_mode & S_IXOTH) == S_IXOTH) { @@ -101,19 +101,19 @@ Result ProjectTemplate::create_project(DeprecatedString if ((errno = posix_spawn(&child_pid, postcreate_script_path.characters(), nullptr, nullptr, const_cast(argv), environ))) { perror("posix_spawn"); - return DeprecatedString("Failed to spawn project post-create script."); + return ByteString("Failed to spawn project post-create script."); } // Command spawned, wait for exit. int status; if (waitpid(child_pid, &status, 0) < 0) - return DeprecatedString("Failed to spawn project post-create script."); + return ByteString("Failed to spawn project post-create script."); int child_error = WEXITSTATUS(status); dbgln("Post-create script exited with code {}", child_error); if (child_error != 0) - return DeprecatedString("Project post-creation script exited with non-zero error code."); + return ByteString("Project post-creation script exited with non-zero error code."); } return {}; diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.h b/Userland/DevTools/HackStudio/ProjectTemplate.h index 3d3bb85322c..e8075421b29 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.h +++ b/Userland/DevTools/HackStudio/ProjectTemplate.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include #include @@ -18,28 +18,28 @@ namespace HackStudio { class ProjectTemplate : public RefCounted { public: - static DeprecatedString templates_path() { return "/res/devel/templates"; } + static ByteString templates_path() { return "/res/devel/templates"; } - static RefPtr load_from_manifest(DeprecatedString const& manifest_path); + static RefPtr load_from_manifest(ByteString const& manifest_path); - explicit ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority); + explicit ProjectTemplate(ByteString const& id, ByteString const& name, ByteString const& description, const GUI::Icon& icon, int priority); - Result create_project(DeprecatedString const& name, DeprecatedString const& path); + Result create_project(ByteString const& name, ByteString const& path); - DeprecatedString const& id() const { return m_id; } - DeprecatedString const& name() const { return m_name; } - DeprecatedString const& description() const { return m_description; } + ByteString const& id() const { return m_id; } + ByteString const& name() const { return m_name; } + ByteString const& description() const { return m_description; } const GUI::Icon& icon() const { return m_icon; } - const DeprecatedString content_path() const + const ByteString content_path() const { - return LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", templates_path(), m_id)); + return LexicalPath::canonicalized_path(ByteString::formatted("{}/{}", templates_path(), m_id)); } int priority() const { return m_priority; } private: - DeprecatedString m_id; - DeprecatedString m_name; - DeprecatedString m_description; + ByteString m_id; + ByteString m_name; + ByteString m_description; GUI::Icon m_icon; int m_priority { 0 }; }; diff --git a/Userland/DevTools/HackStudio/TerminalWrapper.cpp b/Userland/DevTools/HackStudio/TerminalWrapper.cpp index a7bb513fcb2..a62db7d440f 100644 --- a/Userland/DevTools/HackStudio/TerminalWrapper.cpp +++ b/Userland/DevTools/HackStudio/TerminalWrapper.cpp @@ -6,7 +6,7 @@ */ #include "TerminalWrapper.h" -#include +#include #include #include #include @@ -24,7 +24,7 @@ namespace HackStudio { -ErrorOr TerminalWrapper::run_command(DeprecatedString const& command, Optional working_directory, WaitForExit wait_for_exit, Optional failure_message) +ErrorOr TerminalWrapper::run_command(ByteString const& command, Optional working_directory, WaitForExit wait_for_exit, Optional failure_message) { if (m_pid != -1) { GUI::MessageBox::show(window(), @@ -92,11 +92,11 @@ ErrorOr TerminalWrapper::setup_master_pseudoterminal(WaitForChildOnExit wai int wstatus = result.release_value().status; if (WIFEXITED(wstatus)) { - m_terminal_widget->inject_string(DeprecatedString::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus))); + m_terminal_widget->inject_string(ByteString::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus))); } else if (WIFSTOPPED(wstatus)) { m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\r\n"sv); } else if (WIFSIGNALED(wstatus)) { - m_terminal_widget->inject_string(DeprecatedString::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus)))); + m_terminal_widget->inject_string(ByteString::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus)))); } m_child_exit_status = WEXITSTATUS(wstatus); diff --git a/Userland/DevTools/HackStudio/TerminalWrapper.h b/Userland/DevTools/HackStudio/TerminalWrapper.h index e4e94031f1d..5355a8504ba 100644 --- a/Userland/DevTools/HackStudio/TerminalWrapper.h +++ b/Userland/DevTools/HackStudio/TerminalWrapper.h @@ -21,7 +21,7 @@ public: No, Yes }; - ErrorOr run_command(DeprecatedString const&, Optional working_directory = {}, WaitForExit = WaitForExit::No, Optional failure_message = {}); + ErrorOr run_command(ByteString const&, Optional working_directory = {}, WaitForExit = WaitForExit::No, Optional failure_message = {}); ErrorOr kill_running_command(); void clear_including_history(); diff --git a/Userland/DevTools/HackStudio/ToDoEntries.cpp b/Userland/DevTools/HackStudio/ToDoEntries.cpp index 9c81dce40d3..5860946a7f9 100644 --- a/Userland/DevTools/HackStudio/ToDoEntries.cpp +++ b/Userland/DevTools/HackStudio/ToDoEntries.cpp @@ -14,7 +14,7 @@ ToDoEntries& HackStudio::ToDoEntries::the() return s_instance; } -void ToDoEntries::set_entries(DeprecatedString const& filename, Vector const&& entries) +void ToDoEntries::set_entries(ByteString const& filename, Vector const&& entries) { m_document_to_entries.set(filename, move(entries)); if (on_update) diff --git a/Userland/DevTools/HackStudio/ToDoEntries.h b/Userland/DevTools/HackStudio/ToDoEntries.h index d693e1945e3..31e3358dba1 100644 --- a/Userland/DevTools/HackStudio/ToDoEntries.h +++ b/Userland/DevTools/HackStudio/ToDoEntries.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -20,7 +20,7 @@ class ToDoEntries { public: static ToDoEntries& the(); - void set_entries(DeprecatedString const& filename, Vector const&& entries); + void set_entries(ByteString const& filename, Vector const&& entries); Vector get_entries(); @@ -30,7 +30,7 @@ public: private: ToDoEntries() = default; - HashMap> m_document_to_entries; + HashMap> m_document_to_entries; }; } diff --git a/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp b/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp index 5c87472ac85..d3b73557ec3 100644 --- a/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp +++ b/Userland/DevTools/HackStudio/ToDoEntriesWidget.cpp @@ -63,9 +63,9 @@ public: case Column::Text: return match.content; case Column::Line: - return DeprecatedString::formatted("{}", match.line + 1); + return ByteString::formatted("{}", match.line + 1); case Column::Column: - return DeprecatedString::formatted("{}", match.column); + return ByteString::formatted("{}", match.column); } } return {}; diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index 1ecf881e5a3..7d5eb7e0775 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -33,7 +33,7 @@ static WeakPtr s_hack_studio_widget; static bool make_is_available(); static ErrorOr notify_make_not_available(); static void update_path_environment_variable(); -static Optional last_opened_project_path(); +static Optional last_opened_project_path(); static ErrorOr> create_hack_studio_widget(bool mode_coredump, StringView path, pid_t pid_to_debug); ErrorOr serenity_main(Main::Arguments arguments) @@ -68,7 +68,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->set_main_widget(hack_studio_widget); s_hack_studio_widget = hack_studio_widget; - window->set_title(DeprecatedString::formatted("{} - Hack Studio", hack_studio_widget->project().name())); + window->set_title(ByteString::formatted("{} - Hack Studio", hack_studio_widget->project().name())); TRY(hack_studio_widget->initialize_menubar(*window)); @@ -131,10 +131,10 @@ static void update_path_environment_variable() if (path.length()) path.append(':'); path.append(DEFAULT_PATH_SV); - setenv("PATH", path.to_deprecated_string().characters(), true); + setenv("PATH", path.to_byte_string().characters(), true); } -static Optional last_opened_project_path() +static Optional last_opened_project_path() { auto projects = HackStudioWidget::read_recent_projects(); if (projects.size() == 0) @@ -153,12 +153,12 @@ GUI::TextEditor& current_editor() return s_hack_studio_widget->current_editor(); } -void open_file(DeprecatedString const& filename) +void open_file(ByteString const& filename) { s_hack_studio_widget->open_file(filename); } -void open_file(DeprecatedString const& filename, size_t line, size_t column) +void open_file(ByteString const& filename, size_t line, size_t column) { s_hack_studio_widget->open_file(filename, line, column); } @@ -175,7 +175,7 @@ Project& project() return s_hack_studio_widget->project(); } -DeprecatedString currently_open_file() +ByteString currently_open_file() { if (!s_hack_studio_widget) return {}; @@ -212,16 +212,16 @@ bool semantic_syntax_highlighting_is_enabled() static ErrorOr> create_hack_studio_widget(bool mode_coredump, StringView raw_path_argument, pid_t pid_to_debug) { - DeprecatedString project_path; + ByteString project_path; if (pid_to_debug != -1 || mode_coredump) project_path = "/usr/src/serenity"; else if (!raw_path_argument.is_null()) // FIXME: Validation is unintentional, and should be removed when migrating to String. - project_path = TRY(DeprecatedString::from_utf8(raw_path_argument)); + project_path = TRY(ByteString::from_utf8(raw_path_argument)); else if (auto last_path = last_opened_project_path(); last_path.has_value()) project_path = last_path.release_value(); else - project_path = TRY(FileSystem::real_path("."sv)).to_deprecated_string(); + project_path = TRY(FileSystem::real_path("."sv)).to_byte_string(); return HackStudioWidget::create(project_path); } diff --git a/Userland/DevTools/Profiler/DisassemblyModel.cpp b/Userland/DevTools/Profiler/DisassemblyModel.cpp index 9d8618bd798..be5c7672b2f 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.cpp +++ b/Userland/DevTools/Profiler/DisassemblyModel.cpp @@ -51,7 +51,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node) if (elf == nullptr) return; if (g_kernel_debug_info == nullptr) - g_kernel_debug_info = make(g_kernel_debuginfo_object->elf, DeprecatedString::empty(), base_address); + g_kernel_debug_info = make(g_kernel_debuginfo_object->elf, ByteString::empty(), base_address); debug_info = g_kernel_debug_info.ptr(); } else { auto const& process = node.process(); @@ -114,7 +114,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node) break; FlatPtr address_in_profiled_program = node.address() + offset_into_symbol; - auto disassembly = insn.value().to_deprecated_string(address_in_profiled_program, &symbol_provider); + auto disassembly = insn.value().to_byte_string(address_in_profiled_program, &symbol_provider); StringView instruction_bytes = view.substring_view(offset_into_symbol, insn.value().length()); u32 samples_at_this_instruction = m_node.events_per_address().get(address_in_profiled_program).value_or(0); @@ -200,14 +200,14 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole } if (index.column() == Column::Address) - return DeprecatedString::formatted("{:p}", insn.address); + return ByteString::formatted("{:p}", insn.address); if (index.column() == Column::InstructionBytes) { StringBuilder builder; for (auto ch : insn.bytes) { builder.appendff("{:02x} ", (u8)ch); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } if (index.column() == Column::Disassembly) @@ -229,7 +229,7 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole auto const& entry = insn.source_position_with_inlines.source_position.value(); builder.appendff("{}:{}", entry.file_path, entry.line_number); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } return {}; diff --git a/Userland/DevTools/Profiler/DisassemblyModel.h b/Userland/DevTools/Profiler/DisassemblyModel.h index 1c301faecab..038298e5639 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.h +++ b/Userland/DevTools/Profiler/DisassemblyModel.h @@ -18,7 +18,7 @@ class ProfileNode; struct InstructionData { X86::Instruction insn; - DeprecatedString disassembly; + ByteString disassembly; StringView bytes; FlatPtr address { 0 }; u32 event_count { 0 }; diff --git a/Userland/DevTools/Profiler/FilesystemEventModel.cpp b/Userland/DevTools/Profiler/FilesystemEventModel.cpp index 8e9d9476507..80e844a0409 100644 --- a/Userland/DevTools/Profiler/FilesystemEventModel.cpp +++ b/Userland/DevTools/Profiler/FilesystemEventModel.cpp @@ -32,7 +32,7 @@ Duration FileEventNode::total_duration() const return m_open.duration + m_close.duration + m_readv.duration + m_read.duration + m_pread.duration; } -FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& searched_path) +FileEventNode& FileEventNode::find_or_create_node(ByteString const& searched_path) { // TODO: Optimize this function. if (searched_path == ""sv || searched_path == "/"sv) { @@ -45,7 +45,7 @@ FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& search StringBuilder sb; sb.join('/', parts); - auto new_s = sb.to_deprecated_string(); + auto new_s = sb.to_byte_string(); for (auto& child : m_children) { if (child->m_path == current) { @@ -70,7 +70,7 @@ FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& search } } -FileEventNode& FileEventNode::create_recursively(DeprecatedString new_path) +FileEventNode& FileEventNode::create_recursively(ByteString new_path) { auto const lex_path = LexicalPath(new_path); auto parts = lex_path.parts(); @@ -86,7 +86,7 @@ FileEventNode& FileEventNode::create_recursively(DeprecatedString new_path) StringBuilder sb; sb.join('/', parts); - return new_node->create_recursively(sb.to_deprecated_string()); + return new_node->create_recursively(sb.to_byte_string()); } } diff --git a/Userland/DevTools/Profiler/FilesystemEventModel.h b/Userland/DevTools/Profiler/FilesystemEventModel.h index c80b3070296..80e45693771 100644 --- a/Userland/DevTools/Profiler/FilesystemEventModel.h +++ b/Userland/DevTools/Profiler/FilesystemEventModel.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -18,23 +18,23 @@ class Profile; class FileEventNode : public RefCounted { public: - static NonnullRefPtr create(DeprecatedString const& path, FileEventNode* parent = nullptr) + static NonnullRefPtr create(ByteString const& path, FileEventNode* parent = nullptr) { return adopt_ref(*new FileEventNode(path, parent)); } - FileEventNode& find_or_create_node(DeprecatedString const&); + FileEventNode& find_or_create_node(ByteString const&); Vector>& children() { return m_children; } Vector> const& children() const { return m_children; } FileEventNode* parent() { return m_parent; } - FileEventNode& create_recursively(DeprecatedString); + FileEventNode& create_recursively(ByteString); void for_each_parent_node(Function callback); - DeprecatedString const& path() const { return m_path; } + ByteString const& path() const { return m_path; } u64 total_count() const; Duration total_duration() const; @@ -51,11 +51,11 @@ public: FileEventType& pread() { return m_pread; } private: - FileEventNode(DeprecatedString const& path, FileEventNode* parent = nullptr) + FileEventNode(ByteString const& path, FileEventNode* parent = nullptr) : m_path(path) , m_parent(parent) {}; - DeprecatedString m_path; + ByteString m_path; FileEventType m_open; FileEventType m_close; diff --git a/Userland/DevTools/Profiler/FlameGraphView.cpp b/Userland/DevTools/Profiler/FlameGraphView.cpp index 4b70f31f3d6..c59f69d8970 100644 --- a/Userland/DevTools/Profiler/FlameGraphView.cpp +++ b/Userland/DevTools/Profiler/FlameGraphView.cpp @@ -180,7 +180,7 @@ String FlameGraphView::bar_label(StackBar const& bar) const auto label_index = bar.index.sibling_at_column(m_text_column); String label = "All"_string; if (label_index.is_valid()) { - label = MUST(String::from_deprecated_string(m_model.data(label_index).to_deprecated_string())); + label = MUST(String::from_byte_string(m_model.data(label_index).to_byte_string())); } return label; } diff --git a/Userland/DevTools/Profiler/IndividualSampleModel.cpp b/Userland/DevTools/Profiler/IndividualSampleModel.cpp index fb3fb06cfe2..e4d587f80a9 100644 --- a/Userland/DevTools/Profiler/IndividualSampleModel.cpp +++ b/Userland/DevTools/Profiler/IndividualSampleModel.cpp @@ -50,7 +50,7 @@ GUI::Variant IndividualSampleModel::data(GUI::ModelIndex const& index, GUI::Mode if (role == GUI::ModelRole::Display) { if (index.column() == Column::Address) - return DeprecatedString::formatted("{:p}", frame.address); + return ByteString::formatted("{:p}", frame.address); if (index.column() == Column::Symbol) { return frame.symbol; diff --git a/Userland/DevTools/Profiler/PercentageFormatting.h b/Userland/DevTools/Profiler/PercentageFormatting.h index 7d9716fd83d..b3d2fe91ad5 100644 --- a/Userland/DevTools/Profiler/PercentageFormatting.h +++ b/Userland/DevTools/Profiler/PercentageFormatting.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -16,10 +16,10 @@ namespace Profiler { static constexpr int const number_of_percent_digits = 2; static constexpr int const percent_digits_rounding = AK::pow(10, number_of_percent_digits); -DeprecatedString format_percentage(auto value, auto total) +ByteString format_percentage(auto value, auto total) { auto percentage_full_precision = round_to(value * 100.f / total * percent_digits_rounding); - return DeprecatedString::formatted( + return ByteString::formatted( "{}.{:02}", percentage_full_precision / percent_digits_rounding, percentage_full_precision % percent_digits_rounding); diff --git a/Userland/DevTools/Profiler/Process.cpp b/Userland/DevTools/Profiler/Process.cpp index b21b2f45de1..dd4fcdbeba5 100644 --- a/Userland/DevTools/Profiler/Process.cpp +++ b/Userland/DevTools/Profiler/Process.cpp @@ -41,9 +41,9 @@ void Process::handle_thread_exit(pid_t tid, EventSerialNumber serial) thread->end_valid = serial; } -HashMap> g_mapped_object_cache; +HashMap> g_mapped_object_cache; -static MappedObject* get_or_create_mapped_object(DeprecatedString const& path) +static MappedObject* get_or_create_mapped_object(ByteString const& path) { if (auto it = g_mapped_object_cache.find(path); it != g_mapped_object_cache.end()) return it->value.ptr(); @@ -67,7 +67,7 @@ static MappedObject* get_or_create_mapped_object(DeprecatedString const& path) return ptr; } -void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString const& name) +void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, ByteString const& name) { StringView path; if (name.contains("Loader.so"sv)) @@ -82,25 +82,25 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString co // associated base address and size as new regions are discovered. // We don't allocate a temporary String object if an entry already exists. - // This assumes that DeprecatedString::hash and StringView::hash return the same result. + // This assumes that ByteString::hash and StringView::hash return the same result. auto string_view_compare = [&path](auto& entry) { return path == entry.key.view(); }; if (auto existing_it = m_libraries.find(path.hash(), string_view_compare); existing_it != m_libraries.end()) { auto& entry = *existing_it->value; entry.base = min(entry.base, base); entry.size = max(entry.size + size, base - entry.base + size); } else { - DeprecatedString path_string = path.to_deprecated_string(); - DeprecatedString full_path; + ByteString path_string = path.to_byte_string(); + ByteString full_path; if (path_string.starts_with('/')) full_path = path_string; else if (FileSystem::looks_like_shared_library(path_string)) - full_path = DeprecatedString::formatted("/usr/lib/{}", path); + full_path = ByteString::formatted("/usr/lib/{}", path); else full_path = path_string; auto* mapped_object = get_or_create_mapped_object(full_path); if (!mapped_object) { - full_path = DeprecatedString::formatted("/usr/local/lib/{}", path); + full_path = ByteString::formatted("/usr/local/lib/{}", path); mapped_object = get_or_create_mapped_object(full_path); if (!mapped_object) return; @@ -112,14 +112,14 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString co Debug::DebugInfo const& LibraryMetadata::Library::load_debug_info(FlatPtr base_address) const { if (debug_info == nullptr) - debug_info = make(object->elf, DeprecatedString::empty(), base_address); + debug_info = make(object->elf, ByteString::empty(), base_address); return *debug_info.ptr(); } -DeprecatedString LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const +ByteString LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const { if (!object) - return DeprecatedString::formatted("?? <{:p}>", ptr); + return ByteString::formatted("?? <{:p}>", ptr); return object->elf.symbolicate(ptr - base, offset); } diff --git a/Userland/DevTools/Profiler/Process.h b/Userland/DevTools/Profiler/Process.h index 064ca69f2b4..e1ee2080908 100644 --- a/Userland/DevTools/Profiler/Process.h +++ b/Userland/DevTools/Profiler/Process.h @@ -21,27 +21,27 @@ struct MappedObject { ELF::Image elf; }; -extern HashMap> g_mapped_object_cache; +extern HashMap> g_mapped_object_cache; class LibraryMetadata { public: struct Library { FlatPtr base; size_t size; - DeprecatedString name; + ByteString name; MappedObject* object { nullptr }; // This is loaded lazily because we only need it in disassembly view mutable OwnPtr debug_info; - DeprecatedString symbolicate(FlatPtr, u32* offset) const; + ByteString symbolicate(FlatPtr, u32* offset) const; Debug::DebugInfo const& load_debug_info(FlatPtr base_address) const; }; - void handle_mmap(FlatPtr base, size_t size, DeprecatedString const& name); + void handle_mmap(FlatPtr base, size_t size, ByteString const& name); Library const* library_containing(FlatPtr) const; private: - mutable HashMap> m_libraries; + mutable HashMap> m_libraries; }; struct Thread { @@ -57,8 +57,8 @@ struct Thread { struct Process { pid_t pid {}; - DeprecatedString executable; - DeprecatedString basename; + ByteString executable; + ByteString basename; HashMap> threads {}; LibraryMetadata library_metadata {}; EventSerialNumber start_valid; diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index f665227c153..ce8b6200c7e 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -289,10 +289,10 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path return Error::from_string_literal("Malformed profile (strings is not an array)"); auto const& strings = strings_value.value(); - HashMap profile_strings; + HashMap profile_strings; for (FlatPtr string_id = 0; string_id < strings.size(); ++string_id) { auto const& value = strings.at(string_id); - profile_strings.set(string_id, value.to_deprecated_string()); + profile_strings.set(string_id, value.to_byte_string()); } auto events_value = object.get_array("events"sv); @@ -317,7 +317,7 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path event.pid = perf_event.get_i32("pid"sv).value_or(0); event.tid = perf_event.get_i32("tid"sv).value_or(0); - auto type_string = perf_event.get_deprecated_string("type"sv).value_or({}); + auto type_string = perf_event.get_byte_string("type"sv).value_or({}); if (type_string == "sample"sv) { event.data = Event::SampleData {}; @@ -333,13 +333,13 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path } else if (type_string == "signpost"sv) { auto string_id = perf_event.get_addr("arg1"sv).value_or(0); event.data = Event::SignpostData { - .string = profile_strings.get(string_id).value_or(DeprecatedString::formatted("Signpost #{}", string_id)), + .string = profile_strings.get(string_id).value_or(ByteString::formatted("Signpost #{}", string_id)), .arg = perf_event.get_addr("arg2"sv).value_or(0), }; } else if (type_string == "mmap"sv) { auto ptr = perf_event.get_addr("ptr"sv).value_or(0); auto size = perf_event.get_integer("size"sv).value_or(0); - auto name = perf_event.get_deprecated_string("name"sv).value_or({}); + auto name = perf_event.get_byte_string("name"sv).value_or({}); event.data = Event::MmapData { .ptr = ptr, @@ -359,7 +359,7 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path continue; } else if (type_string == "process_create"sv) { auto parent_pid = perf_event.get_integer("parent_pid"sv).value_or(0); - auto executable = perf_event.get_deprecated_string("executable"sv).value_or({}); + auto executable = perf_event.get_byte_string("executable"sv).value_or({}); event.data = Event::ProcessCreateData { .parent_pid = parent_pid, .executable = executable, @@ -377,7 +377,7 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path all_processes.append(move(sampled_process)); continue; } else if (type_string == "process_exec"sv) { - auto executable = perf_event.get_deprecated_string("executable"sv).value_or({}); + auto executable = perf_event.get_byte_string("executable"sv).value_or({}); event.data = Event::ProcessExecData { .executable = executable, }; @@ -482,13 +482,13 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path auto ptr = frame.to_number(); u32 offset = 0; DeprecatedFlyString object_name; - DeprecatedString symbol; + ByteString symbol; if (maybe_kernel_base.has_value() && ptr >= maybe_kernel_base.value()) { if (g_kernel_debuginfo_object.has_value()) { symbol = g_kernel_debuginfo_object->elf.symbolicate(ptr - maybe_kernel_base.value(), &offset); } else { - symbol = DeprecatedString::formatted("?? <{:p}>", ptr); + symbol = ByteString::formatted("?? <{:p}>", ptr); } } else { auto it = current_processes.find(event.pid); @@ -500,7 +500,7 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path object_name = library->name; symbol = library->symbolicate(ptr, &offset); } else { - symbol = DeprecatedString::formatted("?? <{:p}>", ptr); + symbol = ByteString::formatted("?? <{:p}>", ptr); } } @@ -681,7 +681,7 @@ ProfileNode::ProfileNode(Process const& process) { } -ProfileNode::ProfileNode(Process const& process, DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid) +ProfileNode::ProfileNode(Process const& process, DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid) : m_process(process) , m_symbol(move(symbol)) , m_pid(pid) @@ -689,7 +689,7 @@ ProfileNode::ProfileNode(Process const& process, DeprecatedFlyString const& obje , m_offset(offset) , m_timestamp(timestamp) { - DeprecatedString object; + ByteString object; if (object_name.ends_with(": .text"sv)) { object = object_name.view().substring_view(0, object_name.length() - 7); } else { diff --git a/Userland/DevTools/Profiler/Profile.h b/Userland/DevTools/Profiler/Profile.h index 74aa0f53f43..00d7c431440 100644 --- a/Userland/DevTools/Profiler/Profile.h +++ b/Userland/DevTools/Profiler/Profile.h @@ -35,7 +35,7 @@ extern OwnPtr g_kernel_debug_info; class ProfileNode : public RefCounted { public: - static NonnullRefPtr create(Process const& process, DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid) + static NonnullRefPtr create(Process const& process, DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid) { return adopt_ref(*new ProfileNode(process, object_name, move(symbol), address, offset, timestamp, pid)); } @@ -55,7 +55,7 @@ public: void did_see_event(size_t event_index) { m_seen_events.set(event_index, true); } DeprecatedFlyString const& object_name() const { return m_object_name; } - DeprecatedString const& symbol() const { return m_symbol; } + ByteString const& symbol() const { return m_symbol; } FlatPtr address() const { return m_address; } u32 offset() const { return m_offset; } u64 timestamp() const { return m_timestamp; } @@ -75,7 +75,7 @@ public: m_children.append(child); } - ProfileNode& find_or_create_child(DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid) + ProfileNode& find_or_create_child(DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid) { for (size_t i = 0; i < m_children.size(); ++i) { auto& child = m_children[i]; @@ -113,13 +113,13 @@ public: private: explicit ProfileNode(Process const&); - explicit ProfileNode(Process const&, DeprecatedFlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t); + explicit ProfileNode(Process const&, DeprecatedFlyString const& object_name, ByteString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t); bool m_root { false }; Process const& m_process; ProfileNode* m_parent { nullptr }; DeprecatedFlyString m_object_name; - DeprecatedString m_symbol; + ByteString m_symbol; pid_t m_pid { 0 }; FlatPtr m_address { 0 }; u32 m_offset { 0 }; @@ -168,7 +168,7 @@ public: struct Frame { DeprecatedFlyString object_name; - DeprecatedString symbol; + ByteString symbol; FlatPtr address { 0 }; u32 offset { 0 }; }; @@ -196,14 +196,14 @@ public: }; struct SignpostData { - DeprecatedString string; + ByteString string; FlatPtr arg {}; }; struct MmapData { FlatPtr ptr {}; size_t size {}; - DeprecatedString name; + ByteString name; }; struct MunmapData { @@ -213,11 +213,11 @@ public: struct ProcessCreateData { pid_t parent_pid { 0 }; - DeprecatedString executable; + ByteString executable; }; struct ProcessExecData { - DeprecatedString executable; + ByteString executable; }; struct ThreadCreateData { @@ -227,31 +227,31 @@ public: // Based on Syscall::SC_open_params struct OpenEventData { int dirfd; - DeprecatedString path; + ByteString path; int options; u64 mode; }; struct CloseEventData { int fd; - DeprecatedString path; + ByteString path; }; struct ReadvEventData { int fd; - DeprecatedString path; + ByteString path; // struct iovec* iov; // TODO: Implement // int iov_count; // TODO: Implement }; struct ReadEventData { int fd; - DeprecatedString path; + ByteString path; }; struct PreadEventData { int fd; - DeprecatedString path; + ByteString path; FlatPtr buffer_ptr; size_t size; off_t offset; diff --git a/Userland/DevTools/Profiler/ProfileModel.cpp b/Userland/DevTools/Profiler/ProfileModel.cpp index cb09e01bdce..464faacb00f 100644 --- a/Userland/DevTools/Profiler/ProfileModel.cpp +++ b/Userland/DevTools/Profiler/ProfileModel.cpp @@ -126,7 +126,7 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol return node->object_name(); if (index.column() == Column::StackFrame) { if (node->is_root()) { - return DeprecatedString::formatted("{} ({})", node->process().basename, node->process().pid); + return ByteString::formatted("{} ({})", node->process().basename, node->process().pid); } return node->symbol(); } @@ -136,7 +136,7 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol auto const* library = node->process().library_metadata.library_containing(node->address()); if (!library) return ""; - return DeprecatedString::formatted("{:p} (offset {:p})", node->address(), node->address() - library->base); + return ByteString::formatted("{:p} (offset {:p})", node->address(), node->address() - library->base); } return {}; } diff --git a/Userland/DevTools/Profiler/SourceModel.cpp b/Userland/DevTools/Profiler/SourceModel.cpp index ae8bd2043b7..def4c06a234 100644 --- a/Userland/DevTools/Profiler/SourceModel.cpp +++ b/Userland/DevTools/Profiler/SourceModel.cpp @@ -17,7 +17,7 @@ namespace Profiler { class SourceFile final { public: struct Line { - DeprecatedString content; + ByteString content; size_t num_samples { 0 }; }; @@ -25,7 +25,7 @@ public: SourceFile(StringView filename) { - DeprecatedString source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly); + ByteString source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly); auto try_read_lines = [&]() -> ErrorOr { auto unbuffered_file = TRY(Core::File::open(source_file_name, Core::File::OpenMode::Read)); @@ -70,7 +70,7 @@ SourceModel::SourceModel(Profile& profile, ProfileNode& node) return; base_address = maybe_kernel_base.release_value(); if (g_kernel_debug_info == nullptr) - g_kernel_debug_info = make(g_kernel_debuginfo_object->elf, DeprecatedString::empty(), base_address); + g_kernel_debug_info = make(g_kernel_debuginfo_object->elf, ByteString::empty(), base_address); debug_info = g_kernel_debug_info.ptr(); } else { auto const& process = node.process(); @@ -86,7 +86,7 @@ SourceModel::SourceModel(Profile& profile, ProfileNode& node) VERIFY(debug_info != nullptr); // Try to read all source files contributing to the selected function and aggregate the samples by line. - HashMap source_files; + HashMap source_files; for (auto const& pair : node.events_per_address()) { auto position = debug_info->get_source_position(pair.key - base_address); if (position.has_value()) { diff --git a/Userland/DevTools/Profiler/SourceModel.h b/Userland/DevTools/Profiler/SourceModel.h index af85480a4a2..396c1a4499a 100644 --- a/Userland/DevTools/Profiler/SourceModel.h +++ b/Userland/DevTools/Profiler/SourceModel.h @@ -16,9 +16,9 @@ class ProfileNode; struct SourceLineData { u32 event_count { 0 }; float percent { 0 }; - DeprecatedString location; + ByteString location; u32 line_number { 0 }; - DeprecatedString source_code; + ByteString source_code; }; class SourceModel final : public GUI::Model { diff --git a/Userland/DevTools/Profiler/TimelineHeader.cpp b/Userland/DevTools/Profiler/TimelineHeader.cpp index 34c9367f1af..d8128459ca3 100644 --- a/Userland/DevTools/Profiler/TimelineHeader.cpp +++ b/Userland/DevTools/Profiler/TimelineHeader.cpp @@ -24,7 +24,7 @@ TimelineHeader::TimelineHeader(Profile& profile, Process const& process) update_selection(); m_icon = GUI::FileIconProvider::icon_for_executable(m_process.executable).bitmap_for_size(32); - m_text = DeprecatedString::formatted("{} ({})", LexicalPath::basename(m_process.executable), m_process.pid); + m_text = ByteString::formatted("{} ({})", LexicalPath::basename(m_process.executable), m_process.pid); } void TimelineHeader::paint_event(GUI::PaintEvent& event) diff --git a/Userland/DevTools/Profiler/TimelineHeader.h b/Userland/DevTools/Profiler/TimelineHeader.h index 334afdbb664..a4a0e0c198e 100644 --- a/Userland/DevTools/Profiler/TimelineHeader.h +++ b/Userland/DevTools/Profiler/TimelineHeader.h @@ -33,7 +33,7 @@ private: Profile& m_profile; Process const& m_process; RefPtr m_icon; - DeprecatedString m_text; + ByteString m_text; bool m_selected; }; diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 5b0a2c2a701..0d2d43caf61 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -62,18 +62,18 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::create(arguments)); auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-profiler"sv)); - DeprecatedString perfcore_file; + ByteString perfcore_file; if (perfcore_file_arg.is_empty()) { if (!generate_profile(pid)) return 0; - perfcore_file = DeprecatedString::formatted("/proc/{}/perf_events", pid); + perfcore_file = ByteString::formatted("/proc/{}/perf_events", pid); } else { perfcore_file = perfcore_file_arg; } auto profile_or_error = Profile::load_from_perfcore_file(perfcore_file); if (profile_or_error.is_error()) { - GUI::MessageBox::show(nullptr, DeprecatedString::formatted("{}", profile_or_error.error()), "Profiler"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(nullptr, ByteString::formatted("{}", profile_or_error.error()), "Profiler"sv, GUI::MessageBox::Type::Error); return 0; } @@ -224,8 +224,8 @@ ErrorOr serenity_main(Main::Arguments arguments) // FIXME: Make this constexpr once String is able to. auto const format_sample_count = [&profile](auto const sample_count) { if (profile->show_percentages()) - return DeprecatedString::formatted("{}%", sample_count.as_string()); - return DeprecatedString::formatted("{} Samples", sample_count.to_i32()); + return ByteString::formatted("{}%", sample_count.as_string()); + return ByteString::formatted("{} Samples", sample_count.to_i32()); }; auto& statusbar = main_widget->add(); @@ -235,7 +235,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto flamegraph_hovered_index = flamegraph_view.hovered_index(); if (flamegraph_hovered_index.is_valid()) { - auto stack = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::StackFrame)).to_deprecated_string(); + auto stack = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::StackFrame)).to_byte_string(); auto sample_count = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::SampleCount)); auto self_count = profile->model().data(flamegraph_hovered_index.sibling_at_column(ProfileModel::Column::SelfCount)); builder.appendff("{}, ", stack); @@ -312,10 +312,10 @@ ErrorOr serenity_main(Main::Arguments arguments) return app->exec(); } -static bool prompt_to_stop_profiling(pid_t pid, DeprecatedString const& process_name) +static bool prompt_to_stop_profiling(pid_t pid, ByteString const& process_name) { auto window = GUI::Window::construct(); - window->set_title(DeprecatedString::formatted("Profiling {}({})", process_name, pid)); + window->set_title(ByteString::formatted("Profiling {}({})", process_name, pid)); window->resize(240, 100); window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-profiler.png"sv).release_value_but_fixme_should_propagate_errors()); window->center_on_screen(); @@ -351,7 +351,7 @@ bool generate_profile(pid_t& pid) pid = process_chooser->pid(); } - DeprecatedString process_name; + ByteString process_name; auto all_processes = Core::ProcessStatisticsReader::get_all(); if (!all_processes.is_error()) { @@ -369,7 +369,7 @@ bool generate_profile(pid_t& pid) if (profiling_enable(pid, event_mask) < 0) { int saved_errno = errno; - GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler"sv, GUI::MessageBox::Type::Error); + GUI::MessageBox::show(nullptr, ByteString::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler"sv, GUI::MessageBox::Type::Error); return false; } diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp index 27c3db4ede0..6de96c655d2 100644 --- a/Userland/DevTools/SQLStudio/MainWidget.cpp +++ b/Userland/DevTools/SQLStudio/MainWidget.cpp @@ -41,16 +41,16 @@ REGISTER_WIDGET(SQLStudio, MainWidget); namespace SQLStudio { -static Vector lookup_database_names() +static Vector lookup_database_names() { static constexpr auto database_extension = ".db"sv; - auto database_path = DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory()); + auto database_path = ByteString::formatted("{}/sql", Core::StandardPaths::data_directory()); if (!FileSystem::exists(database_path)) return {}; Core::DirIterator iterator(move(database_path), Core::DirIterator::SkipParentAndBaseDir); - Vector database_names; + Vector database_names; while (iterator.has_next()) { if (auto database = iterator.next_path(); database.ends_with(database_extension)) @@ -86,7 +86,7 @@ ErrorOr MainWidget::setup() VERIFY(editor); if (auto result = editor->save(); result.is_error()) - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor->path(), result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor->path(), result.error())); }); m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { @@ -94,7 +94,7 @@ ErrorOr MainWidget::setup() VERIFY(editor); if (auto result = editor->save_as(); result.is_error()) - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor->path(), result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor->path(), result.error())); }); m_save_all_action = GUI::Action::create("Save All", { Mod_Ctrl | Mod_Alt, Key_S }, [this](auto&) { @@ -106,7 +106,7 @@ ErrorOr MainWidget::setup() m_tab_widget->set_active_widget(&editor); if (auto result = editor.save(); result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor.path(), result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor.path(), result.error())); return IterationDecision::Break; } else if (!result.value()) { return IterationDecision::Break; @@ -176,7 +176,7 @@ ErrorOr MainWidget::setup() m_connection_id = *connection_id; m_run_script_action->set_enabled(true); } else { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Could not connect to {}", database_name)); + GUI::MessageBox::show_error(window(), ByteString::formatted("Could not connect to {}", database_name)); } }); @@ -191,7 +191,7 @@ ErrorOr MainWidget::setup() m_databases_combo_box = GUI::ComboBox::construct(); m_databases_combo_box->set_editor_placeholder("Enter new database or select existing database"sv); m_databases_combo_box->set_max_width(font().width(m_databases_combo_box->editor_placeholder()) + font().max_glyph_width() + 16); - m_databases_combo_box->set_model(*GUI::ItemListModel::create(database_names)); + m_databases_combo_box->set_model(*GUI::ItemListModel::create(database_names)); m_databases_combo_box->on_return_pressed = [this]() { m_connect_to_database_action->activate(m_databases_combo_box); }; @@ -220,7 +220,7 @@ ErrorOr MainWidget::setup() auto& editor = verify_cast(widget); if (auto result = editor.attempt_to_close(); result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to save {}\n{}", editor.path(), result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to save {}\n{}", editor.path(), result.error())); } else if (result.value()) { m_tab_widget->remove_tab(editor); update_title(); @@ -266,14 +266,14 @@ ErrorOr MainWidget::setup() auto* editor = active_editor(); VERIFY(editor); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Error executing {}\n{}", editor->path(), result.error_message)); + GUI::MessageBox::show_error(window(), ByteString::formatted("Error executing {}\n{}", editor->path(), result.error_message)); }; m_sql_client->on_next_result = [this](auto result) { m_results.append({}); m_results.last().ensure_capacity(result.values.size()); for (auto const& value : result.values) - m_results.last().unchecked_append(value.to_deprecated_string()); + m_results.last().unchecked_append(value.to_byte_string()); }; m_sql_client->on_results_exhausted = [this](auto) { if (m_results.size() == 0) @@ -283,7 +283,7 @@ ErrorOr MainWidget::setup() Vector query_result_fields; for (auto& column_name : m_result_column_names) - query_result_fields.empend(column_name, String::from_deprecated_string(column_name).release_value_but_fixme_should_propagate_errors(), Gfx::TextAlignment::CenterLeft); + query_result_fields.empend(column_name, String::from_byte_string(column_name).release_value_but_fixme_should_propagate_errors(), Gfx::TextAlignment::CenterLeft); auto query_results_model = GUI::JsonArrayModel::create("{}", move(query_result_fields)); m_query_results_table_view->set_model(MUST(GUI::SortingProxyModel::create(*query_results_model))); @@ -333,10 +333,10 @@ ErrorOr MainWidget::initialize_menu(GUI::Window* window) void MainWidget::open_new_script() { - auto new_script_name = DeprecatedString::formatted("New Script - {}", m_new_script_counter); + auto new_script_name = ByteString::formatted("New Script - {}", m_new_script_counter); ++m_new_script_counter; - auto& editor = m_tab_widget->add_tab(String::from_deprecated_string(new_script_name).release_value_but_fixme_should_propagate_errors()); + auto& editor = m_tab_widget->add_tab(String::from_byte_string(new_script_name).release_value_but_fixme_should_propagate_errors()); editor.new_script_with_temp_name(new_script_name); editor.on_cursor_change = [this] { on_editor_change(); }; @@ -351,7 +351,7 @@ void MainWidget::open_script_from_file(LexicalPath const& file_path) auto& editor = m_tab_widget->add_tab(String::from_utf8(file_path.title()).release_value_but_fixme_should_propagate_errors()); if (auto result = editor.open_script_from_file(file_path); result.is_error()) { - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to open {}\n{}", file_path, result.error())); + GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to open {}\n{}", file_path, result.error())); return; } @@ -407,7 +407,7 @@ ScriptEditor* MainWidget::active_editor() void MainWidget::update_title() { if (auto* editor = active_editor()) - window()->set_title(DeprecatedString::formatted("{} - SQL Studio", editor->name())); + window()->set_title(ByteString::formatted("{} - SQL Studio", editor->name())); else window()->set_title("SQL Studio"); } @@ -548,7 +548,7 @@ void MainWidget::read_next_sql_statement_of_editor() m_editor_line_level = last_token_ended_statement ? 0 : (m_editor_line_level > 0 ? m_editor_line_level : 1); } while ((m_editor_line_level > 0) || piece.is_empty()); - auto sql_statement = piece.to_deprecated_string(); + auto sql_statement = piece.to_byte_string(); if (auto statement_id = m_sql_client->prepare_statement(*m_connection_id, sql_statement); statement_id.has_value()) { m_sql_client->async_execute_statement(*statement_id, {}); @@ -556,11 +556,11 @@ void MainWidget::read_next_sql_statement_of_editor() auto* editor = active_editor(); VERIFY(editor); - GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Could not parse {}\n{}", editor->path(), sql_statement)); + GUI::MessageBox::show_error(window(), ByteString::formatted("Could not parse {}\n{}", editor->path(), sql_statement)); } } -Optional MainWidget::read_next_line_of_editor() +Optional MainWidget::read_next_line_of_editor() { auto* editor = active_editor(); if (!editor) diff --git a/Userland/DevTools/SQLStudio/MainWidget.h b/Userland/DevTools/SQLStudio/MainWidget.h index 76058555a5c..dfb9b4f9515 100644 --- a/Userland/DevTools/SQLStudio/MainWidget.h +++ b/Userland/DevTools/SQLStudio/MainWidget.h @@ -65,11 +65,11 @@ private: RefPtr m_sql_client; Optional m_connection_id; - Vector m_result_column_names; - Vector> m_results; + Vector m_result_column_names; + Vector> m_results; void read_next_sql_statement_of_editor(); - Optional read_next_line_of_editor(); + Optional read_next_line_of_editor(); size_t m_current_line_for_parsing { 0 }; int m_editor_line_level { 0 }; }; diff --git a/Userland/DevTools/SQLStudio/ScriptEditor.cpp b/Userland/DevTools/SQLStudio/ScriptEditor.cpp index 410866adb81..25d0b112bdd 100644 --- a/Userland/DevTools/SQLStudio/ScriptEditor.cpp +++ b/Userland/DevTools/SQLStudio/ScriptEditor.cpp @@ -21,7 +21,7 @@ ScriptEditor::ScriptEditor() set_ruler_visible(true); } -void ScriptEditor::new_script_with_temp_name(DeprecatedString name) +void ScriptEditor::new_script_with_temp_name(ByteString name) { set_name(name); } @@ -37,7 +37,7 @@ ErrorOr ScriptEditor::open_script_from_file(LexicalPath const& file_path) return {}; } -static ErrorOr save_text_to_file(StringView filename, DeprecatedString text) +static ErrorOr save_text_to_file(StringView filename, ByteString text) { auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write)); diff --git a/Userland/DevTools/SQLStudio/ScriptEditor.h b/Userland/DevTools/SQLStudio/ScriptEditor.h index 0de219c0bb5..17e11beb571 100644 --- a/Userland/DevTools/SQLStudio/ScriptEditor.h +++ b/Userland/DevTools/SQLStudio/ScriptEditor.h @@ -17,19 +17,19 @@ class ScriptEditor : public GUI::TextEditor { public: virtual ~ScriptEditor() = default; - void new_script_with_temp_name(DeprecatedString); + void new_script_with_temp_name(ByteString); ErrorOr open_script_from_file(LexicalPath const&); ErrorOr save(); ErrorOr save_as(); ErrorOr attempt_to_close(); - DeprecatedString const& path() const { return m_path; } + ByteString const& path() const { return m_path; } private: ScriptEditor(); - DeprecatedString m_path; + ByteString m_path; }; } diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index b73082053e3..b6746965a41 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -42,7 +42,7 @@ Emulator& Emulator::the() return *s_the; } -Emulator::Emulator(DeprecatedString const& executable_path, Vector const& arguments, Vector const& environment) +Emulator::Emulator(ByteString const& executable_path, Vector const& arguments, Vector const& environment) : m_executable_path(executable_path) , m_arguments(arguments) , m_environment(environment) @@ -70,7 +70,7 @@ Emulator::Emulator(DeprecatedString const& executable_path, Vector c setup_signal_trampoline(); } -Vector Emulator::generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, DeprecatedString const& executable_path, int executable_fd) const +Vector Emulator::generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, ByteString const& executable_path, int executable_fd) const { // FIXME: This is not fully compatible with the auxiliary vector the kernel generates, this is just the bare // minimum to get the loader going. @@ -227,7 +227,7 @@ int Emulator::exec() size_t instructions_until_next_profile_dump = profile_instruction_interval(); if (is_profiling() && m_loader_text_size.has_value()) - emit_profile_event(profile_stream(), "mmap"sv, DeprecatedString::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size)); + emit_profile_event(profile_stream(), "mmap"sv, ByteString::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size)); while (!m_shutdown) { if (m_steps_til_pause) [[likely]] { @@ -235,7 +235,7 @@ int Emulator::exec() auto insn = X86::Instruction::from_stream(*m_cpu, X86::ProcessorMode::Protected); // Exec cycle if constexpr (trace) { - outln("{:p} \033[33;1m{}\033[0m", m_cpu->base_eip(), insn.to_deprecated_string(m_cpu->base_eip(), symbol_provider)); + outln("{:p} \033[33;1m{}\033[0m", m_cpu->base_eip(), insn.to_byte_string(m_cpu->base_eip(), symbol_provider)); } (m_cpu->*insn.handler())(insn); @@ -419,13 +419,13 @@ MmapRegion const* Emulator::load_library_from_address(FlatPtr address) if (!region) return {}; - DeprecatedString lib_name = region->lib_name(); + ByteString lib_name = region->lib_name(); if (lib_name.is_null()) return {}; - DeprecatedString lib_path = lib_name; + ByteString lib_path = lib_name; if (FileSystem::looks_like_shared_library(lib_name)) - lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_path); + lib_path = ByteString::formatted("/usr/lib/{}", lib_path); if (!m_dynamic_library_cache.contains(lib_path)) { auto file_or_error = Core::MappedFile::map(lib_path); @@ -463,7 +463,7 @@ Optional Emulator::symbol_at(FlatPtr address) VERIFY(first_region); auto lib_path = lib_name; if (FileSystem::looks_like_shared_library(lib_name)) { - lib_path = DeprecatedString::formatted("/usr/lib/{}", lib_name); + lib_path = ByteString::formatted("/usr/lib/{}", lib_name); } auto it = m_dynamic_library_cache.find(lib_path); @@ -474,18 +474,18 @@ Optional Emulator::symbol_at(FlatPtr address) return { { lib_name, symbol, source_position } }; } -DeprecatedString Emulator::create_backtrace_line(FlatPtr address) +ByteString Emulator::create_backtrace_line(FlatPtr address) { auto maybe_symbol = symbol_at(address); if (!maybe_symbol.has_value()) { - return DeprecatedString::formatted("=={}== {:p}", getpid(), address); + return ByteString::formatted("=={}== {:p}", getpid(), address); } if (!maybe_symbol->source_position.has_value()) { - return DeprecatedString::formatted("=={}== {:p} [{}]: {}", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol); + return ByteString::formatted("=={}== {:p} [{}]: {}", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol); } auto const& source_position = maybe_symbol->source_position.value(); - return DeprecatedString::formatted("=={}== {:p} [{}]: {} (\e[34;1m{}\e[0m:{})", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol, LexicalPath::basename(source_position.file_path), source_position.line_number); + return ByteString::formatted("=={}== {:p} [{}]: {} (\e[34;1m{}\e[0m:{})", getpid(), address, maybe_symbol->lib_name, maybe_symbol->symbol, LexicalPath::basename(source_position.file_path), source_position.line_number); } void Emulator::dump_backtrace(Vector const& backtrace) @@ -513,7 +513,7 @@ void Emulator::emit_profile_sample(Stream& output) output.write_until_depleted(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); } -void Emulator::emit_profile_event(Stream& output, StringView event_name, DeprecatedString const& contents) +void Emulator::emit_profile_event(Stream& output, StringView event_name, ByteString const& contents) { StringBuilder builder; timeval tv {}; @@ -523,13 +523,13 @@ void Emulator::emit_profile_event(Stream& output, StringView event_name, Depreca output.write_until_depleted(builder.string_view().bytes()).release_value_but_fixme_should_propagate_errors(); } -DeprecatedString Emulator::create_instruction_line(FlatPtr address, X86::Instruction const& insn) +ByteString Emulator::create_instruction_line(FlatPtr address, X86::Instruction const& insn) { auto symbol = symbol_at(address); if (!symbol.has_value() || !symbol->source_position.has_value()) - return DeprecatedString::formatted("{:p}: {}", address, insn.to_deprecated_string(address)); + return ByteString::formatted("{:p}: {}", address, insn.to_byte_string(address)); - return DeprecatedString::formatted("{:p}: {} \e[34;1m{}\e[0m:{}", address, insn.to_deprecated_string(address), LexicalPath::basename(symbol->source_position->file_path), symbol->source_position.value().line_number); + return ByteString::formatted("{:p}: {} \e[34;1m{}\e[0m:{}", address, insn.to_byte_string(address), LexicalPath::basename(symbol->source_position->file_path), symbol->source_position.value().line_number); } static void emulator_signal_handler(int signum, siginfo_t* signal_info, void* context) diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h index 20424fa3a3c..f295508a4a2 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.h +++ b/Userland/DevTools/UserspaceEmulator/Emulator.h @@ -30,9 +30,9 @@ class Emulator { public: static Emulator& the(); - Emulator(DeprecatedString const& executable_path, Vector const& arguments, Vector const& environment); + Emulator(ByteString const& executable_path, Vector const& arguments, Vector const& environment); - void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, Vector>* profiler_strings, Vector* profiler_string_id_map) + void set_profiling_details(bool should_dump_profile, size_t instruction_interval, Stream* profile_stream, Vector>* profiler_strings, Vector* profiler_string_id_map) { m_is_profiling = should_dump_profile; m_profile_instruction_interval = instruction_interval; @@ -47,7 +47,7 @@ public: } Stream& profile_stream() { return *m_profile_stream; } - Vector>& profiler_strings() { return *m_profiler_strings; } + Vector>& profiler_strings() { return *m_profiler_strings; } Vector& profiler_string_id_map() { return *m_profiler_string_id_map; } bool is_profiling() const { return m_is_profiling; } @@ -113,8 +113,8 @@ public: } struct SymbolInfo { - DeprecatedString lib_name; - DeprecatedString symbol; + ByteString lib_name; + ByteString symbol; Optional source_position; }; @@ -123,9 +123,9 @@ public: void dump_regions() const; private: - const DeprecatedString m_executable_path; + const ByteString m_executable_path; Vector const m_arguments; - Vector const m_environment; + Vector const m_environment; SoftMMU m_mmu; NonnullOwnPtr m_cpu; @@ -133,14 +133,14 @@ private: OwnPtr m_malloc_tracer; void setup_stack(Vector); - Vector generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, DeprecatedString const& executable_path, int executable_fd) const; + Vector generate_auxiliary_vector(FlatPtr load_base, FlatPtr entry_eip, ByteString const& executable_path, int executable_fd) const; void register_signal_handlers(); void setup_signal_trampoline(); void send_signal(int); void emit_profile_sample(Stream&); - void emit_profile_event(Stream&, StringView event_name, DeprecatedString const& contents); + void emit_profile_event(Stream&, StringView event_name, ByteString const& contents); int virt$accept4(FlatPtr); u32 virt$allocate_tls(FlatPtr, size_t); @@ -254,8 +254,8 @@ private: MmapRegion const* find_text_region(FlatPtr address); MmapRegion const* load_library_from_address(FlatPtr address); MmapRegion const* first_region_for_object(StringView name); - DeprecatedString create_backtrace_line(FlatPtr address); - DeprecatedString create_instruction_line(FlatPtr address, X86::Instruction const& insn); + ByteString create_backtrace_line(FlatPtr address); + ByteString create_instruction_line(FlatPtr address, X86::Instruction const& insn); bool m_shutdown { false }; int m_exit_status { 0 }; @@ -290,13 +290,13 @@ private: NonnullOwnPtr image; }; - HashMap m_dynamic_library_cache; + HashMap m_dynamic_library_cache; RangeAllocator m_range_allocator; Stream* m_profile_stream { nullptr }; Vector* m_profiler_string_id_map { nullptr }; - Vector>* m_profiler_strings { nullptr }; + Vector>* m_profiler_strings { nullptr }; bool m_is_profiling { false }; size_t m_profile_instruction_interval { 0 }; diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp index 07cf3abc7ee..6658d75b490 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp @@ -292,7 +292,7 @@ FlatPtr Emulator::virt$perf_event(int event, FlatPtr arg1, FlatPtr arg2) if (event == PERF_EVENT_SIGNPOST) { if (is_profiling()) { if (profiler_string_id_map().size() > arg1) - emit_profile_event(profile_stream(), "signpost"sv, DeprecatedString::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2)); + emit_profile_event(profile_stream(), "signpost"sv, ByteString::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2)); syscall(SC_perf_event, PERF_EVENT_SIGNPOST, profiler_string_id_map().at(arg1), arg2); } else { syscall(SC_perf_event, PERF_EVENT_SIGNPOST, arg1, arg2); @@ -311,7 +311,7 @@ FlatPtr Emulator::virt$perf_register_string(FlatPtr string, size_t size) auto ret = (int)syscall(SC_perf_register_string, buffer, size + 4); if (ret >= 0 && is_profiling()) { - profiler_strings().append(make(StringView { buffer + 4, size })); + profiler_strings().append(make(StringView { buffer + 4, size })); profiler_string_id_map().append(ret); ret = profiler_string_id_map().size() - 1; } @@ -564,7 +564,7 @@ int Emulator::virt$set_mmap_name(FlatPtr params_addr) auto* region = mmu().find_region({ 0x23, (FlatPtr)params.addr }); if (!region || !is(*region)) return -EINVAL; - static_cast(*region).set_name(DeprecatedString::copy(name)); + static_cast(*region).set_name(ByteString::copy(name)); return 0; } @@ -802,7 +802,7 @@ static void round_to_page_size(FlatPtr& address, size_t& size) u32 Emulator::virt$munmap(FlatPtr address, size_t size) { if (is_profiling()) - emit_profile_event(profile_stream(), "munmap"sv, DeprecatedString::formatted("\"ptr\": {}, \"size\": {}", address, size)); + emit_profile_event(profile_stream(), "munmap"sv, ByteString::formatted("\"ptr\": {}, \"size\": {}", address, size)); round_to_page_size(address, size); Vector marked_for_deletion; bool has_non_mmap_region = false; @@ -861,7 +861,7 @@ u32 Emulator::virt$mmap(u32 params_addr) final_address = result.value().base().get(); auto final_size = result.value().size(); - DeprecatedString name_str; + ByteString name_str; if (params.name.characters) { auto buffer_result = ByteBuffer::create_uninitialized(params.name.length); if (buffer_result.is_error()) @@ -872,7 +872,7 @@ u32 Emulator::virt$mmap(u32 params_addr) } if (is_profiling()) - emit_profile_event(profile_stream(), "mmap"sv, DeprecatedString::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str)); + emit_profile_event(profile_stream(), "mmap"sv, ByteString::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str)); if (params.flags & MAP_ANONYMOUS) { mmu().add_region(MmapRegion::create_anonymous(final_address, final_size, params.prot, move(name_str))); @@ -1216,15 +1216,15 @@ int Emulator::virt$execve(FlatPtr params_addr) Syscall::SC_execve_params params; mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); - auto path = DeprecatedString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length)); - Vector arguments; - Vector environment; + auto path = ByteString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length)); + Vector arguments; + Vector environment; auto copy_string_list = [this](auto& output_vector, auto& string_list) { for (size_t i = 0; i < string_list.length; ++i) { Syscall::StringArgument string; mmu().copy_from_vm(&string, (FlatPtr)&string_list.strings[i], sizeof(string)); - output_vector.append(DeprecatedString::copy(mmu().copy_buffer_from_vm((FlatPtr)string.characters, string.length))); + output_vector.append(ByteString::copy(mmu().copy_buffer_from_vm((FlatPtr)string.characters, string.length))); } }; @@ -1270,7 +1270,7 @@ int Emulator::virt$stat(FlatPtr params_addr) Syscall::SC_stat_params params; mmu().copy_from_vm(¶ms, params_addr, sizeof(params)); - auto path = DeprecatedString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length)); + auto path = ByteString::copy(mmu().copy_buffer_from_vm((FlatPtr)params.path.characters, params.path.length)); struct stat host_statbuf; int rc; if (params.follow_symlinks) diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp index 981b2977e9b..9373862589a 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp @@ -26,20 +26,20 @@ static void free_pages(void* ptr, size_t bytes) VERIFY(rc == 0); } -NonnullOwnPtr MmapRegion::create_anonymous(u32 base, u32 size, u32 prot, DeprecatedString name) +NonnullOwnPtr MmapRegion::create_anonymous(u32 base, u32 size, u32 prot, ByteString name) { - auto* data = (u8*)mmap_initialized(size, 0, DeprecatedString::formatted("(UE) {}", name).characters()); + auto* data = (u8*)mmap_initialized(size, 0, ByteString::formatted("(UE) {}", name).characters()); auto* shadow_data = (u8*)mmap_initialized(size, 1, "MmapRegion ShadowData"); auto region = adopt_own(*new MmapRegion(base, size, prot, data, shadow_data)); region->m_name = move(name); return region; } -NonnullOwnPtr MmapRegion::create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, DeprecatedString name) +NonnullOwnPtr MmapRegion::create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, ByteString name) { // Since we put the memory to an arbitrary location, do not pass MAP_FIXED and MAP_FIXED_NOREPLACE to the Kernel. auto real_flags = flags & ~(MAP_FIXED | MAP_FIXED_NOREPLACE); - auto* data = (u8*)mmap_with_name(nullptr, size, prot, real_flags, fd, offset, name.is_empty() ? nullptr : DeprecatedString::formatted("(UE) {}", name).characters()); + auto* data = (u8*)mmap_with_name(nullptr, size, prot, real_flags, fd, offset, name.is_empty() ? nullptr : ByteString::formatted("(UE) {}", name).characters()); VERIFY(data != MAP_FAILED); auto* shadow_data = (u8*)mmap_initialized(size, 1, "MmapRegion ShadowData"); auto region = adopt_own(*new MmapRegion(base, size, prot, data, shadow_data)); @@ -318,10 +318,10 @@ void MmapRegion::set_prot(int prot) } } -void MmapRegion::set_name(DeprecatedString name) +void MmapRegion::set_name(ByteString name) { m_name = move(name); - set_mmap_name(range().base().as_ptr(), range().size(), DeprecatedString::formatted("(UE) {}", m_name).characters()); + set_mmap_name(range().base().as_ptr(), range().size(), ByteString::formatted("(UE) {}", m_name).characters()); } } diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.h b/Userland/DevTools/UserspaceEmulator/MmapRegion.h index a4f37f45253..e4593ea04d8 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.h +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.h @@ -16,8 +16,8 @@ class MallocTracer; class MmapRegion final : public Region { public: - static NonnullOwnPtr create_anonymous(u32 base, u32 size, u32 prot, DeprecatedString name); - static NonnullOwnPtr create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, DeprecatedString name); + static NonnullOwnPtr create_anonymous(u32 base, u32 size, u32 prot, ByteString name); + static NonnullOwnPtr create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, ByteString name); virtual ~MmapRegion() override; virtual ValueWithShadow read8(u32 offset) override; @@ -51,8 +51,8 @@ public: MallocRegionMetadata* malloc_metadata() { return m_malloc_metadata; } void set_malloc_metadata(Badge, NonnullOwnPtr metadata) { m_malloc_metadata = move(metadata); } - DeprecatedString const& name() const { return m_name; } - DeprecatedString lib_name() const + ByteString const& name() const { return m_name; } + ByteString lib_name() const { if (m_name.contains("Loader.so"sv)) return "Loader.so"; @@ -61,7 +61,7 @@ public: return {}; return m_name.substring(0, *maybe_separator); } - void set_name(DeprecatedString name); + void set_name(ByteString name); private: MmapRegion(u32 base, u32 size, int prot, u8* data, u8* shadow_data); @@ -72,7 +72,7 @@ private: bool m_malloc { false }; OwnPtr m_malloc_metadata; - DeprecatedString m_name; + ByteString m_name; }; template<> diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.h b/Userland/DevTools/UserspaceEmulator/SoftFPU.h index 5b61fcb9f3e..2abdcbaa93b 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftFPU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.h @@ -114,7 +114,7 @@ private: } } - DeprecatedString fpu_exception_string(FPU_Exception ex) + ByteString fpu_exception_string(FPU_Exception ex) { switch (ex) { case FPU_Exception::StackFault: diff --git a/Userland/DevTools/UserspaceEmulator/main.cpp b/Userland/DevTools/UserspaceEmulator/main.cpp index 3f46eb6f1a7..25993a7d0cc 100644 --- a/Userland/DevTools/UserspaceEmulator/main.cpp +++ b/Userland/DevTools/UserspaceEmulator/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char** argv, char** env) { Vector arguments; bool pause_on_startup { false }; - DeprecatedString profile_dump_path; + ByteString profile_dump_path; bool enable_roi_mode { false }; bool dump_profile { false }; unsigned profile_instruction_interval { 0 }; @@ -51,13 +51,13 @@ int main(int argc, char** argv, char** env) reportln("Cannot find executable for '{}'."sv, arguments[0]); return 1; } - auto executable_path = executable_path_or_error.release_value().to_deprecated_string(); + auto executable_path = executable_path_or_error.release_value().to_byte_string(); if (dump_profile && profile_dump_path.is_empty()) - profile_dump_path = DeprecatedString::formatted("{}.{}.profile", LexicalPath(executable_path).basename(), getpid()); + profile_dump_path = ByteString::formatted("{}.{}.profile", LexicalPath(executable_path).basename(), getpid()); OwnPtr profile_stream; - OwnPtr>> profile_strings; + OwnPtr>> profile_strings; OwnPtr> profile_string_id_map; if (dump_profile) { @@ -67,21 +67,21 @@ int main(int argc, char** argv, char** env) return 1; } profile_stream = profile_stream_or_error.release_value(); - profile_strings = make>>(); + profile_strings = make>>(); profile_string_id_map = make>(); profile_stream->write_until_depleted(R"({"events":[)"sv.bytes()).release_value_but_fixme_should_propagate_errors(); timeval tv {}; gettimeofday(&tv, nullptr); profile_stream->write_until_depleted( - DeprecatedString::formatted( + ByteString::formatted( R"~({{"type": "process_create", "parent_pid": 1, "executable": "{}", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": []}})~", executable_path, getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000) .bytes()) .release_value_but_fixme_should_propagate_errors(); } - Vector environment; + Vector environment; for (int i = 0; env[i]; ++i) { environment.append(env[i]); } @@ -112,8 +112,8 @@ int main(int argc, char** argv, char** env) emulator.profile_stream().write_until_depleted("], \"strings\": ["sv.bytes()).release_value_but_fixme_should_propagate_errors(); if (emulator.profiler_strings().size()) { for (size_t i = 0; i < emulator.profiler_strings().size() - 1; ++i) - emulator.profile_stream().write_until_depleted(DeprecatedString::formatted("\"{}\", ", emulator.profiler_strings().at(i)).bytes()).release_value_but_fixme_should_propagate_errors(); - emulator.profile_stream().write_until_depleted(DeprecatedString::formatted("\"{}\"", emulator.profiler_strings().last()).bytes()).release_value_but_fixme_should_propagate_errors(); + emulator.profile_stream().write_until_depleted(ByteString::formatted("\"{}\", ", emulator.profiler_strings().at(i)).bytes()).release_value_but_fixme_should_propagate_errors(); + emulator.profile_stream().write_until_depleted(ByteString::formatted("\"{}\"", emulator.profiler_strings().last()).bytes()).release_value_but_fixme_should_propagate_errors(); } emulator.profile_stream().write_until_depleted("]}"sv.bytes()).release_value_but_fixme_should_propagate_errors(); } diff --git a/Userland/DynamicLoader/main.cpp b/Userland/DynamicLoader/main.cpp index 3d0d1a80eda..efaf3eb2111 100644 --- a/Userland/DynamicLoader/main.cpp +++ b/Userland/DynamicLoader/main.cpp @@ -122,7 +122,7 @@ void _entry(int argc, char** argv, char** envp) init_libc(); int main_program_fd = -1; - DeprecatedString main_program_path; + ByteString main_program_path; bool is_secure = false; for (; auxvp->a_type != AT_NULL; ++auxvp) { if (auxvp->a_type == ELF::AuxiliaryValue::ExecFileDescriptor) { diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 35a059c1d22..faa676f5c95 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -638,11 +638,11 @@ ErrorOr ChessWidget::export_pgn(Core::File& file) const // Tag Pair Section TRY(file.write_until_depleted("[Event \"Casual Game\"]\n"sv.bytes())); TRY(file.write_until_depleted("[Site \"SerenityOS Chess\"]\n"sv.bytes())); - TRY(file.write_formatted("[Date \"{}\"]\n", Core::DateTime::now().to_deprecated_string("%Y.%m.%d"sv))); + TRY(file.write_formatted("[Date \"{}\"]\n", Core::DateTime::now().to_byte_string("%Y.%m.%d"sv))); TRY(file.write_until_depleted("[Round \"1\"]\n"sv.bytes())); auto current_user = TRY(Core::Account::self(Core::Account::Read::PasswdOnly)); - auto const username = TRY(String::from_deprecated_string(current_user.username())); + auto const username = TRY(String::from_byte_string(current_user.username())); auto const player1 = (!username.is_empty() ? username : "?"sv); auto const player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv : "?"sv); diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index 685d0a9cdc7..729620455f2 100644 --- a/Userland/Games/Hearts/Game.cpp +++ b/Userland/Games/Hearts/Game.cpp @@ -147,7 +147,7 @@ void Game::show_score_card(bool game_over) title_builder.append("Score Card"sv); if (game_over) title_builder.append(" - Game Over"sv); - score_dialog->set_title(title_builder.to_deprecated_string()); + score_dialog->set_title(title_builder.to_byte_string()); RefPtr close_timer; if (!m_players[0].is_human) { @@ -160,7 +160,7 @@ void Game::show_score_card(bool game_over) score_dialog->exec(); } -void Game::setup(DeprecatedString player_name, int hand_number) +void Game::setup(ByteString player_name, int hand_number) { m_players[0].name = move(player_name); @@ -619,7 +619,7 @@ void Game::play_card(Player& player, size_t card_index) 0); } -bool Game::is_valid_play(Player& player, Card& card, DeprecatedString* explanation) const +bool Game::is_valid_play(Player& player, Card& card, ByteString* explanation) const { // First card must be 2 of Clubs. if (m_trick_number == 0 && m_trick.is_empty()) { @@ -692,7 +692,7 @@ void Game::card_clicked_during_passing(size_t, Card& card) void Game::card_clicked_during_play(size_t card_index, Card& card) { - DeprecatedString explanation; + ByteString explanation; if (!is_valid_play(m_players[0], card, &explanation)) { if (m_inverted_card) m_inverted_card->set_inverted(false); diff --git a/Userland/Games/Hearts/Game.h b/Userland/Games/Hearts/Game.h index 85122969196..605f231d055 100644 --- a/Userland/Games/Hearts/Game.h +++ b/Userland/Games/Hearts/Game.h @@ -26,7 +26,7 @@ public: virtual ~Game() override = default; - void setup(DeprecatedString player_name, int hand_number = 0); + void setup(ByteString player_name, int hand_number = 0); Function on_status_change; @@ -41,7 +41,7 @@ private: void play_card(Player& player, size_t card_index); bool are_hearts_broken() const; - bool is_valid_play(Player& player, Card& card, DeprecatedString* explanation = nullptr) const; + bool is_valid_play(Player& player, Card& card, ByteString* explanation = nullptr) const; void let_player_play_card(); void continue_game_after_delay(int interval_ms = 750); void advance_game(); diff --git a/Userland/Games/Hearts/Player.h b/Userland/Games/Hearts/Player.h index 2a7b576d00d..d401eb7c4af 100644 --- a/Userland/Games/Hearts/Player.h +++ b/Userland/Games/Hearts/Player.h @@ -55,7 +55,7 @@ public: Gfx::IntRect name_position; Gfx::TextAlignment name_alignment; Gfx::IntPoint taken_cards_target; - DeprecatedString name; + ByteString name; bool is_human { false }; }; diff --git a/Userland/Games/Hearts/ScoreCard.cpp b/Userland/Games/Hearts/ScoreCard.cpp index fd33ece4745..41077681f9c 100644 --- a/Userland/Games/Hearts/ScoreCard.cpp +++ b/Userland/Games/Hearts/ScoreCard.cpp @@ -70,7 +70,7 @@ void ScoreCard::paint_event(GUI::PaintEvent& event) text_color); for (int score_index = 0; score_index < (int)player.scores.size(); score_index++) { auto text_rect = cell_rect(player_index, 1 + score_index); - auto score_text = DeprecatedString::formatted("{}", player.scores[score_index]); + auto score_text = ByteString::formatted("{}", player.scores[score_index]); auto score_text_width = font.width_rounded_up(score_text); if (score_index != (int)player.scores.size() - 1) { painter.draw_line( diff --git a/Userland/Games/Hearts/SettingsDialog.cpp b/Userland/Games/Hearts/SettingsDialog.cpp index cbf85c8903c..3371f5e5827 100644 --- a/Userland/Games/Hearts/SettingsDialog.cpp +++ b/Userland/Games/Hearts/SettingsDialog.cpp @@ -10,7 +10,7 @@ #include #include -SettingsDialog::SettingsDialog(GUI::Window* parent, DeprecatedString player_name) +SettingsDialog::SettingsDialog(GUI::Window* parent, ByteString player_name) : GUI::Dialog(parent) , m_player_name(move(player_name)) { diff --git a/Userland/Games/Hearts/SettingsDialog.h b/Userland/Games/Hearts/SettingsDialog.h index 1933537960b..d85407c82d9 100644 --- a/Userland/Games/Hearts/SettingsDialog.h +++ b/Userland/Games/Hearts/SettingsDialog.h @@ -12,10 +12,10 @@ class SettingsDialog : public GUI::Dialog { C_OBJECT(SettingsDialog) public: - DeprecatedString const& player_name() const { return m_player_name; } + ByteString const& player_name() const { return m_player_name; } private: - SettingsDialog(GUI::Window* parent, DeprecatedString player_name); + SettingsDialog(GUI::Window* parent, ByteString player_name); - DeprecatedString m_player_name { "Gunnar" }; + ByteString m_player_name { "Gunnar" }; }; diff --git a/Userland/Games/Hearts/main.cpp b/Userland/Games/Hearts/main.cpp index 076d869b46a..94964170ba0 100644 --- a/Userland/Games/Hearts/main.cpp +++ b/Userland/Games/Hearts/main.cpp @@ -59,7 +59,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& statusbar = *widget->find_descendant_of_type_named("statusbar"); statusbar.set_text(0, "Score: 0"_string); - DeprecatedString player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv); + ByteString player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv); game.on_status_change = [&](String const& status) { statusbar.set_override_text(status); diff --git a/Userland/Games/MasterWord/WordGame.cpp b/Userland/Games/MasterWord/WordGame.cpp index aba0f46aec7..f1897d092b2 100644 --- a/Userland/Games/MasterWord/WordGame.cpp +++ b/Userland/Games/MasterWord/WordGame.cpp @@ -40,7 +40,7 @@ void WordGame::reset() if (maybe_word.has_value()) m_current_word = maybe_word.value(); else { - GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not get a random {} letter word. Defaulting to 5.", m_num_letters), "MasterWord"sv); + GUI::MessageBox::show(window(), ByteString::formatted("Could not get a random {} letter word. Defaulting to 5.", m_num_letters), "MasterWord"sv); if (m_num_letters != 5) { m_num_letters = 5; reset(); @@ -53,7 +53,7 @@ void WordGame::reset() void WordGame::pick_font() { - DeprecatedString best_font_name; + ByteString best_font_name; auto best_font_size = -1; auto& font_database = Gfx::FontDatabase::the(); font_database.for_each_font([&](Gfx::Font const& font) { @@ -61,7 +61,7 @@ void WordGame::pick_font() return; auto size = font.pixel_size_rounded_up(); if (size * 2 <= m_letter_height && size > best_font_size) { - best_font_name = font.qualified_name().to_deprecated_string(); + best_font_name = font.qualified_name().to_byte_string(); best_font_size = size; } }); @@ -80,7 +80,7 @@ void WordGame::keydown_event(GUI::KeyEvent& event) { // If we can still add a letter and the key was alpha if (m_current_guess.length() < m_num_letters && is_ascii_alpha(event.code_point())) { - m_current_guess = DeprecatedString::formatted("{}{}", m_current_guess, event.text().to_uppercase()); + m_current_guess = ByteString::formatted("{}{}", m_current_guess, event.text().to_uppercase()); m_last_word_invalid = false; } // If backspace pressed and already have some letters entered @@ -107,7 +107,7 @@ void WordGame::keydown_event(GUI::KeyEvent& event) GUI::MessageBox::show(window(), "You win!"sv, "MasterWord"sv); reset(); } else if (m_guesses.size() == m_max_guesses) { - GUI::MessageBox::show(window(), DeprecatedString::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"sv); + GUI::MessageBox::show(window(), ByteString::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"sv); reset(); } } @@ -194,7 +194,7 @@ void WordGame::read_words() } } -Optional WordGame::random_word(size_t length) +Optional WordGame::random_word(size_t length) { auto words_for_length = m_words.get(length); if (words_for_length.has_value()) { diff --git a/Userland/Games/MasterWord/WordGame.h b/Userland/Games/MasterWord/WordGame.h index 4b7fa90eb8a..ebda18b2649 100644 --- a/Userland/Games/MasterWord/WordGame.h +++ b/Userland/Games/MasterWord/WordGame.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -30,7 +30,7 @@ public: void set_max_guesses(size_t max_guesses); Gfx::IntSize game_size() const; - Optional random_word(size_t length); + Optional random_word(size_t length); size_t shortest_word(); size_t longest_word(); bool is_checking_guesses() const; @@ -77,15 +77,15 @@ private: }; struct Guess { - AK::DeprecatedString text; + AK::ByteString text; AK::Vector letter_states; }; AK::Vector m_guesses; - AK::DeprecatedString m_current_guess; - AK::DeprecatedString m_current_word; + AK::ByteString m_current_guess; + AK::ByteString m_current_word; - HashMap> m_words; + HashMap> m_words; NonnullRefPtr m_clear_message_timer; }; diff --git a/Userland/Games/Minesweeper/Field.cpp b/Userland/Games/Minesweeper/Field.cpp index e7ddc75a32c..516b510136b 100644 --- a/Userland/Games/Minesweeper/Field.cpp +++ b/Userland/Games/Minesweeper/Field.cpp @@ -120,7 +120,7 @@ ErrorOr> Field::create(GUI::Label& flag_label, GUI::Label& field->m_good_face_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/graphics/minesweeper/face-good.png"sv)); field->m_bad_face_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/graphics/minesweeper/face-bad.png"sv)); for (int i = 0; i < 8; ++i) - field->m_number_bitmap[i] = TRY(Gfx::Bitmap::load_from_file(DeprecatedString::formatted("/res/graphics/minesweeper/{}.png", i + 1))); + field->m_number_bitmap[i] = TRY(Gfx::Bitmap::load_from_file(ByteString::formatted("/res/graphics/minesweeper/{}.png", i + 1))); field->initialize(); return field; } @@ -138,7 +138,7 @@ void Field::initialize() m_timer = Core::Timer::create_repeating( 1000, [this] { ++m_time_elapsed; - m_time_label.set_text(String::from_deprecated_string(human_readable_digital_time(m_time_elapsed)).release_value_but_fixme_should_propagate_errors()); + m_time_label.set_text(String::from_byte_string(human_readable_digital_time(m_time_elapsed)).release_value_but_fixme_should_propagate_errors()); }, this) .release_value_but_fixme_should_propagate_errors(); diff --git a/Userland/Games/Snake/Game.cpp b/Userland/Games/Snake/Game.cpp index dc8e945aedd..25c250c3a47 100644 --- a/Userland/Games/Snake/Game.cpp +++ b/Userland/Games/Snake/Game.cpp @@ -66,7 +66,7 @@ ErrorOr> Game::try_create() } auto color = Color::from_argb(Config::read_u32("Snake"sv, "Snake"sv, "BaseColor"sv, Color(Color::Green).value())); - auto skin_name = TRY(String::from_deprecated_string(Config::read_string("Snake"sv, "Snake"sv, "SnakeSkin"sv, "Classic"sv))); + auto skin_name = TRY(String::from_byte_string(Config::read_string("Snake"sv, "Snake"sv, "SnakeSkin"sv, "Classic"sv))); auto skin = TRY(SnakeSkin::create(skin_name, color)); return adopt_nonnull_ref_or_enomem(new (nothrow) Game(move(food_bitmaps), color, skin_name, move(skin))); @@ -275,7 +275,7 @@ void Game::game_over() text.append("\nThat's a new high score!"sv); } GUI::MessageBox::show(window(), - text.to_deprecated_string(), + text.to_byte_string(), "Game Over"sv, GUI::MessageBox::Type::Information); diff --git a/Userland/Games/Snake/Skins/ImageSkin.cpp b/Userland/Games/Snake/Skins/ImageSkin.cpp index 73ee0177f0d..608a73937f0 100644 --- a/Userland/Games/Snake/Skins/ImageSkin.cpp +++ b/Userland/Games/Snake/Skins/ImageSkin.cpp @@ -14,7 +14,7 @@ namespace Snake { ErrorOr> ImageSkin::create(StringView skin_name) { - auto skin_directory = TRY(Core::Directory::create(DeprecatedString::formatted("/res/graphics/snake/skins/{}", skin_name), Core::Directory::CreateDirectories::No)); + auto skin_directory = TRY(Core::Directory::create(ByteString::formatted("/res/graphics/snake/skins/{}", skin_name), Core::Directory::CreateDirectories::No)); auto head = TRY(Gfx::Bitmap::load_from_file(TRY(skin_directory.open("head.png"sv, Core::File::OpenMode::Read)), "head.png"sv)); Vector> head_bitmaps; diff --git a/Userland/Games/Snake/main.cpp b/Userland/Games/Snake/main.cpp index 6a25515095d..18e17af94c2 100644 --- a/Userland/Games/Snake/main.cpp +++ b/Userland/Games/Snake/main.cpp @@ -92,14 +92,14 @@ ErrorOr serenity_main(Main::Arguments arguments) auto const pause_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"sv)); static String const continue_text = "&Continue Game"_string; auto const continue_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"sv)); - game_menu->add_action(GUI::Action::create(pause_text.to_deprecated_string(), { Mod_None, Key_Space }, pause_icon, [&](auto& action) { + game_menu->add_action(GUI::Action::create(pause_text.to_byte_string(), { Mod_None, Key_Space }, pause_icon, [&](auto& action) { if (game.has_timer()) { game.pause(); - action.set_text(continue_text.to_deprecated_string()); + action.set_text(continue_text.to_byte_string()); action.set_icon(continue_icon); } else { game.start(); - action.set_text(pause_text.to_deprecated_string()); + action.set_text(pause_text.to_byte_string()); action.set_icon(pause_icon); } })); @@ -129,7 +129,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto add_skin_action = [&](StringView name, bool enable_color) -> ErrorOr { auto action = GUI::Action::create_checkable(name, GUI::Shortcut {}, [&, enable_color](auto& action) { Config::write_string("Snake"sv, "Snake"sv, "SnakeSkin"sv, action.text()); - game.set_skin_name(String::from_deprecated_string(action.text()).release_value_but_fixme_should_propagate_errors()); + game.set_skin_name(String::from_byte_string(action.text()).release_value_but_fixme_should_propagate_errors()); change_snake_color->set_enabled(enable_color); }); diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp index 0ebb485db79..6d809d65284 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.cpp +++ b/Userland/Libraries/LibAudio/FlacLoader.cpp @@ -4,9 +4,9 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include -#include #include #include #include @@ -63,11 +63,11 @@ MaybeLoaderError FlacLoaderPlugin::parse_header() BigEndianInputBitStream bit_input { MaybeOwned(*m_stream) }; // A mixture of VERIFY and the non-crashing TRY(). -#define FLAC_VERIFY(check, category, msg) \ - do { \ - if (!(check)) { \ - return LoaderError { category, TRY(m_stream->tell()), DeprecatedString::formatted("FLAC header: {}", msg) }; \ - } \ +#define FLAC_VERIFY(check, category, msg) \ + do { \ + if (!(check)) { \ + return LoaderError { category, TRY(m_stream->tell()), ByteString::formatted("FLAC header: {}", msg) }; \ + } \ } while (0) // Magic number @@ -305,7 +305,7 @@ MaybeLoaderError FlacLoaderPlugin::seek(int int_sample_index) dbgln_if(AFLACLOADER_DEBUG, "Seeking to seektable: sample index {}, byte offset {}", target_seekpoint.sample_index, target_seekpoint.byte_offset); auto position = target_seekpoint.byte_offset + m_data_start_location; if (m_stream->seek(static_cast(position), SeekMode::SetPosition).is_error()) - return LoaderError { LoaderError::Category::IO, m_loaded_samples, DeprecatedString::formatted("Invalid seek position {}", position) }; + return LoaderError { LoaderError::Category::IO, m_loaded_samples, ByteString::formatted("Invalid seek position {}", position) }; m_loaded_samples = target_seekpoint.sample_index; } } @@ -367,11 +367,11 @@ ErrorOr>, LoaderError> FlacLoaderPlugin::load_chunks(s // 11.21. FRAME LoaderSamples FlacLoaderPlugin::next_frame() { -#define FLAC_VERIFY(check, category, msg) \ - do { \ - if (!(check)) { \ - return LoaderError { category, static_cast(m_current_sample_or_frame), DeprecatedString::formatted("FLAC header: {}", msg) }; \ - } \ +#define FLAC_VERIFY(check, category, msg) \ + do { \ + if (!(check)) { \ + return LoaderError { category, static_cast(m_current_sample_or_frame), ByteString::formatted("FLAC header: {}", msg) }; \ + } \ } while (0) auto frame_byte_index = TRY(m_stream->tell()); @@ -612,7 +612,7 @@ ErrorOr FlacLoaderPlugin::convert_bit_depth_code(u8 bit_depth_c case 7: return 32; default: - return LoaderError { LoaderError::Category::Format, static_cast(m_current_sample_or_frame), DeprecatedString::formatted("Unsupported sample size {}", bit_depth_code) }; + return LoaderError { LoaderError::Category::Format, static_cast(m_current_sample_or_frame), ByteString::formatted("Unsupported sample size {}", bit_depth_code) }; } } @@ -900,7 +900,7 @@ ErrorOr, LoaderError> FlacLoaderPlugin::decode_fixed_lpc(FlacSubfram decoded[i] += 4 * decoded[i - 1] - 6 * decoded[i - 2] + 4 * decoded[i - 3] - decoded[i - 4]; break; default: - return LoaderError { LoaderError::Category::Format, static_cast(m_current_sample_or_frame), DeprecatedString::formatted("Unrecognized predictor order {}", subframe.order) }; + return LoaderError { LoaderError::Category::Format, static_cast(m_current_sample_or_frame), ByteString::formatted("Unrecognized predictor order {}", subframe.order) }; } return decoded; } diff --git a/Userland/Libraries/LibAudio/FlacLoader.h b/Userland/Libraries/LibAudio/FlacLoader.h index f1343406176..99b73c40da8 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.h +++ b/Userland/Libraries/LibAudio/FlacLoader.h @@ -52,7 +52,7 @@ public: virtual int total_samples() override { return static_cast(m_total_samples); } virtual u32 sample_rate() override { return m_sample_rate; } virtual u16 num_channels() override { return m_num_channels; } - virtual DeprecatedString format_name() override { return "FLAC (.flac)"; } + virtual ByteString format_name() override { return "FLAC (.flac)"; } virtual PcmSampleFormat pcm_format() override { return m_sample_format; } bool is_fixed_blocksize_stream() const { return m_min_block_size == m_max_block_size; } diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h index e1f0d806796..ba7cc4a5409 100644 --- a/Userland/Libraries/LibAudio/Loader.h +++ b/Userland/Libraries/LibAudio/Loader.h @@ -70,7 +70,7 @@ public: virtual u16 num_channels() = 0; // Human-readable name of the file format, of the form (.) - virtual DeprecatedString format_name() = 0; + virtual ByteString format_name() = 0; virtual PcmSampleFormat pcm_format() = 0; Metadata const& metadata() const { return m_metadata; } @@ -107,7 +107,7 @@ public: int total_samples() const { return m_plugin->total_samples(); } u32 sample_rate() const { return m_plugin->sample_rate(); } u16 num_channels() const { return m_plugin->num_channels(); } - DeprecatedString format_name() const { return m_plugin->format_name(); } + ByteString format_name() const { return m_plugin->format_name(); } u16 bits_per_sample() const { return pcm_bits_per_sample(m_plugin->pcm_format()); } PcmSampleFormat pcm_format() const { return m_plugin->pcm_format(); } Metadata const& metadata() const { return m_plugin->metadata(); } diff --git a/Userland/Libraries/LibAudio/LoaderError.h b/Userland/Libraries/LibAudio/LoaderError.h index 925b09fab36..252fe7a3cc6 100644 --- a/Userland/Libraries/LibAudio/LoaderError.h +++ b/Userland/Libraries/LibAudio/LoaderError.h @@ -28,7 +28,7 @@ struct LoaderError { Category category { Category::Unknown }; // Binary index: where in the file the error occurred. size_t index { 0 }; - DeprecatedFlyString description { DeprecatedString::empty() }; + DeprecatedFlyString description { ByteString::empty() }; constexpr LoaderError() = default; LoaderError(Category category, size_t index, DeprecatedFlyString description) @@ -54,7 +54,7 @@ struct LoaderError { { if (error.is_errno()) { auto code = error.code(); - description = DeprecatedString::formatted("{} ({})", strerror(code), code); + description = ByteString::formatted("{} ({})", strerror(code), code); if (code == EBADF || code == EBUSY || code == EEXIST || code == EIO || code == EISDIR || code == ENOENT || code == ENOMEM || code == EPIPE) category = Category::IO; } else { diff --git a/Userland/Libraries/LibAudio/MP3Loader.h b/Userland/Libraries/LibAudio/MP3Loader.h index f841744bb0f..0787379bbcc 100644 --- a/Userland/Libraries/LibAudio/MP3Loader.h +++ b/Userland/Libraries/LibAudio/MP3Loader.h @@ -37,7 +37,7 @@ public: virtual u32 sample_rate() override { return m_sample_rate; } virtual u16 num_channels() override { return m_num_channels; } virtual PcmSampleFormat pcm_format() override { return m_sample_format; } - virtual DeprecatedString format_name() override { return "MP3 (.mp3)"; } + virtual ByteString format_name() override { return "MP3 (.mp3)"; } private: MaybeLoaderError initialize(); diff --git a/Userland/Libraries/LibAudio/QOALoader.h b/Userland/Libraries/LibAudio/QOALoader.h index 385cb0abcfe..753ffe29e50 100644 --- a/Userland/Libraries/LibAudio/QOALoader.h +++ b/Userland/Libraries/LibAudio/QOALoader.h @@ -37,7 +37,7 @@ public: virtual int total_samples() override { return static_cast(m_total_samples); } virtual u32 sample_rate() override { return m_sample_rate; } virtual u16 num_channels() override { return m_num_channels; } - virtual DeprecatedString format_name() override { return "Quite Okay Audio (.qoa)"; } + virtual ByteString format_name() override { return "Quite Okay Audio (.qoa)"; } virtual PcmSampleFormat pcm_format() override { return PcmSampleFormat::Int16; } private: diff --git a/Userland/Libraries/LibAudio/SampleFormats.cpp b/Userland/Libraries/LibAudio/SampleFormats.cpp index 73e2a4d2f55..3f750e61349 100644 --- a/Userland/Libraries/LibAudio/SampleFormats.cpp +++ b/Userland/Libraries/LibAudio/SampleFormats.cpp @@ -48,10 +48,10 @@ Optional integer_sample_format_for(u16 bits_per_sample) } } -DeprecatedString sample_format_name(PcmSampleFormat format) +ByteString sample_format_name(PcmSampleFormat format) { bool is_float = format == PcmSampleFormat::Float32 || format == PcmSampleFormat::Float64; - return DeprecatedString::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE"); + return ByteString::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE"); } } diff --git a/Userland/Libraries/LibAudio/SampleFormats.h b/Userland/Libraries/LibAudio/SampleFormats.h index bccb20d7565..918a43e49a1 100644 --- a/Userland/Libraries/LibAudio/SampleFormats.h +++ b/Userland/Libraries/LibAudio/SampleFormats.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace Audio { @@ -25,5 +25,5 @@ enum class PcmSampleFormat : u8 { u16 pcm_bits_per_sample(PcmSampleFormat format); bool is_integer_format(PcmSampleFormat format); Optional integer_sample_format_for(u16 bits_per_sample); -DeprecatedString sample_format_name(PcmSampleFormat format); +ByteString sample_format_name(PcmSampleFormat format); } diff --git a/Userland/Libraries/LibAudio/WavLoader.cpp b/Userland/Libraries/LibAudio/WavLoader.cpp index f533ac92519..a5077361a27 100644 --- a/Userland/Libraries/LibAudio/WavLoader.cpp +++ b/Userland/Libraries/LibAudio/WavLoader.cpp @@ -178,11 +178,11 @@ MaybeLoaderError WavLoaderPlugin::seek(int sample_index) // Specification reference: http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html MaybeLoaderError WavLoaderPlugin::parse_header() { -#define CHECK(check, category, msg) \ - do { \ - if (!(check)) { \ - return LoaderError { category, static_cast(TRY(m_stream->tell())), DeprecatedString::formatted("WAV header: {}", msg) }; \ - } \ +#define CHECK(check, category, msg) \ + do { \ + if (!(check)) { \ + return LoaderError { category, static_cast(TRY(m_stream->tell())), ByteString::formatted("WAV header: {}", msg) }; \ + } \ } while (0) auto riff = TRY(m_stream->read_value()); diff --git a/Userland/Libraries/LibAudio/WavLoader.h b/Userland/Libraries/LibAudio/WavLoader.h index 49da79e685c..1a06c8c08cd 100644 --- a/Userland/Libraries/LibAudio/WavLoader.h +++ b/Userland/Libraries/LibAudio/WavLoader.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -41,7 +41,7 @@ public: virtual int total_samples() override { return static_cast(m_total_samples); } virtual u32 sample_rate() override { return m_sample_rate; } virtual u16 num_channels() override { return m_num_channels; } - virtual DeprecatedString format_name() override { return "RIFF WAVE (.wav)"; } + virtual ByteString format_name() override { return "RIFF WAVE (.wav)"; } virtual PcmSampleFormat pcm_format() override { return m_sample_format; } private: diff --git a/Userland/Libraries/LibAudio/WavWriter.h b/Userland/Libraries/LibAudio/WavWriter.h index 845eb7b06cb..d026833dad0 100644 --- a/Userland/Libraries/LibAudio/WavWriter.h +++ b/Userland/Libraries/LibAudio/WavWriter.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include diff --git a/Userland/Libraries/LibC/bits/dlfcn_integration.h b/Userland/Libraries/LibC/bits/dlfcn_integration.h index 01421879063..1acf07cf13f 100644 --- a/Userland/Libraries/LibC/bits/dlfcn_integration.h +++ b/Userland/Libraries/LibC/bits/dlfcn_integration.h @@ -7,11 +7,11 @@ #pragma once -#include +#include #include struct DlErrorMessage { - DlErrorMessage(DeprecatedString&& other) + DlErrorMessage(ByteString&& other) : text(move(other)) { } @@ -21,7 +21,7 @@ struct DlErrorMessage { // from the one in libc.so virtual ~DlErrorMessage() = default; - DeprecatedString text; + ByteString text; }; struct __Dl_info; diff --git a/Userland/Libraries/LibC/dlfcn.cpp b/Userland/Libraries/LibC/dlfcn.cpp index abbc722e44b..e5eecdfbf87 100644 --- a/Userland/Libraries/LibC/dlfcn.cpp +++ b/Userland/Libraries/LibC/dlfcn.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -25,7 +25,7 @@ __thread char* s_dlerror_text = NULL; __thread bool s_dlerror_retrieved = false; #endif -static void store_error(DeprecatedString const& error) +static void store_error(ByteString const& error) { free(s_dlerror_text); s_dlerror_text = strdup(error.characters()); diff --git a/Userland/Libraries/LibC/netdb.cpp b/Userland/Libraries/LibC/netdb.cpp index c707a9b7151..f4dca809ed7 100644 --- a/Userland/Libraries/LibC/netdb.cpp +++ b/Userland/Libraries/LibC/netdb.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -54,8 +54,8 @@ struct ServiceFileLine { static ErrorOr> parse_service_file_line(char const* line, ssize_t read); static servent __getserv_buffer; -static DeprecatedString __getserv_name_buffer; -static DeprecatedString __getserv_protocol_buffer; +static ByteString __getserv_name_buffer; +static ByteString __getserv_protocol_buffer; static int __getserv_port_buffer; static Vector __getserv_alias_list_buffer; static Vector __getserv_alias_list; @@ -68,7 +68,7 @@ static char const* protocols_path = "/etc/protocols"; static bool fill_getproto_buffers(char const* line, ssize_t read); static protoent __getproto_buffer; -static DeprecatedString __getproto_name_buffer; +static ByteString __getproto_name_buffer; static Vector __getproto_alias_list_buffer; static Vector __getproto_alias_list; static int __getproto_protocol_buffer; @@ -96,7 +96,7 @@ static int connect_to_lookup_server() return fd; } -static DeprecatedString gethostbyname_name_buffer; +static ByteString gethostbyname_name_buffer; hostent* gethostbyname(char const* name) { @@ -226,7 +226,7 @@ int gethostbyname_r(char const* __restrict name, struct hostent* __restrict ret, auto ipv4_address = IPv4Address::from_string({ name, strlen(name) }); if (ipv4_address.has_value()) { - return populate_ret(ipv4_address.value().to_deprecated_string().characters(), ipv4_address.value().to_in_addr_t()); + return populate_ret(ipv4_address.value().to_byte_string().characters(), ipv4_address.value().to_in_addr_t()); } int fd = connect_to_lookup_server(); @@ -318,7 +318,7 @@ int gethostbyname_r(char const* __restrict name, struct hostent* __restrict ret, return populate_ret(name, address); } -static DeprecatedString gethostbyaddr_name_buffer; +static ByteString gethostbyaddr_name_buffer; hostent* gethostbyaddr(void const* addr, socklen_t addr_size, int type) { @@ -474,9 +474,9 @@ struct servent* getservent() servent* service_entry = nullptr; - __getserv_name_buffer = service_file_line.value().name.to_deprecated_string(); + __getserv_name_buffer = service_file_line.value().name.to_byte_string(); __getserv_port_buffer = service_file_line.value().port; - __getserv_protocol_buffer = service_file_line.value().protocol.to_deprecated_string(); + __getserv_protocol_buffer = service_file_line.value().protocol.to_byte_string(); __getserv_alias_list_buffer = service_file_line.value().aliases; __getserv_buffer.s_name = const_cast(__getserv_name_buffer.characters()); @@ -583,9 +583,9 @@ static ErrorOr> parse_service_file_line(char const* li if (split_line.size() < 2) return Error::from_string_view("malformed service file"sv); - auto name = TRY(String::from_deprecated_string(split_line[0])); + auto name = TRY(String::from_byte_string(split_line[0])); - auto port_protocol = TRY(String::from_deprecated_string(split_line[1])); + auto port_protocol = TRY(String::from_byte_string(split_line[1])); auto port_protocol_split = TRY(port_protocol.split('/')); if (port_protocol_split.size() < 2) @@ -756,7 +756,7 @@ void endprotoent() static bool fill_getproto_buffers(char const* line, ssize_t read) { - DeprecatedString string_line = DeprecatedString(line, read); + ByteString string_line = ByteString(line, read); auto split_line = string_line.replace(" "sv, "\t"sv, ReplaceMode::All).split('\t'); // This indicates an incorrect file format. Protocols file entries should diff --git a/Userland/Libraries/LibC/shadow.cpp b/Userland/Libraries/LibC/shadow.cpp index 207c1240fd0..929fce23e06 100644 --- a/Userland/Libraries/LibC/shadow.cpp +++ b/Userland/Libraries/LibC/shadow.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -20,8 +20,8 @@ static FILE* s_stream = nullptr; static unsigned s_line_number = 0; static struct spwd s_shadow_entry; -static DeprecatedString s_name; -static DeprecatedString s_pwdp; +static ByteString s_name; +static ByteString s_pwdp; void setspent() { @@ -61,7 +61,7 @@ struct spwd* getspnam(char const* name) return nullptr; } -static bool parse_shadow_entry(DeprecatedString const& line) +static bool parse_shadow_entry(ByteString const& line) { auto parts = line.split_view(':', SplitBehavior::KeepEmpty); if (parts.size() != 9) { @@ -168,7 +168,7 @@ struct spwd* getspent() if ((!s || !s[0]) && feof(s_stream)) return nullptr; - DeprecatedString line(s, Chomp); + ByteString line(s, Chomp); if (parse_shadow_entry(line)) return &s_shadow_entry; // Otherwise, proceed to the next line. diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp index a146ffba4da..32c6e5851c8 100644 --- a/Userland/Libraries/LibC/stdio.cpp +++ b/Userland/Libraries/LibC/stdio.cpp @@ -6,7 +6,7 @@ */ #include -#include +#include #include #include #include @@ -947,7 +947,7 @@ int vasprintf(char** strp, char const* fmt, va_list ap) builder.appendvf(fmt, ap); VERIFY(builder.length() <= NumericLimits::max()); int length = builder.length(); - *strp = strdup(builder.to_deprecated_string().characters()); + *strp = strdup(builder.to_byte_string().characters()); return length; } @@ -961,7 +961,7 @@ int asprintf(char** strp, char const* fmt, ...) va_end(ap); VERIFY(builder.length() <= NumericLimits::max()); int length = builder.length(); - *strp = strdup(builder.to_deprecated_string().characters()); + *strp = strdup(builder.to_byte_string().characters()); return length; } diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp index eb393b9bdcf..29325d555b1 100644 --- a/Userland/Libraries/LibC/stdlib.cpp +++ b/Userland/Libraries/LibC/stdlib.cpp @@ -649,7 +649,7 @@ int ptsname_r(int fd, char* buffer, size_t size) return -1; } memset(buffer, 0, devpts_path_builder.length() + 1); - auto full_devpts_path_string = devpts_path_builder.to_deprecated_string(); + auto full_devpts_path_string = devpts_path_builder.to_byte_string(); if (!full_devpts_path_string.copy_characters_to_buffer(buffer, size)) { errno = ERANGE; return -1; diff --git a/Userland/Libraries/LibC/sys/devices/gpu.h b/Userland/Libraries/LibC/sys/devices/gpu.h index e5eb843b79f..dadeeaf272e 100644 --- a/Userland/Libraries/LibC/sys/devices/gpu.h +++ b/Userland/Libraries/LibC/sys/devices/gpu.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -34,7 +34,7 @@ ALWAYS_INLINE int graphics_connector_get_head_edid(int fd, GraphicsHeadEDID* inf } auto minor_number = minor(display_connector_stat.st_rdev); - auto edid_fd = open(DeprecatedString::formatted("/sys/devices/graphics/connectors/{}/edid", minor_number).characters(), O_RDONLY); + auto edid_fd = open(ByteString::formatted("/sys/devices/graphics/connectors/{}/edid", minor_number).characters(), O_RDONLY); if (edid_fd < 0) { return edid_fd; } diff --git a/Userland/Libraries/LibC/syslog.cpp b/Userland/Libraries/LibC/syslog.cpp index 5866b59ca7a..9131f0e60de 100644 --- a/Userland/Libraries/LibC/syslog.cpp +++ b/Userland/Libraries/LibC/syslog.cpp @@ -7,7 +7,7 @@ // Has to be defined before including due to legacy Unices #define SYSLOG_NAMES 1 -#include +#include #include #include #include @@ -124,7 +124,7 @@ void vsyslog_r(int priority, struct syslog_data* data, char const* message, va_l combined.appendff("{}: ", get_syslog_ident(data)); combined.appendvf(message, args); - auto combined_string = combined.to_deprecated_string(); + auto combined_string = combined.to_byte_string(); if (data->logopt & LOG_CONS) dbgputstr(combined_string.characters(), combined_string.length()); diff --git a/Userland/Libraries/LibC/time.cpp b/Userland/Libraries/LibC/time.cpp index 34b7f9c9f66..67798b877d6 100644 --- a/Userland/Libraries/LibC/time.cpp +++ b/Userland/Libraries/LibC/time.cpp @@ -414,7 +414,7 @@ size_t strftime(char* destination, size_t max_size, char const* format, const st return 0; } - auto str = builder.to_deprecated_string(); + auto str = builder.to_byte_string(); bool fits = str.copy_characters_to_buffer(destination, max_size); return fits ? str.length() : 0; } diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index c187b795d39..4db929e3b9b 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -190,12 +190,12 @@ int execvpe(char const* filename, char* const argv[], char* const envp[]) ScopedValueRollback errno_rollback(errno); // TODO: Make this use the PATH search implementation from LibFileSystem. - DeprecatedString path = getenv("PATH"); + ByteString path = getenv("PATH"); if (path.is_empty()) path = DEFAULT_PATH; auto parts = path.split(':'); for (auto& part : parts) { - auto candidate = DeprecatedString::formatted("{}/{}", part, filename); + auto candidate = ByteString::formatted("{}/{}", part, filename); int rc = execve(candidate.characters(), argv, envp); if (rc < 0 && errno != ENOENT) { errno_rollback.set_override_rollback_value(errno); @@ -881,13 +881,13 @@ void sync() syscall(SC_sync); } -static Optional getlogin_buffer {}; +static Optional getlogin_buffer {}; char* getlogin() { if (!getlogin_buffer.has_value()) { if (auto* passwd = getpwuid(getuid())) { - getlogin_buffer = DeprecatedString(passwd->pw_name); + getlogin_buffer = ByteString(passwd->pw_name); } endpwent(); } diff --git a/Userland/Libraries/LibCards/CardPainter.cpp b/Userland/Libraries/LibCards/CardPainter.cpp index bb403c1e529..498f4d1adba 100644 --- a/Userland/Libraries/LibCards/CardPainter.cpp +++ b/Userland/Libraries/LibCards/CardPainter.cpp @@ -24,8 +24,8 @@ CardPainter& CardPainter::the() CardPainter::CardPainter() { - m_back_image_path = MUST(String::from_deprecated_string(Config::read_string("Games"sv, "Cards"sv, "CardBackImage"sv, "/res/graphics/cards/backs/Red.png"sv))); - set_front_images_set_name(MUST(String::from_deprecated_string(Config::read_string("Games"sv, "Cards"sv, "CardFrontImages"sv, "Classic"sv)))); + m_back_image_path = MUST(String::from_byte_string(Config::read_string("Games"sv, "Cards"sv, "CardBackImage"sv, "/res/graphics/cards/backs/Red.png"sv))); + set_front_images_set_name(MUST(String::from_byte_string(Config::read_string("Games"sv, "Cards"sv, "CardFrontImages"sv, "Classic"sv)))); } static constexpr Gfx::CharacterBitmap s_diamond { diff --git a/Userland/Libraries/LibCards/CardStack.h b/Userland/Libraries/LibCards/CardStack.h index b65b7684d08..49b482de746 100644 --- a/Userland/Libraries/LibCards/CardStack.h +++ b/Userland/Libraries/LibCards/CardStack.h @@ -140,6 +140,6 @@ struct AK::Formatter : Formatter { first_card = false; } - return Formatter::format(builder, "{:<10} {:>16}: {}"sv, type, stack.bounding_box(), cards.to_deprecated_string()); + return Formatter::format(builder, "{:<10} {:>16}: {}"sv, type, stack.bounding_box(), cards.to_byte_string()); } }; diff --git a/Userland/Libraries/LibChess/UCIEndpoint.h b/Userland/Libraries/LibChess/UCIEndpoint.h index 1aa31cdda18..406b65acff7 100644 --- a/Userland/Libraries/LibChess/UCIEndpoint.h +++ b/Userland/Libraries/LibChess/UCIEndpoint.h @@ -19,7 +19,7 @@ class Endpoint : public Core::EventReceiver { public: virtual ~Endpoint() override = default; - Function on_command_read_error; + Function on_command_read_error; virtual void handle_uci() { } virtual void handle_debug(DebugCommand const&) { } diff --git a/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.cpp index 432c91f0df9..ffeef2ecaf2 100644 --- a/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.cpp @@ -15,7 +15,7 @@ CodeComprehensionEngine::CodeComprehensionEngine(FileDB const& filedb, bool shou { } -void CodeComprehensionEngine::set_declarations_of_document(DeprecatedString const& filename, Vector&& declarations) +void CodeComprehensionEngine::set_declarations_of_document(ByteString const& filename, Vector&& declarations) { // Callback may not be configured if we're running tests if (!set_declarations_of_document_callback) @@ -31,7 +31,7 @@ void CodeComprehensionEngine::set_declarations_of_document(DeprecatedString cons set_declarations_of_document_callback(filename, move(declarations)); } -void CodeComprehensionEngine::set_todo_entries_of_document(DeprecatedString const& filename, Vector&& todo_entries) +void CodeComprehensionEngine::set_todo_entries_of_document(ByteString const& filename, Vector&& todo_entries) { // Callback may not be configured if we're running tests if (!set_todo_entries_of_document_callback) diff --git a/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.h b/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.h index e228b906823..b708cf410f3 100644 --- a/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.h +++ b/Userland/Libraries/LibCodeComprehension/CodeComprehensionEngine.h @@ -24,33 +24,33 @@ public: CodeComprehensionEngine(FileDB const& filedb, bool store_all_declarations = false); virtual ~CodeComprehensionEngine() = default; - virtual Vector get_suggestions(DeprecatedString const& file, GUI::TextPosition const& autocomplete_position) = 0; + virtual Vector get_suggestions(ByteString const& file, GUI::TextPosition const& autocomplete_position) = 0; // TODO: In the future we can pass the range that was edited and only re-parse what we have to. - virtual void on_edit([[maybe_unused]] DeprecatedString const& file) {}; - virtual void file_opened([[maybe_unused]] DeprecatedString const& file) {}; + virtual void on_edit([[maybe_unused]] ByteString const& file) {}; + virtual void file_opened([[maybe_unused]] ByteString const& file) {}; - virtual Optional find_declaration_of(DeprecatedString const&, GUI::TextPosition const&) { return {}; } + virtual Optional find_declaration_of(ByteString const&, GUI::TextPosition const&) { return {}; } struct FunctionParamsHint { - Vector params; + Vector params; size_t current_index { 0 }; }; - virtual Optional get_function_params_hint(DeprecatedString const&, GUI::TextPosition const&) { return {}; } + virtual Optional get_function_params_hint(ByteString const&, GUI::TextPosition const&) { return {}; } - virtual Vector get_tokens_info(DeprecatedString const&) { return {}; } + virtual Vector get_tokens_info(ByteString const&) { return {}; } - Function&&)> set_declarations_of_document_callback; - Function&&)> set_todo_entries_of_document_callback; + Function&&)> set_declarations_of_document_callback; + Function&&)> set_todo_entries_of_document_callback; protected: FileDB const& filedb() const { return m_filedb; } - void set_declarations_of_document(DeprecatedString const&, Vector&&); - void set_todo_entries_of_document(DeprecatedString const&, Vector&&); - HashMap> const& all_declarations() const { return m_all_declarations; } + void set_declarations_of_document(ByteString const&, Vector&&); + void set_todo_entries_of_document(ByteString const&, Vector&&); + HashMap> const& all_declarations() const { return m_all_declarations; } private: - HashMap> m_all_declarations; + HashMap> m_all_declarations; FileDB const& m_filedb; bool m_store_all_declarations { false }; }; diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/ConnectionFromClient.h b/Userland/Libraries/LibCodeComprehension/Cpp/ConnectionFromClient.h index 2b8428eab51..3fea907fb70 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/ConnectionFromClient.h +++ b/Userland/Libraries/LibCodeComprehension/Cpp/ConnectionFromClient.h @@ -19,10 +19,10 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = make(m_filedb); - m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector&& declarations) { async_declarations_in_document(filename, move(declarations)); }; - m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector&& todo_entries) { + m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector&& todo_entries) { async_todo_entries_in_document(filename, move(todo_entries)); }; } diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp index 4d793d1d63f..e0b080b59e9 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp @@ -25,7 +25,7 @@ CppComprehensionEngine::CppComprehensionEngine(FileDB const& filedb) { } -CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(DeprecatedString const& file) +CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(ByteString const& file) { auto absolute_path = filedb().to_absolute_path(file); if (!m_documents.contains(absolute_path)) { @@ -34,7 +34,7 @@ CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_creat return get_document_data(absolute_path); } -CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(DeprecatedString const& file) const +CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(ByteString const& file) const { auto absolute_path = filedb().to_absolute_path(file); auto document_data = m_documents.get(absolute_path); @@ -43,7 +43,7 @@ CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document return document_data.value(); } -OwnPtr CppComprehensionEngine::create_document_data_for(DeprecatedString const& file) +OwnPtr CppComprehensionEngine::create_document_data_for(ByteString const& file) { if (m_unfinished_documents.contains(file)) { return {}; @@ -56,12 +56,12 @@ OwnPtr CppComprehensionEngine::create_docu return create_document_data(move(document.value()), file); } -void CppComprehensionEngine::set_document_data(DeprecatedString const& file, OwnPtr&& data) +void CppComprehensionEngine::set_document_data(ByteString const& file, OwnPtr&& data) { m_documents.set(filedb().to_absolute_path(file), move(data)); } -Vector CppComprehensionEngine::get_suggestions(DeprecatedString const& file, const GUI::TextPosition& autocomplete_position) +Vector CppComprehensionEngine::get_suggestions(ByteString const& file, const GUI::TextPosition& autocomplete_position) { Cpp::Position position { autocomplete_position.line(), autocomplete_position.column() > 0 ? autocomplete_position.column() - 1 : 0 }; @@ -104,7 +104,7 @@ Vector CppComprehensionEngine::get_s Optional> CppComprehensionEngine::try_autocomplete_name(DocumentData const& document, ASTNode const& node, Optional containing_token) const { - auto partial_text = DeprecatedString::empty(); + auto partial_text = ByteString::empty(); if (containing_token.has_value() && containing_token.value().type() != Token::Type::ColonColon) { partial_text = containing_token.value().text(); } @@ -121,7 +121,7 @@ Optional> CppComprehensionEng auto const& parent = static_cast(*node.parent()); - auto partial_text = DeprecatedString::empty(); + auto partial_text = ByteString::empty(); if (containing_token.value().type() != Token::Type::Dot) { if (&node != parent.property()) return {}; @@ -131,7 +131,7 @@ Optional> CppComprehensionEng return autocomplete_property(document, parent, partial_text); } -Vector CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, DeprecatedString const& partial_text) const +Vector CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, ByteString const& partial_text) const { auto reference_scope = scope_of_reference_to_symbol(node); auto current_scope = scope_of_node(node); @@ -206,7 +206,7 @@ Vector CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode return scope_parts; } -Vector CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const DeprecatedString partial_text) const +Vector CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const ByteString partial_text) const { VERIFY(parent.object()); auto type = type_of(document, *parent.object()); @@ -233,7 +233,7 @@ bool CppComprehensionEngine::is_property(ASTNode const& node) const return parent.property() == &node; } -DeprecatedString CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const +ByteString CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const { auto& parent = verify_cast(*identifier.parent()); VERIFY(parent.object()); @@ -253,12 +253,12 @@ DeprecatedString CppComprehensionEngine::type_of_property(DocumentData const& do VERIFY(verify_cast(*type).name()); if (verify_cast(*type).name()) return verify_cast(*type).name()->full_name(); - return DeprecatedString::empty(); + return ByteString::empty(); } return {}; } -DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& identifier) const +ByteString CppComprehensionEngine::type_of_variable(Identifier const& identifier) const { ASTNode const* current = &identifier; while (current) { @@ -269,7 +269,7 @@ DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& iden VERIFY(verify_cast(*var_or_param.type()).name()); if (verify_cast(*var_or_param.type()).name()) return verify_cast(*var_or_param.type()).name()->full_name(); - return DeprecatedString::empty(); + return ByteString::empty(); } } } @@ -278,7 +278,7 @@ DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& iden return {}; } -DeprecatedString CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const +ByteString CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const { if (expression.is_member_expression()) { auto& member_expression = verify_cast(expression); @@ -304,7 +304,7 @@ DeprecatedString CppComprehensionEngine::type_of(DocumentData const& document, E return type_of_variable(*identifier); } -Vector CppComprehensionEngine::properties_of_type(DocumentData const& document, DeprecatedString const& type) const +Vector CppComprehensionEngine::properties_of_type(DocumentData const& document, ByteString const& type) const { auto type_symbol = SymbolName::create(type); auto decl = find_declaration_of(document, type_symbol); @@ -362,21 +362,21 @@ Vector CppComprehensionEngine::get_child_symbols return symbols; } -DeprecatedString CppComprehensionEngine::document_path_from_include_path(StringView include_path) const +ByteString CppComprehensionEngine::document_path_from_include_path(StringView include_path) const { static Regex library_include("<(.+)>"); static Regex user_defined_include("\"(.+)\""); - auto document_path_for_library_include = [&](StringView include_path) -> DeprecatedString { + auto document_path_for_library_include = [&](StringView include_path) -> ByteString { RegexResult result; if (!library_include.search(include_path, result)) return {}; auto path = result.capture_group_matches.at(0).at(0).view.string_view(); - return DeprecatedString::formatted("/usr/include/{}", path); + return ByteString::formatted("/usr/include/{}", path); }; - auto document_path_for_user_defined_include = [&](StringView include_path) -> DeprecatedString { + auto document_path_for_user_defined_include = [&](StringView include_path) -> ByteString { RegexResult result; if (!user_defined_include.search(include_path, result)) return {}; @@ -391,17 +391,17 @@ DeprecatedString CppComprehensionEngine::document_path_from_include_path(StringV return result; } -void CppComprehensionEngine::on_edit(DeprecatedString const& file) +void CppComprehensionEngine::on_edit(ByteString const& file) { set_document_data(file, create_document_data_for(file)); } -void CppComprehensionEngine::file_opened([[maybe_unused]] DeprecatedString const& file) +void CppComprehensionEngine::file_opened([[maybe_unused]] ByteString const& file) { get_or_create_document_data(file); } -Optional CppComprehensionEngine::find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position) +Optional CppComprehensionEngine::find_declaration_of(ByteString const& filename, const GUI::TextPosition& identifier_position) { auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) @@ -456,10 +456,10 @@ struct TargetDeclaration { Property, Scope } type; - DeprecatedString name; + ByteString name; }; -static Optional get_target_declaration(ASTNode const& node, DeprecatedString name); +static Optional get_target_declaration(ASTNode const& node, ByteString name); static Optional get_target_declaration(ASTNode const& node) { if (node.is_identifier()) { @@ -478,7 +478,7 @@ static Optional get_target_declaration(ASTNode const& node) return {}; } -static Optional get_target_declaration(ASTNode const& node, DeprecatedString name) +static Optional get_target_declaration(ASTNode const& node, ByteString name) { if (node.parent() && node.parent()->is_name()) { auto& name_node = *verify_cast(node.parent()); @@ -612,7 +612,7 @@ CodeComprehension::DeclarationType CppComprehensionEngine::type_of_declaration(C return CodeComprehension::DeclarationType::Variable; } -OwnPtr CppComprehensionEngine::create_document_data(DeprecatedString text, DeprecatedString const& filename) +OwnPtr CppComprehensionEngine::create_document_data(ByteString text, ByteString const& filename) { auto document_data = make(); document_data->m_filename = filename; @@ -693,7 +693,7 @@ Optional> CppComprehensionEng System, } include_type { Project }; - DeprecatedString include_root; + ByteString include_root; bool already_has_suffix = false; if (partial_include.starts_with('<')) { include_root = "/usr/include/"; @@ -716,7 +716,7 @@ Optional> CppComprehensionEng return {}; auto last_slash = partial_include.find_last('/'); - auto include_dir = DeprecatedString::empty(); + auto include_dir = ByteString::empty(); auto partial_basename = partial_include.substring_view((last_slash.has_value() ? last_slash.value() : 0) + 1); if (last_slash.has_value()) { include_dir = partial_include.substring_view(1, last_slash.value()); @@ -738,12 +738,12 @@ Optional> CppComprehensionEng if (FileSystem::is_directory(LexicalPath::join(full_dir, path).string())) { // FIXME: Don't dismiss the autocomplete when filling these suggestions. - auto completion = DeprecatedString::formatted("{}{}{}/", prefix, include_dir, path); + auto completion = ByteString::formatted("{}{}{}/", prefix, include_dir, path); options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path, CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying::No); } else if (path.ends_with(".h"sv)) { // FIXME: Place the cursor after the trailing > or ", even if it was // already typed. - auto completion = DeprecatedString::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix); + auto completion = ByteString::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix); options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path); } } @@ -764,17 +764,17 @@ RefPtr CppComprehensionEngine::find_declaration_of(CppCo return target_declaration; } -DeprecatedString CppComprehensionEngine::SymbolName::scope_as_string() const +ByteString CppComprehensionEngine::SymbolName::scope_as_string() const { if (scope.is_empty()) - return DeprecatedString::empty(); + return ByteString::empty(); StringBuilder builder; for (size_t i = 0; i < scope.size() - 1; ++i) { builder.appendff("{}::", scope[i]); } builder.append(scope.last()); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } CppComprehensionEngine::SymbolName CppComprehensionEngine::SymbolName::create(StringView name, Vector&& scope) @@ -790,11 +790,11 @@ CppComprehensionEngine::SymbolName CppComprehensionEngine::SymbolName::create(St return SymbolName::create(name, move(parts)); } -DeprecatedString CppComprehensionEngine::SymbolName::to_deprecated_string() const +ByteString CppComprehensionEngine::SymbolName::to_byte_string() const { if (scope.is_empty()) return name; - return DeprecatedString::formatted("{}::{}", scope_as_string(), name); + return ByteString::formatted("{}::{}", scope_as_string(), name); } bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector const& current_scope, Vector const& reference_scope) @@ -818,7 +818,7 @@ bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector CppComprehensionEngine::get_function_params_hint(DeprecatedString const& filename, const GUI::TextPosition& identifier_position) +Optional CppComprehensionEngine::get_function_params_hint(ByteString const& filename, const GUI::TextPosition& identifier_position) { auto const* document_ptr = get_or_create_document_data(filename); if (!document_ptr) @@ -923,13 +923,13 @@ Optional CppComprehensionEngine::get for (auto token : document_of_declaration->parser().tokens_in_range(arg->start(), arg->end())) { tokens_text.append(token.text()); } - hint.params.append(DeprecatedString::join(' ', tokens_text)); + hint.params.append(ByteString::join(' ', tokens_text)); } return hint; } -Vector CppComprehensionEngine::get_tokens_info(DeprecatedString const& filename) +Vector CppComprehensionEngine::get_tokens_info(ByteString const& filename) { dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "CppComprehensionEngine::get_tokens_info: {}", filename); diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h index 43f24cb4f20..c6580613e96 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -25,12 +25,12 @@ class CppComprehensionEngine : public CodeComprehensionEngine { public: CppComprehensionEngine(FileDB const& filedb); - virtual Vector get_suggestions(DeprecatedString const& file, GUI::TextPosition const& autocomplete_position) override; - virtual void on_edit(DeprecatedString const& file) override; - virtual void file_opened([[maybe_unused]] DeprecatedString const& file) override; - virtual Optional find_declaration_of(DeprecatedString const& filename, GUI::TextPosition const& identifier_position) override; - virtual Optional get_function_params_hint(DeprecatedString const&, GUI::TextPosition const&) override; - virtual Vector get_tokens_info(DeprecatedString const& filename) override; + virtual Vector get_suggestions(ByteString const& file, GUI::TextPosition const& autocomplete_position) override; + virtual void on_edit(ByteString const& file) override; + virtual void file_opened([[maybe_unused]] ByteString const& file) override; + virtual Optional find_declaration_of(ByteString const& filename, GUI::TextPosition const& identifier_position) override; + virtual Optional get_function_params_hint(ByteString const&, GUI::TextPosition const&) override; + virtual Vector get_tokens_info(ByteString const& filename) override; private: struct SymbolName { @@ -39,8 +39,8 @@ private: static SymbolName create(StringView, Vector&&); static SymbolName create(StringView); - DeprecatedString scope_as_string() const; - DeprecatedString to_deprecated_string() const; + ByteString scope_as_string() const; + ByteString to_byte_string() const; bool operator==(SymbolName const&) const = default; }; @@ -63,8 +63,8 @@ private: friend Traits; struct DocumentData { - DeprecatedString const& filename() const { return m_filename; } - DeprecatedString const& text() const { return m_text; } + ByteString const& filename() const { return m_filename; } + ByteString const& text() const { return m_text; } Preprocessor const& preprocessor() const { VERIFY(m_preprocessor); @@ -86,20 +86,20 @@ private: return *m_parser; } - DeprecatedString m_filename; - DeprecatedString m_text; + ByteString m_filename; + ByteString m_text; OwnPtr m_preprocessor; OwnPtr m_parser; HashMap m_symbols; - HashTable m_available_headers; + HashTable m_available_headers; }; - Vector autocomplete_property(DocumentData const&, MemberExpression const&, const DeprecatedString partial_text) const; - Vector autocomplete_name(DocumentData const&, ASTNode const&, DeprecatedString const& partial_text) const; - DeprecatedString type_of(DocumentData const&, Expression const&) const; - DeprecatedString type_of_property(DocumentData const&, Identifier const&) const; - DeprecatedString type_of_variable(Identifier const&) const; + Vector autocomplete_property(DocumentData const&, MemberExpression const&, const ByteString partial_text) const; + Vector autocomplete_name(DocumentData const&, ASTNode const&, ByteString const& partial_text) const; + ByteString type_of(DocumentData const&, Expression const&) const; + ByteString type_of_property(DocumentData const&, Identifier const&) const; + ByteString type_of_variable(Identifier const&) const; bool is_property(ASTNode const&) const; RefPtr find_declaration_of(DocumentData const&, ASTNode const&) const; RefPtr find_declaration_of(DocumentData const&, SymbolName const&) const; @@ -110,16 +110,16 @@ private: Yes }; - Vector properties_of_type(DocumentData const& document, DeprecatedString const& type) const; + Vector properties_of_type(DocumentData const& document, ByteString const& type) const; Vector get_child_symbols(ASTNode const&) const; Vector get_child_symbols(ASTNode const&, Vector const& scope, Symbol::IsLocal) const; - DocumentData const* get_document_data(DeprecatedString const& file) const; - DocumentData const* get_or_create_document_data(DeprecatedString const& file); - void set_document_data(DeprecatedString const& file, OwnPtr&& data); + DocumentData const* get_document_data(ByteString const& file) const; + DocumentData const* get_or_create_document_data(ByteString const& file); + void set_document_data(ByteString const& file, OwnPtr&& data); - OwnPtr create_document_data_for(DeprecatedString const& file); - DeprecatedString document_path_from_include_path(StringView include_path) const; + OwnPtr create_document_data_for(ByteString const& file); + ByteString document_path_from_include_path(StringView include_path) const; void update_declared_symbols(DocumentData&); void update_todo_entries(DocumentData&); CodeComprehension::DeclarationType type_of_declaration(Cpp::Declaration const&); @@ -129,7 +129,7 @@ private: Optional find_preprocessor_definition(DocumentData const&, const GUI::TextPosition&); Optional find_preprocessor_substitution(DocumentData const&, Cpp::Position const&); - OwnPtr create_document_data(DeprecatedString text, DeprecatedString const& filename); + OwnPtr create_document_data(ByteString text, ByteString const& filename); Optional> try_autocomplete_property(DocumentData const&, ASTNode const&, Optional containing_token) const; Optional> try_autocomplete_name(DocumentData const&, ASTNode const&, Optional containing_token) const; Optional> try_autocomplete_include(DocumentData const&, Token include_path_token, Cpp::Position const& cursor_position) const; @@ -145,12 +145,12 @@ private: CodeComprehension::TokenInfo::SemanticType get_token_semantic_type(DocumentData const&, Token const&); CodeComprehension::TokenInfo::SemanticType get_semantic_type_for_identifier(DocumentData const&, Position); - HashMap> m_documents; + HashMap> m_documents; // A document's path will be in this set if we're currently processing it. // A document is added to this set when we start processing it (e.g because it was #included) and removed when we're done. // We use this to prevent circular #includes from looping indefinitely. - HashTable m_unfinished_documents; + HashTable m_unfinished_documents; }; template diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp index 84a7774ab04..38ff863f21e 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp @@ -44,14 +44,14 @@ class FileDB : public CodeComprehension::FileDB { public: FileDB() = default; - void add(DeprecatedString filename, DeprecatedString content) + void add(ByteString filename, ByteString content) { m_map.set(filename, content); } - virtual Optional get_or_read_from_filesystem(StringView filename) const override + virtual Optional get_or_read_from_filesystem(StringView filename) const override { - DeprecatedString target_filename = filename; + ByteString target_filename = filename; if (project_root().has_value() && filename.starts_with(*project_root())) { target_filename = LexicalPath::relative_path(filename, *project_root()); } @@ -59,7 +59,7 @@ public: } private: - HashMap m_map; + HashMap m_map; }; static void test_complete_local_args(); @@ -86,10 +86,10 @@ int run_tests() return 0; } -static void add_file(FileDB& filedb, DeprecatedString const& name) +static void add_file(FileDB& filedb, ByteString const& name) { auto file = Core::File::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); - filedb.add(name, DeprecatedString::copy(MUST(file->read_until_eof()))); + filedb.add(name, ByteString::copy(MUST(file->read_until_eof()))); } void test_complete_local_args() @@ -246,19 +246,19 @@ void test_parameters_hint() auto result = engine.get_function_params_hint("parameters_hint1.cpp", { 4, 9 }); if (!result.has_value()) FAIL("failed to get parameters hint (1)"); - if (result->params != Vector { "int x", "char y" } || result->current_index != 0) + if (result->params != Vector { "int x", "char y" } || result->current_index != 0) FAIL("bad result (1)"); result = engine.get_function_params_hint("parameters_hint1.cpp", { 5, 15 }); if (!result.has_value()) FAIL("failed to get parameters hint (2)"); - if (result->params != Vector { "int x", "char y" } || result->current_index != 1) + if (result->params != Vector { "int x", "char y" } || result->current_index != 1) FAIL("bad result (2)"); result = engine.get_function_params_hint("parameters_hint1.cpp", { 6, 8 }); if (!result.has_value()) FAIL("failed to get parameters hint (3)"); - if (result->params != Vector { "int x", "char y" } || result->current_index != 0) + if (result->params != Vector { "int x", "char y" } || result->current_index != 0) FAIL("bad result (3)"); PASS; diff --git a/Userland/Libraries/LibCodeComprehension/FileDB.cpp b/Userland/Libraries/LibCodeComprehension/FileDB.cpp index 684527c366f..8273b00c58d 100644 --- a/Userland/Libraries/LibCodeComprehension/FileDB.cpp +++ b/Userland/Libraries/LibCodeComprehension/FileDB.cpp @@ -9,14 +9,14 @@ namespace CodeComprehension { -DeprecatedString FileDB::to_absolute_path(StringView filename) const +ByteString FileDB::to_absolute_path(StringView filename) const { if (LexicalPath { filename }.is_absolute()) { return filename; } if (!m_project_root.has_value()) return filename; - return LexicalPath { DeprecatedString::formatted("{}/{}", *m_project_root, filename) }.string(); + return LexicalPath { ByteString::formatted("{}/{}", *m_project_root, filename) }.string(); } } diff --git a/Userland/Libraries/LibCodeComprehension/FileDB.h b/Userland/Libraries/LibCodeComprehension/FileDB.h index 1947be59a28..efa599a7219 100644 --- a/Userland/Libraries/LibCodeComprehension/FileDB.h +++ b/Userland/Libraries/LibCodeComprehension/FileDB.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace CodeComprehension { @@ -18,7 +18,7 @@ class FileDB { public: virtual ~FileDB() = default; - virtual Optional get_or_read_from_filesystem(StringView filename) const = 0; + virtual Optional get_or_read_from_filesystem(StringView filename) const = 0; void set_project_root(StringView project_root) { if (project_root.is_null()) @@ -26,14 +26,14 @@ public: else m_project_root = project_root; } - Optional const& project_root() const { return m_project_root; } - DeprecatedString to_absolute_path(StringView filename) const; + Optional const& project_root() const { return m_project_root; } + ByteString to_absolute_path(StringView filename) const; protected: FileDB() = default; private: - Optional m_project_root; + Optional m_project_root; }; } diff --git a/Userland/Libraries/LibCodeComprehension/Shell/ConnectionFromClient.h b/Userland/Libraries/LibCodeComprehension/Shell/ConnectionFromClient.h index e461bc51eab..e0694d7d8c6 100644 --- a/Userland/Libraries/LibCodeComprehension/Shell/ConnectionFromClient.h +++ b/Userland/Libraries/LibCodeComprehension/Shell/ConnectionFromClient.h @@ -20,10 +20,10 @@ private: : LanguageServers::ConnectionFromClient(move(socket)) { m_autocomplete_engine = make(m_filedb); - m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector&& declarations) { + m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector&& declarations) { async_declarations_in_document(filename, move(declarations)); }; - m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector&& todo_entries) { + m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector&& todo_entries) { async_todo_entries_in_document(filename, move(todo_entries)); }; } diff --git a/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp index 8caa8ad8dbb..1f863a9e81a 100644 --- a/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.cpp @@ -18,7 +18,7 @@ ShellComprehensionEngine::ShellComprehensionEngine(FileDB const& filedb) { } -ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(DeprecatedString const& file) +ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(ByteString const& file) { auto absolute_path = filedb().to_absolute_path(file); if (!m_documents.contains(absolute_path)) { @@ -27,7 +27,7 @@ ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_c return get_document_data(absolute_path); } -ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(DeprecatedString const& file) const +ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(ByteString const& file) const { auto absolute_path = filedb().to_absolute_path(file); auto document_data = m_documents.get(absolute_path); @@ -35,7 +35,7 @@ ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_docu return *document_data.value(); } -OwnPtr ShellComprehensionEngine::create_document_data_for(DeprecatedString const& file) +OwnPtr ShellComprehensionEngine::create_document_data_for(ByteString const& file) { auto document = filedb().get_or_read_from_filesystem(file); if (!document.has_value()) @@ -50,19 +50,19 @@ OwnPtr ShellComprehensionEngine::create_ return document_data; } -void ShellComprehensionEngine::set_document_data(DeprecatedString const& file, OwnPtr&& data) +void ShellComprehensionEngine::set_document_data(ByteString const& file, OwnPtr&& data) { m_documents.set(filedb().to_absolute_path(file), move(data)); } -ShellComprehensionEngine::DocumentData::DocumentData(DeprecatedString&& _text, DeprecatedString _filename) +ShellComprehensionEngine::DocumentData::DocumentData(ByteString&& _text, ByteString _filename) : filename(move(_filename)) , text(move(_text)) , node(parse()) { } -Vector const& ShellComprehensionEngine::DocumentData::sourced_paths() const +Vector const& ShellComprehensionEngine::DocumentData::sourced_paths() const { if (all_sourced_paths.has_value()) return all_sourced_paths.value(); @@ -82,19 +82,19 @@ Vector const& ShellComprehensionEngine::DocumentData::sourced_ auto name_list = name_list_node->resolve_as_list(nullptr).release_value_but_fixme_should_propagate_errors(); StringBuilder builder; builder.join(' ', name_list); - sourced_files.set(builder.to_deprecated_string()); + sourced_files.set(builder.to_byte_string()); } } } ::Shell::AST::NodeVisitor::visit(node); } - HashTable sourced_files; + HashTable sourced_files; } visitor; node->visit(visitor); - Vector sourced_paths; + Vector sourced_paths; for (auto& entry : visitor.sourced_files) sourced_paths.append(move(entry)); @@ -134,7 +134,7 @@ size_t ShellComprehensionEngine::resolve(ShellComprehensionEngine::DocumentData return offset; } -Vector ShellComprehensionEngine::get_suggestions(DeprecatedString const& file, const GUI::TextPosition& position) +Vector ShellComprehensionEngine::get_suggestions(ByteString const& file, const GUI::TextPosition& position) { dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "ShellComprehensionEngine position {}:{}", position.line(), position.column()); @@ -155,17 +155,17 @@ Vector ShellComprehensionEngine::get return entries; } -void ShellComprehensionEngine::on_edit(DeprecatedString const& file) +void ShellComprehensionEngine::on_edit(ByteString const& file) { set_document_data(file, create_document_data_for(file)); } -void ShellComprehensionEngine::file_opened([[maybe_unused]] DeprecatedString const& file) +void ShellComprehensionEngine::file_opened([[maybe_unused]] ByteString const& file) { set_document_data(file, create_document_data_for(file)); } -Optional ShellComprehensionEngine::find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position) +Optional ShellComprehensionEngine::find_declaration_of(ByteString const& filename, const GUI::TextPosition& identifier_position) { dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "find_declaration_of({}, {}:{})", filename, identifier_position.line(), identifier_position.column()); auto const& document = get_or_create_document_data(filename); @@ -196,7 +196,7 @@ Optional ShellComprehensionEngine::find_decl void ShellComprehensionEngine::update_declared_symbols(DocumentData const& document) { struct Visitor : public ::Shell::AST::NodeVisitor { - explicit Visitor(DeprecatedString const& filename) + explicit Visitor(ByteString const& filename) : filename(filename) { } @@ -208,9 +208,9 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum if (!literal) continue; - DeprecatedString name; + ByteString name; if (literal->is_bareword()) - name = static_ptr_cast<::Shell::AST::BarewordLiteral const>(literal)->text().to_deprecated_string(); + name = static_ptr_cast<::Shell::AST::BarewordLiteral const>(literal)->text().to_byte_string(); if (!name.is_empty()) { dbgln("Found variable {}", name); @@ -223,10 +223,10 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum void visit(::Shell::AST::FunctionDeclaration const* node) override { dbgln("Found function {}", node->name().name); - declarations.append({ node->name().name.to_deprecated_string(), { filename, node->position().start_line.line_number, node->position().start_line.line_column }, CodeComprehension::DeclarationType::Function, {} }); + declarations.append({ node->name().name.to_byte_string(), { filename, node->position().start_line.line_number, node->position().start_line.line_column }, CodeComprehension::DeclarationType::Function, {} }); } - DeprecatedString const& filename; + ByteString const& filename; Vector declarations; } visitor { document.filename }; diff --git a/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.h b/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.h index 5b36c1b082a..9de44b24cd8 100644 --- a/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.h +++ b/Userland/Libraries/LibCodeComprehension/Shell/ShellComprehensionEngine.h @@ -14,31 +14,31 @@ namespace CodeComprehension::Shell { class ShellComprehensionEngine : public CodeComprehensionEngine { public: ShellComprehensionEngine(FileDB const& filedb); - virtual Vector get_suggestions(DeprecatedString const& file, const GUI::TextPosition& position) override; - virtual void on_edit(DeprecatedString const& file) override; - virtual void file_opened([[maybe_unused]] DeprecatedString const& file) override; - virtual Optional find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position) override; + virtual Vector get_suggestions(ByteString const& file, const GUI::TextPosition& position) override; + virtual void on_edit(ByteString const& file) override; + virtual void file_opened([[maybe_unused]] ByteString const& file) override; + virtual Optional find_declaration_of(ByteString const& filename, const GUI::TextPosition& identifier_position) override; private: struct DocumentData { - DocumentData(DeprecatedString&& text, DeprecatedString filename); - DeprecatedString filename; - DeprecatedString text; + DocumentData(ByteString&& text, ByteString filename); + ByteString filename; + ByteString text; NonnullRefPtr<::Shell::AST::Node> node; - Vector const& sourced_paths() const; + Vector const& sourced_paths() const; private: NonnullRefPtr<::Shell::AST::Node> parse() const; - mutable Optional> all_sourced_paths {}; + mutable Optional> all_sourced_paths {}; }; - DocumentData const& get_document_data(DeprecatedString const& file) const; - DocumentData const& get_or_create_document_data(DeprecatedString const& file); - void set_document_data(DeprecatedString const& file, OwnPtr&& data); + DocumentData const& get_document_data(ByteString const& file) const; + DocumentData const& get_or_create_document_data(ByteString const& file); + void set_document_data(ByteString const& file, OwnPtr&& data); - OwnPtr create_document_data_for(DeprecatedString const& file); + OwnPtr create_document_data_for(ByteString const& file); void update_declared_symbols(DocumentData const&); static size_t resolve(ShellComprehensionEngine::DocumentData const& document, const GUI::TextPosition& position); @@ -51,7 +51,7 @@ private: return *s_shell; } - HashMap> m_documents; + HashMap> m_documents; static RefPtr<::Shell::Shell> s_shell; }; } diff --git a/Userland/Libraries/LibCodeComprehension/Types.h b/Userland/Libraries/LibCodeComprehension/Types.h index d5943cd28b6..68ee592a675 100644 --- a/Userland/Libraries/LibCodeComprehension/Types.h +++ b/Userland/Libraries/LibCodeComprehension/Types.h @@ -6,7 +6,7 @@ #pragma once -#include +#include namespace CodeComprehension { @@ -16,11 +16,11 @@ enum class Language { }; struct AutocompleteResultEntry { - DeprecatedString completion; + ByteString completion; size_t partial_input_length { 0 }; // TODO: Actually assign the value of this field in more places (when applicable). Language language { Language::Unspecified }; - DeprecatedString display_text {}; + ByteString display_text {}; enum class HideAutocompleteAfterApplying { No, @@ -30,7 +30,7 @@ struct AutocompleteResultEntry { }; struct ProjectLocation { - DeprecatedString file; + ByteString file; size_t line { 0 }; size_t column { 0 }; @@ -51,10 +51,10 @@ enum class DeclarationType { }; struct Declaration { - DeprecatedString name; + ByteString name; ProjectLocation position; DeclarationType type; - DeprecatedString scope; + ByteString scope; bool operator==(Declaration const& other) const { @@ -109,8 +109,8 @@ struct TokenInfo { }; struct TodoEntry { - DeprecatedString content; - DeprecatedString filename; + ByteString content; + ByteString filename; size_t line { 0 }; size_t column { 0 }; }; diff --git a/Userland/Libraries/LibConfig/Client.cpp b/Userland/Libraries/LibConfig/Client.cpp index 4de308853b3..e01141dce66 100644 --- a/Userland/Libraries/LibConfig/Client.cpp +++ b/Userland/Libraries/LibConfig/Client.cpp @@ -19,27 +19,27 @@ Client& Client::the() return *s_the; } -void Client::pledge_domains(Vector const& domains) +void Client::pledge_domains(Vector const& domains) { async_pledge_domains(domains); } -void Client::monitor_domain(DeprecatedString const& domain) +void Client::monitor_domain(ByteString const& domain) { async_monitor_domain(domain); } -Vector Client::list_keys(StringView domain, StringView group) +Vector Client::list_keys(StringView domain, StringView group) { return list_config_keys(domain, group); } -Vector Client::list_groups(StringView domain) +Vector Client::list_groups(StringView domain) { return list_config_groups(domain); } -DeprecatedString Client::read_string(StringView domain, StringView group, StringView key, StringView fallback) +ByteString Client::read_string(StringView domain, StringView group, StringView key, StringView fallback) { return read_string_value(domain, group, key).value_or(fallback); } @@ -94,49 +94,49 @@ void Client::add_group(StringView domain, StringView group) add_group_entry(domain, group); } -void Client::notify_changed_string_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) +void Client::notify_changed_string_value(ByteString const& domain, ByteString const& group, ByteString const& key, ByteString const& value) { Listener::for_each([&](auto& listener) { listener.config_string_did_change(domain, group, key, value); }); } -void Client::notify_changed_i32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, i32 value) +void Client::notify_changed_i32_value(ByteString const& domain, ByteString const& group, ByteString const& key, i32 value) { Listener::for_each([&](auto& listener) { listener.config_i32_did_change(domain, group, key, value); }); } -void Client::notify_changed_u32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, u32 value) +void Client::notify_changed_u32_value(ByteString const& domain, ByteString const& group, ByteString const& key, u32 value) { Listener::for_each([&](auto& listener) { listener.config_u32_did_change(domain, group, key, value); }); } -void Client::notify_changed_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value) +void Client::notify_changed_bool_value(ByteString const& domain, ByteString const& group, ByteString const& key, bool value) { Listener::for_each([&](auto& listener) { listener.config_bool_did_change(domain, group, key, value); }); } -void Client::notify_removed_key(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key) +void Client::notify_removed_key(ByteString const& domain, ByteString const& group, ByteString const& key) { Listener::for_each([&](auto& listener) { listener.config_key_was_removed(domain, group, key); }); } -void Client::notify_removed_group(DeprecatedString const& domain, DeprecatedString const& group) +void Client::notify_removed_group(ByteString const& domain, ByteString const& group) { Listener::for_each([&](auto& listener) { listener.config_group_was_removed(domain, group); }); } -void Client::notify_added_group(DeprecatedString const& domain, DeprecatedString const& group) +void Client::notify_added_group(ByteString const& domain, ByteString const& group) { Listener::for_each([&](auto& listener) { listener.config_group_was_added(domain, group); diff --git a/Userland/Libraries/LibConfig/Client.h b/Userland/Libraries/LibConfig/Client.h index 0da1805894e..601188c80d3 100644 --- a/Userland/Libraries/LibConfig/Client.h +++ b/Userland/Libraries/LibConfig/Client.h @@ -20,13 +20,13 @@ class Client final IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/config"sv) public: - void pledge_domains(Vector const&); - void monitor_domain(DeprecatedString const&); + void pledge_domains(Vector const&); + void monitor_domain(ByteString const&); - Vector list_groups(StringView domain); - Vector list_keys(StringView domain, StringView group); + Vector list_groups(StringView domain); + Vector list_keys(StringView domain, StringView group); - DeprecatedString read_string(StringView domain, StringView group, StringView key, StringView fallback); + ByteString read_string(StringView domain, StringView group, StringView key, StringView fallback); i32 read_i32(StringView domain, StringView group, StringView key, i32 fallback); u32 read_u32(StringView domain, StringView group, StringView key, u32 fallback); bool read_bool(StringView domain, StringView group, StringView key, bool fallback); @@ -47,26 +47,26 @@ private: { } - void notify_changed_string_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override; - void notify_changed_i32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, i32 value) override; - void notify_changed_u32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, u32 value) override; - void notify_changed_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value) override; - void notify_removed_key(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key) override; - void notify_removed_group(DeprecatedString const& domain, DeprecatedString const& group) override; - void notify_added_group(DeprecatedString const& domain, DeprecatedString const& group) override; + void notify_changed_string_value(ByteString const& domain, ByteString const& group, ByteString const& key, ByteString const& value) override; + void notify_changed_i32_value(ByteString const& domain, ByteString const& group, ByteString const& key, i32 value) override; + void notify_changed_u32_value(ByteString const& domain, ByteString const& group, ByteString const& key, u32 value) override; + void notify_changed_bool_value(ByteString const& domain, ByteString const& group, ByteString const& key, bool value) override; + void notify_removed_key(ByteString const& domain, ByteString const& group, ByteString const& key) override; + void notify_removed_group(ByteString const& domain, ByteString const& group) override; + void notify_added_group(ByteString const& domain, ByteString const& group) override; }; -inline Vector list_groups(StringView domain) +inline Vector list_groups(StringView domain) { return Client::the().list_groups(domain); } -inline Vector list_keys(StringView domain, StringView group) +inline Vector list_keys(StringView domain, StringView group) { return Client::the().list_keys(domain, group); } -inline DeprecatedString read_string(StringView domain, StringView group, StringView key, StringView fallback = {}) +inline ByteString read_string(StringView domain, StringView group, StringView key, StringView fallback = {}) { return Client::the().read_string(domain, group, key, fallback); } @@ -121,17 +121,17 @@ inline void add_group(StringView domain, StringView group) Client::the().add_group(domain, group); } -inline void pledge_domains(Vector const& domains) +inline void pledge_domains(Vector const& domains) { Client::the().pledge_domains(domains); } -inline void pledge_domain(DeprecatedString const& domain) +inline void pledge_domain(ByteString const& domain) { Client::the().pledge_domains({ domain }); } -inline void monitor_domain(DeprecatedString const& domain) +inline void monitor_domain(ByteString const& domain) { Client::the().monitor_domain(domain); } diff --git a/Userland/Libraries/LibConfig/Listener.cpp b/Userland/Libraries/LibConfig/Listener.cpp index 170aa6c536a..cb95fc95a6e 100644 --- a/Userland/Libraries/LibConfig/Listener.cpp +++ b/Userland/Libraries/LibConfig/Listener.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include diff --git a/Userland/Libraries/LibCore/Account.cpp b/Userland/Libraries/LibCore/Account.cpp index 031524c421d..40a9fccf468 100644 --- a/Userland/Libraries/LibCore/Account.cpp +++ b/Userland/Libraries/LibCore/Account.cpp @@ -27,7 +27,7 @@ namespace Core { -static DeprecatedString get_salt() +static ByteString get_salt() { char random_data[12]; fill_with_random({ random_data, sizeof(random_data) }); @@ -39,7 +39,7 @@ static DeprecatedString get_salt() auto salt_string = MUST(encode_base64({ random_data, sizeof(random_data) })); builder.append(salt_string); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } static Vector get_extra_gids(passwd const& pwd) @@ -191,25 +191,25 @@ void Account::set_password(SecretString const& password) void Account::set_password_enabled(bool enabled) { - auto flattened_password_hash = m_password_hash.value_or(DeprecatedString::empty()); + auto flattened_password_hash = m_password_hash.value_or(ByteString::empty()); if (enabled && !flattened_password_hash.is_empty() && flattened_password_hash[0] == '!') { m_password_hash = flattened_password_hash.substring(1, flattened_password_hash.length() - 1); } else if (!enabled && (flattened_password_hash.is_empty() || flattened_password_hash[0] != '!')) { StringBuilder builder; builder.append('!'); builder.append(flattened_password_hash); - m_password_hash = builder.to_deprecated_string(); + m_password_hash = builder.to_byte_string(); } } void Account::delete_password() { - m_password_hash = DeprecatedString::empty(); + m_password_hash = ByteString::empty(); } Account::Account(passwd const& pwd, spwd const& spwd, Vector extra_gids) : m_username(pwd.pw_name) - , m_password_hash(spwd.sp_pwdp ? Optional(spwd.sp_pwdp) : OptionalNone {}) + , m_password_hash(spwd.sp_pwdp ? Optional(spwd.sp_pwdp) : OptionalNone {}) , m_uid(pwd.pw_uid) , m_gid(pwd.pw_gid) , m_gecos(pwd.pw_gecos) @@ -219,7 +219,7 @@ Account::Account(passwd const& pwd, spwd const& spwd, Vector extra_gids) { } -ErrorOr Account::generate_passwd_file() const +ErrorOr Account::generate_passwd_file() const { StringBuilder builder; char buffer[1024] = { 0 }; @@ -250,10 +250,10 @@ ErrorOr Account::generate_passwd_file() const } } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -ErrorOr Account::generate_group_file() const +ErrorOr Account::generate_group_file() const { StringBuilder builder; char buffer[1024] = { 0 }; @@ -283,14 +283,14 @@ ErrorOr Account::generate_group_file() const if (should_be_present && !already_present) members.append(m_username.characters()); - builder.appendff("{}:{}:{}:{}\n", group->gr_name, group->gr_passwd, group->gr_gid, DeprecatedString::join(","sv, members)); + builder.appendff("{}:{}:{}:{}\n", group->gr_name, group->gr_passwd, group->gr_gid, ByteString::join(","sv, members)); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } #ifndef AK_OS_BSD_GENERIC -ErrorOr Account::generate_shadow_file() const +ErrorOr Account::generate_shadow_file() const { StringBuilder builder; @@ -302,25 +302,25 @@ ErrorOr Account::generate_shadow_file() const if (p->sp_namp == m_username) { if (m_deleted) continue; - builder.appendff("{}:{}", m_username, m_password_hash.value_or(DeprecatedString::empty())); + builder.appendff("{}:{}", m_username, m_password_hash.value_or(ByteString::empty())); } else builder.appendff("{}:{}", p->sp_namp, p->sp_pwdp); builder.appendff(":{}:{}:{}:{}:{}:{}:{}\n", - (p->sp_lstchg == -1) ? "" : DeprecatedString::formatted("{}", p->sp_lstchg), - (p->sp_min == -1) ? "" : DeprecatedString::formatted("{}", p->sp_min), - (p->sp_max == -1) ? "" : DeprecatedString::formatted("{}", p->sp_max), - (p->sp_warn == -1) ? "" : DeprecatedString::formatted("{}", p->sp_warn), - (p->sp_inact == -1) ? "" : DeprecatedString::formatted("{}", p->sp_inact), - (p->sp_expire == -1) ? "" : DeprecatedString::formatted("{}", p->sp_expire), - (p->sp_flag == 0) ? "" : DeprecatedString::formatted("{}", p->sp_flag)); + (p->sp_lstchg == -1) ? "" : ByteString::formatted("{}", p->sp_lstchg), + (p->sp_min == -1) ? "" : ByteString::formatted("{}", p->sp_min), + (p->sp_max == -1) ? "" : ByteString::formatted("{}", p->sp_max), + (p->sp_warn == -1) ? "" : ByteString::formatted("{}", p->sp_warn), + (p->sp_inact == -1) ? "" : ByteString::formatted("{}", p->sp_inact), + (p->sp_expire == -1) ? "" : ByteString::formatted("{}", p->sp_expire), + (p->sp_flag == 0) ? "" : ByteString::formatted("{}", p->sp_flag)); } endspent(); if (errno) return Error::from_errno(errno); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } #endif diff --git a/Userland/Libraries/LibCore/Account.h b/Userland/Libraries/LibCore/Account.h index c371ff4fa93..b176a443819 100644 --- a/Userland/Libraries/LibCore/Account.h +++ b/Userland/Libraries/LibCore/Account.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -40,8 +40,8 @@ public: bool authenticate(SecretString const& password) const; ErrorOr login() const; - DeprecatedString username() const { return m_username; } - DeprecatedString password_hash() const { return m_password_hash.value_or(DeprecatedString::empty()); } + ByteString username() const { return m_username; } + ByteString password_hash() const { return m_password_hash.value_or(ByteString::empty()); } // Setters only affect in-memory copy of password. // You must call sync to apply changes. @@ -62,9 +62,9 @@ public: uid_t uid() const { return m_uid; } gid_t gid() const { return m_gid; } - DeprecatedString const& gecos() const { return m_gecos; } - DeprecatedString const& home_directory() const { return m_home_directory; } - DeprecatedString const& shell() const { return m_shell; } + ByteString const& gecos() const { return m_gecos; } + ByteString const& home_directory() const { return m_home_directory; } + ByteString const& shell() const { return m_shell; } Vector const& extra_gids() const { return m_extra_gids; } ErrorOr sync(); @@ -74,20 +74,20 @@ private: Account(passwd const& pwd, spwd const& spwd, Vector extra_gids); - ErrorOr generate_passwd_file() const; - ErrorOr generate_group_file() const; + ErrorOr generate_passwd_file() const; + ErrorOr generate_group_file() const; #ifndef AK_OS_BSD_GENERIC - ErrorOr generate_shadow_file() const; + ErrorOr generate_shadow_file() const; #endif - DeprecatedString m_username; + ByteString m_username; - Optional m_password_hash; + Optional m_password_hash; uid_t m_uid { 0 }; gid_t m_gid { 0 }; - DeprecatedString m_gecos; - DeprecatedString m_home_directory; - DeprecatedString m_shell; + ByteString m_gecos; + ByteString m_home_directory; + ByteString m_shell; Vector m_extra_gids; bool m_deleted { false }; }; diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index ec94fd0f366..bf51e8ae0ba 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -88,7 +88,7 @@ bool ArgsParser::parse(Span arguments, FailureBehavior failure_behav } } - auto short_options = short_options_builder.to_deprecated_string(); + auto short_options = short_options_builder.to_byte_string(); size_t option_index = 1; while (true) { auto result = parser.getopt(arguments.slice(1), short_options, long_options, {}); @@ -439,7 +439,7 @@ void ArgsParser::add_option(bool& value, char const* help_string, char const* lo add_option(move(option)); } -void ArgsParser::add_option(DeprecatedString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode) +void ArgsParser::add_option(ByteString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode) { Option option { OptionArgumentMode::Required, @@ -599,7 +599,7 @@ void ArgsParser::add_option(Vector& values, char const* help_string, cha add_option(move(option)); } -void ArgsParser::add_option(Vector& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode) +void ArgsParser::add_option(Vector& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode) { Option option { OptionArgumentMode::Optional, @@ -622,7 +622,7 @@ void ArgsParser::add_positional_argument(Arg&& arg) m_positional_args.append(move(arg)); } -void ArgsParser::add_positional_argument(DeprecatedString& value, char const* help_string, char const* name, Required required) +void ArgsParser::add_positional_argument(ByteString& value, char const* help_string, char const* name, Required required) { Arg arg { help_string, @@ -713,7 +713,7 @@ void ArgsParser::add_positional_argument(double& value, char const* help_string, add_positional_argument(move(arg)); } -void ArgsParser::add_positional_argument(Vector& values, char const* help_string, char const* name, Required required) +void ArgsParser::add_positional_argument(Vector& values, char const* help_string, char const* name, Required required) { Arg arg { help_string, @@ -837,12 +837,12 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, ReadonlySpan< auto write_completion = [&](auto format, auto& option, auto has_invariant, auto... args) { JsonObject object; - object.set("completion", DeprecatedString::formatted(StringView { format, strlen(format) }, args...)); + object.set("completion", ByteString::formatted(StringView { format, strlen(format) }, args...)); object.set("static_offset", 0); object.set("invariant_offset", has_invariant ? option_to_complete.length() : 0u); object.set("display_trivia", option.help_string); object.set("trailing_trivia", option.argument_mode == OptionArgumentMode::Required ? " " : ""); - outln(file, "{}", object.to_deprecated_string()); + outln(file, "{}", object.to_byte_string()); }; if (option_to_complete.starts_with("--"sv)) { diff --git a/Userland/Libraries/LibCore/ArgsParser.h b/Userland/Libraries/LibCore/ArgsParser.h index 9b42e943752..254fa317ed3 100644 --- a/Userland/Libraries/LibCore/ArgsParser.h +++ b/Userland/Libraries/LibCore/ArgsParser.h @@ -6,8 +6,8 @@ #pragma once +#include #include -#include #include #include #include @@ -54,11 +54,11 @@ public: Function(StringView)> accept_value; OptionHideMode hide_mode { OptionHideMode::None }; - DeprecatedString name_for_display() const + ByteString name_for_display() const { if (long_name) - return DeprecatedString::formatted("--{}", long_name); - return DeprecatedString::formatted("-{:c}", short_name); + return ByteString::formatted("--{}", long_name); + return ByteString::formatted("-{:c}", short_name); } }; @@ -101,7 +101,7 @@ public: }, .hide_mode = hide_mode }); } - void add_option(DeprecatedString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None); + void add_option(ByteString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None); void add_option(String& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None); void add_option(StringView& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None); template @@ -112,16 +112,16 @@ public: void add_option(Vector& values, char const* help_string, char const* long_name, char short_name, char const* value_name, char separator = ',', OptionHideMode hide_mode = OptionHideMode::None); // Note: This option is being used when we expect the user to use the same option // multiple times (e.g. "program --option=example --option=anotherexample ..."). - void add_option(Vector& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None); + void add_option(Vector& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None); void add_positional_argument(Arg&&); - void add_positional_argument(DeprecatedString& value, char const* help_string, char const* name, Required required = Required::Yes); + void add_positional_argument(ByteString& value, char const* help_string, char const* name, Required required = Required::Yes); void add_positional_argument(StringView& value, char const* help_string, char const* name, Required required = Required::Yes); void add_positional_argument(String& value, char const* help_string, char const* name, Required required = Required::Yes); template void add_positional_argument(I& value, char const* help_string, char const* name, Required required = Required::Yes); void add_positional_argument(double& value, char const* help_string, char const* name, Required required = Required::Yes); - void add_positional_argument(Vector& value, char const* help_string, char const* name, Required required = Required::Yes); + void add_positional_argument(Vector& value, char const* help_string, char const* name, Required required = Required::Yes); void add_positional_argument(Vector& value, char const* help_string, char const* name, Required required = Required::Yes); void add_positional_argument(Vector& value, char const* help_string, char const* name, Required required = Required::Yes); diff --git a/Userland/Libraries/LibCore/Command.cpp b/Userland/Libraries/LibCore/Command.cpp index 2e6420c595e..86505babd51 100644 --- a/Userland/Libraries/LibCore/Command.cpp +++ b/Userland/Libraries/LibCore/Command.cpp @@ -63,7 +63,7 @@ ErrorOr Command::write(StringView input) return {}; } -ErrorOr Command::write_lines(Span lines) +ErrorOr Command::write_lines(Span lines) { // It's possible the process dies before we can write everything to the // stdin. So make sure that we don't crash but just stop writing. @@ -83,8 +83,8 @@ ErrorOr Command::write_lines(Span lines) perror("sigaction"); }); - for (DeprecatedString const& line : lines) - TRY(m_stdin->write_until_depleted(DeprecatedString::formatted("{}\n", line).bytes())); + for (ByteString const& line : lines) + TRY(m_stdin->write_until_depleted(ByteString::formatted("{}\n", line).bytes())); return {}; } @@ -120,7 +120,7 @@ ErrorOr Command::status(int options) // Only supported in serenity mode because we use `posix_spawn_file_actions_addchdir` #ifdef AK_OS_SERENITY -ErrorOr command(DeprecatedString const& command_string, Optional chdir) +ErrorOr command(ByteString const& command_string, Optional chdir) { auto parts = command_string.split(' '); if (parts.is_empty()) @@ -130,7 +130,7 @@ ErrorOr command(DeprecatedString const& command_string, Optional< return command(program, parts, chdir); } -ErrorOr command(DeprecatedString const& program, Vector const& arguments, Optional chdir) +ErrorOr command(ByteString const& program, Vector const& arguments, Optional chdir) { int stdout_pipe[2] = {}; int stderr_pipe[2] = {}; diff --git a/Userland/Libraries/LibCore/Command.h b/Userland/Libraries/LibCore/Command.h index 88ba2d43791..e136310aa44 100644 --- a/Userland/Libraries/LibCore/Command.h +++ b/Userland/Libraries/LibCore/Command.h @@ -25,8 +25,8 @@ struct CommandResult { ByteBuffer error; }; -ErrorOr command(DeprecatedString const& program, Vector const& arguments, Optional chdir); -ErrorOr command(DeprecatedString const& command_string, Optional chdir); +ErrorOr command(ByteString const& program, Vector const& arguments, Optional chdir); +ErrorOr command(ByteString const& command_string, Optional chdir); class Command { public: @@ -41,7 +41,7 @@ public: ErrorOr write(StringView input); - ErrorOr write_lines(Span lines); + ErrorOr write_lines(Span lines); ErrorOr read_all(); diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp index 8e392898bae..6951cbf6939 100644 --- a/Userland/Libraries/LibCore/ConfigFile.cpp +++ b/Userland/Libraries/LibCore/ConfigFile.cpp @@ -17,28 +17,28 @@ namespace Core { -ErrorOr> ConfigFile::open_for_lib(DeprecatedString const& lib_name, AllowWriting allow_altering) +ErrorOr> ConfigFile::open_for_lib(ByteString const& lib_name, AllowWriting allow_altering) { - DeprecatedString directory_name = DeprecatedString::formatted("{}/lib", StandardPaths::config_directory()); + ByteString directory_name = ByteString::formatted("{}/lib", StandardPaths::config_directory()); auto directory = TRY(Directory::create(directory_name, Directory::CreateDirectories::Yes)); - auto path = DeprecatedString::formatted("{}/{}.ini", directory, lib_name); + auto path = ByteString::formatted("{}/{}.ini", directory, lib_name); return ConfigFile::open(path, allow_altering); } -ErrorOr> ConfigFile::open_for_app(DeprecatedString const& app_name, AllowWriting allow_altering) +ErrorOr> ConfigFile::open_for_app(ByteString const& app_name, AllowWriting allow_altering) { auto directory = TRY(Directory::create(StandardPaths::config_directory(), Directory::CreateDirectories::Yes)); - auto path = DeprecatedString::formatted("{}/{}.ini", directory, app_name); + auto path = ByteString::formatted("{}/{}.ini", directory, app_name); return ConfigFile::open(path, allow_altering); } -ErrorOr> ConfigFile::open_for_system(DeprecatedString const& app_name, AllowWriting allow_altering) +ErrorOr> ConfigFile::open_for_system(ByteString const& app_name, AllowWriting allow_altering) { - auto path = DeprecatedString::formatted("/etc/{}.ini", app_name); + auto path = ByteString::formatted("/etc/{}.ini", app_name); return ConfigFile::open(path, allow_altering); } -ErrorOr> ConfigFile::open(DeprecatedString const& filename, AllowWriting allow_altering) +ErrorOr> ConfigFile::open(ByteString const& filename, AllowWriting allow_altering) { auto maybe_file = File::open(filename, allow_altering == AllowWriting::Yes ? File::OpenMode::ReadWrite : File::OpenMode::Read); OwnPtr buffered_file; @@ -57,13 +57,13 @@ ErrorOr> ConfigFile::open(DeprecatedString const& file return config_file; } -ErrorOr> ConfigFile::open(DeprecatedString const& filename, int fd) +ErrorOr> ConfigFile::open(ByteString const& filename, int fd) { auto file = TRY(File::adopt_fd(fd, File::OpenMode::ReadWrite)); return open(filename, move(file)); } -ErrorOr> ConfigFile::open(DeprecatedString const& filename, NonnullOwnPtr file) +ErrorOr> ConfigFile::open(ByteString const& filename, NonnullOwnPtr file) { auto buffered_file = TRY(InputBufferedFile::create(move(file))); @@ -72,7 +72,7 @@ ErrorOr> ConfigFile::open(DeprecatedString const& file return config_file; } -ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr open_file) +ConfigFile::ConfigFile(ByteString const& filename, OwnPtr open_file) : m_filename(filename) , m_file(move(open_file)) { @@ -89,7 +89,7 @@ ErrorOr ConfigFile::reparse() if (!m_file) return {}; - HashMap* current_group = nullptr; + HashMap* current_group = nullptr; auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); while (TRY(m_file->can_read_line())) { @@ -113,7 +113,7 @@ ErrorOr ConfigFile::reparse() builder.append(line[i]); ++i; } - current_group = &m_groups.ensure(builder.to_deprecated_string()); + current_group = &m_groups.ensure(builder.to_byte_string()); break; } default: { // Start of key @@ -132,15 +132,15 @@ ErrorOr ConfigFile::reparse() // We're not in a group yet, create one with the name ""... current_group = &m_groups.ensure(""); } - auto value_string = value_builder.to_deprecated_string(); - current_group->set(key_builder.to_deprecated_string(), value_string.trim_whitespace(TrimMode::Right)); + auto value_string = value_builder.to_byte_string(); + current_group->set(key_builder.to_byte_string(), value_string.trim_whitespace(TrimMode::Right)); } } } return {}; } -Optional ConfigFile::read_entry_optional(const AK::DeprecatedString& group, const AK::DeprecatedString& key) const +Optional ConfigFile::read_entry_optional(const AK::ByteString& group, const AK::ByteString& key) const { if (!has_key(group, key)) return {}; @@ -149,19 +149,19 @@ Optional ConfigFile::read_entry_optional(const AK::DeprecatedS return jt->value; } -bool ConfigFile::read_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool default_value) const +bool ConfigFile::read_bool_entry(ByteString const& group, ByteString const& key, bool default_value) const { auto value = read_entry(group, key, default_value ? "true" : "false"); return value == "1" || value.equals_ignoring_ascii_case("true"sv); } -void ConfigFile::write_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) +void ConfigFile::write_entry(ByteString const& group, ByteString const& key, ByteString const& value) { m_groups.ensure(group).ensure(key) = value; m_dirty = true; } -void ConfigFile::write_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool value) +void ConfigFile::write_bool_entry(ByteString const& group, ByteString const& key, bool value) { write_entry(group, key, value ? "true" : "false"); } @@ -178,9 +178,9 @@ ErrorOr ConfigFile::sync() TRY(m_file->seek(0, SeekMode::SetPosition)); for (auto& it : m_groups) { - TRY(m_file->write_until_depleted(DeprecatedString::formatted("[{}]\n", it.key).bytes())); + TRY(m_file->write_until_depleted(ByteString::formatted("[{}]\n", it.key).bytes())); for (auto& jt : it.value) - TRY(m_file->write_until_depleted(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes())); + TRY(m_file->write_until_depleted(ByteString::formatted("{}={}\n", jt.key, jt.value).bytes())); TRY(m_file->write_until_depleted("\n"sv.bytes())); } @@ -198,12 +198,12 @@ void ConfigFile::dump() const } } -Vector ConfigFile::groups() const +Vector ConfigFile::groups() const { return m_groups.keys(); } -Vector ConfigFile::keys(DeprecatedString const& group) const +Vector ConfigFile::keys(ByteString const& group) const { auto it = m_groups.find(group); if (it == m_groups.end()) @@ -211,7 +211,7 @@ Vector ConfigFile::keys(DeprecatedString const& group) const return it->value.keys(); } -bool ConfigFile::has_key(DeprecatedString const& group, DeprecatedString const& key) const +bool ConfigFile::has_key(ByteString const& group, ByteString const& key) const { auto it = m_groups.find(group); if (it == m_groups.end()) @@ -219,24 +219,24 @@ bool ConfigFile::has_key(DeprecatedString const& group, DeprecatedString const& return it->value.contains(key); } -bool ConfigFile::has_group(DeprecatedString const& group) const +bool ConfigFile::has_group(ByteString const& group) const { return m_groups.contains(group); } -void ConfigFile::add_group(DeprecatedString const& group) +void ConfigFile::add_group(ByteString const& group) { m_groups.ensure(group); m_dirty = true; } -void ConfigFile::remove_group(DeprecatedString const& group) +void ConfigFile::remove_group(ByteString const& group) { m_groups.remove(group); m_dirty = true; } -void ConfigFile::remove_entry(DeprecatedString const& group, DeprecatedString const& key) +void ConfigFile::remove_entry(ByteString const& group, ByteString const& key) { auto it = m_groups.find(group); if (it == m_groups.end()) diff --git a/Userland/Libraries/LibCore/ConfigFile.h b/Userland/Libraries/LibCore/ConfigFile.h index b2c7a0e8495..a9f054bc60f 100644 --- a/Userland/Libraries/LibCore/ConfigFile.h +++ b/Userland/Libraries/LibCore/ConfigFile.h @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -26,31 +26,31 @@ public: No, }; - static ErrorOr> open_for_lib(DeprecatedString const& lib_name, AllowWriting = AllowWriting::No); - static ErrorOr> open_for_app(DeprecatedString const& app_name, AllowWriting = AllowWriting::No); - static ErrorOr> open_for_system(DeprecatedString const& app_name, AllowWriting = AllowWriting::No); - static ErrorOr> open(DeprecatedString const& filename, AllowWriting = AllowWriting::No); - static ErrorOr> open(DeprecatedString const& filename, int fd); - static ErrorOr> open(DeprecatedString const& filename, NonnullOwnPtr); + static ErrorOr> open_for_lib(ByteString const& lib_name, AllowWriting = AllowWriting::No); + static ErrorOr> open_for_app(ByteString const& app_name, AllowWriting = AllowWriting::No); + static ErrorOr> open_for_system(ByteString const& app_name, AllowWriting = AllowWriting::No); + static ErrorOr> open(ByteString const& filename, AllowWriting = AllowWriting::No); + static ErrorOr> open(ByteString const& filename, int fd); + static ErrorOr> open(ByteString const& filename, NonnullOwnPtr); ~ConfigFile(); - bool has_group(DeprecatedString const&) const; - bool has_key(DeprecatedString const& group, DeprecatedString const& key) const; + bool has_group(ByteString const&) const; + bool has_key(ByteString const& group, ByteString const& key) const; - Vector groups() const; - Vector keys(DeprecatedString const& group) const; + Vector groups() const; + Vector keys(ByteString const& group) const; size_t num_groups() const { return m_groups.size(); } - DeprecatedString read_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& default_value = {}) const + ByteString read_entry(ByteString const& group, ByteString const& key, ByteString const& default_value = {}) const { return read_entry_optional(group, key).value_or(default_value); } - Optional read_entry_optional(DeprecatedString const& group, DeprecatedString const& key) const; - bool read_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool default_value = false) const; + Optional read_entry_optional(ByteString const& group, ByteString const& key) const; + bool read_bool_entry(ByteString const& group, ByteString const& key, bool default_value = false) const; template - T read_num_entry(DeprecatedString const& group, DeprecatedString const& key, T default_value = 0) const + T read_num_entry(ByteString const& group, ByteString const& key, T default_value = 0) const { if (!has_key(group, key)) return default_value; @@ -61,13 +61,13 @@ public: return read_entry(group, key, "").to_uint().value_or(default_value); } - void write_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value); - void write_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool value); + void write_entry(ByteString const& group, ByteString const& key, ByteString const& value); + void write_bool_entry(ByteString const& group, ByteString const& key, bool value); template - void write_num_entry(DeprecatedString const& group, DeprecatedString const& key, T value) + void write_num_entry(ByteString const& group, ByteString const& key, T value) { - write_entry(group, key, DeprecatedString::number(value)); + write_entry(group, key, ByteString::number(value)); } void dump() const; @@ -76,20 +76,20 @@ public: ErrorOr sync(); - void add_group(DeprecatedString const& group); - void remove_group(DeprecatedString const& group); - void remove_entry(DeprecatedString const& group, DeprecatedString const& key); + void add_group(ByteString const& group); + void remove_group(ByteString const& group); + void remove_entry(ByteString const& group, ByteString const& key); - DeprecatedString const& filename() const { return m_filename; } + ByteString const& filename() const { return m_filename; } private: - ConfigFile(DeprecatedString const& filename, OwnPtr open_file); + ConfigFile(ByteString const& filename, OwnPtr open_file); ErrorOr reparse(); - DeprecatedString m_filename; + ByteString m_filename; OwnPtr m_file; - HashMap> m_groups; + HashMap> m_groups; bool m_dirty { false }; }; diff --git a/Userland/Libraries/LibCore/DateTime.cpp b/Userland/Libraries/LibCore/DateTime.cpp index 000d684e0d5..14d3f86f9ae 100644 --- a/Userland/Libraries/LibCore/DateTime.cpp +++ b/Userland/Libraries/LibCore/DateTime.cpp @@ -283,9 +283,9 @@ ErrorOr DateTime::to_string(StringView format) const return builder.to_string(); } -DeprecatedString DateTime::to_deprecated_string(StringView format) const +ByteString DateTime::to_byte_string(StringView format) const { - return MUST(to_string(format)).to_deprecated_string(); + return MUST(to_string(format)).to_byte_string(); } Optional DateTime::parse(StringView format, StringView string) diff --git a/Userland/Libraries/LibCore/DateTime.h b/Userland/Libraries/LibCore/DateTime.h index d15dc9f40cf..724d8430afb 100644 --- a/Userland/Libraries/LibCore/DateTime.h +++ b/Userland/Libraries/LibCore/DateTime.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -32,7 +32,7 @@ public: void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0); ErrorOr to_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const; - DeprecatedString to_deprecated_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const; + ByteString to_byte_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const; static DateTime create(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0); static DateTime now(); diff --git a/Userland/Libraries/LibCore/DirIterator.cpp b/Userland/Libraries/LibCore/DirIterator.cpp index 0e5f2c4e13d..1151bf7b71d 100644 --- a/Userland/Libraries/LibCore/DirIterator.cpp +++ b/Userland/Libraries/LibCore/DirIterator.cpp @@ -11,7 +11,7 @@ namespace Core { -DirIterator::DirIterator(DeprecatedString path, Flags flags) +DirIterator::DirIterator(ByteString path, Flags flags) : m_path(move(path)) , m_flags(flags) { @@ -93,7 +93,7 @@ Optional DirIterator::next() return result; } -DeprecatedString DirIterator::next_path() +ByteString DirIterator::next_path() { auto entry = next(); if (entry.has_value()) @@ -101,14 +101,14 @@ DeprecatedString DirIterator::next_path() return ""; } -DeprecatedString DirIterator::next_full_path() +ByteString DirIterator::next_full_path() { StringBuilder builder; builder.append(m_path); if (!m_path.ends_with('/')) builder.append('/'); builder.append(next_path()); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } int DirIterator::fd() const diff --git a/Userland/Libraries/LibCore/DirIterator.h b/Userland/Libraries/LibCore/DirIterator.h index fcdbfbe7741..bf9561e359b 100644 --- a/Userland/Libraries/LibCore/DirIterator.h +++ b/Userland/Libraries/LibCore/DirIterator.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -22,7 +22,7 @@ public: SkipParentAndBaseDir = 0x2, }; - explicit DirIterator(DeprecatedString path, Flags = Flags::NoFlags); + explicit DirIterator(ByteString path, Flags = Flags::NoFlags); ~DirIterator(); DirIterator(DirIterator&&); @@ -32,15 +32,15 @@ public: Error error() const { return Error::copy(m_error.value()); } bool has_next(); Optional next(); - DeprecatedString next_path(); - DeprecatedString next_full_path(); + ByteString next_path(); + ByteString next_full_path(); int fd() const; private: DIR* m_dir = nullptr; Optional m_error; Optional m_next; - DeprecatedString m_path; + ByteString m_path; int m_flags; bool advance_next(); diff --git a/Userland/Libraries/LibCore/Directory.cpp b/Userland/Libraries/LibCore/Directory.cpp index 5509ee59478..482ae4ecce0 100644 --- a/Userland/Libraries/LibCore/Directory.cpp +++ b/Userland/Libraries/LibCore/Directory.cpp @@ -53,7 +53,7 @@ ErrorOr Directory::adopt_fd(int fd, LexicalPath path) return Directory { fd, move(path) }; } -ErrorOr Directory::create(DeprecatedString path, CreateDirectories create_directories, mode_t creation_mode) +ErrorOr Directory::create(ByteString path, CreateDirectories create_directories, mode_t creation_mode) { return create(LexicalPath { move(path) }, create_directories, creation_mode); } diff --git a/Userland/Libraries/LibCore/Directory.h b/Userland/Libraries/LibCore/Directory.h index 44b1048d19a..9f9b401ad93 100644 --- a/Userland/Libraries/LibCore/Directory.h +++ b/Userland/Libraries/LibCore/Directory.h @@ -37,7 +37,7 @@ public: }; static ErrorOr create(LexicalPath path, CreateDirectories, mode_t creation_mode = 0755); - static ErrorOr create(DeprecatedString path, CreateDirectories, mode_t creation_mode = 0755); + static ErrorOr create(ByteString path, CreateDirectories, mode_t creation_mode = 0755); static ErrorOr adopt_fd(int fd, LexicalPath path); ErrorOr> open(StringView filename, File::OpenMode mode) const; diff --git a/Userland/Libraries/LibCore/DirectoryEntry.h b/Userland/Libraries/LibCore/DirectoryEntry.h index 83eed689586..7244ec83dd2 100644 --- a/Userland/Libraries/LibCore/DirectoryEntry.h +++ b/Userland/Libraries/LibCore/DirectoryEntry.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace Core { @@ -25,7 +25,7 @@ struct DirectoryEntry { }; Type type; // FIXME: Once we have a special Path string class, use that. - DeprecatedString name; + ByteString name; ino_t inode_number; static DirectoryEntry from_dirent(dirent const&); diff --git a/Userland/Libraries/LibCore/EventReceiver.h b/Userland/Libraries/LibCore/EventReceiver.h index 24d9c623fda..f51a788facf 100644 --- a/Userland/Libraries/LibCore/EventReceiver.h +++ b/Userland/Libraries/LibCore/EventReceiver.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -67,8 +67,8 @@ public: virtual bool is_widget() const { return false; } - DeprecatedString const& name() const { return m_name; } - void set_name(DeprecatedString name) { m_name = move(name); } + ByteString const& name() const { return m_name; } + void set_name(ByteString name) { m_name = move(name); } Vector>& children() { return m_children; } Vector> const& children() const { return m_children; } @@ -168,7 +168,7 @@ protected: private: EventReceiver* m_parent { nullptr }; - DeprecatedString m_name; + ByteString m_name; int m_timer_id { 0 }; Vector> m_children; Function m_event_filter; diff --git a/Userland/Libraries/LibCore/FileWatcher.h b/Userland/Libraries/LibCore/FileWatcher.h index 694e9f485bd..42bb783131f 100644 --- a/Userland/Libraries/LibCore/FileWatcher.h +++ b/Userland/Libraries/LibCore/FileWatcher.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -27,7 +27,7 @@ struct FileWatcherEvent { ChildDeleted = 1 << 4, }; Type type { Type::Invalid }; - DeprecatedString event_path; + ByteString event_path; }; AK_ENUM_BITWISE_OPERATORS(FileWatcherEvent::Type); @@ -44,9 +44,9 @@ class FileWatcherBase { public: virtual ~FileWatcherBase() = default; - ErrorOr add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask); - ErrorOr remove_watch(DeprecatedString path); - bool is_watching(DeprecatedString const& path) const { return m_path_to_wd.find(path) != m_path_to_wd.end(); } + ErrorOr add_watch(ByteString path, FileWatcherEvent::Type event_mask); + ErrorOr remove_watch(ByteString path); + bool is_watching(ByteString const& path) const { return m_path_to_wd.find(path) != m_path_to_wd.end(); } protected: FileWatcherBase(int watcher_fd) @@ -55,8 +55,8 @@ protected: } int m_watcher_fd { -1 }; - HashMap m_path_to_wd; - HashMap m_wd_to_path; + HashMap m_path_to_wd; + HashMap m_wd_to_path; }; class BlockingFileWatcher final : public FileWatcherBase { diff --git a/Userland/Libraries/LibCore/FileWatcherLinux.cpp b/Userland/Libraries/LibCore/FileWatcherLinux.cpp index 4c0ccdc969d..69f8d5e1c88 100644 --- a/Userland/Libraries/LibCore/FileWatcherLinux.cpp +++ b/Userland/Libraries/LibCore/FileWatcherLinux.cpp @@ -5,8 +5,8 @@ */ #include "FileWatcher.h" +#include #include -#include #include #include #include @@ -34,7 +34,7 @@ static constexpr unsigned file_watcher_flags_to_inotify_flags(FileWatcherFlags f return result; } -static Optional get_event_from_fd(int fd, HashMap const& wd_to_path) +static Optional get_event_from_fd(int fd, HashMap const& wd_to_path) { static constexpr auto max_event_size = sizeof(inotify_event) + NAME_MAX + 1; @@ -123,7 +123,7 @@ FileWatcher::FileWatcher(int watcher_fd, NonnullRefPtr notifier) FileWatcher::~FileWatcher() = default; -ErrorOr FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask) +ErrorOr FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask) { if (m_path_to_wd.find(path) != m_path_to_wd.end()) { dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' is already being watched", path); @@ -154,7 +154,7 @@ ErrorOr FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent return true; } -ErrorOr FileWatcherBase::remove_watch(DeprecatedString path) +ErrorOr FileWatcherBase::remove_watch(ByteString path) { auto it = m_path_to_wd.find(path); if (it == m_path_to_wd.end()) { diff --git a/Userland/Libraries/LibCore/FileWatcherMacOS.mm b/Userland/Libraries/LibCore/FileWatcherMacOS.mm index 4b718c65f9c..fcebf99335d 100644 --- a/Userland/Libraries/LibCore/FileWatcherMacOS.mm +++ b/Userland/Libraries/LibCore/FileWatcherMacOS.mm @@ -29,7 +29,7 @@ static_assert(false, "This file must only be used for macOS"); namespace Core { struct MonitoredPath { - DeprecatedString path; + ByteString path; FileWatcherEvent::Type event_mask { FileWatcherEvent::Type::Invalid }; }; @@ -55,7 +55,7 @@ public: { auto context = TRY(try_make()); - auto queue_name = DeprecatedString::formatted("Serenity.FileWatcher.{:p}", context.ptr()); + auto queue_name = ByteString::formatted("Serenity.FileWatcher.{:p}", context.ptr()); auto dispatch_queue = dispatch_queue_create(queue_name.characters(), DISPATCH_QUEUE_SERIAL); if (dispatch_queue == nullptr) return Error::from_errno(errno); @@ -67,7 +67,7 @@ public: return adopt_nonnull_ref_or_enomem(new (nothrow) FileWatcherMacOS(move(context), dispatch_queue, move(notifier))); } - ErrorOr add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask) + ErrorOr add_watch(ByteString path, FileWatcherEvent::Type event_mask) { if (m_path_to_inode_id.contains(path)) { dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' is already being watched", path); @@ -84,7 +84,7 @@ public: return true; } - ErrorOr remove_watch(DeprecatedString path) + ErrorOr remove_watch(ByteString path) { auto it = m_path_to_inode_id.find(path); if (it == m_path_to_inode_id.end()) { @@ -101,7 +101,7 @@ public: return true; } - ErrorOr canonicalize_path(DeprecatedString path) + ErrorOr canonicalize_path(ByteString path) { LexicalPath lexical_path { move(path) }; auto parent_path = lexical_path.parent(); @@ -200,7 +200,7 @@ private: dispatch_queue_t m_dispatch_queue { nullptr }; FSEventStreamRef m_stream { nullptr }; - HashMap m_path_to_inode_id; + HashMap m_path_to_inode_id; HashMap m_inode_id_to_path; }; @@ -219,7 +219,7 @@ void on_file_system_event(ConstFSEventStreamRef, void* user_data, size_t event_s continue; } - auto maybe_monitored_path = file_watcher.canonicalize_path(DeprecatedString { file_path_buffer }); + auto maybe_monitored_path = file_watcher.canonicalize_path(ByteString { file_path_buffer }); if (maybe_monitored_path.is_error()) { dbgln_if(FILE_WATCHER_DEBUG, "Could not canonicalize path {}: {}", file_path_buffer, maybe_monitored_path.error()); continue; @@ -265,13 +265,13 @@ FileWatcher::FileWatcher(int watcher_fd, NonnullRefPtr notifier) FileWatcher::~FileWatcher() = default; -ErrorOr FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask) +ErrorOr FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask) { auto& file_watcher = verify_cast(*this); return file_watcher.add_watch(move(path), event_mask); } -ErrorOr FileWatcherBase::remove_watch(DeprecatedString path) +ErrorOr FileWatcherBase::remove_watch(ByteString path) { auto& file_watcher = verify_cast(*this); return file_watcher.remove_watch(move(path)); diff --git a/Userland/Libraries/LibCore/FileWatcherSerenity.cpp b/Userland/Libraries/LibCore/FileWatcherSerenity.cpp index 946826981e9..4e347bd334b 100644 --- a/Userland/Libraries/LibCore/FileWatcherSerenity.cpp +++ b/Userland/Libraries/LibCore/FileWatcherSerenity.cpp @@ -6,8 +6,8 @@ */ #include "FileWatcher.h" +#include #include -#include #include #include #include @@ -36,7 +36,7 @@ static constexpr unsigned file_watcher_flags_to_inode_watcher_flags(FileWatcherF return static_cast(result); } -static Optional get_event_from_fd(int fd, HashMap const& wd_to_path) +static Optional get_event_from_fd(int fd, HashMap const& wd_to_path) { u8 buffer[MAXIMUM_EVENT_SIZE]; int rc = read(fd, &buffer, MAXIMUM_EVENT_SIZE); @@ -55,7 +55,7 @@ static Optional get_event_from_fd(int fd, HashMapwatch_descriptor); return {}; } - DeprecatedString const& path = it->value; + ByteString const& path = it->value; switch (event->type) { case InodeWatcherEvent::Type::ChildCreated: @@ -80,7 +80,7 @@ static Optional get_event_from_fd(int fd, HashMapname_length > 0) { - DeprecatedString child_name { event->name, event->name_length - 1 }; + ByteString child_name { event->name, event->name_length - 1 }; result.event_path = LexicalPath::join(path, child_name).string(); } else { result.event_path = path; @@ -90,7 +90,7 @@ static Optional get_event_from_fd(int fd, HashMap FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask) +ErrorOr FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask) { - DeprecatedString canonical_path = canonicalize_path(move(path)); + ByteString canonical_path = canonicalize_path(move(path)); if (m_path_to_wd.find(canonical_path) != m_path_to_wd.end()) { dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' is already being watched", canonical_path); @@ -131,9 +131,9 @@ ErrorOr FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent return true; } -ErrorOr FileWatcherBase::remove_watch(DeprecatedString path) +ErrorOr FileWatcherBase::remove_watch(ByteString path) { - DeprecatedString canonical_path = canonicalize_path(move(path)); + ByteString canonical_path = canonicalize_path(move(path)); auto it = m_path_to_wd.find(canonical_path); if (it == m_path_to_wd.end()) { diff --git a/Userland/Libraries/LibCore/FileWatcherUnimplemented.cpp b/Userland/Libraries/LibCore/FileWatcherUnimplemented.cpp index 2e12ac688f0..81a33e26d88 100644 --- a/Userland/Libraries/LibCore/FileWatcherUnimplemented.cpp +++ b/Userland/Libraries/LibCore/FileWatcherUnimplemented.cpp @@ -24,12 +24,12 @@ FileWatcher::FileWatcher(int watcher_fd, NonnullRefPtr notifier) FileWatcher::~FileWatcher() = default; -ErrorOr FileWatcherBase::add_watch(DeprecatedString, FileWatcherEvent::Type) +ErrorOr FileWatcherBase::add_watch(ByteString, FileWatcherEvent::Type) { return Error::from_errno(ENOTSUP); } -ErrorOr FileWatcherBase::remove_watch(DeprecatedString) +ErrorOr FileWatcherBase::remove_watch(ByteString) { return Error::from_errno(ENOTSUP); } diff --git a/Userland/Libraries/LibCore/Group.cpp b/Userland/Libraries/LibCore/Group.cpp index bc60a08caf2..7f1c07722a3 100644 --- a/Userland/Libraries/LibCore/Group.cpp +++ b/Userland/Libraries/LibCore/Group.cpp @@ -15,7 +15,7 @@ namespace Core { -ErrorOr Group::generate_group_file() const +ErrorOr Group::generate_group_file() const { StringBuilder builder; char buffer[1024] = { 0 }; @@ -29,19 +29,19 @@ ErrorOr Group::generate_group_file() const break; if (group->gr_name == m_name) - builder.appendff("{}:x:{}:{}\n", m_name, m_id, DeprecatedString::join(',', m_members)); + builder.appendff("{}:x:{}:{}\n", m_name, m_id, ByteString::join(',', m_members)); else { - Vector members; + Vector members; if (group->gr_mem) { for (size_t i = 0; group->gr_mem[i]; ++i) members.append(group->gr_mem[i]); } - builder.appendff("{}:x:{}:{}\n", group->gr_name, group->gr_gid, DeprecatedString::join(',', members)); + builder.appendff("{}:x:{}:{}\n", group->gr_name, group->gr_gid, ByteString::join(',', members)); } } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } ErrorOr Group::sync() @@ -74,7 +74,7 @@ ErrorOr Group::add_group(Group& group) return Error::from_string_literal("Group name can not be empty."); // A quick sanity check on group name - if (group.name().find_any_of("\\/!@#$%^&*()~+=`:\n"sv, DeprecatedString::SearchDirection::Forward).has_value()) + if (group.name().find_any_of("\\/!@#$%^&*()~+=`:\n"sv, ByteString::SearchDirection::Forward).has_value()) return Error::from_string_literal("Group name has invalid characters."); // Disallow names starting with '_', '-' or other non-alpha characters. @@ -129,7 +129,7 @@ ErrorOr> Group::all() if (!group.has_value()) break; - Vector members; + Vector members; if (group->gr_mem) { for (size_t i = 0; group->gr_mem[i]; ++i) members.append(group->gr_mem[i]); @@ -141,7 +141,7 @@ ErrorOr> Group::all() return groups; } -Group::Group(DeprecatedString name, gid_t id, Vector members) +Group::Group(ByteString name, gid_t id, Vector members) : m_name(move(name)) , m_id(id) , m_members(move(members)) diff --git a/Userland/Libraries/LibCore/Group.h b/Userland/Libraries/LibCore/Group.h index 53d3617d191..3a985247a4b 100644 --- a/Userland/Libraries/LibCore/Group.h +++ b/Userland/Libraries/LibCore/Group.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -22,17 +22,17 @@ public: static ErrorOr> all(); Group() = default; - Group(DeprecatedString name, gid_t id = 0, Vector members = {}); + Group(ByteString name, gid_t id = 0, Vector members = {}); ~Group() = default; - DeprecatedString const& name() const { return m_name; } - void set_name(DeprecatedString const& name) { m_name = name; } + ByteString const& name() const { return m_name; } + void set_name(ByteString const& name) { m_name = name; } gid_t id() const { return m_id; } void set_group_id(gid_t const id) { m_id = id; } - Vector& members() { return m_members; } + Vector& members() { return m_members; } ErrorOr sync(); @@ -41,11 +41,11 @@ private: static ErrorOr id_exists(gid_t id); ErrorOr to_libc_group(); - ErrorOr generate_group_file() const; + ErrorOr generate_group_file() const; - DeprecatedString m_name; + ByteString m_name; gid_t m_id { 0 }; - Vector m_members; + Vector m_members; }; } diff --git a/Userland/Libraries/LibCore/LocalServer.cpp b/Userland/Libraries/LibCore/LocalServer.cpp index 6051526213e..a96c6043db8 100644 --- a/Userland/Libraries/LibCore/LocalServer.cpp +++ b/Userland/Libraries/LibCore/LocalServer.cpp @@ -33,7 +33,7 @@ LocalServer::~LocalServer() ::close(m_fd); } -ErrorOr LocalServer::take_over_from_system_server(DeprecatedString const& socket_path) +ErrorOr LocalServer::take_over_from_system_server(ByteString const& socket_path) { if (m_listening) return Error::from_string_literal("Core::LocalServer: Can't perform socket takeover when already listening"); @@ -65,7 +65,7 @@ void LocalServer::setup_notifier() }; } -bool LocalServer::listen(DeprecatedString const& address) +bool LocalServer::listen(ByteString const& address) { if (m_listening) return false; diff --git a/Userland/Libraries/LibCore/LocalServer.h b/Userland/Libraries/LibCore/LocalServer.h index d2a9e8b4862..cdccfcb6eb4 100644 --- a/Userland/Libraries/LibCore/LocalServer.h +++ b/Userland/Libraries/LibCore/LocalServer.h @@ -16,9 +16,9 @@ class LocalServer : public EventReceiver { public: virtual ~LocalServer() override; - ErrorOr take_over_from_system_server(DeprecatedString const& path = DeprecatedString()); + ErrorOr take_over_from_system_server(ByteString const& path = ByteString()); bool is_listening() const { return m_listening; } - bool listen(DeprecatedString const& address); + bool listen(ByteString const& address); ErrorOr> accept(); diff --git a/Userland/Libraries/LibCore/MimeData.cpp b/Userland/Libraries/LibCore/MimeData.cpp index 9a68f9f39ce..716046bc20b 100644 --- a/Userland/Libraries/LibCore/MimeData.cpp +++ b/Userland/Libraries/LibCore/MimeData.cpp @@ -27,7 +27,7 @@ ErrorOr MimeData::set_urls(Vector const& urls) { StringBuilder builder; for (auto& url : urls) { - TRY(builder.try_append(url.to_deprecated_string())); + TRY(builder.try_append(url.to_byte_string())); TRY(builder.try_append('\n')); } set_data("text/uri-list"_string, TRY(builder.to_byte_buffer())); @@ -35,12 +35,12 @@ ErrorOr MimeData::set_urls(Vector const& urls) return {}; } -DeprecatedString MimeData::text() const +ByteString MimeData::text() const { - return DeprecatedString::copy(m_data.get("text/plain"sv).value_or({})); + return ByteString::copy(m_data.get("text/plain"sv).value_or({})); } -void MimeData::set_text(DeprecatedString const& text) +void MimeData::set_text(ByteString const& text) { set_data("text/plain"_string, text.to_byte_buffer()); } diff --git a/Userland/Libraries/LibCore/MimeData.h b/Userland/Libraries/LibCore/MimeData.h index 64b24df8533..ee70e506b51 100644 --- a/Userland/Libraries/LibCore/MimeData.h +++ b/Userland/Libraries/LibCore/MimeData.h @@ -28,8 +28,8 @@ public: // Convenience helpers for "text/plain" bool has_text() const { return has_format("text/plain"sv); } - DeprecatedString text() const; - void set_text(DeprecatedString const&); + ByteString text() const; + void set_text(ByteString const&); // Convenience helpers for "text/uri-list" bool has_urls() const { return has_format("text/uri-list"sv); } diff --git a/Userland/Libraries/LibCore/NetworkJob.h b/Userland/Libraries/LibCore/NetworkJob.h index 3e790a098e4..dad0f5a5390 100644 --- a/Userland/Libraries/LibCore/NetworkJob.h +++ b/Userland/Libraries/LibCore/NetworkJob.h @@ -27,7 +27,7 @@ public: virtual ~NetworkJob() override = default; // Could fire twice, after Headers and after Trailers! - Function const& response_headers, Optional response_code)> on_headers_received; + Function const& response_headers, Optional response_code)> on_headers_received; Function on_finish; Function, u64)> on_progress; diff --git a/Userland/Libraries/LibCore/Process.cpp b/Userland/Libraries/LibCore/Process.cpp index f4ea72ec000..b7912ecd4ca 100644 --- a/Userland/Libraries/LibCore/Process.cpp +++ b/Userland/Libraries/LibCore/Process.cpp @@ -6,7 +6,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -35,10 +35,10 @@ extern "C" { namespace Core { struct ArgvList { - DeprecatedString m_path; + ByteString m_path; Vector m_argv; - ArgvList(DeprecatedString path, size_t size) + ArgvList(ByteString path, size_t size) : m_path { path } { m_argv.ensure_capacity(size + 2); @@ -103,12 +103,12 @@ ErrorOr Process::spawn(ProcessSpawnOptions const& options) return Process { pid }; } -ErrorOr Process::spawn(StringView path, ReadonlySpan arguments, DeprecatedString working_directory, KeepAsChild keep_as_child) +ErrorOr Process::spawn(StringView path, ReadonlySpan arguments, ByteString working_directory, KeepAsChild keep_as_child) { auto process = TRY(spawn({ .path = path, - .arguments = Vector { arguments }, - .working_directory = working_directory.is_empty() ? Optional {} : Optional { working_directory }, + .arguments = Vector { arguments }, + .working_directory = working_directory.is_empty() ? Optional {} : Optional { working_directory }, })); if (keep_as_child == KeepAsChild::No) @@ -120,9 +120,9 @@ ErrorOr Process::spawn(StringView path, ReadonlySpan ar return process.pid(); } -ErrorOr Process::spawn(StringView path, ReadonlySpan arguments, DeprecatedString working_directory, KeepAsChild keep_as_child) +ErrorOr Process::spawn(StringView path, ReadonlySpan arguments, ByteString working_directory, KeepAsChild keep_as_child) { - Vector backing_strings; + Vector backing_strings; backing_strings.ensure_capacity(arguments.size()); for (auto const& argument : arguments) backing_strings.append(argument); @@ -130,7 +130,7 @@ ErrorOr Process::spawn(StringView path, ReadonlySpan argument auto process = TRY(spawn({ .path = path, .arguments = backing_strings, - .working_directory = working_directory.is_empty() ? Optional {} : Optional { working_directory }, + .working_directory = working_directory.is_empty() ? Optional {} : Optional { working_directory }, })); if (keep_as_child == KeepAsChild::No) @@ -140,9 +140,9 @@ ErrorOr Process::spawn(StringView path, ReadonlySpan argument return process.pid(); } -ErrorOr Process::spawn(StringView path, ReadonlySpan arguments, DeprecatedString working_directory, KeepAsChild keep_as_child) +ErrorOr Process::spawn(StringView path, ReadonlySpan arguments, ByteString working_directory, KeepAsChild keep_as_child) { - Vector backing_strings; + Vector backing_strings; backing_strings.ensure_capacity(arguments.size()); for (auto const& argument : arguments) backing_strings.append(argument); @@ -150,7 +150,7 @@ ErrorOr Process::spawn(StringView path, ReadonlySpan argumen auto process = TRY(spawn({ .path = path, .arguments = backing_strings, - .working_directory = working_directory.is_empty() ? Optional {} : Optional { working_directory }, + .working_directory = working_directory.is_empty() ? Optional {} : Optional { working_directory }, })); if (keep_as_child == KeepAsChild::No) diff --git a/Userland/Libraries/LibCore/Process.h b/Userland/Libraries/LibCore/Process.h index 36db835d1fc..d50fb856d48 100644 --- a/Userland/Libraries/LibCore/Process.h +++ b/Userland/Libraries/LibCore/Process.h @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -18,7 +18,7 @@ namespace Core { namespace FileAction { struct OpenFile { - DeprecatedString path; + ByteString path; File::OpenMode mode = File::OpenMode::NotOpen; int fd = -1; mode_t permissions = 0600; @@ -29,9 +29,9 @@ struct OpenFile { } struct ProcessSpawnOptions { - DeprecatedString path; - Vector const& arguments = {}; - Optional working_directory = {}; + ByteString path; + Vector const& arguments = {}; + Optional working_directory = {}; Vector> const& file_actions = {}; }; @@ -60,11 +60,11 @@ public: static ErrorOr spawn(ProcessSpawnOptions const& options); // FIXME: Make the following 2 functions return Process instance or delete them. - static ErrorOr spawn(StringView path, ReadonlySpan arguments, DeprecatedString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No); - static ErrorOr spawn(StringView path, ReadonlySpan arguments, DeprecatedString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No); + static ErrorOr spawn(StringView path, ReadonlySpan arguments, ByteString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No); + static ErrorOr spawn(StringView path, ReadonlySpan arguments, ByteString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No); // FIXME: Remove this. char const* should not exist on this level of abstraction. - static ErrorOr spawn(StringView path, ReadonlySpan arguments = {}, DeprecatedString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No); + static ErrorOr spawn(StringView path, ReadonlySpan arguments = {}, ByteString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No); static ErrorOr get_name(); enum class SetThreadName { diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp index 43e8d3bab2b..de66ac1f006 100644 --- a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp +++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp @@ -14,7 +14,7 @@ namespace Core { -HashMap ProcessStatisticsReader::s_usernames; +HashMap ProcessStatisticsReader::s_usernames; ErrorOr ProcessStatisticsReader::get_all(SeekableStream& proc_all_file, bool include_usernames) { @@ -37,11 +37,11 @@ ErrorOr ProcessStatisticsReader::get_all(SeekableStream& process.gid = process_object.get_u32("gid"sv).value_or(0); process.ppid = process_object.get_u32("ppid"sv).value_or(0); process.kernel = process_object.get_bool("kernel"sv).value_or(false); - process.name = process_object.get_deprecated_string("name"sv).value_or(""); - process.executable = process_object.get_deprecated_string("executable"sv).value_or(""); - process.tty = process_object.get_deprecated_string("tty"sv).value_or(""); - process.pledge = process_object.get_deprecated_string("pledge"sv).value_or(""); - process.veil = process_object.get_deprecated_string("veil"sv).value_or(""); + process.name = process_object.get_byte_string("name"sv).value_or(""); + process.executable = process_object.get_byte_string("executable"sv).value_or(""); + process.tty = process_object.get_byte_string("tty"sv).value_or(""); + process.pledge = process_object.get_byte_string("pledge"sv).value_or(""); + process.veil = process_object.get_byte_string("veil"sv).value_or(""); process.creation_time = UnixDateTime::from_nanoseconds_since_epoch(process_object.get_i64("creation_time"sv).value_or(0)); process.amount_virtual = process_object.get_u32("amount_virtual"sv).value_or(0); process.amount_resident = process_object.get_u32("amount_resident"sv).value_or(0); @@ -58,8 +58,8 @@ ErrorOr ProcessStatisticsReader::get_all(SeekableStream& Core::ThreadStatistics thread; thread.tid = thread_object.get_u32("tid"sv).value_or(0); thread.times_scheduled = thread_object.get_u32("times_scheduled"sv).value_or(0); - thread.name = thread_object.get_deprecated_string("name"sv).value_or(""); - thread.state = thread_object.get_deprecated_string("state"sv).value_or(""); + thread.name = thread_object.get_byte_string("name"sv).value_or(""); + thread.state = thread_object.get_byte_string("state"sv).value_or(""); thread.time_user = thread_object.get_u64("time_user"sv).value_or(0); thread.time_kernel = thread_object.get_u64("time_kernel"sv).value_or(0); thread.cpu = thread_object.get_u32("cpu"sv).value_or(0); @@ -95,7 +95,7 @@ ErrorOr ProcessStatisticsReader::get_all(bool include_us return get_all(*proc_all_file, include_usernames); } -DeprecatedString ProcessStatisticsReader::username_from_uid(uid_t uid) +ByteString ProcessStatisticsReader::username_from_uid(uid_t uid) { if (s_usernames.is_empty()) { setpwent(); @@ -107,6 +107,6 @@ DeprecatedString ProcessStatisticsReader::username_from_uid(uid_t uid) auto it = s_usernames.find(uid); if (it != s_usernames.end()) return (*it).value; - return DeprecatedString::number(uid); + return ByteString::number(uid); } } diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.h b/Userland/Libraries/LibCore/ProcessStatisticsReader.h index ded72705a42..e30c97242f5 100644 --- a/Userland/Libraries/LibCore/ProcessStatisticsReader.h +++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -28,10 +28,10 @@ struct ThreadStatistics { u64 ipv4_socket_write_bytes; u64 file_read_bytes; u64 file_write_bytes; - DeprecatedString state; + ByteString state; u32 cpu; u32 priority; - DeprecatedString name; + ByteString name; }; struct ProcessStatistics { @@ -45,11 +45,11 @@ struct ProcessStatistics { gid_t gid; pid_t ppid; bool kernel; - DeprecatedString name; - DeprecatedString executable; - DeprecatedString tty; - DeprecatedString pledge; - DeprecatedString veil; + ByteString name; + ByteString executable; + ByteString tty; + ByteString pledge; + ByteString veil; UnixDateTime creation_time; size_t amount_virtual; size_t amount_resident; @@ -62,7 +62,7 @@ struct ProcessStatistics { Vector threads; // synthetic - DeprecatedString username; + ByteString username; }; struct AllProcessesStatistics { @@ -77,8 +77,8 @@ public: static ErrorOr get_all(bool include_usernames = true); private: - static DeprecatedString username_from_uid(uid_t); - static HashMap s_usernames; + static ByteString username_from_uid(uid_t); + static HashMap s_usernames; }; } diff --git a/Userland/Libraries/LibCore/ResourceImplementation.cpp b/Userland/Libraries/LibCore/ResourceImplementation.cpp index e1852b3aeea..347d91d5921 100644 --- a/Userland/Libraries/LibCore/ResourceImplementation.cpp +++ b/Userland/Libraries/LibCore/ResourceImplementation.cpp @@ -72,9 +72,9 @@ Vector ResourceImplementation::child_names(Resource const& resource) VERIFY(resource.m_scheme == Resource::Scheme::File); Vector children; - Core::DirIterator it(resource.filesystem_path().to_deprecated_string(), Core::DirIterator::SkipParentAndBaseDir); + Core::DirIterator it(resource.filesystem_path().to_byte_string(), Core::DirIterator::SkipParentAndBaseDir); while (it.has_next()) - children.append(MUST(String::from_deprecated_string(it.next_path()))); + children.append(MUST(String::from_byte_string(it.next_path()))); return children; } diff --git a/Userland/Libraries/LibCore/ResourceImplementationFile.cpp b/Userland/Libraries/LibCore/ResourceImplementationFile.cpp index 894afe81fe1..566b83e3edb 100644 --- a/Userland/Libraries/LibCore/ResourceImplementationFile.cpp +++ b/Userland/Libraries/LibCore/ResourceImplementationFile.cpp @@ -24,7 +24,7 @@ ErrorOr> ResourceImplementationFile::load_from_resource_ VERIFY(uri.starts_with(resource_scheme)); auto path = TRY(String::from_utf8(uri.substring_view(resource_scheme.length()))); - auto full_path = TRY(String::from_deprecated_string(LexicalPath::join(m_base_directory, path).string())); + auto full_path = TRY(String::from_byte_string(LexicalPath::join(m_base_directory, path).string())); if (is_directory(full_path)) return make_directory_resource(move(path)); @@ -34,16 +34,16 @@ ErrorOr> ResourceImplementationFile::load_from_resource_ Vector ResourceImplementationFile::child_names_for_resource_scheme(Resource const& resource) { Vector children; - Core::DirIterator it(resource.filesystem_path().to_deprecated_string(), Core::DirIterator::SkipParentAndBaseDir); + Core::DirIterator it(resource.filesystem_path().to_byte_string(), Core::DirIterator::SkipParentAndBaseDir); while (it.has_next()) - children.append(MUST(String::from_deprecated_string(it.next_path()))); + children.append(MUST(String::from_byte_string(it.next_path()))); return children; } String ResourceImplementationFile::filesystem_path_for_resource_scheme(String const& relative_path) { - return MUST(String::from_deprecated_string(LexicalPath::join(m_base_directory, relative_path).string())); + return MUST(String::from_byte_string(LexicalPath::join(m_base_directory, relative_path).string())); } } diff --git a/Userland/Libraries/LibCore/SOCKSProxyClient.cpp b/Userland/Libraries/LibCore/SOCKSProxyClient.cpp index 199def7297c..db738c47ba4 100644 --- a/Userland/Libraries/LibCore/SOCKSProxyClient.cpp +++ b/Userland/Libraries/LibCore/SOCKSProxyClient.cpp @@ -161,7 +161,7 @@ ErrorOr send_connect_request_message(Core::Socket& socket, Core::SOCKSPro TRY(stream.write_value(header)); TRY(target.visit( - [&](DeprecatedString const& hostname) -> ErrorOr { + [&](ByteString const& hostname) -> ErrorOr { u8 address_data[2]; address_data[0] = to_underlying(AddressType::DomainName); address_data[1] = hostname.length(); @@ -298,7 +298,7 @@ ErrorOr> SOCKSProxyClient::connect(HostOrIPV4 co [&](u32 ipv4) { return Core::TCPSocket::connect({ IPv4Address(ipv4), static_cast(server_port) }); }, - [&](DeprecatedString const& hostname) { + [&](ByteString const& hostname) { return Core::TCPSocket::connect(hostname, static_cast(server_port)); })); diff --git a/Userland/Libraries/LibCore/SOCKSProxyClient.h b/Userland/Libraries/LibCore/SOCKSProxyClient.h index 24b47bb606b..cbb816870df 100644 --- a/Userland/Libraries/LibCore/SOCKSProxyClient.h +++ b/Userland/Libraries/LibCore/SOCKSProxyClient.h @@ -19,8 +19,8 @@ public: }; struct UsernamePasswordAuthenticationData { - DeprecatedString username; - DeprecatedString password; + ByteString username; + ByteString password; }; enum class Command : u8 { @@ -29,7 +29,7 @@ public: UDPAssociate = 0x03, }; - using HostOrIPV4 = Variant; + using HostOrIPV4 = Variant; static ErrorOr> connect(Socket& underlying, Version, HostOrIPV4 const& target, int target_port, Variant const& auth_data = {}, Command = Command::Connect); static ErrorOr> connect(HostOrIPV4 const& server, int server_port, Version, HostOrIPV4 const& target, int target_port, Variant const& auth_data = {}, Command = Command::Connect); diff --git a/Userland/Libraries/LibCore/SessionManagement.cpp b/Userland/Libraries/LibCore/SessionManagement.cpp index a12fef8210a..6ec367c3a69 100644 --- a/Userland/Libraries/LibCore/SessionManagement.cpp +++ b/Userland/Libraries/LibCore/SessionManagement.cpp @@ -34,19 +34,19 @@ ErrorOr logout(Optional force_sid) return {}; } -ErrorOr parse_path_with_sid(StringView general_path, Optional force_sid) +ErrorOr parse_path_with_sid(StringView general_path, Optional force_sid) { if (general_path.contains("%sid"sv)) { pid_t sid = TRY(root_session_id(force_sid)); - return general_path.replace("%sid"sv, DeprecatedString::number(sid), ReplaceMode::All); + return general_path.replace("%sid"sv, ByteString::number(sid), ReplaceMode::All); } - return DeprecatedString(general_path); + return ByteString(general_path); } ErrorOr create_session_temporary_directory_if_needed(uid_t uid, gid_t gid, Optional force_sid) { pid_t sid = TRY(root_session_id(force_sid)); - auto const temporary_directory = DeprecatedString::formatted("/tmp/session/{}", sid); + auto const temporary_directory = ByteString::formatted("/tmp/session/{}", sid); auto directory = TRY(Core::Directory::create(temporary_directory, Core::Directory::CreateDirectories::Yes)); TRY(directory.chown(uid, gid)); return {}; diff --git a/Userland/Libraries/LibCore/SessionManagement.h b/Userland/Libraries/LibCore/SessionManagement.h index 29eda5588b3..339280a7bfb 100644 --- a/Userland/Libraries/LibCore/SessionManagement.h +++ b/Userland/Libraries/LibCore/SessionManagement.h @@ -14,7 +14,7 @@ namespace Core::SessionManagement { ErrorOr root_session_id(Optional force_sid = {}); ErrorOr logout(Optional force_sid = {}); -ErrorOr parse_path_with_sid(StringView general_path, Optional force_sid = {}); +ErrorOr parse_path_with_sid(StringView general_path, Optional force_sid = {}); ErrorOr create_session_temporary_directory_if_needed(uid_t uid, gid_t gid, Optional force_sid = {}); } diff --git a/Userland/Libraries/LibCore/SharedCircularQueue.h b/Userland/Libraries/LibCore/SharedCircularQueue.h index b7ba276a394..e35b5fa83a5 100644 --- a/Userland/Libraries/LibCore/SharedCircularQueue.h +++ b/Userland/Libraries/LibCore/SharedCircularQueue.h @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -200,7 +200,7 @@ private: static ErrorOr> create_internal(int fd, bool is_new) { - auto name = DeprecatedString::formatted("SharedSingleProducerCircularQueue@{:x}", fd); + auto name = ByteString::formatted("SharedSingleProducerCircularQueue@{:x}", fd); auto* raw_mapping = TRY(System::mmap(nullptr, sizeof(SharedMemorySPCQ), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0, 0, name)); dbgln_if(SHARED_QUEUE_DEBUG, "successfully mmapped {} at {:p}", name, raw_mapping); @@ -212,7 +212,7 @@ private: return SharedSingleProducerCircularQueue { move(name), adopt_ref(*new (nothrow) RefCountedSharedMemorySPCQ(shared_queue, fd)) }; } - SharedSingleProducerCircularQueue(DeprecatedString name, RefPtr queue) + SharedSingleProducerCircularQueue(ByteString name, RefPtr queue) : m_queue(queue) , m_name(move(name)) { @@ -220,7 +220,7 @@ private: RefPtr m_queue; - DeprecatedString m_name {}; + ByteString m_name {}; }; } diff --git a/Userland/Libraries/LibCore/Socket.cpp b/Userland/Libraries/LibCore/Socket.cpp index f0a3a641bc4..395c0ac0083 100644 --- a/Userland/Libraries/LibCore/Socket.cpp +++ b/Userland/Libraries/LibCore/Socket.cpp @@ -46,7 +46,7 @@ ErrorOr Socket::create_fd(SocketDomain domain, SocketType type) #endif } -ErrorOr Socket::resolve_host(DeprecatedString const& host, SocketType type) +ErrorOr Socket::resolve_host(ByteString const& host, SocketType type) { int socket_type; switch (type) { @@ -79,7 +79,7 @@ ErrorOr Socket::resolve_host(DeprecatedString const& host, SocketTy return Error::from_string_literal("Could not resolve to IPv4 address"); } -ErrorOr Socket::connect_local(int fd, DeprecatedString const& path) +ErrorOr Socket::connect_local(int fd, ByteString const& path) { auto address = SocketAddress::local(path); auto maybe_sockaddr = address.to_sockaddr_un(); @@ -189,7 +189,7 @@ void PosixSocketHelper::setup_notifier() m_notifier = Core::Notifier::construct(m_fd, Core::Notifier::Type::Read); } -ErrorOr> TCPSocket::connect(DeprecatedString const& host, u16 port) +ErrorOr> TCPSocket::connect(ByteString const& host, u16 port) { auto ip_address = TRY(resolve_host(host, SocketType::Stream)); return connect(SocketAddress { ip_address, port }); @@ -231,7 +231,7 @@ ErrorOr PosixSocketHelper::pending_bytes() const return static_cast(value); } -ErrorOr> UDPSocket::connect(DeprecatedString const& host, u16 port, Optional timeout) +ErrorOr> UDPSocket::connect(ByteString const& host, u16 port, Optional timeout) { auto ip_address = TRY(resolve_host(host, SocketType::Datagram)); return connect(SocketAddress { ip_address, port }, timeout); @@ -253,7 +253,7 @@ ErrorOr> UDPSocket::connect(SocketAddress const& addres return socket; } -ErrorOr> LocalSocket::connect(DeprecatedString const& path, PreventSIGPIPE prevent_sigpipe) +ErrorOr> LocalSocket::connect(ByteString const& path, PreventSIGPIPE prevent_sigpipe) { auto socket = TRY(adopt_nonnull_own_or_enomem(new (nothrow) LocalSocket(prevent_sigpipe))); diff --git a/Userland/Libraries/LibCore/Socket.h b/Userland/Libraries/LibCore/Socket.h index 55e18cdaea7..c9b4622e17e 100644 --- a/Userland/Libraries/LibCore/Socket.h +++ b/Userland/Libraries/LibCore/Socket.h @@ -72,9 +72,9 @@ protected: static ErrorOr create_fd(SocketDomain, SocketType); // FIXME: This will need to be updated when IPv6 socket arrives. Perhaps a // base class for all address types is appropriate. - static ErrorOr resolve_host(DeprecatedString const&, SocketType); + static ErrorOr resolve_host(ByteString const&, SocketType); - static ErrorOr connect_local(int fd, DeprecatedString const& path); + static ErrorOr connect_local(int fd, ByteString const& path); static ErrorOr connect_inet(int fd, SocketAddress const&); int default_flags() const @@ -97,7 +97,7 @@ public: virtual bool is_connected() = 0; /// Reconnects the socket to the given host and port. Returns EALREADY if /// is_connected() is true. - virtual ErrorOr reconnect(DeprecatedString const& host, u16 port) = 0; + virtual ErrorOr reconnect(ByteString const& host, u16 port) = 0; /// Connects the socket to the given socket address (IP address + port). /// Returns EALREADY is_connected() is true. virtual ErrorOr reconnect(SocketAddress const&) = 0; @@ -154,7 +154,7 @@ private: class TCPSocket final : public Socket { public: - static ErrorOr> connect(DeprecatedString const& host, u16 port); + static ErrorOr> connect(ByteString const& host, u16 port); static ErrorOr> connect(SocketAddress const& address); static ErrorOr> adopt_fd(int fd); @@ -215,7 +215,7 @@ private: class UDPSocket final : public Socket { public: - static ErrorOr> connect(DeprecatedString const& host, u16 port, Optional timeout = {}); + static ErrorOr> connect(ByteString const& host, u16 port, Optional timeout = {}); static ErrorOr> connect(SocketAddress const& address, Optional timeout = {}); UDPSocket(UDPSocket&& other) @@ -289,7 +289,7 @@ private: class LocalSocket final : public Socket { public: - static ErrorOr> connect(DeprecatedString const& path, PreventSIGPIPE = PreventSIGPIPE::No); + static ErrorOr> connect(ByteString const& path, PreventSIGPIPE = PreventSIGPIPE::No); static ErrorOr> adopt_fd(int fd, PreventSIGPIPE = PreventSIGPIPE::No); LocalSocket(LocalSocket&& other) @@ -450,7 +450,7 @@ using BufferedLocalSocket = BufferedSocket; template class BasicReusableSocket final : public ReusableSocket { public: - static ErrorOr>> connect(DeprecatedString const& host, u16 port) + static ErrorOr>> connect(ByteString const& host, u16 port) { return make>(TRY(T::connect(host, port))); } @@ -465,7 +465,7 @@ public: return m_socket.is_open(); } - virtual ErrorOr reconnect(DeprecatedString const& host, u16 port) override + virtual ErrorOr reconnect(ByteString const& host, u16 port) override { if (is_connected()) return Error::from_errno(EALREADY); diff --git a/Userland/Libraries/LibCore/SocketAddress.h b/Userland/Libraries/LibCore/SocketAddress.h index 48f7cb6426d..4e7d1e75595 100644 --- a/Userland/Libraries/LibCore/SocketAddress.h +++ b/Userland/Libraries/LibCore/SocketAddress.h @@ -38,7 +38,7 @@ public: { } - static SocketAddress local(DeprecatedString const& address) + static SocketAddress local(ByteString const& address) { SocketAddress addr; addr.m_type = Type::Local; @@ -51,11 +51,11 @@ public: IPv4Address ipv4_address() const { return m_ipv4_address; } u16 port() const { return m_port; } - DeprecatedString to_deprecated_string() const + ByteString to_byte_string() const { switch (m_type) { case Type::IPv4: - return DeprecatedString::formatted("{}:{}", m_ipv4_address, m_port); + return ByteString::formatted("{}:{}", m_ipv4_address, m_port); case Type::Local: return m_local_address; default: @@ -91,16 +91,16 @@ private: Type m_type { Type::Invalid }; IPv4Address m_ipv4_address; u16 m_port { 0 }; - DeprecatedString m_local_address; + ByteString m_local_address; }; } template<> -struct AK::Formatter : Formatter { +struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Core::SocketAddress const& value) { - return Formatter::format(builder, value.to_deprecated_string()); + return Formatter::format(builder, value.to_byte_string()); } }; diff --git a/Userland/Libraries/LibCore/StandardPaths.cpp b/Userland/Libraries/LibCore/StandardPaths.cpp index b25eb8ee9be..f6dce7c023b 100644 --- a/Userland/Libraries/LibCore/StandardPaths.cpp +++ b/Userland/Libraries/LibCore/StandardPaths.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -22,42 +22,42 @@ namespace Core { -DeprecatedString StandardPaths::home_directory() +ByteString StandardPaths::home_directory() { if (auto* home_env = getenv("HOME")) return LexicalPath::canonicalized_path(home_env); auto* pwd = getpwuid(getuid()); - DeprecatedString path = pwd ? pwd->pw_dir : "/"; + ByteString path = pwd ? pwd->pw_dir : "/"; endpwent(); return LexicalPath::canonicalized_path(path); } -DeprecatedString StandardPaths::desktop_directory() +ByteString StandardPaths::desktop_directory() { StringBuilder builder; builder.append(home_directory()); builder.append("/Desktop"sv); - return LexicalPath::canonicalized_path(builder.to_deprecated_string()); + return LexicalPath::canonicalized_path(builder.to_byte_string()); } -DeprecatedString StandardPaths::documents_directory() +ByteString StandardPaths::documents_directory() { StringBuilder builder; builder.append(home_directory()); builder.append("/Documents"sv); - return LexicalPath::canonicalized_path(builder.to_deprecated_string()); + return LexicalPath::canonicalized_path(builder.to_byte_string()); } -DeprecatedString StandardPaths::downloads_directory() +ByteString StandardPaths::downloads_directory() { StringBuilder builder; builder.append(home_directory()); builder.append("/Downloads"sv); - return LexicalPath::canonicalized_path(builder.to_deprecated_string()); + return LexicalPath::canonicalized_path(builder.to_byte_string()); } -DeprecatedString StandardPaths::config_directory() +ByteString StandardPaths::config_directory() { if (auto* config_directory = getenv("XDG_CONFIG_HOME")) return LexicalPath::canonicalized_path(config_directory); @@ -71,10 +71,10 @@ DeprecatedString StandardPaths::config_directory() #else builder.append("/.config"sv); #endif - return LexicalPath::canonicalized_path(builder.to_deprecated_string()); + return LexicalPath::canonicalized_path(builder.to_byte_string()); } -DeprecatedString StandardPaths::data_directory() +ByteString StandardPaths::data_directory() { if (auto* data_directory = getenv("XDG_DATA_HOME")) return LexicalPath::canonicalized_path(data_directory); @@ -91,10 +91,10 @@ DeprecatedString StandardPaths::data_directory() builder.append("/.local/share"sv); #endif - return LexicalPath::canonicalized_path(builder.to_deprecated_string()); + return LexicalPath::canonicalized_path(builder.to_byte_string()); } -ErrorOr StandardPaths::runtime_directory() +ErrorOr StandardPaths::runtime_directory() { if (auto* data_directory = getenv("XDG_RUNTIME_DIR")) return LexicalPath::canonicalized_path(data_directory); @@ -114,10 +114,10 @@ ErrorOr StandardPaths::runtime_directory() builder.appendff("/run/user/{}", uid); #endif - return LexicalPath::canonicalized_path(builder.to_deprecated_string()); + return LexicalPath::canonicalized_path(builder.to_byte_string()); } -DeprecatedString StandardPaths::tempfile_directory() +ByteString StandardPaths::tempfile_directory() { return "/tmp"; } diff --git a/Userland/Libraries/LibCore/StandardPaths.h b/Userland/Libraries/LibCore/StandardPaths.h index 470438c62d5..5791f8fadfa 100644 --- a/Userland/Libraries/LibCore/StandardPaths.h +++ b/Userland/Libraries/LibCore/StandardPaths.h @@ -14,14 +14,14 @@ namespace Core { class StandardPaths { public: - static DeprecatedString home_directory(); - static DeprecatedString desktop_directory(); - static DeprecatedString documents_directory(); - static DeprecatedString downloads_directory(); - static DeprecatedString tempfile_directory(); - static DeprecatedString config_directory(); - static DeprecatedString data_directory(); - static ErrorOr runtime_directory(); + static ByteString home_directory(); + static ByteString desktop_directory(); + static ByteString documents_directory(); + static ByteString downloads_directory(); + static ByteString tempfile_directory(); + static ByteString config_directory(); + static ByteString data_directory(); + static ErrorOr runtime_directory(); static ErrorOr> font_directories(); }; diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index f7de49ee62f..ab49f2cadf3 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -7,7 +7,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -202,7 +202,7 @@ ErrorOr unveil(StringView path, StringView permissions) { nullptr, 0 }, }; - DeprecatedString parsed_path; + ByteString parsed_path; if (!path.is_null()) { parsed_path = TRY(Core::SessionManagement::parse_path_with_sid(path)); params.path = { parsed_path.characters(), parsed_path.length() }; @@ -215,7 +215,7 @@ ErrorOr unveil(StringView path, StringView permissions) ErrorOr unveil_after_exec(StringView path, StringView permissions) { - DeprecatedString parsed_path; + ByteString parsed_path; Syscall::SC_unveil_params params { static_cast(UnveilFlags::AfterExec), { nullptr, 0 }, @@ -448,7 +448,7 @@ ErrorOr fstatat(int fd, StringView path, int flags) Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, fd, !(flags & AT_SYMLINK_NOFOLLOW) }; int rc = syscall(SC_stat, ¶ms); #else - DeprecatedString path_string = path; + ByteString path_string = path; int rc = ::fstatat(fd, path_string.characters(), &st, flags); #endif HANDLE_SYSCALL_RETURN_VALUE("fstatat", rc, st); @@ -531,7 +531,7 @@ ErrorOr anon_create([[maybe_unused]] size_t size, [[maybe_unused]] int opti #elif defined(AK_OS_BSD_GENERIC) || defined(AK_OS_EMSCRIPTEN) || defined(AK_OS_HAIKU) struct timespec time; clock_gettime(CLOCK_REALTIME, &time); - auto name = DeprecatedString::formatted("/shm-{}{}", (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec); + auto name = ByteString::formatted("/shm-{}{}", (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec); fd = shm_open(name.characters(), O_RDWR | O_CREAT | options, 0600); if (shm_unlink(name.characters()) == -1) { @@ -576,7 +576,7 @@ ErrorOr openat(int fd, StringView path, int options, mode_t mode) HANDLE_SYSCALL_RETURN_VALUE("open", rc, rc); #else // NOTE: We have to ensure that the path is null-terminated. - DeprecatedString path_string = path; + ByteString path_string = path; int rc = ::openat(fd, path_string.characters(), options, mode); if (rc < 0) return Error::from_syscall("open"sv, -errno); @@ -609,7 +609,7 @@ ErrorOr stat(StringView path) int rc = syscall(SC_stat, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("stat", rc, st); #else - DeprecatedString path_string = path; + ByteString path_string = path; if (::stat(path_string.characters(), &st) < 0) return Error::from_syscall("stat"sv, -errno); return st; @@ -627,7 +627,7 @@ ErrorOr lstat(StringView path) int rc = syscall(SC_stat, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("lstat", rc, st); #else - DeprecatedString path_string = path; + ByteString path_string = path; if (::lstat(path_string.characters(), &st) < 0) return Error::from_syscall("lstat"sv, -errno); return st; @@ -680,21 +680,21 @@ ErrorOr dup2(int source_fd, int destination_fd) return fd; } -ErrorOr ptsname(int fd) +ErrorOr ptsname(int fd) { auto* name = ::ptsname(fd); if (!name) return Error::from_syscall("ptsname"sv, -errno); - return DeprecatedString(name); + return ByteString(name); } -ErrorOr gethostname() +ErrorOr gethostname() { char hostname[HOST_NAME_MAX]; int rc = ::gethostname(hostname, sizeof(hostname)); if (rc < 0) return Error::from_syscall("gethostname"sv, -errno); - return DeprecatedString(&hostname[0]); + return ByteString(&hostname[0]); } ErrorOr sethostname(StringView hostname) @@ -709,13 +709,13 @@ ErrorOr sethostname(StringView hostname) return {}; } -ErrorOr getcwd() +ErrorOr getcwd() { auto* cwd = ::getcwd(nullptr, 0); if (!cwd) return Error::from_syscall("getcwd"sv, -errno); - DeprecatedString string_cwd(cwd); + ByteString string_cwd(cwd); free(cwd); return string_cwd; } @@ -773,7 +773,7 @@ ErrorOr chmod(StringView pathname, mode_t mode) int rc = syscall(SC_chmod, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("chmod", rc, {}); #else - DeprecatedString path = pathname; + ByteString path = pathname; if (::chmod(path.characters(), mode) < 0) return Error::from_syscall("chmod"sv, -errno); return {}; @@ -804,7 +804,7 @@ ErrorOr lchown(StringView pathname, uid_t uid, gid_t gid) int rc = syscall(SC_chown, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {}); #else - DeprecatedString path = pathname; + ByteString path = pathname; if (::chown(path.characters(), uid, gid) < 0) return Error::from_syscall("chown"sv, -errno); return {}; @@ -821,7 +821,7 @@ ErrorOr chown(StringView pathname, uid_t uid, gid_t gid) int rc = syscall(SC_chown, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {}); #else - DeprecatedString path = pathname; + ByteString path = pathname; if (::lchown(path.characters(), uid, gid) < 0) return Error::from_syscall("lchown"sv, -errno); return {}; @@ -913,7 +913,7 @@ ErrorOr clock_settime(clockid_t clock_id, struct timespec* ts) static ALWAYS_INLINE ErrorOr posix_spawn_wrapper(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[], StringView function_name, decltype(::posix_spawn) spawn_function) { pid_t child_pid; - if ((errno = spawn_function(&child_pid, path.to_deprecated_string().characters(), file_actions, attr, arguments, envp))) + if ((errno = spawn_function(&child_pid, path.to_byte_string().characters(), file_actions, attr, arguments, envp))) return Error::from_syscall(function_name, -errno); return child_pid; } @@ -1036,8 +1036,8 @@ ErrorOr link(StringView old_path, StringView new_path) int rc = syscall(SC_link, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("link", rc, {}); #else - DeprecatedString old_path_string = old_path; - DeprecatedString new_path_string = new_path; + ByteString old_path_string = old_path; + ByteString new_path_string = new_path; if (::link(old_path_string.characters(), new_path_string.characters()) < 0) return Error::from_syscall("link"sv, -errno); return {}; @@ -1055,8 +1055,8 @@ ErrorOr symlink(StringView target, StringView link_path) int rc = syscall(SC_symlink, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("symlink", rc, {}); #else - DeprecatedString target_string = target; - DeprecatedString link_path_string = link_path; + ByteString target_string = target; + ByteString link_path_string = link_path; if (::symlink(target_string.characters(), link_path_string.characters()) < 0) return Error::from_syscall("symlink"sv, -errno); return {}; @@ -1071,7 +1071,7 @@ ErrorOr mkdir(StringView path, mode_t mode) int rc = syscall(SC_mkdir, AT_FDCWD, path.characters_without_null_termination(), path.length(), mode); HANDLE_SYSCALL_RETURN_VALUE("mkdir", rc, {}); #else - DeprecatedString path_string = path; + ByteString path_string = path; if (::mkdir(path_string.characters(), mode) < 0) return Error::from_syscall("mkdir"sv, -errno); return {}; @@ -1086,7 +1086,7 @@ ErrorOr chdir(StringView path) int rc = syscall(SC_chdir, path.characters_without_null_termination(), path.length()); HANDLE_SYSCALL_RETURN_VALUE("chdir", rc, {}); #else - DeprecatedString path_string = path; + ByteString path_string = path; if (::chdir(path_string.characters()) < 0) return Error::from_syscall("chdir"sv, -errno); return {}; @@ -1101,7 +1101,7 @@ ErrorOr rmdir(StringView path) int rc = syscall(SC_rmdir, path.characters_without_null_termination(), path.length()); HANDLE_SYSCALL_RETURN_VALUE("rmdir", rc, {}); #else - DeprecatedString path_string = path; + ByteString path_string = path; if (::rmdir(path_string.characters()) < 0) return Error::from_syscall("rmdir"sv, -errno); return {}; @@ -1149,8 +1149,8 @@ ErrorOr rename(StringView old_path, StringView new_path) int rc = syscall(SC_rename, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("rename", rc, {}); #else - DeprecatedString old_path_string = old_path; - DeprecatedString new_path_string = new_path; + ByteString old_path_string = old_path; + ByteString new_path_string = new_path; if (::rename(old_path_string.characters(), new_path_string.characters()) < 0) return Error::from_syscall("rename"sv, -errno); return {}; @@ -1166,7 +1166,7 @@ ErrorOr unlink(StringView path) int rc = syscall(SC_unlink, AT_FDCWD, path.characters_without_null_termination(), path.length(), 0); HANDLE_SYSCALL_RETURN_VALUE("unlink", rc, {}); #else - DeprecatedString path_string = path; + ByteString path_string = path; if (::unlink(path_string.characters()) < 0) return Error::from_syscall("unlink"sv, -errno); return {}; @@ -1185,7 +1185,7 @@ ErrorOr utime(StringView path, Optional maybe_buf) int rc = syscall(SC_utime, path.characters_without_null_termination(), path.length(), buf); HANDLE_SYSCALL_RETURN_VALUE("utime", rc, {}); #else - DeprecatedString path_string = path; + ByteString path_string = path; if (::utime(path_string.characters(), buf) < 0) return Error::from_syscall("utime"sv, -errno); return {}; @@ -1364,22 +1364,22 @@ ErrorOr exec(StringView filename, ReadonlySpan arguments, Sear TRY(run_exec(params)); VERIFY_NOT_REACHED(); #else - DeprecatedString filename_string { filename }; + ByteString filename_string { filename }; - auto argument_strings = TRY(FixedArray::create(arguments.size())); + auto argument_strings = TRY(FixedArray::create(arguments.size())); auto argv = TRY(FixedArray::create(arguments.size() + 1)); for (size_t i = 0; i < arguments.size(); ++i) { - argument_strings[i] = arguments[i].to_deprecated_string(); + argument_strings[i] = arguments[i].to_byte_string(); argv[i] = const_cast(argument_strings[i].characters()); } argv[arguments.size()] = nullptr; int rc = 0; if (environment.has_value()) { - auto environment_strings = TRY(FixedArray::create(environment->size())); + auto environment_strings = TRY(FixedArray::create(environment->size())); auto envp = TRY(FixedArray::create(environment->size() + 1)); for (size_t i = 0; i < environment->size(); ++i) { - environment_strings[i] = environment->at(i).to_deprecated_string(); + environment_strings[i] = environment->at(i).to_byte_string(); envp[i] = const_cast(environment_strings[i].characters()); } envp[environment->size()] = nullptr; @@ -1396,7 +1396,7 @@ ErrorOr exec(StringView filename, ReadonlySpan arguments, Sear return executable_or_error.release_error(); } - DeprecatedString executable = executable_or_error.release_value().to_deprecated_string(); + ByteString executable = executable_or_error.release_value().to_byte_string(); rc = ::execve(executable.characters(), argv.data(), envp.data()); # else rc = ::execvpe(filename_string.characters(), argv.data(), envp.data()); @@ -1611,7 +1611,7 @@ ErrorOr mknod(StringView pathname, mode_t mode, dev_t dev) int rc = syscall(SC_mknod, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("mknod", rc, {}); #else - DeprecatedString path_string = pathname; + ByteString path_string = pathname; if (::mknod(path_string.characters(), mode, dev) < 0) return Error::from_syscall("mknod"sv, -errno); return {}; @@ -1705,7 +1705,7 @@ ErrorOr access(StringView pathname, int mode, int flags) int rc = ::syscall(Syscall::SC_faccessat, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("access", rc, {}); #else - DeprecatedString path_string = pathname; + ByteString path_string = pathname; (void)flags; if (::access(path_string.characters(), mode) < 0) return Error::from_syscall("access"sv, -errno); @@ -1713,7 +1713,7 @@ ErrorOr access(StringView pathname, int mode, int flags) #endif } -ErrorOr readlink(StringView pathname) +ErrorOr readlink(StringView pathname) { // FIXME: Try again with a larger buffer. #ifdef AK_OS_SERENITY @@ -1724,7 +1724,7 @@ ErrorOr readlink(StringView pathname) .dirfd = AT_FDCWD, }; int rc = syscall(SC_readlink, &small_params); - HANDLE_SYSCALL_RETURN_VALUE("readlink", rc, DeprecatedString(data, rc)); + HANDLE_SYSCALL_RETURN_VALUE("readlink", rc, ByteString(data, rc)); #elif defined(AK_OS_GNU_HURD) // PATH_MAX is not defined, nor is there an upper limit on path lengths. // Let's do this the right way. @@ -1732,15 +1732,15 @@ ErrorOr readlink(StringView pathname) auto file = TRY(File::adopt_fd(fd, File::OpenMode::Read)); auto buffer = TRY(file->read_until_eof()); // TODO: Get rid of this copy here. - return DeprecatedString::copy(buffer); + return ByteString::copy(buffer); #else char data[PATH_MAX]; - DeprecatedString path_string = pathname; + ByteString path_string = pathname; int rc = ::readlink(path_string.characters(), data, sizeof(data)); if (rc == -1) return Error::from_syscall("readlink"sv, -errno); - return DeprecatedString(data, rc); + return ByteString(data, rc); #endif } @@ -1806,7 +1806,7 @@ char** environment() #endif } -ErrorOr current_executable_path() +ErrorOr current_executable_path() { char path[4096] = {}; #if defined(AK_OS_LINUX) || defined(AK_OS_ANDROID) || defined(AK_OS_SERENITY) @@ -1862,7 +1862,7 @@ ErrorOr current_executable_path() return Error::from_string_view("current_executable_path unknown"sv); #endif path[sizeof(path) - 1] = '\0'; - return DeprecatedString { path, strlen(path) }; + return ByteString { path, strlen(path) }; } ErrorOr allocate(size_t count, size_t size) diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index c170adbbb13..70e350eacda 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -135,10 +135,10 @@ ErrorOr kill(pid_t, int signal); ErrorOr killpg(int pgrp, int signal); ErrorOr dup(int source_fd); ErrorOr dup2(int source_fd, int destination_fd); -ErrorOr ptsname(int fd); -ErrorOr gethostname(); +ErrorOr ptsname(int fd); +ErrorOr gethostname(); ErrorOr sethostname(StringView); -ErrorOr getcwd(); +ErrorOr getcwd(); ErrorOr ioctl(int fd, unsigned request, ...); ErrorOr tcgetattr(int fd); ErrorOr tcsetattr(int fd, int optional_actions, struct termios const&); @@ -235,7 +235,7 @@ ErrorOr posix_openpt(int flags); ErrorOr grantpt(int fildes); ErrorOr unlockpt(int fildes); ErrorOr access(StringView pathname, int mode, int flags = 0); -ErrorOr readlink(StringView pathname); +ErrorOr readlink(StringView pathname); ErrorOr poll(Span, int timeout); #ifdef AK_OS_SERENITY @@ -279,7 +279,7 @@ ErrorOr resolve_executable_from_environment(StringView filename, int fla char** environment(); -ErrorOr current_executable_path(); +ErrorOr current_executable_path(); ErrorOr allocate(size_t count, size_t size); diff --git a/Userland/Libraries/LibCore/SystemServerTakeover.cpp b/Userland/Libraries/LibCore/SystemServerTakeover.cpp index d15f52fb845..357f6f3bf77 100644 --- a/Userland/Libraries/LibCore/SystemServerTakeover.cpp +++ b/Userland/Libraries/LibCore/SystemServerTakeover.cpp @@ -10,7 +10,7 @@ namespace Core { -HashMap s_overtaken_sockets {}; +HashMap s_overtaken_sockets {}; bool s_overtaken_sockets_parsed { false }; static void parse_sockets_from_system_server() @@ -27,7 +27,7 @@ static void parse_sockets_from_system_server() for (auto const socket : StringView { sockets, strlen(sockets) }.split_view(';')) { auto params = socket.split_view(':'); VERIFY(params.size() == 2); - s_overtaken_sockets.set(params[0].to_deprecated_string(), params[1].to_int().value()); + s_overtaken_sockets.set(params[0].to_byte_string(), params[1].to_int().value()); } s_overtaken_sockets_parsed = true; @@ -36,7 +36,7 @@ static void parse_sockets_from_system_server() unsetenv(socket_takeover); } -ErrorOr> take_over_socket_from_system_server(DeprecatedString const& socket_path) +ErrorOr> take_over_socket_from_system_server(ByteString const& socket_path) { if (!s_overtaken_sockets_parsed) parse_sockets_from_system_server(); diff --git a/Userland/Libraries/LibCore/SystemServerTakeover.h b/Userland/Libraries/LibCore/SystemServerTakeover.h index fb1fa97dbb0..0a1bdae0387 100644 --- a/Userland/Libraries/LibCore/SystemServerTakeover.h +++ b/Userland/Libraries/LibCore/SystemServerTakeover.h @@ -10,6 +10,6 @@ namespace Core { -ErrorOr> take_over_socket_from_system_server(DeprecatedString const& socket_path = {}); +ErrorOr> take_over_socket_from_system_server(ByteString const& socket_path = {}); } diff --git a/Userland/Libraries/LibCoredump/Backtrace.cpp b/Userland/Libraries/LibCoredump/Backtrace.cpp index 3bdbc5c1174..d8064529eac 100644 --- a/Userland/Libraries/LibCoredump/Backtrace.cpp +++ b/Userland/Libraries/LibCoredump/Backtrace.cpp @@ -20,7 +20,7 @@ namespace Coredump { ELFObjectInfo const* Backtrace::object_info_for_region(Reader const& coredump, MemoryRegionInfo const& region) { - DeprecatedString path = coredump.resolve_object_path(region.object_name()); + ByteString path = coredump.resolve_object_path(region.object_name()); auto maybe_ptr = m_debug_info_cache.get(path); if (maybe_ptr.has_value()) @@ -127,13 +127,13 @@ void Backtrace::add_entry(Reader const& coredump, FlatPtr ip) m_entries.append({ ip, object_name, function_name, source_position }); } -DeprecatedString Backtrace::Entry::to_deprecated_string(bool color) const +ByteString Backtrace::Entry::to_byte_string(bool color) const { StringBuilder builder; builder.appendff("{:p}: ", eip); if (object_name.is_empty()) { builder.append("???"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } builder.appendff("[{}] {}", object_name, function_name.is_empty() ? "???" : function_name); builder.append(" ("sv); @@ -160,7 +160,7 @@ DeprecatedString Backtrace::Entry::to_deprecated_string(bool color) const builder.append(')'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } } diff --git a/Userland/Libraries/LibCoredump/Backtrace.h b/Userland/Libraries/LibCoredump/Backtrace.h index 598cecccec2..6c22776d574 100644 --- a/Userland/Libraries/LibCoredump/Backtrace.h +++ b/Userland/Libraries/LibCoredump/Backtrace.h @@ -31,11 +31,11 @@ class Backtrace { public: struct Entry { FlatPtr eip; - DeprecatedString object_name; - DeprecatedString function_name; + ByteString object_name; + ByteString function_name; Debug::DebugInfo::SourcePositionWithInlines source_position_with_inlines; - DeprecatedString to_deprecated_string(bool color = false) const; + ByteString to_byte_string(bool color = false) const; }; Backtrace(Reader const&, const ELF::Core::ThreadInfo&, Function on_progress = {}); @@ -51,7 +51,7 @@ private: bool m_skip_loader_so { false }; ELF::Core::ThreadInfo m_thread_info; Vector m_entries; - HashMap> m_debug_info_cache; + HashMap> m_debug_info_cache; }; } diff --git a/Userland/Libraries/LibCoredump/Inspector.cpp b/Userland/Libraries/LibCoredump/Inspector.cpp index bad065ab632..d9d4423fa77 100644 --- a/Userland/Libraries/LibCoredump/Inspector.cpp +++ b/Userland/Libraries/LibCoredump/Inspector.cpp @@ -46,7 +46,7 @@ void Inspector::parse_loaded_libraries(Function on_progress) return; auto image = make(file_or_error.value()->bytes()); - auto debug_info = make(*image, DeprecatedString {}, library.base_address); + auto debug_info = make(*image, ByteString {}, library.base_address); m_loaded_libraries.append(make(library.name, file_or_error.release_value(), move(image), move(debug_info), library.base_address)); }); } diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp index 42ffb597ac8..293f48b3552 100644 --- a/Userland/Libraries/LibCoredump/Reader.cpp +++ b/Userland/Libraries/LibCoredump/Reader.cpp @@ -210,20 +210,20 @@ u8 Reader::process_termination_signal() const return *termination_signal; } -DeprecatedString Reader::process_executable_path() const +ByteString Reader::process_executable_path() const { auto process_info = this->process_info(); - auto executable_path = process_info.get_deprecated_string("executable_path"sv); + auto executable_path = process_info.get_byte_string("executable_path"sv); return executable_path.value_or({}); } -Vector Reader::process_arguments() const +Vector Reader::process_arguments() const { auto process_info = this->process_info(); auto arguments = process_info.get_array("arguments"sv); if (!arguments.has_value()) return {}; - Vector vector; + Vector vector; arguments->for_each([&](auto& value) { if (value.is_string()) vector.append(value.as_string()); @@ -231,13 +231,13 @@ Vector Reader::process_arguments() const return vector; } -Vector Reader::process_environment() const +Vector Reader::process_environment() const { auto process_info = this->process_info(); auto environment = process_info.get_array("environment"sv); if (!environment.has_value()) return {}; - Vector vector; + Vector vector; environment->for_each([&](auto& value) { if (value.is_string()) vector.append(value.as_string()); @@ -245,7 +245,7 @@ Vector Reader::process_environment() const return vector; } -HashMap Reader::metadata() const +HashMap Reader::metadata() const { const ELF::Core::Metadata* metadata_notes_entry = nullptr; NotesEntryIterator it(bit_cast(m_coredump_image.program_header(m_notes_segment_index).raw_data())); @@ -263,7 +263,7 @@ HashMap Reader::metadata() const return {}; if (!metadata_json_value.value().is_object()) return {}; - HashMap metadata; + HashMap metadata; metadata_json_value.value().as_object().for_each_member([&](auto& key, auto& value) { metadata.set(key, value.as_string_or({})); }); @@ -272,13 +272,13 @@ HashMap Reader::metadata() const Reader::LibraryData const* Reader::library_containing(FlatPtr address) const { - static HashMap> cached_libs; + static HashMap> cached_libs; auto region = region_containing(address); if (!region.has_value()) return {}; auto name = region->object_name(); - DeprecatedString path = resolve_object_path(name); + ByteString path = resolve_object_path(name); if (!cached_libs.contains(path)) { auto file_or_error = Core::MappedFile::map(path); @@ -292,7 +292,7 @@ Reader::LibraryData const* Reader::library_containing(FlatPtr address) const return lib_data; } -DeprecatedString Reader::resolve_object_path(StringView name) const +ByteString Reader::resolve_object_path(StringView name) const { // TODO: There are other places where similar method is implemented or would be useful. // (e.g. UserspaceEmulator, LibSymbolication, Profiler, and DynamicLinker itself) @@ -302,7 +302,7 @@ DeprecatedString Reader::resolve_object_path(StringView name) const return name; } - Vector library_search_directories; + Vector library_search_directories; // If LD_LIBRARY_PATH is present, check its folders first for (auto& environment_variable : process_environment()) { @@ -336,7 +336,7 @@ DeprecatedString Reader::resolve_object_path(StringView name) const void Reader::for_each_library(Function func) const { - HashTable libraries; + HashTable libraries; for_each_memory_region_info([&](auto const& region) { auto name = region.object_name(); if (name.is_null() || libraries.contains(name)) @@ -344,7 +344,7 @@ void Reader::for_each_library(Function func) const libraries.set(name); - DeprecatedString path = resolve_object_path(name); + ByteString path = resolve_object_path(name); func(LibraryInfo { name, path, static_cast(region.region_start) }); return IterationDecision::Continue; diff --git a/Userland/Libraries/LibCoredump/Reader.h b/Userland/Libraries/LibCoredump/Reader.h index 959c8f8c74e..7c5be3544ad 100644 --- a/Userland/Libraries/LibCoredump/Reader.h +++ b/Userland/Libraries/LibCoredump/Reader.h @@ -47,8 +47,8 @@ public: void for_each_memory_region_info(Func func) const; struct LibraryInfo { - DeprecatedString name; - DeprecatedString path; + ByteString name; + ByteString path; FlatPtr base_address { 0 }; }; @@ -64,21 +64,21 @@ public: Optional region_containing(FlatPtr address) const; struct LibraryData { - DeprecatedString name; + ByteString name; FlatPtr base_address { 0 }; NonnullOwnPtr file; ELF::Image lib_elf; }; LibraryData const* library_containing(FlatPtr address) const; - DeprecatedString resolve_object_path(StringView object_name) const; + ByteString resolve_object_path(StringView object_name) const; int process_pid() const; u8 process_termination_signal() const; - DeprecatedString process_executable_path() const; - Vector process_arguments() const; - Vector process_environment() const; - HashMap metadata() const; + ByteString process_executable_path() const; + Vector process_arguments() const; + Vector process_environment() const; + HashMap metadata() const; private: explicit Reader(ReadonlyBytes); diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp index 8370b947967..14a7e0f1ea7 100644 --- a/Userland/Libraries/LibCpp/AST.cpp +++ b/Userland/Libraries/LibCpp/AST.cpp @@ -32,10 +32,10 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const { ASTNode::dump(output, indent); - DeprecatedString qualifiers_string; + ByteString qualifiers_string; if (!m_qualifiers.is_empty()) { print_indent(output, indent + 1); - outln(output, "[{}]", DeprecatedString::join(' ', m_qualifiers)); + outln(output, "[{}]", ByteString::join(' ', m_qualifiers)); } m_return_type->dump(output, indent + 1); @@ -72,51 +72,51 @@ void Type::dump(FILE* output, size_t indent) const { ASTNode::dump(output, indent); print_indent(output, indent + 1); - outln(output, "{}", to_deprecated_string()); + outln(output, "{}", to_byte_string()); } -DeprecatedString NamedType::to_deprecated_string() const +ByteString NamedType::to_byte_string() const { - DeprecatedString qualifiers_string; + ByteString qualifiers_string; if (!qualifiers().is_empty()) - qualifiers_string = DeprecatedString::formatted("[{}] ", DeprecatedString::join(' ', qualifiers())); + qualifiers_string = ByteString::formatted("[{}] ", ByteString::join(' ', qualifiers())); - DeprecatedString name; + ByteString name; if (is_auto()) name = "auto"; else name = m_name.is_null() ? ""sv : m_name->full_name(); - return DeprecatedString::formatted("{}{}", qualifiers_string, name); + return ByteString::formatted("{}{}", qualifiers_string, name); } -DeprecatedString Pointer::to_deprecated_string() const +ByteString Pointer::to_byte_string() const { if (!m_pointee) return {}; StringBuilder builder; - builder.append(m_pointee->to_deprecated_string()); + builder.append(m_pointee->to_byte_string()); builder.append('*'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString Reference::to_deprecated_string() const +ByteString Reference::to_byte_string() const { if (!m_referenced_type) return {}; StringBuilder builder; - builder.append(m_referenced_type->to_deprecated_string()); + builder.append(m_referenced_type->to_byte_string()); if (m_kind == Kind::Lvalue) builder.append('&'); else builder.append("&&"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString FunctionType::to_deprecated_string() const +ByteString FunctionType::to_byte_string() const { StringBuilder builder; - builder.append(m_return_type->to_deprecated_string()); + builder.append(m_return_type->to_byte_string()); builder.append('('); bool first = true; for (auto& parameter : m_parameters) { @@ -125,14 +125,14 @@ DeprecatedString FunctionType::to_deprecated_string() const else builder.append(", "sv); if (parameter->type()) - builder.append(parameter->type()->to_deprecated_string()); + builder.append(parameter->type()->to_byte_string()); if (parameter->name() && !parameter->full_name().is_empty()) { builder.append(' '); builder.append(parameter->full_name()); } } builder.append(')'); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } void Parameter::dump(FILE* output, size_t indent) const @@ -552,7 +552,7 @@ StringView Name::full_name() const builder.appendff("{}::", scope->name()); } } - m_full_name = DeprecatedString::formatted("{}{}", builder.to_deprecated_string(), m_name.is_null() ? ""sv : m_name->name()); + m_full_name = ByteString::formatted("{}{}", builder.to_byte_string(), m_name.is_null() ? ""sv : m_name->name()); return *m_full_name; } @@ -565,10 +565,10 @@ StringView TemplatizedName::full_name() const name.append(Name::full_name()); name.append('<'); for (auto& type : m_template_arguments) { - name.append(type->to_deprecated_string()); + name.append(type->to_byte_string()); } name.append('>'); - m_full_name = name.to_deprecated_string(); + m_full_name = name.to_byte_string(); return *m_full_name; } @@ -587,7 +587,7 @@ void SizedName::dump(FILE* output, size_t indent) const if (dimension_info.is_empty()) { dimension_info.append("[]"sv); } - outln(output, "{}", dimension_info.to_deprecated_string()); + outln(output, "{}", dimension_info.to_byte_string()); } void CppCastExpression::dump(FILE* output, size_t indent) const @@ -670,7 +670,7 @@ StringView Declaration::full_name() const if (m_name) m_full_name = m_name->full_name(); else - m_full_name = DeprecatedString::empty(); + m_full_name = ByteString::empty(); } return *m_full_name; diff --git a/Userland/Libraries/LibCpp/AST.h b/Userland/Libraries/LibCpp/AST.h index d08e42975ee..9b354b353c8 100644 --- a/Userland/Libraries/LibCpp/AST.h +++ b/Userland/Libraries/LibCpp/AST.h @@ -6,8 +6,8 @@ #pragma once +#include #include -#include #include #include #include @@ -65,7 +65,7 @@ public: virtual bool is_dummy_node() const { return false; } protected: - ASTNode(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + ASTNode(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : m_parent(parent) , m_start(start) , m_end(end) @@ -88,7 +88,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual Vector> declarations() const override { return m_declarations; } - TranslationUnit(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + TranslationUnit(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : ASTNode(parent, start, end, filename) { } @@ -107,7 +107,7 @@ public: virtual Vector> declarations() const override; protected: - Statement(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Statement(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : ASTNode(parent, start, end, filename) { } @@ -131,13 +131,13 @@ public: void set_name(RefPtr name) { m_name = move(name); } protected: - Declaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Declaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } RefPtr m_name; - mutable Optional m_full_name; + mutable Optional m_full_name; }; class InvalidDeclaration : public Declaration { @@ -145,7 +145,7 @@ class InvalidDeclaration : public Declaration { public: virtual ~InvalidDeclaration() override = default; virtual StringView class_name() const override { return "InvalidDeclaration"sv; } - InvalidDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + InvalidDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Declaration(parent, start, end, filename) { } @@ -161,7 +161,7 @@ public: virtual bool is_destructor() const { return false; } RefPtr definition() { return m_definition; } - FunctionDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + FunctionDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Declaration(parent, start, end, filename) { } @@ -192,7 +192,7 @@ public: Type const* type() const { return m_type.ptr(); } protected: - VariableOrParameterDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + VariableOrParameterDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Declaration(parent, start, end, filename) { } @@ -207,7 +207,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_parameter() const override { return true; } - Parameter(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename, RefPtr name) + Parameter(ASTNode const* parent, Optional start, Optional end, ByteString const& filename, RefPtr name) : VariableOrParameterDeclaration(parent, start, end, filename) { m_name = name; @@ -227,7 +227,7 @@ public: virtual bool is_type() const override { return true; } virtual bool is_templatized() const { return false; } virtual bool is_named_type() const { return false; } - virtual DeprecatedString to_deprecated_string() const = 0; + virtual ByteString to_byte_string() const = 0; virtual void dump(FILE* = stdout, size_t indent = 0) const override; bool is_auto() const { return m_is_auto; } @@ -236,7 +236,7 @@ public: void set_qualifiers(Vector&& qualifiers) { m_qualifiers = move(qualifiers); } protected: - Type(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Type(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : ASTNode(parent, start, end, filename) { } @@ -250,10 +250,10 @@ class NamedType : public Type { public: virtual ~NamedType() override = default; virtual StringView class_name() const override { return "NamedType"sv; } - virtual DeprecatedString to_deprecated_string() const override; + virtual ByteString to_byte_string() const override; virtual bool is_named_type() const override { return true; } - NamedType(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + NamedType(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Type(parent, start, end, filename) { } @@ -270,9 +270,9 @@ public: virtual ~Pointer() override = default; virtual StringView class_name() const override { return "Pointer"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - virtual DeprecatedString to_deprecated_string() const override; + virtual ByteString to_byte_string() const override; - Pointer(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Pointer(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Type(parent, start, end, filename) { } @@ -289,14 +289,14 @@ public: virtual ~Reference() override = default; virtual StringView class_name() const override { return "Reference"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - virtual DeprecatedString to_deprecated_string() const override; + virtual ByteString to_byte_string() const override; enum class Kind { Lvalue, Rvalue, }; - Reference(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename, Kind kind) + Reference(ASTNode const* parent, Optional start, Optional end, ByteString const& filename, Kind kind) : Type(parent, start, end, filename) , m_kind(kind) { @@ -316,9 +316,9 @@ public: virtual ~FunctionType() override = default; virtual StringView class_name() const override { return "FunctionType"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - virtual DeprecatedString to_deprecated_string() const override; + virtual ByteString to_byte_string() const override; - FunctionType(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + FunctionType(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Type(parent, start, end, filename) { } @@ -337,7 +337,7 @@ public: virtual StringView class_name() const override { return "FunctionDefinition"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - FunctionDefinition(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + FunctionDefinition(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : ASTNode(parent, start, end, filename) { } @@ -354,7 +354,7 @@ class InvalidStatement : public Statement { public: virtual ~InvalidStatement() override = default; virtual StringView class_name() const override { return "InvalidStatement"sv; } - InvalidStatement(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + InvalidStatement(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } @@ -366,7 +366,7 @@ public: virtual StringView class_name() const override { return "Expression"sv; } protected: - Expression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Expression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } @@ -376,7 +376,7 @@ class InvalidExpression : public Expression { public: virtual ~InvalidExpression() override = default; virtual StringView class_name() const override { return "InvalidExpression"sv; } - InvalidExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + InvalidExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -388,7 +388,7 @@ public: virtual StringView class_name() const override { return "VariableDeclaration"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - VariableDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + VariableDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : VariableOrParameterDeclaration(parent, start, end, filename) { } @@ -408,12 +408,12 @@ public: virtual StringView class_name() const override { return "Identifier"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - Identifier(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename, StringView name) + Identifier(ASTNode const* parent, Optional start, Optional end, ByteString const& filename, StringView name) : Expression(parent, start, end, filename) , m_name(name) { } - Identifier(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Identifier(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Identifier(parent, start, end, filename, {}) { } @@ -436,7 +436,7 @@ public: virtual bool is_templatized() const { return false; } virtual bool is_sized() const { return false; } - Name(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Name(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -451,7 +451,7 @@ public: private: RefPtr m_name; Vector> m_scope; - mutable Optional m_full_name; + mutable Optional m_full_name; }; class SizedName : public Name { @@ -461,7 +461,7 @@ public: virtual bool is_sized() const override { return true; } void dump(FILE* output, size_t indent) const override; - SizedName(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + SizedName(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Name(parent, start, end, filename) { } @@ -470,7 +470,7 @@ public: private: Vector m_dimensions; - mutable Optional m_full_name; + mutable Optional m_full_name; }; class TemplatizedName : public Name { @@ -480,7 +480,7 @@ public: virtual bool is_templatized() const override { return true; } virtual StringView full_name() const override; - TemplatizedName(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + TemplatizedName(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Name(parent, start, end, filename) { } @@ -489,7 +489,7 @@ public: private: Vector> m_template_arguments; - mutable Optional m_full_name; + mutable Optional m_full_name; }; class NumericLiteral : public Expression { @@ -498,7 +498,7 @@ public: virtual StringView class_name() const override { return "NumericLiteral"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - NumericLiteral(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename, StringView value) + NumericLiteral(ASTNode const* parent, Optional start, Optional end, ByteString const& filename, StringView value) : Expression(parent, start, end, filename) , m_value(value) { @@ -516,7 +516,7 @@ public: virtual StringView class_name() const override { return "NullPointerLiteral"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - NullPointerLiteral(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + NullPointerLiteral(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -528,7 +528,7 @@ public: virtual StringView class_name() const override { return "BooleanLiteral"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - BooleanLiteral(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename, bool value) + BooleanLiteral(ASTNode const* parent, Optional start, Optional end, ByteString const& filename, bool value) : Expression(parent, start, end, filename) , m_value(value) { @@ -562,7 +562,7 @@ enum class BinaryOp { class BinaryExpression : public Expression { public: - BinaryExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + BinaryExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -592,7 +592,7 @@ enum class AssignmentOp { class AssignmentExpression : public Expression { public: - AssignmentExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + AssignmentExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -616,7 +616,7 @@ private: class FunctionCall : public Expression { public: - FunctionCall(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + FunctionCall(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -639,7 +639,7 @@ private: class StringLiteral final : public Expression { public: - StringLiteral(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + StringLiteral(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -648,11 +648,11 @@ public: virtual StringView class_name() const override { return "StringLiteral"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - DeprecatedString const& value() const { return m_value; } - void set_value(DeprecatedString value) { m_value = move(value); } + ByteString const& value() const { return m_value; } + void set_value(ByteString value) { m_value = move(value); } private: - DeprecatedString m_value; + ByteString m_value; }; class ReturnStatement : public Statement { @@ -660,7 +660,7 @@ public: virtual ~ReturnStatement() override = default; virtual StringView class_name() const override { return "ReturnStatement"sv; } - ReturnStatement(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + ReturnStatement(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } @@ -680,7 +680,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_enum() const override { return true; } - EnumDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + EnumDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Declaration(parent, start, end, filename) { } @@ -717,7 +717,7 @@ public: Class }; - StructOrClassDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename, StructOrClassDeclaration::Type type) + StructOrClassDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename, StructOrClassDeclaration::Type type) : Declaration(parent, start, end, filename) , m_type(type) { @@ -747,7 +747,7 @@ enum class UnaryOp { class UnaryExpression : public Expression { public: - UnaryExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + UnaryExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -766,7 +766,7 @@ private: class MemberExpression : public Expression { public: - MemberExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + MemberExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -788,7 +788,7 @@ private: class ForStatement : public Statement { public: - ForStatement(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + ForStatement(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } @@ -814,7 +814,7 @@ private: class BlockStatement final : public Statement { public: - BlockStatement(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + BlockStatement(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } @@ -835,7 +835,7 @@ private: class Comment final : public Statement { public: - Comment(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Comment(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } @@ -846,7 +846,7 @@ public: class IfStatement : public Statement { public: - IfStatement(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + IfStatement(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Statement(parent, start, end, filename) { } @@ -877,7 +877,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_namespace() const override { return true; } - NamespaceDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + NamespaceDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Declaration(parent, start, end, filename) { } @@ -891,7 +891,7 @@ private: class CppCastExpression : public Expression { public: - CppCastExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + CppCastExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -912,7 +912,7 @@ private: class CStyleCastExpression : public Expression { public: - CStyleCastExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + CStyleCastExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -931,7 +931,7 @@ private: class SizeofExpression : public Expression { public: - SizeofExpression(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + SizeofExpression(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -948,7 +948,7 @@ private: class BracedInitList : public Expression { public: - BracedInitList(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + BracedInitList(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Expression(parent, start, end, filename) { } @@ -965,7 +965,7 @@ private: class DummyAstNode : public ASTNode { public: - DummyAstNode(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + DummyAstNode(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : ASTNode(parent, start, end, filename) { } @@ -981,7 +981,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_constructor() const override { return true; } - Constructor(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Constructor(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : FunctionDeclaration(parent, start, end, filename) { } @@ -994,7 +994,7 @@ public: virtual void dump(FILE* = stdout, size_t indent = 0) const override; virtual bool is_destructor() const override { return true; } - Destructor(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + Destructor(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : FunctionDeclaration(parent, start, end, filename) { } @@ -1006,7 +1006,7 @@ public: virtual StringView class_name() const override { return "UsingNamespaceDeclaration"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - UsingNamespaceDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + UsingNamespaceDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Declaration(parent, start, end, filename) { } @@ -1018,7 +1018,7 @@ public: virtual StringView class_name() const override { return "TypedefDeclaration"sv; } virtual void dump(FILE* = stdout, size_t indent = 0) const override; - TypedefDeclaration(ASTNode const* parent, Optional start, Optional end, DeprecatedString const& filename) + TypedefDeclaration(ASTNode const* parent, Optional start, Optional end, ByteString const& filename) : Declaration(parent, start, end, filename) { } diff --git a/Userland/Libraries/LibCpp/Lexer.cpp b/Userland/Libraries/LibCpp/Lexer.cpp index d10083fa756..e7ab750ca69 100644 --- a/Userland/Libraries/LibCpp/Lexer.cpp +++ b/Userland/Libraries/LibCpp/Lexer.cpp @@ -5,8 +5,8 @@ */ #include "Lexer.h" +#include #include -#include #include #include #include @@ -203,7 +203,7 @@ constexpr StringView s_known_types[] = { static bool is_keyword(StringView string) { - static HashTable keywords(array_size(s_known_keywords)); + static HashTable keywords(array_size(s_known_keywords)); if (keywords.is_empty()) { keywords.set_from(s_known_keywords); } @@ -212,7 +212,7 @@ static bool is_keyword(StringView string) static bool is_known_type(StringView string) { - static HashTable types(array_size(s_known_types)); + static HashTable types(array_size(s_known_types)); if (types.is_empty()) { types.set_from(s_known_types); } diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index d39c30a0b2c..2ecb7ff5bc6 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -11,18 +11,18 @@ #include #include -#define LOG_SCOPE() ScopeLogger logger(DeprecatedString::formatted("'{}' - {} ({})", peek().text(), peek().type_as_deprecated_string(), m_state.token_index)) +#define LOG_SCOPE() ScopeLogger logger(ByteString::formatted("'{}' - {} ({})", peek().text(), peek().type_as_byte_string(), m_state.token_index)) namespace Cpp { -Parser::Parser(Vector tokens, DeprecatedString const& filename) +Parser::Parser(Vector tokens, ByteString const& filename) : m_filename(filename) , m_tokens(move(tokens)) { if constexpr (CPP_DEBUG) { dbgln("Tokens:"); for (size_t i = 0; i < m_tokens.size(); ++i) { - dbgln("{}- {}", i, m_tokens[i].to_deprecated_string()); + dbgln("{}- {}", i, m_tokens[i].to_byte_string()); } } } @@ -598,7 +598,7 @@ NonnullRefPtr Parser::parse_secondary_expression(ASTNode const return func; } default: { - error(DeprecatedString::formatted("unexpected operator for expression. operator: {}", peek().to_deprecated_string())); + error(ByteString::formatted("unexpected operator for expression. operator: {}", peek().to_byte_string())); auto token = consume(); return create_ast_node(parent, token.start(), token.end()); } @@ -845,7 +845,7 @@ Token Parser::consume(Token::Type type) { auto token = consume(); if (token.type() != type) - error(DeprecatedString::formatted("expected {} at {}:{}, found: {}", Token::type_to_string(type), token.start().line, token.start().column, Token::type_to_string(token.type()))); + error(ByteString::formatted("expected {} at {}:{}, found: {}", Token::type_to_string(type), token.start().line, token.start().column, Token::type_to_string(token.type()))); return token; } @@ -894,18 +894,18 @@ StringView Parser::text_of_token(Cpp::Token const& token) const return token.text(); } -DeprecatedString Parser::text_of_node(ASTNode const& node) const +ByteString Parser::text_of_node(ASTNode const& node) const { return text_in_range(node.start(), node.end()); } -DeprecatedString Parser::text_in_range(Position start, Position end) const +ByteString Parser::text_in_range(Position start, Position end) const { StringBuilder builder; for (auto token : tokens_in_range(start, end)) { builder.append(token.text()); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } Vector Parser::tokens_in_range(Position start, Position end) const @@ -931,11 +931,11 @@ void Parser::error(StringView message) if (message.is_null() || message.is_empty()) message = ""sv; - DeprecatedString formatted_message; + ByteString formatted_message; if (m_state.token_index >= m_tokens.size()) { - formatted_message = DeprecatedString::formatted("C++ Parsed error on EOF.{}", message); + formatted_message = ByteString::formatted("C++ Parsed error on EOF.{}", message); } else { - formatted_message = DeprecatedString::formatted("C++ Parser error: {}. token: {} ({}:{})", + formatted_message = ByteString::formatted("C++ Parser error: {}. token: {} ({}:{})", message, m_state.token_index < m_tokens.size() ? text_of_token(m_tokens[m_state.token_index]) : "EOF"sv, m_tokens[m_state.token_index].start().line, @@ -1033,7 +1033,7 @@ Optional Parser::index_of_token_at(Position pos) const void Parser::print_tokens() const { for (auto& token : m_tokens) { - outln("{}", token.to_deprecated_string()); + outln("{}", token.to_byte_string()); } } @@ -1131,21 +1131,21 @@ NonnullRefPtr Parser::parse_enum_declaration(ASTNode cons return enum_decl; } -Token Parser::consume_keyword(DeprecatedString const& keyword) +Token Parser::consume_keyword(ByteString const& keyword) { auto token = consume(); if (token.type() != Token::Type::Keyword) { - error(DeprecatedString::formatted("unexpected token: {}, expected Keyword", token.to_deprecated_string())); + error(ByteString::formatted("unexpected token: {}, expected Keyword", token.to_byte_string())); return token; } if (text_of_token(token) != keyword) { - error(DeprecatedString::formatted("unexpected keyword: {}, expected {}", text_of_token(token), keyword)); + error(ByteString::formatted("unexpected keyword: {}, expected {}", text_of_token(token), keyword)); return token; } return token; } -bool Parser::match_keyword(DeprecatedString const& keyword) +bool Parser::match_keyword(ByteString const& keyword) { auto token = peek(); if (token.type() != Token::Type::Keyword) { @@ -1257,7 +1257,7 @@ NonnullRefPtr Parser::parse_type(ASTNode const& parent) if (!match_name()) { named_type->set_end(position()); - error(DeprecatedString::formatted("expected name instead of: {}", peek().text())); + error(ByteString::formatted("expected name instead of: {}", peek().text())); return named_type; } named_type->set_name(parse_name(*named_type)); diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h index e43f238d88d..1f0d6d65343 100644 --- a/Userland/Libraries/LibCpp/Parser.h +++ b/Userland/Libraries/LibCpp/Parser.h @@ -19,7 +19,7 @@ class Parser final { AK_MAKE_NONCOPYABLE(Parser); public: - explicit Parser(Vector tokens, DeprecatedString const& filename); + explicit Parser(Vector tokens, ByteString const& filename); ~Parser() = default; NonnullRefPtr parse(); @@ -30,11 +30,11 @@ public: Optional token_at(Position) const; Optional index_of_token_at(Position) const; RefPtr root_node() const { return m_root_node; } - DeprecatedString text_of_node(ASTNode const&) const; + ByteString text_of_node(ASTNode const&) const; StringView text_of_token(Cpp::Token const& token) const; void print_tokens() const; Vector const& tokens() const { return m_tokens; } - Vector const& errors() const { return m_errors; } + Vector const& errors() const { return m_errors; } Vector get_todo_entries() const; @@ -69,7 +69,7 @@ private: bool match_literal(); bool match_unary_expression(); bool match_boolean_literal(); - bool match_keyword(DeprecatedString const&); + bool match_keyword(ByteString const&); bool match_block_statement(); bool match_namespace_declaration(); bool match_template_arguments(); @@ -132,12 +132,12 @@ private: bool match(Token::Type); Token consume(Token::Type); Token consume(); - Token consume_keyword(DeprecatedString const&); + Token consume_keyword(ByteString const&); Token peek(size_t offset = 0) const; Optional peek(Token::Type) const; Position position() const; Position previous_token_end() const; - DeprecatedString text_in_range(Position start, Position end) const; + ByteString text_in_range(Position start, Position end) const; void save_state(); void load_state(); @@ -192,12 +192,12 @@ private: }; void parse_constructor_or_destructor_impl(FunctionDeclaration&, CtorOrDtor); - DeprecatedString m_filename; + ByteString m_filename; Vector m_tokens; State m_state; Vector m_saved_states; RefPtr m_root_node; - Vector m_errors; + Vector m_errors; Vector> m_nodes; }; diff --git a/Userland/Libraries/LibCpp/Preprocessor.cpp b/Userland/Libraries/LibCpp/Preprocessor.cpp index 8a0832c7637..2de36a47b48 100644 --- a/Userland/Libraries/LibCpp/Preprocessor.cpp +++ b/Userland/Libraries/LibCpp/Preprocessor.cpp @@ -12,7 +12,7 @@ #include namespace Cpp { -Preprocessor::Preprocessor(DeprecatedString const& filename, StringView program) +Preprocessor::Preprocessor(ByteString const& filename, StringView program) : m_filename(filename) , m_program(program) { @@ -369,7 +369,7 @@ Optional Preprocessor::create_definition(StringView li return definition; } -DeprecatedString Preprocessor::remove_escaped_newlines(StringView value) +ByteString Preprocessor::remove_escaped_newlines(StringView value) { static constexpr auto escaped_newline = "\\\n"sv; AK::StringBuilder processed_value; @@ -378,10 +378,10 @@ DeprecatedString Preprocessor::remove_escaped_newlines(StringView value) processed_value.append(lexer.consume_until(escaped_newline)); lexer.ignore(escaped_newline.length()); } - return processed_value.to_deprecated_string(); + return processed_value.to_byte_string(); } -DeprecatedString Preprocessor::evaluate_macro_call(MacroCall const& macro_call, Definition const& definition) +ByteString Preprocessor::evaluate_macro_call(MacroCall const& macro_call, Definition const& definition) { if (macro_call.arguments.size() != definition.parameters.size()) { dbgln("mismatch in # of arguments for macro call: {}", macro_call.name.text()); @@ -408,7 +408,7 @@ DeprecatedString Preprocessor::evaluate_macro_call(MacroCall const& macro_call, } }); - return processed_value.to_deprecated_string(); + return processed_value.to_byte_string(); } }; diff --git a/Userland/Libraries/LibCpp/Preprocessor.h b/Userland/Libraries/LibCpp/Preprocessor.h index eb98146a5a5..337c40d7090 100644 --- a/Userland/Libraries/LibCpp/Preprocessor.h +++ b/Userland/Libraries/LibCpp/Preprocessor.h @@ -6,8 +6,8 @@ #pragma once +#include #include -#include #include #include #include @@ -20,24 +20,24 @@ namespace Cpp { class Preprocessor { public: - explicit Preprocessor(DeprecatedString const& filename, StringView program); + explicit Preprocessor(ByteString const& filename, StringView program); Vector process_and_lex(); Vector included_paths() const { return m_included_paths; } struct Definition { - DeprecatedString key; - Vector parameters; - DeprecatedString value; + ByteString key; + Vector parameters; + ByteString value; DeprecatedFlyString filename; size_t line { 0 }; size_t column { 0 }; }; - using Definitions = HashMap; + using Definitions = HashMap; struct Substitution { Vector original_tokens; Definition defined_value; - DeprecatedString processed_value; + ByteString processed_value; }; Definitions const& definitions() const { return m_definitions; } @@ -55,7 +55,7 @@ private: void handle_preprocessor_statement(StringView); void handle_include_statement(StringView); void handle_preprocessor_keyword(StringView keyword, GenericLexer& line_lexer); - DeprecatedString remove_escaped_newlines(StringView value); + ByteString remove_escaped_newlines(StringView value); size_t do_substitution(Vector const& tokens, size_t token_index, Definition const&); Optional create_definition(StringView line); @@ -69,10 +69,10 @@ private: size_t end_token_index { 0 }; }; Optional parse_macro_call(Vector const& tokens, size_t token_index); - DeprecatedString evaluate_macro_call(MacroCall const&, Definition const&); + ByteString evaluate_macro_call(MacroCall const&, Definition const&); - DeprecatedString m_filename; - DeprecatedString m_program; + ByteString m_filename; + ByteString m_program; Vector m_unprocessed_tokens; Vector m_processed_tokens; diff --git a/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp b/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp index 2f37178905b..cb2f941794d 100644 --- a/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp +++ b/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp @@ -45,13 +45,13 @@ void SemanticSyntaxHighlighter::rehighlight(Palette const& palette) StringBuilder previous_tokens_as_lines; for (auto& token : current_tokens) - current_tokens_as_lines.appendff("{}\n", token.type_as_deprecated_string()); + current_tokens_as_lines.appendff("{}\n", token.type_as_byte_string()); for (Cpp::Token const& token : m_saved_tokens) - previous_tokens_as_lines.appendff("{}\n", token.type_as_deprecated_string()); + previous_tokens_as_lines.appendff("{}\n", token.type_as_byte_string()); - auto previous = previous_tokens_as_lines.to_deprecated_string(); - auto current = current_tokens_as_lines.to_deprecated_string(); + auto previous = previous_tokens_as_lines.to_byte_string(); + auto current = current_tokens_as_lines.to_byte_string(); // FIXME: Computing the diff on the entire document's tokens is quite inefficient. // An improvement over this could be only including the tokens that are in edited text ranges in the diff. diff --git a/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.h b/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.h index eb8787e67d2..b3b0913803b 100644 --- a/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.h +++ b/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.h @@ -43,7 +43,7 @@ private: Cpp::SyntaxHighlighter m_simple_syntax_highlighter; Vector m_tokens_info; - DeprecatedString m_saved_tokens_text; + ByteString m_saved_tokens_text; Vector m_saved_tokens; Threading::Mutex m_lock; }; diff --git a/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp b/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp index dcb1e251167..da9bc8bc82e 100644 --- a/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp @@ -65,7 +65,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette) Vector spans; lexer.lex_iterable([&](auto token) { // FIXME: The +1 for the token end column is a quick hack due to not wanting to modify the lexer (which is also used by the parser). Maybe there's a better way to do this. - dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_deprecated_string(), token.start().line, token.start().column, token.end().line, token.end().column + 1); + dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_byte_string(), token.start().line, token.start().column, token.end().line, token.end().column + 1); GUI::TextDocumentSpan span; span.range.set_start({ token.start().line, token.start().column }); span.range.set_end({ token.end().line, token.end().column + 1 }); diff --git a/Userland/Libraries/LibCpp/Token.cpp b/Userland/Libraries/LibCpp/Token.cpp index 60b5a1fb8af..b82bcd6d9fb 100644 --- a/Userland/Libraries/LibCpp/Token.cpp +++ b/Userland/Libraries/LibCpp/Token.cpp @@ -5,7 +5,7 @@ */ #include "Token.h" -#include +#include namespace Cpp { @@ -26,12 +26,12 @@ bool Position::operator<=(Position const& other) const return !(*this > other); } -DeprecatedString Token::to_deprecated_string() const +ByteString Token::to_byte_string() const { - return DeprecatedString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text()); + return ByteString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text()); } -DeprecatedString Token::type_as_deprecated_string() const +ByteString Token::type_as_byte_string() const { return type_to_string(m_type); } diff --git a/Userland/Libraries/LibCpp/Token.h b/Userland/Libraries/LibCpp/Token.h index 7986aaa9c82..2448e7f06f7 100644 --- a/Userland/Libraries/LibCpp/Token.h +++ b/Userland/Libraries/LibCpp/Token.h @@ -116,8 +116,8 @@ struct Token { VERIFY_NOT_REACHED(); } - DeprecatedString to_deprecated_string() const; - DeprecatedString type_as_deprecated_string() const; + ByteString to_byte_string() const; + ByteString type_as_byte_string() const; Position const& start() const { return m_start; } Position const& end() const { return m_end; } diff --git a/Userland/Libraries/LibCrypt/crypt.cpp b/Userland/Libraries/LibCrypt/crypt.cpp index fcb378353e6..7d6a4f09c9c 100644 --- a/Userland/Libraries/LibCrypt/crypt.cpp +++ b/Userland/Libraries/LibCrypt/crypt.cpp @@ -40,7 +40,7 @@ char* crypt_r(char const* key, char const* salt, struct crypt_data* data) size_t salt_len = min(strcspn(salt_value, "$"), crypt_salt_max); size_t header_len = salt_len + 3; - bool fits = DeprecatedString(salt, header_len).copy_characters_to_buffer(data->result, sizeof(data->result)); + bool fits = ByteString(salt, header_len).copy_characters_to_buffer(data->result, sizeof(data->result)); if (!fits) { errno = EINVAL; return nullptr; diff --git a/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp b/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp index 25c66441eb7..73a09e538f9 100644 --- a/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp @@ -9,7 +9,7 @@ namespace Crypto::ASN1 { -DeprecatedString kind_name(Kind kind) +ByteString kind_name(Kind kind) { switch (kind) { case Kind::Eol: @@ -91,7 +91,7 @@ DeprecatedString kind_name(Kind kind) return "InvalidKind"; } -DeprecatedString class_name(Class class_) +ByteString class_name(Class class_) { switch (class_) { case Class::Application: @@ -107,7 +107,7 @@ DeprecatedString class_name(Class class_) return "InvalidClass"; } -DeprecatedString type_name(Type type) +ByteString type_name(Type type) { switch (type) { case Type::Constructed: diff --git a/Userland/Libraries/LibCrypto/ASN1/ASN1.h b/Userland/Libraries/LibCrypto/ASN1/ASN1.h index 5553b7d81b7..4c4f0ac7322 100644 --- a/Userland/Libraries/LibCrypto/ASN1/ASN1.h +++ b/Userland/Libraries/LibCrypto/ASN1/ASN1.h @@ -71,9 +71,9 @@ struct Tag { Type type; }; -DeprecatedString kind_name(Kind); -DeprecatedString class_name(Class); -DeprecatedString type_name(Type); +ByteString kind_name(Kind); +ByteString class_name(Class); +ByteString type_name(Type); Optional parse_utc_time(StringView); Optional parse_generalized_time(StringView); diff --git a/Userland/Libraries/LibCrypto/Authentication/GHash.h b/Userland/Libraries/LibCrypto/Authentication/GHash.h index 6b1f955ceb4..e61a09b76b6 100644 --- a/Userland/Libraries/LibCrypto/Authentication/GHash.h +++ b/Userland/Libraries/LibCrypto/Authentication/GHash.h @@ -12,7 +12,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Authentication { @@ -48,7 +48,7 @@ public: constexpr static size_t digest_size() { return TagType::Size; } #ifndef KERNEL - DeprecatedString class_name() const + ByteString class_name() const { return "GHash"; } diff --git a/Userland/Libraries/LibCrypto/Authentication/HMAC.h b/Userland/Libraries/LibCrypto/Authentication/HMAC.h index 71b4e9732a2..29e353c6e8b 100644 --- a/Userland/Libraries/LibCrypto/Authentication/HMAC.h +++ b/Userland/Libraries/LibCrypto/Authentication/HMAC.h @@ -13,7 +13,7 @@ #include #ifndef KERNEL -# include +# include #endif constexpr static auto IPAD = 0x36; @@ -73,12 +73,12 @@ public: } #ifndef KERNEL - DeprecatedString class_name() const + ByteString class_name() const { StringBuilder builder; builder.append("HMAC-"sv); builder.append(m_inner_hasher.class_name()); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } #endif diff --git a/Userland/Libraries/LibCrypto/BigFraction/BigFraction.cpp b/Userland/Libraries/LibCrypto/BigFraction/BigFraction.cpp index f7694db5a76..97c2382def3 100644 --- a/Userland/Libraries/LibCrypto/BigFraction/BigFraction.cpp +++ b/Userland/Libraries/LibCrypto/BigFraction/BigFraction.cpp @@ -5,7 +5,7 @@ */ #include "BigFraction.h" -#include +#include #include #include #include @@ -184,7 +184,7 @@ void BigFraction::reduce() m_denominator = denominator_divide.quotient; } -DeprecatedString BigFraction::to_deprecated_string(unsigned rounding_threshold) const +ByteString BigFraction::to_byte_string(unsigned rounding_threshold) const { StringBuilder builder; if (m_numerator.is_negative() && m_numerator != "0"_bigint) @@ -239,7 +239,7 @@ DeprecatedString BigFraction::to_deprecated_string(unsigned rounding_threshold) builder.append(fractional_value); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } BigFraction BigFraction::sqrt() const diff --git a/Userland/Libraries/LibCrypto/BigFraction/BigFraction.h b/Userland/Libraries/LibCrypto/BigFraction/BigFraction.h index 25a8352ad9d..682fe9431dc 100644 --- a/Userland/Libraries/LibCrypto/BigFraction/BigFraction.h +++ b/Userland/Libraries/LibCrypto/BigFraction/BigFraction.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace Crypto { @@ -54,7 +54,7 @@ public: // - m_denominator = 10000 BigFraction rounded(unsigned rounding_threshold) const; - DeprecatedString to_deprecated_string(unsigned rounding_threshold) const; + ByteString to_byte_string(unsigned rounding_threshold) const; double to_double() const; private: diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp index 76421ed7082..1aca97dfc35 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp @@ -64,9 +64,9 @@ ErrorOr SignedBigInteger::to_base(u16 N) const return builder.to_string(); } -DeprecatedString SignedBigInteger::to_base_deprecated(u16 N) const +ByteString SignedBigInteger::to_base_deprecated(u16 N) const { - return MUST(to_base(N)).to_deprecated_string(); + return MUST(to_base(N)).to_byte_string(); } u64 SignedBigInteger::to_u64() const diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h index 83168baa973..f6100d8bc5d 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h @@ -65,7 +65,7 @@ public: [[nodiscard]] static SignedBigInteger from_base(u16 N, StringView str); [[nodiscard]] ErrorOr to_base(u16 N) const; - [[nodiscard]] DeprecatedString to_base_deprecated(u16 N) const; + [[nodiscard]] ByteString to_base_deprecated(u16 N) const; [[nodiscard]] u64 to_u64() const; [[nodiscard]] double to_double(UnsignedBigInteger::RoundingMode rounding_mode = UnsignedBigInteger::RoundingMode::IEEERoundAndTiesToEvenMantissa) const; diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp index 7b35a7451e0..041e92eb0da 100644 --- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp @@ -167,9 +167,9 @@ ErrorOr UnsignedBigInteger::to_base(u16 N) const return TRY(builder.to_string()).reverse(); } -DeprecatedString UnsignedBigInteger::to_base_deprecated(u16 N) const +ByteString UnsignedBigInteger::to_base_deprecated(u16 N) const { - return MUST(to_base(N)).to_deprecated_string(); + return MUST(to_base(N)).to_byte_string(); } u64 UnsignedBigInteger::to_u64() const diff --git a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h index 6fb7975b3c1..2df4652ec57 100644 --- a/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h +++ b/Userland/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h @@ -9,8 +9,8 @@ #pragma once #include +#include #include -#include #include #include #include @@ -65,7 +65,7 @@ public: [[nodiscard]] static UnsignedBigInteger from_base(u16 N, StringView str); [[nodiscard]] ErrorOr to_base(u16 N) const; - [[nodiscard]] DeprecatedString to_base_deprecated(u16 N) const; + [[nodiscard]] ByteString to_base_deprecated(u16 N) const; [[nodiscard]] u64 to_u64() const; diff --git a/Userland/Libraries/LibCrypto/Cipher/AES.cpp b/Userland/Libraries/LibCrypto/Cipher/AES.cpp index 3f5d8994538..1c63e5abb17 100644 --- a/Userland/Libraries/LibCrypto/Cipher/AES.cpp +++ b/Userland/Libraries/LibCrypto/Cipher/AES.cpp @@ -24,20 +24,20 @@ constexpr void swap_keys(u32* keys, size_t i, size_t j) } #ifndef KERNEL -DeprecatedString AESCipherBlock::to_deprecated_string() const +ByteString AESCipherBlock::to_byte_string() const { StringBuilder builder; for (auto value : m_data) builder.appendff("{:02x}", value); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } -DeprecatedString AESCipherKey::to_deprecated_string() const +ByteString AESCipherKey::to_byte_string() const { StringBuilder builder; for (size_t i = 0; i < (rounds() + 1) * 4; ++i) builder.appendff("{:02x}", m_rd_keys[i]); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } #endif diff --git a/Userland/Libraries/LibCrypto/Cipher/AES.h b/Userland/Libraries/LibCrypto/Cipher/AES.h index 3221b53eea5..835188c17cc 100644 --- a/Userland/Libraries/LibCrypto/Cipher/AES.h +++ b/Userland/Libraries/LibCrypto/Cipher/AES.h @@ -14,7 +14,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Cipher { @@ -48,7 +48,7 @@ public: } #ifndef KERNEL - DeprecatedString to_deprecated_string() const; + ByteString to_byte_string() const; #endif private: @@ -64,7 +64,7 @@ struct AESCipherKey : public CipherKey { static bool is_valid_key_size(size_t bits) { return bits == 128 || bits == 192 || bits == 256; } #ifndef KERNEL - DeprecatedString to_deprecated_string() const; + ByteString to_byte_string() const; #endif u32 const* round_keys() const @@ -120,7 +120,7 @@ public: virtual void decrypt_block(BlockType const& in, BlockType& out) override; #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { return "AES"; } diff --git a/Userland/Libraries/LibCrypto/Cipher/Cipher.h b/Userland/Libraries/LibCrypto/Cipher/Cipher.h index 6a9dee84b8a..acfcbc0dd9b 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Cipher.h +++ b/Userland/Libraries/LibCrypto/Cipher/Cipher.h @@ -112,7 +112,7 @@ public: virtual void decrypt_block(BlockType const& in, BlockType& out) = 0; #ifndef KERNEL - virtual DeprecatedString class_name() const = 0; + virtual ByteString class_name() const = 0; #endif protected: diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h index 69519d7f987..777121a4dba 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h @@ -11,7 +11,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Cipher { @@ -29,12 +29,12 @@ public: } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { StringBuilder builder; builder.append(this->cipher().class_name()); builder.append("_CBC"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } #endif diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h index 4c002f66a2f..7420d82ea25 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h @@ -11,7 +11,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Cipher { @@ -104,12 +104,12 @@ public: } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { StringBuilder builder; builder.append(this->cipher().class_name()); builder.append("_CTR"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } #endif diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h index 8f295a9f5f0..994fd609c15 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h @@ -15,7 +15,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Cipher { @@ -44,12 +44,12 @@ public: } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { StringBuilder builder; builder.append(this->cipher().class_name()); builder.append("_GCM"sv); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } #endif diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h b/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h index 6c8e554727c..c74a57fc1d0 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/Mode.h @@ -34,7 +34,7 @@ public: } #ifndef KERNEL - virtual DeprecatedString class_name() const = 0; + virtual ByteString class_name() const = 0; #endif T& cipher() diff --git a/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h b/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h index 463bbe233b4..756616a3bb2 100644 --- a/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h +++ b/Userland/Libraries/LibCrypto/Hash/BLAKE2b.h @@ -10,7 +10,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Hash { @@ -44,7 +44,7 @@ public: static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { return "BLAKE2b"; } diff --git a/Userland/Libraries/LibCrypto/Hash/HashFunction.h b/Userland/Libraries/LibCrypto/Hash/HashFunction.h index 0ea0df7f357..4848b947a37 100644 --- a/Userland/Libraries/LibCrypto/Hash/HashFunction.h +++ b/Userland/Libraries/LibCrypto/Hash/HashFunction.h @@ -55,7 +55,7 @@ public: virtual void reset() = 0; #ifndef KERNEL - virtual DeprecatedString class_name() const = 0; + virtual ByteString class_name() const = 0; #endif protected: diff --git a/Userland/Libraries/LibCrypto/Hash/HashManager.h b/Userland/Libraries/LibCrypto/Hash/HashManager.h index 9ff2bbd0ada..f2fc526877b 100644 --- a/Userland/Libraries/LibCrypto/Hash/HashManager.h +++ b/Userland/Libraries/LibCrypto/Hash/HashManager.h @@ -197,10 +197,10 @@ public: } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { return m_algorithm.visit( - [&](Empty const&) -> DeprecatedString { return "UninitializedHashManager"; }, + [&](Empty const&) -> ByteString { return "UninitializedHashManager"; }, [&](auto const& hash) { return hash.class_name(); }); } #endif diff --git a/Userland/Libraries/LibCrypto/Hash/MD5.h b/Userland/Libraries/LibCrypto/Hash/MD5.h index 01b1dc1096a..a732dcb99a2 100644 --- a/Userland/Libraries/LibCrypto/Hash/MD5.h +++ b/Userland/Libraries/LibCrypto/Hash/MD5.h @@ -10,7 +10,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Hash { @@ -56,7 +56,7 @@ public: virtual DigestType peek() override; #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { return "MD5"; } diff --git a/Userland/Libraries/LibCrypto/Hash/SHA1.h b/Userland/Libraries/LibCrypto/Hash/SHA1.h index e85a910878e..d70e5fc7b32 100644 --- a/Userland/Libraries/LibCrypto/Hash/SHA1.h +++ b/Userland/Libraries/LibCrypto/Hash/SHA1.h @@ -9,7 +9,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Hash { @@ -52,7 +52,7 @@ public: static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { return "SHA1"; } diff --git a/Userland/Libraries/LibCrypto/Hash/SHA2.h b/Userland/Libraries/LibCrypto/Hash/SHA2.h index f17c8e7aa09..87509ae0211 100644 --- a/Userland/Libraries/LibCrypto/Hash/SHA2.h +++ b/Userland/Libraries/LibCrypto/Hash/SHA2.h @@ -10,7 +10,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::Hash { @@ -100,9 +100,9 @@ public: static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { - return DeprecatedString::formatted("SHA{}", DigestSize * 8); + return ByteString::formatted("SHA{}", DigestSize * 8); } #endif @@ -152,9 +152,9 @@ public: static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { - return DeprecatedString::formatted("SHA{}", DigestSize * 8); + return ByteString::formatted("SHA{}", DigestSize * 8); } #endif @@ -204,9 +204,9 @@ public: static DigestType hash(StringView buffer) { return hash((u8 const*)buffer.characters_without_null_termination(), buffer.length()); } #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { - return DeprecatedString::formatted("SHA{}", DigestSize * 8); + return ByteString::formatted("SHA{}", DigestSize * 8); } #endif diff --git a/Userland/Libraries/LibCrypto/PK/PK.h b/Userland/Libraries/LibCrypto/PK/PK.h index 6a4ffaad24c..129328ec3ef 100644 --- a/Userland/Libraries/LibCrypto/PK/PK.h +++ b/Userland/Libraries/LibCrypto/PK/PK.h @@ -9,7 +9,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace Crypto::PK { @@ -36,7 +36,7 @@ public: virtual void verify(ReadonlyBytes in, Bytes& out) = 0; #ifndef KERNEL - virtual DeprecatedString class_name() const = 0; + virtual ByteString class_name() const = 0; #endif virtual size_t output_size() const = 0; diff --git a/Userland/Libraries/LibCrypto/PK/RSA.h b/Userland/Libraries/LibCrypto/PK/RSA.h index bfc7c9a368a..15229b451f5 100644 --- a/Userland/Libraries/LibCrypto/PK/RSA.h +++ b/Userland/Libraries/LibCrypto/PK/RSA.h @@ -162,7 +162,7 @@ public: virtual void verify(ReadonlyBytes in, Bytes& out) override; #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { return "RSA"; } @@ -214,7 +214,7 @@ public: virtual void verify(ReadonlyBytes, Bytes&) override; #ifndef KERNEL - virtual DeprecatedString class_name() const override + virtual ByteString class_name() const override { return "RSA_PKCS1-EME"; } diff --git a/Userland/Libraries/LibDNS/Answer.cpp b/Userland/Libraries/LibDNS/Answer.cpp index eb8d86e1746..68c1ce983a5 100644 --- a/Userland/Libraries/LibDNS/Answer.cpp +++ b/Userland/Libraries/LibDNS/Answer.cpp @@ -11,7 +11,7 @@ namespace DNS { -Answer::Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, DeprecatedString const& record_data, bool mdns_cache_flush) +Answer::Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, ByteString const& record_data, bool mdns_cache_flush) : m_name(name) , m_type(type) , m_class_code(class_code) @@ -115,11 +115,11 @@ ErrorOr encode(Encoder& encoder, DNS::Answer const& answer) template<> ErrorOr decode(Decoder& decoder) { - auto name = TRY(decoder.decode()); + auto name = TRY(decoder.decode()); auto record_type = TRY(decoder.decode()); auto class_code = TRY(decoder.decode()); auto ttl = TRY(decoder.decode()); - auto record_data = TRY(decoder.decode()); + auto record_data = TRY(decoder.decode()); auto cache_flush = TRY(decoder.decode()); return DNS::Answer { name, record_type, class_code, ttl, record_data, cache_flush }; diff --git a/Userland/Libraries/LibDNS/Answer.h b/Userland/Libraries/LibDNS/Answer.h index 73263315dbd..f7b49414b56 100644 --- a/Userland/Libraries/LibDNS/Answer.h +++ b/Userland/Libraries/LibDNS/Answer.h @@ -7,7 +7,7 @@ #pragma once #include "Name.h" -#include +#include #include #include #include @@ -36,7 +36,7 @@ enum class RecordClass : u16 { class Answer { public: Answer() = default; - Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, DeprecatedString const& record_data, bool mdns_cache_flush); + Answer(Name const& name, RecordType type, RecordClass class_code, u32 ttl, ByteString const& record_data, bool mdns_cache_flush); Name const& name() const { return m_name; } RecordType type() const { return m_type; } @@ -44,7 +44,7 @@ public: u16 raw_class_code() const { return (u16)m_class_code | (m_mdns_cache_flush ? MDNS_CACHE_FLUSH : 0); } u32 ttl() const { return m_ttl; } time_t received_time() const { return m_received_time; } - DeprecatedString const& record_data() const { return m_record_data; } + ByteString const& record_data() const { return m_record_data; } bool mdns_cache_flush() const { return m_mdns_cache_flush; } bool has_expired() const; @@ -58,7 +58,7 @@ private: RecordClass m_class_code { 0 }; u32 m_ttl { 0 }; time_t m_received_time { 0 }; - DeprecatedString m_record_data; + ByteString m_record_data; bool m_mdns_cache_flush { false }; }; diff --git a/Userland/Libraries/LibDNS/Name.cpp b/Userland/Libraries/LibDNS/Name.cpp index 0dfef512e3d..f0627f44926 100644 --- a/Userland/Libraries/LibDNS/Name.cpp +++ b/Userland/Libraries/LibDNS/Name.cpp @@ -13,7 +13,7 @@ namespace DNS { -Name::Name(DeprecatedString const& name) +Name::Name(ByteString const& name) { if (name.ends_with('.')) m_name = name.substring(0, name.length() - 1); @@ -38,7 +38,7 @@ ErrorOr Name::parse(ReadonlyBytes data, size_t& offset, size_t recursion_l if (builder.length() > MAX_NAME_SIZE) return Error::from_string_literal("Domain name exceeds maximum allowed length"); // This terminates the name. - return builder.to_deprecated_string(); + return builder.to_byte_string(); } else if ((b & 0xc0) == 0xc0) { // The two bytes tell us the offset when to continue from. if (offset >= data.size()) @@ -48,7 +48,7 @@ ErrorOr Name::parse(ReadonlyBytes data, size_t& offset, size_t recursion_l builder.append(rest_of_name.as_string()); if (builder.length() > MAX_NAME_SIZE) return Error::from_string_literal("Domain name exceeds maximum allowed length"); - return builder.to_deprecated_string(); + return builder.to_byte_string(); } else { // This is the length of a part. if (offset + b >= data.size()) @@ -84,7 +84,7 @@ void Name::randomize_case() } builder.append(c); } - m_name = builder.to_deprecated_string(); + m_name = builder.to_byte_string(); } ErrorOr Name::write_to_stream(Stream& stream) const diff --git a/Userland/Libraries/LibDNS/Name.h b/Userland/Libraries/LibDNS/Name.h index 66b8ceb28e5..29bbd39a496 100644 --- a/Userland/Libraries/LibDNS/Name.h +++ b/Userland/Libraries/LibDNS/Name.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include namespace DNS { @@ -15,12 +15,12 @@ namespace DNS { class Name { public: Name() = default; - Name(DeprecatedString const&); + Name(ByteString const&); static ErrorOr parse(ReadonlyBytes data, size_t& offset, size_t recursion_level = 0); size_t serialized_size() const; - DeprecatedString const& as_string() const { return m_name; } + ByteString const& as_string() const { return m_name; } ErrorOr write_to_stream(Stream&) const; void randomize_case(); @@ -34,7 +34,7 @@ public: }; private: - DeprecatedString m_name; + ByteString m_name; }; } diff --git a/Userland/Libraries/LibDNS/Packet.cpp b/Userland/Libraries/LibDNS/Packet.cpp index 8250f1efaf8..e829eaaf380 100644 --- a/Userland/Libraries/LibDNS/Packet.cpp +++ b/Userland/Libraries/LibDNS/Packet.cpp @@ -150,7 +150,7 @@ ErrorOr Packet::from_raw_packet(ReadonlyBytes bytes) if (record.data_length() > bytes.size() - offset) return Error::from_string_literal("Unexpected EOF when parsing DNS packet"); - DeprecatedString data; + ByteString data; switch ((RecordType)record.type()) { case RecordType::PTR: { diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index 71b0b0a4dec..ae885347aee 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -13,7 +13,7 @@ namespace Debug { -DebugInfo::DebugInfo(ELF::Image const& elf, DeprecatedString source_root, FlatPtr base_address) +DebugInfo::DebugInfo(ELF::Image const& elf, ByteString source_root, FlatPtr base_address) : m_elf(elf) , m_source_root(move(source_root)) , m_base_address(base_address) @@ -91,8 +91,8 @@ ErrorOr DebugInfo::prepare_lines() return {}; })); - HashMap> memoized_full_paths; - auto compute_full_path = [&](DeprecatedFlyString const& file_path) -> Optional { + HashMap> memoized_full_paths; + auto compute_full_path = [&](DeprecatedFlyString const& file_path) -> Optional { if (file_path.view().contains("Toolchain/"sv) || file_path.view().contains("libgcc"sv)) return {}; if (file_path.view().starts_with("./"sv) && !m_source_root.is_empty()) @@ -135,11 +135,11 @@ Optional DebugInfo::get_source_position(FlatPtr targe return {}; } -Optional DebugInfo::get_address_from_source_position(DeprecatedString const& file, size_t line) const +Optional DebugInfo::get_address_from_source_position(ByteString const& file, size_t line) const { - DeprecatedString file_path = file; + ByteString file_path = file; if (!file_path.starts_with('/')) - file_path = DeprecatedString::formatted("/{}", file_path); + file_path = ByteString::formatted("/{}", file_path); Optional result; for (auto const& line_entry : m_sorted_lines) { @@ -327,10 +327,10 @@ ErrorOr DebugInfo::add_type_info_to_variable(Dwarf::DIE const& type_die, P array_type_name.append(type_info->type_name); for (auto array_size : type_info->dimension_sizes) { array_type_name.append('['); - array_type_name.append(DeprecatedString::formatted("{:d}", array_size)); + array_type_name.append(ByteString::formatted("{:d}", array_size)); array_type_name.append(']'); } - parent_variable->type_name = array_type_name.to_deprecated_string(); + parent_variable->type_name = array_type_name.to_byte_string(); } parent_variable->type = move(type_info); parent_variable->type->type_tag = type_die.tag(); @@ -350,7 +350,7 @@ bool DebugInfo::is_variable_tag_supported(Dwarf::EntryTag const& tag) || tag == Dwarf::EntryTag::ArrayType; } -DeprecatedString DebugInfo::name_of_containing_function(FlatPtr address) const +ByteString DebugInfo::name_of_containing_function(FlatPtr address) const { auto function = get_containing_function(address); if (!function.has_value()) @@ -408,7 +408,7 @@ ErrorOr DebugInfo::get_source_position_wit return {}; } - inline_chain.append({ DeprecatedString::formatted("{}/{}", caller_source_path->directory, caller_source_path->filename), caller_line.value() }); + inline_chain.append({ ByteString::formatted("{}/{}", caller_source_path->directory, caller_source_path->filename), caller_line.value() }); return {}; }; diff --git a/Userland/Libraries/LibDebug/DebugInfo.h b/Userland/Libraries/LibDebug/DebugInfo.h index 6c344cae266..1fc11492d7f 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.h +++ b/Userland/Libraries/LibDebug/DebugInfo.h @@ -23,7 +23,7 @@ class DebugInfo { AK_MAKE_NONMOVABLE(DebugInfo); public: - explicit DebugInfo(ELF::Image const&, DeprecatedString source_root = {}, FlatPtr base_address = 0); + explicit DebugInfo(ELF::Image const&, ByteString source_root = {}, FlatPtr base_address = 0); ELF::Image const& elf() const { return m_elf; } @@ -33,15 +33,15 @@ public: Optional address_of_first_statement; SourcePosition() - : SourcePosition(DeprecatedString::empty(), 0) + : SourcePosition(ByteString::empty(), 0) { } - SourcePosition(DeprecatedString file_path, size_t line_number) + SourcePosition(ByteString file_path, size_t line_number) : file_path(file_path) , line_number(line_number) { } - SourcePosition(DeprecatedString file_path, size_t line_number, FlatPtr address_of_first_statement) + SourcePosition(ByteString file_path, size_t line_number, FlatPtr address_of_first_statement) : file_path(file_path) , line_number(line_number) , address_of_first_statement(address_of_first_statement) @@ -59,8 +59,8 @@ public: Address, Register, }; - DeprecatedString name; - DeprecatedString type_name; + ByteString name; + ByteString type_name; LocationType location_type { LocationType::None }; union { FlatPtr address; @@ -83,7 +83,7 @@ public: struct VariablesScope { bool is_function { false }; - DeprecatedString name; + ByteString name; FlatPtr address_low { 0 }; FlatPtr address_high { 0 }; // Non-inclusive - the lowest address after address_low that's not in this scope Vector dies_of_variables; @@ -100,14 +100,14 @@ public: ErrorOr get_source_position_with_inlines(FlatPtr address) const; struct SourcePositionAndAddress { - DeprecatedString file; + ByteString file; size_t line; FlatPtr address; }; - Optional get_address_from_source_position(DeprecatedString const& file, size_t line) const; + Optional get_address_from_source_position(ByteString const& file, size_t line) const; - DeprecatedString name_of_containing_function(FlatPtr address) const; + ByteString name_of_containing_function(FlatPtr address) const; Vector source_lines_in_scope(VariablesScope const&) const; Optional get_containing_function(FlatPtr address) const; @@ -123,7 +123,7 @@ private: ErrorOr> get_line_of_inline(Dwarf::DIE const&) const; ELF::Image const& m_elf; - DeprecatedString m_source_root; + ByteString m_source_root; FlatPtr m_base_address { 0 }; Dwarf::DwarfInfo m_dwarf_info; diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp index f9974d04e98..d6b0761a451 100644 --- a/Userland/Libraries/LibDebug/DebugSession.cpp +++ b/Userland/Libraries/LibDebug/DebugSession.cpp @@ -17,7 +17,7 @@ namespace Debug { -DebugSession::DebugSession(pid_t pid, DeprecatedString source_root, Function on_initialization_progress) +DebugSession::DebugSession(pid_t pid, ByteString source_root, Function on_initialization_progress) : m_debuggee_pid(pid) , m_source_root(source_root) , m_on_initialization_progress(move(on_initialization_progress)) @@ -53,8 +53,8 @@ void DebugSession::for_each_loaded_library(Function DebugSession::exec_and_attach(DeprecatedString const& command, - DeprecatedString source_root, +OwnPtr DebugSession::exec_and_attach(ByteString const& command, + ByteString source_root, Function()> setup_child, Function on_initialization_progress) { @@ -134,7 +134,7 @@ OwnPtr DebugSession::exec_and_attach(DeprecatedString const& comma return debug_session; } -OwnPtr DebugSession::attach(pid_t pid, DeprecatedString source_root, Function on_initialization_progress) +OwnPtr DebugSession::attach(pid_t pid, ByteString source_root, Function on_initialization_progress) { if (ptrace(PT_ATTACH, pid, 0, 0) < 0) { perror("PT_ATTACH"); @@ -415,7 +415,7 @@ void DebugSession::detach() continue_debuggee(); } -Optional DebugSession::insert_breakpoint(DeprecatedString const& symbol_name) +Optional DebugSession::insert_breakpoint(ByteString const& symbol_name) { Optional result; for_each_loaded_library([this, symbol_name, &result](auto& lib) { @@ -438,7 +438,7 @@ Optional DebugSession::insert_brea return result; } -Optional DebugSession::insert_breakpoint(DeprecatedString const& filename, size_t line_number) +Optional DebugSession::insert_breakpoint(ByteString const& filename, size_t line_number) { auto address_and_source_position = get_address_from_source_position(filename, line_number); if (!address_and_source_position.has_value()) @@ -466,17 +466,17 @@ ErrorOr DebugSession::update_loaded_libs() auto const& vm_entries = json.as_array(); Regex segment_name_re("(.+): "); - auto get_path_to_object = [&segment_name_re](DeprecatedString const& vm_name) -> Optional { + auto get_path_to_object = [&segment_name_re](ByteString const& vm_name) -> Optional { if (vm_name == "/usr/lib/Loader.so") return vm_name; RegexResult result; auto rc = segment_name_re.search(vm_name, result); if (!rc) return {}; - auto lib_name = result.capture_group_matches.at(0).at(0).view.string_view().to_deprecated_string(); + auto lib_name = result.capture_group_matches.at(0).at(0).view.string_view().to_byte_string(); if (lib_name.starts_with('/')) return lib_name; - return DeprecatedString::formatted("/usr/lib/{}", lib_name); + return ByteString::formatted("/usr/lib/{}", lib_name); }; ScopeGuard progress_guard([this]() { @@ -492,13 +492,13 @@ ErrorOr DebugSession::update_loaded_libs() m_on_initialization_progress(vm_entry_index / static_cast(vm_entries.size())); // TODO: check that region is executable - auto vm_name = entry.as_object().get_deprecated_string("name"sv).value(); + auto vm_name = entry.as_object().get_byte_string("name"sv).value(); auto object_path = get_path_to_object(vm_name); if (!object_path.has_value()) return IterationDecision::Continue; - DeprecatedString lib_name = object_path.value(); + ByteString lib_name = object_path.value(); if (FileSystem::looks_like_shared_library(lib_name)) lib_name = LexicalPath::basename(object_path.value()); diff --git a/Userland/Libraries/LibDebug/DebugSession.h b/Userland/Libraries/LibDebug/DebugSession.h index 24990ffeeea..cc1aef27c43 100644 --- a/Userland/Libraries/LibDebug/DebugSession.h +++ b/Userland/Libraries/LibDebug/DebugSession.h @@ -6,8 +6,8 @@ #pragma once +#include #include -#include #include #include #include @@ -27,8 +27,8 @@ namespace Debug { class DebugSession : public ProcessInspector { public: - static OwnPtr exec_and_attach(DeprecatedString const& command, DeprecatedString source_root = {}, Function()> setup_child = {}, Function on_initialization_progress = {}); - static OwnPtr attach(pid_t pid, DeprecatedString source_root = {}, Function on_initialization_progress = {}); + static OwnPtr exec_and_attach(ByteString const& command, ByteString source_root = {}, Function()> setup_child = {}, Function on_initialization_progress = {}); + static OwnPtr attach(pid_t pid, ByteString source_root = {}, Function on_initialization_progress = {}); virtual ~DebugSession() override; @@ -56,20 +56,20 @@ public: }; struct InsertBreakpointAtSymbolResult { - DeprecatedString library_name; + ByteString library_name; FlatPtr address { 0 }; }; - Optional insert_breakpoint(DeprecatedString const& symbol_name); + Optional insert_breakpoint(ByteString const& symbol_name); struct InsertBreakpointAtSourcePositionResult { - DeprecatedString library_name; - DeprecatedString filename; + ByteString library_name; + ByteString filename; size_t line_number { 0 }; FlatPtr address { 0 }; }; - Optional insert_breakpoint(DeprecatedString const& filename, size_t line_number); + Optional insert_breakpoint(ByteString const& filename, size_t line_number); bool insert_breakpoint(FlatPtr address); bool disable_breakpoint(FlatPtr address); @@ -132,7 +132,7 @@ public: }; private: - explicit DebugSession(pid_t, DeprecatedString source_root, Function on_initialization_progress = {}); + explicit DebugSession(pid_t, ByteString source_root, Function on_initialization_progress = {}); // x86 breakpoint instruction "int3" static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc; @@ -140,14 +140,14 @@ private: ErrorOr update_loaded_libs(); int m_debuggee_pid { -1 }; - DeprecatedString m_source_root; + ByteString m_source_root; bool m_is_debuggee_dead { false }; HashMap m_breakpoints; HashMap m_watchpoints; // Maps from library name to LoadedLibrary object - HashMap> m_loaded_libraries; + HashMap> m_loaded_libraries; Function m_on_initialization_progress; }; diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp index 8ca4e4c5a40..5c0d2626c47 100644 --- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp @@ -81,7 +81,7 @@ ErrorOr LineProgram::parse_path_entries(Function c StringBuilder builder; while (auto c = TRY(m_stream.read_value())) TRY(builder.try_append(c)); - auto path = builder.to_deprecated_string(); + auto path = builder.to_byte_string(); if (path.length() == 0) break; dbgln_if(DWARF_DEBUG, "path: {}", path); diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h index 69ce47b50c0..74061af564b 100644 --- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h +++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h @@ -95,7 +95,7 @@ struct PathEntryFormat { }; struct PathEntry { - DeprecatedString path; + ByteString path; size_t directory_index { 0 }; }; @@ -180,7 +180,7 @@ private: size_t m_unit_offset { 0 }; LineProgramUnitHeader32 m_unit_header {}; - Vector m_source_directories; + Vector m_source_directories; Vector m_source_files; // The registers of the "line program" virtual machine diff --git a/Userland/Libraries/LibDebug/LoadedLibrary.h b/Userland/Libraries/LibDebug/LoadedLibrary.h index 658b31b435e..f8efef2b62a 100644 --- a/Userland/Libraries/LibDebug/LoadedLibrary.h +++ b/Userland/Libraries/LibDebug/LoadedLibrary.h @@ -13,13 +13,13 @@ namespace Debug { struct LoadedLibrary { - DeprecatedString name; + ByteString name; NonnullOwnPtr file; NonnullOwnPtr image; NonnullOwnPtr debug_info; FlatPtr base_address {}; - LoadedLibrary(DeprecatedString const& name, NonnullOwnPtr file, NonnullOwnPtr image, NonnullOwnPtr&& debug_info, FlatPtr base_address) + LoadedLibrary(ByteString const& name, NonnullOwnPtr file, NonnullOwnPtr image, NonnullOwnPtr&& debug_info, FlatPtr base_address) : name(name) , file(move(file)) , image(move(image)) diff --git a/Userland/Libraries/LibDebug/ProcessInspector.cpp b/Userland/Libraries/LibDebug/ProcessInspector.cpp index a627a14f9de..5a564d97577 100644 --- a/Userland/Libraries/LibDebug/ProcessInspector.cpp +++ b/Userland/Libraries/LibDebug/ProcessInspector.cpp @@ -27,12 +27,12 @@ Optional ProcessInspector::symbolicate(Fl auto* lib = library_at(address); if (!lib) return {}; - // FIXME: ELF::Image symbolicate() API should return DeprecatedString::empty() if symbol is not found (It currently returns ??) + // FIXME: ELF::Image symbolicate() API should return ByteString::empty() if symbol is not found (It currently returns ??) auto symbol = lib->debug_info->elf().symbolicate(address - lib->base_address); return { { lib->name, symbol } }; } -Optional ProcessInspector::get_address_from_source_position(DeprecatedString const& file, size_t line) const +Optional ProcessInspector::get_address_from_source_position(ByteString const& file, size_t line) const { Optional result; for_each_loaded_library([file, line, &result](auto& lib) { diff --git a/Userland/Libraries/LibDebug/ProcessInspector.h b/Userland/Libraries/LibDebug/ProcessInspector.h index 8247f6bb193..4b6a388ae22 100644 --- a/Userland/Libraries/LibDebug/ProcessInspector.h +++ b/Userland/Libraries/LibDebug/ProcessInspector.h @@ -24,11 +24,11 @@ public: LoadedLibrary const* library_at(FlatPtr address) const; struct SymbolicationResult { - DeprecatedString library_name; - DeprecatedString symbol; + ByteString library_name; + ByteString symbol; }; Optional symbolicate(FlatPtr address) const; - Optional get_address_from_source_position(DeprecatedString const& file, size_t line) const; + Optional get_address_from_source_position(ByteString const& file, size_t line) const; Optional get_source_position(FlatPtr address) const; protected: diff --git a/Userland/Libraries/LibDesktop/AppFile.cpp b/Userland/Libraries/LibDesktop/AppFile.cpp index 00633f8e4f9..635682703d0 100644 --- a/Userland/Libraries/LibDesktop/AppFile.cpp +++ b/Userland/Libraries/LibDesktop/AppFile.cpp @@ -16,9 +16,9 @@ namespace Desktop { -DeprecatedString AppFile::app_file_path_for_app(StringView app_name) +ByteString AppFile::app_file_path_for_app(StringView app_name) { - return DeprecatedString::formatted("{}/{}.af", APP_FILES_DIRECTORY, app_name); + return ByteString::formatted("{}/{}.af", APP_FILES_DIRECTORY, app_name); } bool AppFile::exists_for_app(StringView app_name) @@ -45,7 +45,7 @@ void AppFile::for_each(Function)> callback, StringVi auto name = di.next_path(); if (!name.ends_with(".af"sv)) continue; - auto path = DeprecatedString::formatted("{}/{}", directory, name); + auto path = ByteString::formatted("{}/{}", directory, name); auto af = AppFile::open(path); if (!af->is_valid()) continue; @@ -68,36 +68,36 @@ bool AppFile::validate() const return true; } -DeprecatedString AppFile::name() const +ByteString AppFile::name() const { auto name = m_config->read_entry("App", "Name").trim_whitespace(); VERIFY(!name.is_empty()); return name; } -DeprecatedString AppFile::executable() const +ByteString AppFile::executable() const { auto executable = m_config->read_entry("App", "Executable").trim_whitespace(); VERIFY(!executable.is_empty()); return executable; } -DeprecatedString AppFile::description() const +ByteString AppFile::description() const { return m_config->read_entry("App", "Description").trim_whitespace(); } -DeprecatedString AppFile::category() const +ByteString AppFile::category() const { return m_config->read_entry("App", "Category").trim_whitespace(); } -DeprecatedString AppFile::working_directory() const +ByteString AppFile::working_directory() const { return m_config->read_entry("App", "WorkingDirectory").trim_whitespace(); } -DeprecatedString AppFile::icon_path() const +ByteString AppFile::icon_path() const { return m_config->read_entry("App", "IconPath").trim_whitespace(); } @@ -127,9 +127,9 @@ bool AppFile::exclude_from_system_menu() const return m_config->read_bool_entry("App", "ExcludeFromSystemMenu", false); } -Vector AppFile::launcher_mime_types() const +Vector AppFile::launcher_mime_types() const { - Vector mime_types; + Vector mime_types; for (auto& entry : m_config->read_entry("Launcher", "MimeTypes").split(',')) { entry = entry.trim_whitespace(); if (!entry.is_empty()) @@ -138,9 +138,9 @@ Vector AppFile::launcher_mime_types() const return mime_types; } -Vector AppFile::launcher_file_types() const +Vector AppFile::launcher_file_types() const { - Vector file_types; + Vector file_types; for (auto& entry : m_config->read_entry("Launcher", "FileTypes").split(',')) { entry = entry.trim_whitespace(); if (!entry.is_empty()) @@ -149,9 +149,9 @@ Vector AppFile::launcher_file_types() const return file_types; } -Vector AppFile::launcher_protocols() const +Vector AppFile::launcher_protocols() const { - Vector protocols; + Vector protocols; for (auto& entry : m_config->read_entry("Launcher", "Protocols").split(',')) { entry = entry.trim_whitespace(); if (!entry.is_empty()) diff --git a/Userland/Libraries/LibDesktop/AppFile.h b/Userland/Libraries/LibDesktop/AppFile.h index e132ea2cc66..1e1216d97cb 100644 --- a/Userland/Libraries/LibDesktop/AppFile.h +++ b/Userland/Libraries/LibDesktop/AppFile.h @@ -18,8 +18,8 @@ public: static constexpr auto APP_FILES_DIRECTORY = "/res/apps"sv; static bool exists_for_app(StringView app_name); - static DeprecatedString file_for_app(StringView app_name); - static DeprecatedString app_file_path_for_app(StringView app_name); + static ByteString file_for_app(StringView app_name); + static ByteString app_file_path_for_app(StringView app_name); static NonnullRefPtr get_for_app(StringView app_name); static NonnullRefPtr open(StringView path); @@ -27,21 +27,21 @@ public: ~AppFile() = default; bool is_valid() const { return m_valid; } - DeprecatedString filename() const { return m_config->filename(); } + ByteString filename() const { return m_config->filename(); } - DeprecatedString name() const; - DeprecatedString executable() const; - DeprecatedString category() const; - DeprecatedString description() const; - DeprecatedString working_directory() const; - DeprecatedString icon_path() const; + ByteString name() const; + ByteString executable() const; + ByteString category() const; + ByteString description() const; + ByteString working_directory() const; + ByteString icon_path() const; GUI::Icon icon() const; bool run_in_terminal() const; bool requires_root() const; bool exclude_from_system_menu() const; - Vector launcher_mime_types() const; - Vector launcher_file_types() const; - Vector launcher_protocols() const; + Vector launcher_mime_types() const; + Vector launcher_file_types() const; + Vector launcher_protocols() const; bool spawn(ReadonlySpan arguments = {}) const; private: diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index de182ddfea7..c30d2c520f2 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -13,14 +13,14 @@ namespace Desktop { -auto Launcher::Details::from_details_str(DeprecatedString const& details_str) -> NonnullRefPtr
+auto Launcher::Details::from_details_str(ByteString const& details_str) -> NonnullRefPtr
{ auto details = adopt_ref(*new Details); auto json = JsonValue::from_string(details_str).release_value_but_fixme_should_propagate_errors(); auto const& obj = json.as_object(); - details->executable = obj.get_deprecated_string("executable"sv).value_or({}); - details->name = obj.get_deprecated_string("name"sv).value_or({}); - if (auto type_value = obj.get_deprecated_string("type"sv); type_value.has_value()) { + details->executable = obj.get_byte_string("executable"sv).value_or({}); + details->name = obj.get_byte_string("name"sv).value_or({}); + if (auto type_value = obj.get_byte_string("type"sv); type_value.has_value()) { auto const& type_str = type_value.value(); if (type_str == "app") details->launcher_type = LauncherType::Application; @@ -62,7 +62,7 @@ ErrorOr Launcher::add_allowed_url(URL const& url) return {}; } -ErrorOr Launcher::add_allowed_handler_with_any_url(DeprecatedString const& handler) +ErrorOr Launcher::add_allowed_handler_with_any_url(ByteString const& handler) { auto response_or_error = connection().try_add_allowed_handler_with_any_url(handler); if (response_or_error.is_error()) @@ -70,7 +70,7 @@ ErrorOr Launcher::add_allowed_handler_with_any_url(DeprecatedString const& return {}; } -ErrorOr Launcher::add_allowed_handler_with_only_specific_urls(DeprecatedString const& handler, Vector const& urls) +ErrorOr Launcher::add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector const& urls) { auto response_or_error = connection().try_add_allowed_handler_with_only_specific_urls(handler, urls); if (response_or_error.is_error()) @@ -86,7 +86,7 @@ ErrorOr Launcher::seal_allowlist() return {}; } -bool Launcher::open(const URL& url, DeprecatedString const& handler_name) +bool Launcher::open(const URL& url, ByteString const& handler_name) { return connection().open_url(url, handler_name); } @@ -97,14 +97,14 @@ bool Launcher::open(const URL& url, Details const& details) return open(url, details.executable); } -Vector Launcher::get_handlers_for_url(const URL& url) +Vector Launcher::get_handlers_for_url(const URL& url) { - return connection().get_handlers_for_url(url.to_deprecated_string()); + return connection().get_handlers_for_url(url.to_byte_string()); } auto Launcher::get_handlers_with_details_for_url(const URL& url) -> Vector> { - auto details = connection().get_handlers_with_details_for_url(url.to_deprecated_string()); + auto details = connection().get_handlers_with_details_for_url(url.to_byte_string()); Vector> handlers_with_details; for (auto& value : details) { handlers_with_details.append(Details::from_details_str(value)); diff --git a/Userland/Libraries/LibDesktop/Launcher.h b/Userland/Libraries/LibDesktop/Launcher.h index 52f7a019ded..2ddddd306d4 100644 --- a/Userland/Libraries/LibDesktop/Launcher.h +++ b/Userland/Libraries/LibDesktop/Launcher.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -23,21 +23,21 @@ public: }; struct Details : public RefCounted
{ - DeprecatedString name; - DeprecatedString executable; + ByteString name; + ByteString executable; LauncherType launcher_type { LauncherType::Default }; - static NonnullRefPtr
from_details_str(DeprecatedString const&); + static NonnullRefPtr
from_details_str(ByteString const&); }; static void ensure_connection(); static ErrorOr add_allowed_url(URL const&); - static ErrorOr add_allowed_handler_with_any_url(DeprecatedString const& handler); - static ErrorOr add_allowed_handler_with_only_specific_urls(DeprecatedString const& handler, Vector const&); + static ErrorOr add_allowed_handler_with_any_url(ByteString const& handler); + static ErrorOr add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector const&); static ErrorOr seal_allowlist(); - static bool open(const URL&, DeprecatedString const& handler_name = {}); + static bool open(const URL&, ByteString const& handler_name = {}); static bool open(const URL&, Details const& details); - static Vector get_handlers_for_url(const URL&); + static Vector get_handlers_for_url(const URL&); static Vector> get_handlers_with_details_for_url(const URL&); }; diff --git a/Userland/Libraries/LibDiff/Format.cpp b/Userland/Libraries/LibDiff/Format.cpp index 7af72006f35..7fbb0b1bed8 100644 --- a/Userland/Libraries/LibDiff/Format.cpp +++ b/Userland/Libraries/LibDiff/Format.cpp @@ -8,14 +8,14 @@ #include "Format.h" #include -#include +#include #include #include #include #include namespace Diff { -DeprecatedString generate_only_additions(StringView text) +ByteString generate_only_additions(StringView text) { auto lines = text.split_view('\n', SplitBehavior::KeepEmpty); StringBuilder builder; @@ -23,7 +23,7 @@ DeprecatedString generate_only_additions(StringView text) for (auto const& line : lines) { builder.appendff("+{}\n", line); } - return builder.to_deprecated_string(); + return builder.to_byte_string(); } ErrorOr write_unified_header(StringView old_path, StringView new_path, Stream& stream) diff --git a/Userland/Libraries/LibDiff/Format.h b/Userland/Libraries/LibDiff/Format.h index 858e6d7c75d..7266e7b9244 100644 --- a/Userland/Libraries/LibDiff/Format.h +++ b/Userland/Libraries/LibDiff/Format.h @@ -13,7 +13,7 @@ namespace Diff { -DeprecatedString generate_only_additions(StringView); +ByteString generate_only_additions(StringView); enum class ColorOutput { Yes, diff --git a/Userland/Libraries/LibDiff/Hunks.cpp b/Userland/Libraries/LibDiff/Hunks.cpp index 205b3d67783..3f3b9448e99 100644 --- a/Userland/Libraries/LibDiff/Hunks.cpp +++ b/Userland/Libraries/LibDiff/Hunks.cpp @@ -65,7 +65,7 @@ ErrorOr Parser::parse_file_line(Optional const& strip_count) // No strip count given. Default to basename of file. if (!strip_count.has_value()) - return String::from_deprecated_string(LexicalPath::basename(path)); + return String::from_byte_string(LexicalPath::basename(path)); // NOTE: We cannot use LexicalPath::parts as we want to strip the non-canonicalized path. auto const& parts = path.split_view('/'); diff --git a/Userland/Libraries/LibEDID/DMT.cpp b/Userland/Libraries/LibEDID/DMT.cpp index a145e3a0fa4..6ce87d36ead 100644 --- a/Userland/Libraries/LibEDID/DMT.cpp +++ b/Userland/Libraries/LibEDID/DMT.cpp @@ -7,7 +7,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace EDID { @@ -120,11 +120,11 @@ u32 DMT::MonitorTiming::refresh_rate_hz() const } #ifndef KERNEL -DeprecatedString DMT::MonitorTiming::name() const +ByteString DMT::MonitorTiming::name() const { if (scan_type == ScanType::Interlaced) - return DeprecatedString::formatted("{} x {} @ {}Hz (Interlaced)", horizontal_pixels, vertical_lines, refresh_rate_hz()); - return DeprecatedString::formatted("{} x {} @ {}Hz", horizontal_pixels, vertical_lines, refresh_rate_hz()); + return ByteString::formatted("{} x {} @ {}Hz (Interlaced)", horizontal_pixels, vertical_lines, refresh_rate_hz()); + return ByteString::formatted("{} x {} @ {}Hz", horizontal_pixels, vertical_lines, refresh_rate_hz()); } #endif diff --git a/Userland/Libraries/LibEDID/DMT.h b/Userland/Libraries/LibEDID/DMT.h index a5c7de82b80..10d50ce64f0 100644 --- a/Userland/Libraries/LibEDID/DMT.h +++ b/Userland/Libraries/LibEDID/DMT.h @@ -54,7 +54,7 @@ public: FixedPoint<16, u32> vertical_frequency_hz() const; u32 refresh_rate_hz() const; #ifndef KERNEL - DeprecatedString name() const; + ByteString name() const; #endif }; diff --git a/Userland/Libraries/LibEDID/EDID.cpp b/Userland/Libraries/LibEDID/EDID.cpp index 940399643a1..0a2d3f1eaf9 100644 --- a/Userland/Libraries/LibEDID/EDID.cpp +++ b/Userland/Libraries/LibEDID/EDID.cpp @@ -227,7 +227,7 @@ ErrorOr Parser::from_display_connector_device(int display_connector_fd) return from_bytes(move(edid_byte_buffer)); } -ErrorOr Parser::from_display_connector_device(DeprecatedString const& display_connector_device) +ErrorOr Parser::from_display_connector_device(ByteString const& display_connector_device) { int display_connector_fd = open(display_connector_device.characters(), O_RDWR | O_CLOEXEC); if (display_connector_fd < 0) { @@ -314,7 +314,7 @@ ErrorOr Parser::parse() #ifdef KERNEL m_version = TRY(Kernel::KString::formatted("1.{}", (int)m_revision)); #else - m_version = DeprecatedString::formatted("1.{}", (int)m_revision); + m_version = ByteString::formatted("1.{}", (int)m_revision); #endif u8 checksum = 0x0; @@ -420,7 +420,7 @@ StringView Parser::legacy_manufacturer_id() const } #ifndef KERNEL -DeprecatedString Parser::manufacturer_name() const +ByteString Parser::manufacturer_name() const { if (!m_legacy_manufacturer_id_valid) return "Unknown"; @@ -998,9 +998,9 @@ ErrorOr Parser::for_each_display_descriptor(Function #else -# include +# include #endif namespace EDID { @@ -87,12 +87,12 @@ public: #ifndef KERNEL static ErrorOr from_display_connector_device(int); - static ErrorOr from_display_connector_device(DeprecatedString const&); + static ErrorOr from_display_connector_device(ByteString const&); #endif StringView legacy_manufacturer_id() const; #ifndef KERNEL - DeprecatedString manufacturer_name() const; + ByteString manufacturer_name() const; #endif u16 product_code() const; @@ -367,8 +367,8 @@ public: Optional detailed_timing(size_t) const; #ifndef KERNEL - DeprecatedString display_product_name() const; - DeprecatedString display_product_serial_number() const; + ByteString display_product_name() const; + ByteString display_product_serial_number() const; #endif ErrorOr for_each_short_video_descriptor(Function) const; @@ -455,7 +455,7 @@ private: #ifdef KERNEL OwnPtr m_version; #else - DeprecatedString m_version; + ByteString m_version; #endif char m_legacy_manufacturer_id[4] {}; bool m_legacy_manufacturer_id_valid { false }; diff --git a/Userland/Libraries/LibELF/Core.h b/Userland/Libraries/LibELF/Core.h index 3d1b4f17ef4..ac0ac5962d8 100644 --- a/Userland/Libraries/LibELF/Core.h +++ b/Userland/Libraries/LibELF/Core.h @@ -10,7 +10,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace ELF::Core { @@ -39,9 +39,9 @@ struct [[gnu::packed]] ProcessInfo { // Keys: // - "pid" (int) // - "termination_signal" (u8) - // - "executable_path" (DeprecatedString) - // - "arguments" (Vector) - // - "environment" (Vector) + // - "executable_path" (ByteString) + // - "arguments" (Vector) + // - "environment" (Vector) char json_data[]; // Null terminated }; @@ -59,7 +59,7 @@ struct [[gnu::packed]] MemoryRegionInfo { char region_name[]; // Null terminated #ifndef KERNEL - DeprecatedString object_name() const + ByteString object_name() const { StringView memory_region_name { region_name, strlen(region_name) }; if (memory_region_name.contains("Loader.so"sv)) @@ -67,7 +67,7 @@ struct [[gnu::packed]] MemoryRegionInfo { auto maybe_colon_index = memory_region_name.find(':'); if (!maybe_colon_index.has_value()) return {}; - return memory_region_name.substring_view(0, *maybe_colon_index).to_deprecated_string(); + return memory_region_name.substring_view(0, *maybe_colon_index).to_byte_string(); } #endif }; diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp index 46ee7aebba7..e00f1fe3cb0 100644 --- a/Userland/Libraries/LibELF/DynamicLinker.cpp +++ b/Userland/Libraries/LibELF/DynamicLinker.cpp @@ -36,12 +36,12 @@ namespace ELF { -static HashMap> s_loaders; -static DeprecatedString s_main_program_path; +static HashMap> s_loaders; +static ByteString s_main_program_path; // Dependencies have to always be added after the object that depends on them in `s_global_objects`. // This is needed for calling the destructors in the correct order. -static OrderedHashMap> s_global_objects; +static OrderedHashMap> s_global_objects; using EntryPointFunction = int (*)(int, char**, char**); using LibCExitFunction = void (*)(int); @@ -57,13 +57,13 @@ static size_t s_allocated_tls_block_size = 0; static char** s_envp = nullptr; static LibCExitFunction s_libc_exit = nullptr; static __pthread_mutex_t s_loader_lock = __PTHREAD_MUTEX_INITIALIZER; -static DeprecatedString s_cwd; +static ByteString s_cwd; static bool s_allowed_to_check_environment_variables { false }; static bool s_do_breakpoint_trap_before_entry { false }; static StringView s_ld_library_path; static StringView s_main_program_pledge_promises; -static DeprecatedString s_loader_pledge_promises; +static ByteString s_loader_pledge_promises; static Result __dlclose(void* handle); static Result __dlopen(char const* filename, int flags); @@ -90,7 +90,7 @@ Optional DynamicLinker::lookup_global_symbol( return weak_result; } -static Result, DlErrorMessage> map_library(DeprecatedString const& filepath, int fd) +static Result, DlErrorMessage> map_library(ByteString const& filepath, int fd) { VERIFY(filepath.starts_with('/')); @@ -110,7 +110,7 @@ static Result, DlErrorMessage> map_library(Deprecat return loader; } -Optional DynamicLinker::resolve_library(DeprecatedString const& name, DynamicObject const& parent_object) +Optional DynamicLinker::resolve_library(ByteString const& name, DynamicObject const& parent_object) { // Absolute and relative (to the current working directory) paths are already considered resolved. // However, ensure that the returned path is absolute and canonical, so pass it through LexicalPath. @@ -135,7 +135,7 @@ Optional DynamicLinker::resolve_library(DeprecatedString const for (auto const& search_path : search_paths) { LexicalPath library_path(search_path.replace("$ORIGIN"sv, LexicalPath::dirname(parent_object.filepath()), ReplaceMode::FirstOnly)); - DeprecatedString library_name = library_path.append(name).string(); + ByteString library_name = library_path.append(name).string(); if (access(library_name.characters(), F_OK) == 0) { if (!library_name.starts_with('/')) { @@ -152,24 +152,24 @@ Optional DynamicLinker::resolve_library(DeprecatedString const return {}; } -static Result, DlErrorMessage> map_library(DeprecatedString const& path) +static Result, DlErrorMessage> map_library(ByteString const& path) { VERIFY(path.starts_with('/')); int fd = open(path.characters(), O_RDONLY); if (fd < 0) - return DlErrorMessage { DeprecatedString::formatted("Could not open shared library '{}': {}", path, strerror(errno)) }; + return DlErrorMessage { ByteString::formatted("Could not open shared library '{}': {}", path, strerror(errno)) }; return map_library(path, fd); } -static Vector get_dependencies(DeprecatedString const& path) +static Vector get_dependencies(ByteString const& path) { VERIFY(path.starts_with('/')); auto name = LexicalPath::basename(path); auto lib = s_loaders.get(path).value(); - Vector dependencies; + Vector dependencies; lib->for_each_needed_library([&dependencies, &name](auto needed_name) { if (name == needed_name) @@ -179,7 +179,7 @@ static Vector get_dependencies(DeprecatedString const& path) return dependencies; } -static Result map_dependencies(DeprecatedString const& path) +static Result map_dependencies(ByteString const& path) { VERIFY(path.starts_with('/')); @@ -193,7 +193,7 @@ static Result map_dependencies(DeprecatedString const& pat auto dependency_path = DynamicLinker::resolve_library(needed_name, parent_object); if (!dependency_path.has_value()) - return DlErrorMessage { DeprecatedString::formatted("Could not find required shared library: {}", needed_name) }; + return DlErrorMessage { ByteString::formatted("Could not find required shared library: {}", needed_name) }; if (!s_loaders.contains(dependency_path.value()) && !s_global_objects.contains(dependency_path.value())) { auto loader = TRY(map_library(dependency_path.value())); @@ -321,7 +321,7 @@ static void initialize_libc(DynamicObject& libc) } template -static void for_each_unfinished_dependency_of(DeprecatedString const& path, HashTable& seen_names, Callback callback) +static void for_each_unfinished_dependency_of(ByteString const& path, HashTable& seen_names, Callback callback) { VERIFY(path.starts_with('/')); @@ -356,11 +356,11 @@ static void for_each_unfinished_dependency_of(DeprecatedString const& path, Hash callback(*s_loaders.get(path).value()); } -static Vector> collect_loaders_for_library(DeprecatedString const& path) +static Vector> collect_loaders_for_library(ByteString const& path) { VERIFY(path.starts_with('/')); - HashTable seen_names; + HashTable seen_names; Vector> loaders; for_each_unfinished_dependency_of(path, seen_names, [&](auto& loader) { loaders.append(loader); @@ -375,7 +375,7 @@ static void drop_loader_promise(StringView promise_to_drop) s_loader_pledge_promises = s_loader_pledge_promises.replace(promise_to_drop, ""sv, ReplaceMode::All); - auto extended_promises = DeprecatedString::formatted("{} {}", s_main_program_pledge_promises, s_loader_pledge_promises); + auto extended_promises = ByteString::formatted("{} {}", s_main_program_pledge_promises, s_loader_pledge_promises); Syscall::SC_pledge_params params { { extended_promises.characters(), extended_promises.length() }, { nullptr, 0 }, @@ -387,7 +387,7 @@ static void drop_loader_promise(StringView promise_to_drop) } } -static Result link_main_library(DeprecatedString const& path, int flags) +static Result link_main_library(ByteString const& path, int flags) { VERIFY(path.starts_with('/')); @@ -400,7 +400,7 @@ static Result link_main_library(DeprecatedString const& pa for (auto& loader : loaders) { bool success = loader->link(flags); if (!success) { - return DlErrorMessage { DeprecatedString::formatted("Failed to link library {}", loader->filepath()) }; + return DlErrorMessage { ByteString::formatted("Failed to link library {}", loader->filepath()) }; } } @@ -503,7 +503,7 @@ static Result __dlopen(char const* filename, int flags) auto library_path = (filename ? DynamicLinker::resolve_library(filename, parent_object) : s_main_program_path); if (!library_path.has_value()) - return DlErrorMessage { DeprecatedString::formatted("Could not find required shared library: {}", filename) }; + return DlErrorMessage { ByteString::formatted("Could not find required shared library: {}", filename) }; auto existing_elf_object = s_global_objects.get(library_path.value()); if (existing_elf_object.has_value()) { @@ -552,7 +552,7 @@ static Result __dlsym(void* handle, char const* symbol_na } if (!symbol.has_value()) - return DlErrorMessage { DeprecatedString::formatted("Symbol {} not found", symbol_name_view) }; + return DlErrorMessage { ByteString::formatted("Symbol {} not found", symbol_name_view) }; if (symbol.value().type == STT_GNU_IFUNC) return (void*)reinterpret_cast(symbol.value().address.as_ptr())(); @@ -656,7 +656,7 @@ static void read_environment_variables() } } -void ELF::DynamicLinker::linker_main(DeprecatedString&& main_program_path, int main_program_fd, bool is_secure, int argc, char** argv, char** envp) +void ELF::DynamicLinker::linker_main(ByteString&& main_program_path, int main_program_fd, bool is_secure, int argc, char** argv, char** envp) { VERIFY(main_program_path.starts_with('/')); diff --git a/Userland/Libraries/LibELF/DynamicLinker.h b/Userland/Libraries/LibELF/DynamicLinker.h index 4cfa7a6419d..9dbdeb9a759 100644 --- a/Userland/Libraries/LibELF/DynamicLinker.h +++ b/Userland/Libraries/LibELF/DynamicLinker.h @@ -15,9 +15,9 @@ namespace ELF { class DynamicLinker { public: static Optional lookup_global_symbol(StringView symbol); - [[noreturn]] static void linker_main(DeprecatedString&& main_program_path, int fd, bool is_secure, int argc, char** argv, char** envp); + [[noreturn]] static void linker_main(ByteString&& main_program_path, int fd, bool is_secure, int argc, char** argv, char** envp); - static Optional resolve_library(DeprecatedString const& name, DynamicObject const& parent_object); + static Optional resolve_library(ByteString const& name, DynamicObject const& parent_object); private: DynamicLinker() = delete; diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp index bddae314d0f..6220989c426 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.cpp +++ b/Userland/Libraries/LibELF/DynamicLoader.cpp @@ -44,7 +44,7 @@ void* __tlsdesc_static(void*); namespace ELF { -Result, DlErrorMessage> DynamicLoader::try_create(int fd, DeprecatedString filepath) +Result, DlErrorMessage> DynamicLoader::try_create(int fd, ByteString filepath) { VERIFY(filepath.starts_with('/')); @@ -56,9 +56,9 @@ Result, DlErrorMessage> DynamicLoader::try_create(i VERIFY(stat.st_size >= 0); auto size = static_cast(stat.st_size); if (size < sizeof(Elf_Ehdr)) - return DlErrorMessage { DeprecatedString::formatted("File {} has invalid ELF header", filepath) }; + return DlErrorMessage { ByteString::formatted("File {} has invalid ELF header", filepath) }; - DeprecatedString file_mmap_name = DeprecatedString::formatted("ELF_DYN: {}", filepath); + ByteString file_mmap_name = ByteString::formatted("ELF_DYN: {}", filepath); auto* data = mmap_with_name(nullptr, size, PROT_READ, MAP_SHARED, fd, 0, file_mmap_name.characters()); if (data == MAP_FAILED) { return DlErrorMessage { "DynamicLoader::try_create mmap" }; @@ -70,7 +70,7 @@ Result, DlErrorMessage> DynamicLoader::try_create(i return loader; } -DynamicLoader::DynamicLoader(int fd, DeprecatedString filepath, void* data, size_t size) +DynamicLoader::DynamicLoader(int fd, ByteString filepath, void* data, size_t size) : m_filepath(move(filepath)) , m_file_size(size) , m_image_fd(fd) @@ -293,19 +293,19 @@ Result, DlErrorMessage> DynamicLoader::load_stage_3 // If we don't have textrels, .text has already been made executable by this point in load_stage_2. for (auto& text_segment : m_text_segments) { if (mprotect(text_segment.address().as_ptr(), text_segment.size(), PROT_READ | PROT_EXEC) < 0) { - return DlErrorMessage { DeprecatedString::formatted("mprotect .text: PROT_READ | PROT_EXEC: {}", strerror(errno)) }; + return DlErrorMessage { ByteString::formatted("mprotect .text: PROT_READ | PROT_EXEC: {}", strerror(errno)) }; } } } if (m_relro_segment_size) { if (mprotect(m_relro_segment_address.as_ptr(), m_relro_segment_size, PROT_READ) < 0) { - return DlErrorMessage { DeprecatedString::formatted("mprotect .relro: PROT_READ: {}", strerror(errno)) }; + return DlErrorMessage { ByteString::formatted("mprotect .relro: PROT_READ: {}", strerror(errno)) }; } #ifdef AK_OS_SERENITY - if (set_mmap_name(m_relro_segment_address.as_ptr(), m_relro_segment_size, DeprecatedString::formatted("{}: .relro", m_filepath).characters()) < 0) { - return DlErrorMessage { DeprecatedString::formatted("set_mmap_name .relro: {}", strerror(errno)) }; + if (set_mmap_name(m_relro_segment_address.as_ptr(), m_relro_segment_size, ByteString::formatted("{}: .relro", m_filepath).characters()) < 0) { + return DlErrorMessage { ByteString::formatted("set_mmap_name .relro: {}", strerror(errno)) }; } #endif } @@ -388,7 +388,7 @@ void DynamicLoader::load_program_headers() } // Now that we can't accidentally block our requested space, re-map our ELF image. - DeprecatedString file_mmap_name = DeprecatedString::formatted("ELF_DYN: {}", m_filepath); + ByteString file_mmap_name = ByteString::formatted("ELF_DYN: {}", m_filepath); auto* data = mmap_with_name(nullptr, m_file_size, PROT_READ, MAP_SHARED, m_image_fd, 0, file_mmap_name.characters()); if (data == MAP_FAILED) { perror("mmap new mapping"); @@ -444,9 +444,9 @@ void DynamicLoader::load_program_headers() // Pre-allocate any malloc memory needed before unmapping the reservation. // We don't want any future malloc to accidentally mmap a reserved address! - DeprecatedString text_segment_name = DeprecatedString::formatted("{}: .text", m_filepath); - DeprecatedString rodata_segment_name = DeprecatedString::formatted("{}: .rodata", m_filepath); - DeprecatedString data_segment_name = DeprecatedString::formatted("{}: .data", m_filepath); + ByteString text_segment_name = ByteString::formatted("{}: .text", m_filepath); + ByteString rodata_segment_name = ByteString::formatted("{}: .rodata", m_filepath); + ByteString data_segment_name = ByteString::formatted("{}: .data", m_filepath); m_text_segments.ensure_capacity(map_regions.size()); diff --git a/Userland/Libraries/LibELF/DynamicLoader.h b/Userland/Libraries/LibELF/DynamicLoader.h index cc00ac1d204..14ad59865d9 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.h +++ b/Userland/Libraries/LibELF/DynamicLoader.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include @@ -49,10 +49,10 @@ extern "C" FlatPtr _fixup_plt_entry(DynamicObject* object, u32 relocation_offset class DynamicLoader : public RefCounted { public: - static Result, DlErrorMessage> try_create(int fd, DeprecatedString filepath); + static Result, DlErrorMessage> try_create(int fd, ByteString filepath); ~DynamicLoader(); - DeprecatedString const& filepath() const { return m_filepath; } + ByteString const& filepath() const { return m_filepath; } bool is_valid() const { return m_valid; } @@ -94,7 +94,7 @@ public: bool is_fully_initialized() const { return m_fully_initialized; } private: - DynamicLoader(int fd, DeprecatedString filepath, void* file_data, size_t file_size); + DynamicLoader(int fd, ByteString filepath, void* file_data, size_t file_size); class ProgramHeaderRegion { public: @@ -153,7 +153,7 @@ private: void do_relr_relocations(); void find_tls_size_and_alignment(); - DeprecatedString m_filepath; + ByteString m_filepath; size_t m_file_size { 0 }; int m_image_fd { -1 }; void* m_file_data { nullptr }; diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp index 082710f8e64..f68e65144f4 100644 --- a/Userland/Libraries/LibELF/DynamicObject.cpp +++ b/Userland/Libraries/LibELF/DynamicObject.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include -#include #include #include #include @@ -16,7 +16,7 @@ namespace ELF { -DynamicObject::DynamicObject(DeprecatedString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address) +DynamicObject::DynamicObject(ByteString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address) : m_filepath(filepath) , m_base_address(base_address) , m_dynamic_address(dynamic_section_address) @@ -58,7 +58,7 @@ void DynamicObject::dump() const size_t num_dynamic_sections = 0; for_each_dynamic_entry([&](DynamicObject::DynamicEntry const& entry) { - DeprecatedString name_field = DeprecatedString::formatted("({})", name_for_dtag(entry.tag())); + ByteString name_field = ByteString::formatted("({})", name_for_dtag(entry.tag())); builder.appendff("{:#08x} {:17} {:#08x}\n", entry.tag(), name_field, entry.val()); num_dynamic_sections++; }); @@ -508,7 +508,7 @@ auto DynamicObject::lookup_symbol(HashSymbol const& symbol) const -> Optional DynamicObject::create(DeprecatedString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address) +NonnullRefPtr DynamicObject::create(ByteString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address) { return adopt_ref(*new DynamicObject(filepath, base_address, dynamic_section_address)); } diff --git a/Userland/Libraries/LibELF/DynamicObject.h b/Userland/Libraries/LibELF/DynamicObject.h index 2a08fec5fa5..8d10edc955e 100644 --- a/Userland/Libraries/LibELF/DynamicObject.h +++ b/Userland/Libraries/LibELF/DynamicObject.h @@ -9,8 +9,8 @@ #pragma once #include +#include #include -#include #include #include #include @@ -20,7 +20,7 @@ namespace ELF { class DynamicObject : public RefCounted { public: - static NonnullRefPtr create(DeprecatedString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address); + static NonnullRefPtr create(ByteString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address); static char const* name_for_dtag(Elf_Sword d_tag); ~DynamicObject(); @@ -284,7 +284,7 @@ public: VirtualAddress plt_got_base_address() const { return m_base_address.offset(m_procedure_linkage_table_offset.value()); } VirtualAddress base_address() const { return m_base_address; } - DeprecatedString const& filepath() const { return m_filepath; } + ByteString const& filepath() const { return m_filepath; } StringView rpath() const { return m_has_rpath ? symbol_string_table_string(m_rpath_index) : StringView {}; } StringView runpath() const { return m_has_runpath ? symbol_string_table_string(m_runpath_index) : StringView {}; } @@ -332,13 +332,13 @@ public: void* symbol_for_name(StringView name); private: - explicit DynamicObject(DeprecatedString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address); + explicit DynamicObject(ByteString const& filepath, VirtualAddress base_address, VirtualAddress dynamic_section_address); StringView symbol_string_table_string(Elf_Word) const; char const* raw_symbol_string_table_string(Elf_Word) const; void parse(); - DeprecatedString m_filepath; + ByteString m_filepath; VirtualAddress m_base_address; VirtualAddress m_dynamic_address; diff --git a/Userland/Libraries/LibELF/Image.cpp b/Userland/Libraries/LibELF/Image.cpp index 6b662949140..98c31705087 100644 --- a/Userland/Libraries/LibELF/Image.cpp +++ b/Userland/Libraries/LibELF/Image.cpp @@ -438,7 +438,7 @@ NEVER_INLINE void Image::sort_symbols() const }); } -DeprecatedString Image::symbolicate(FlatPtr address, u32* out_offset) const +ByteString Image::symbolicate(FlatPtr address, u32* out_offset) const { auto symbol_count = this->symbol_count(); if (!symbol_count) { @@ -462,7 +462,7 @@ DeprecatedString Image::symbolicate(FlatPtr address, u32* out_offset) const *out_offset = address - symbol->address; return demangled_name; } - return DeprecatedString::formatted("{} +{:#x}", demangled_name, address - symbol->address); + return ByteString::formatted("{} +{:#x}", demangled_name, address - symbol->address); } #endif diff --git a/Userland/Libraries/LibELF/Image.h b/Userland/Libraries/LibELF/Image.h index 4ca5244b763..fcd3c5248c4 100644 --- a/Userland/Libraries/LibELF/Image.h +++ b/Userland/Libraries/LibELF/Image.h @@ -13,7 +13,7 @@ #include #ifndef KERNEL -# include +# include #endif namespace ELF { @@ -221,7 +221,7 @@ public: bool has_symbols() const { return symbol_count(); } #ifndef KERNEL Optional find_demangled_function(StringView name) const; - DeprecatedString symbolicate(FlatPtr address, u32* offset = nullptr) const; + ByteString symbolicate(FlatPtr address, u32* offset = nullptr) const; #endif Optional find_symbol(FlatPtr address, u32* offset = nullptr) const; @@ -246,7 +246,7 @@ private: struct SortedSymbol { FlatPtr address; StringView name; - DeprecatedString demangled_name; + ByteString demangled_name; Optional symbol; }; diff --git a/Userland/Libraries/LibFileSystem/FileSystem.cpp b/Userland/Libraries/LibFileSystem/FileSystem.cpp index e63ff317cb1..cbae433f043 100644 --- a/Userland/Libraries/LibFileSystem/FileSystem.cpp +++ b/Userland/Libraries/LibFileSystem/FileSystem.cpp @@ -26,7 +26,7 @@ namespace FileSystem { ErrorOr current_working_directory() { auto cwd = TRY(Core::System::getcwd()); - return TRY(String::from_deprecated_string({ cwd })); + return TRY(String::from_byte_string({ cwd })); } ErrorOr absolute_path(StringView path) @@ -35,12 +35,12 @@ ErrorOr absolute_path(StringView path) return TRY(real_path(path)); if (path.starts_with("/"sv)) - return TRY(String::from_deprecated_string(LexicalPath::canonicalized_path(path))); + return TRY(String::from_byte_string(LexicalPath::canonicalized_path(path))); auto working_directory = TRY(current_working_directory()); auto full_path = LexicalPath::join(working_directory, path).string(); - return TRY(String::from_deprecated_string(LexicalPath::canonicalized_path(full_path))); + return TRY(String::from_byte_string(LexicalPath::canonicalized_path(full_path))); } ErrorOr real_path(StringView path) @@ -48,7 +48,7 @@ ErrorOr real_path(StringView path) if (path.is_null()) return Error::from_errno(ENOENT); - DeprecatedString dep_path = path; + ByteString dep_path = path; char* real_path = realpath(dep_path.characters(), nullptr); ScopeGuard free_path = [real_path]() { free(real_path); }; @@ -182,11 +182,11 @@ static ErrorOr get_duplicate_file_name(StringView path) LexicalPath lexical_path(path); auto parent_path = LexicalPath::canonicalized_path(lexical_path.dirname()); auto basename = lexical_path.basename(); - auto current_name = TRY(String::from_deprecated_string(LexicalPath::join(parent_path, basename).string())); + auto current_name = TRY(String::from_byte_string(LexicalPath::join(parent_path, basename).string())); while (exists(current_name)) { ++duplicate_count; - current_name = TRY(String::from_deprecated_string(LexicalPath::join(parent_path, TRY(String::formatted("{} ({})", basename, duplicate_count))).string())); + current_name = TRY(String::from_byte_string(LexicalPath::join(parent_path, TRY(String::formatted("{} ({})", basename, duplicate_count))).string())); } return current_name; @@ -260,7 +260,7 @@ ErrorOr copy_directory(StringView destination_path, StringView source_path return di.error(); while (di.has_next()) { - auto filename = TRY(String::from_deprecated_string(di.next_path())); + auto filename = TRY(String::from_byte_string(di.next_path())); TRY(copy_file_or_directory( TRY(String::formatted("{}/{}", destination_path, filename)), TRY(String::formatted("{}/{}", source_path, filename)), @@ -388,7 +388,7 @@ bool can_delete_or_move(StringView path) ErrorOr read_link(StringView link_path) { - return TRY(String::from_deprecated_string(TRY(Core::System::readlink(link_path)))); + return TRY(String::from_byte_string(TRY(Core::System::readlink(link_path)))); } ErrorOr link_file(StringView destination_path, StringView source_path) diff --git a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp index d6a6ec9d9f1..00634058905 100644 --- a/Userland/Libraries/LibFileSystemAccessClient/Client.cpp +++ b/Userland/Libraries/LibFileSystemAccessClient/Client.cpp @@ -23,7 +23,7 @@ Client& Client::the() return *s_the; } -Result Client::request_file_read_only_approved(GUI::Window* parent_window, DeprecatedString const& path) +Result Client::request_file_read_only_approved(GUI::Window* parent_window, ByteString const& path) { auto const id = get_new_id(); m_promises.set(id, RequestData { { Core::Promise::construct() }, parent_window, Core::File::OpenMode::Read }); @@ -38,7 +38,7 @@ Result Client::request_file_read_only_approved(GUI::Window* parent_window, Depre return handle_promise(id); } -Result Client::request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::File::OpenMode mode) +Result Client::request_file(GUI::Window* parent_window, ByteString const& path, Core::File::OpenMode mode) { auto const id = get_new_id(); m_promises.set(id, RequestData { { Core::Promise::construct() }, parent_window, mode }); @@ -83,7 +83,7 @@ Result Client::open_file(GUI::Window* parent_window, OpenFileOptions const& opti return handle_promise(id); } -Result Client::save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::File::OpenMode requested_access) +Result Client::save_file(GUI::Window* parent_window, ByteString const& name, ByteString const ext, Core::File::OpenMode requested_access) { auto const id = get_new_id(); m_promises.set(id, RequestData { { Core::Promise::construct() }, parent_window, requested_access }); @@ -103,7 +103,7 @@ Result Client::save_file(GUI::Window* parent_window, DeprecatedString const& nam return handle_promise(id); } -void Client::handle_prompt_end(i32 request_id, i32 error, Optional const& ipc_file, Optional const& chosen_file) +void Client::handle_prompt_end(i32 request_id, i32 error, Optional const& ipc_file, Optional const& chosen_file) { auto potential_data = m_promises.get(request_id); VERIFY(potential_data.has_value()); @@ -145,7 +145,7 @@ void Client::handle_prompt_end(i32 request_id, i32 error, Optional co auto file_or_error = [&]() -> ErrorOr { auto stream = TRY(Core::File::adopt_fd(ipc_file->take_fd(), Core::File::OpenMode::ReadWrite)); - auto filename = TRY(String::from_deprecated_string(*chosen_file)); + auto filename = TRY(String::from_byte_string(*chosen_file)); return File({}, move(stream), filename); }(); if (file_or_error.is_error()) { diff --git a/Userland/Libraries/LibFileSystemAccessClient/Client.h b/Userland/Libraries/LibFileSystemAccessClient/Client.h index caf769f4db0..d2044c5f7f2 100644 --- a/Userland/Libraries/LibFileSystemAccessClient/Client.h +++ b/Userland/Libraries/LibFileSystemAccessClient/Client.h @@ -50,7 +50,7 @@ using Result = ErrorOr; struct OpenFileOptions { StringView window_title = {}; - DeprecatedString path = Core::StandardPaths::home_directory(); + ByteString path = Core::StandardPaths::home_directory(); Core::File::OpenMode requested_access = Core::File::OpenMode::Read; Optional> allowed_file_types = {}; }; @@ -61,10 +61,10 @@ class Client final IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/filesystemaccess"sv) public: - Result request_file_read_only_approved(GUI::Window* parent_window, DeprecatedString const& path); - Result request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::File::OpenMode requested_access); + Result request_file_read_only_approved(GUI::Window* parent_window, ByteString const& path); + Result request_file(GUI::Window* parent_window, ByteString const& path, Core::File::OpenMode requested_access); Result open_file(GUI::Window* parent_window, OpenFileOptions const& = {}); - Result save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::File::OpenMode requested_access = Core::File::OpenMode::Write | Core::File::OpenMode::Truncate); + Result save_file(GUI::Window* parent_window, ByteString const& name, ByteString const ext, Core::File::OpenMode requested_access = Core::File::OpenMode::Write | Core::File::OpenMode::Truncate); void set_silence_errors(u32 flags) { m_silenced_errors = flags; } u32 silenced_errors() const { return m_silenced_errors; } @@ -84,7 +84,7 @@ private: { } - virtual void handle_prompt_end(i32 request_id, i32 error, Optional const& fd, Optional const& chosen_file) override; + virtual void handle_prompt_end(i32 request_id, i32 error, Optional const& fd, Optional const& chosen_file) override; int get_new_id(); Result handle_promise(int); diff --git a/Userland/Libraries/LibGPU/DeviceInfo.h b/Userland/Libraries/LibGPU/DeviceInfo.h index b9f11c472d7..c5d23ce6a63 100644 --- a/Userland/Libraries/LibGPU/DeviceInfo.h +++ b/Userland/Libraries/LibGPU/DeviceInfo.h @@ -6,13 +6,13 @@ #pragma once -#include +#include namespace GPU { struct DeviceInfo final { - DeprecatedString vendor_name; - DeprecatedString device_name; + ByteString vendor_name; + ByteString device_name; unsigned num_texture_units; unsigned num_lights; unsigned max_clip_planes; diff --git a/Userland/Libraries/LibGPU/Driver.cpp b/Userland/Libraries/LibGPU/Driver.cpp index 4da642f6277..74b9bfec3de 100644 --- a/Userland/Libraries/LibGPU/Driver.cpp +++ b/Userland/Libraries/LibGPU/Driver.cpp @@ -27,7 +27,7 @@ static HashMap const s_driver_path_map }; // clang-format on -static HashMap> s_loaded_drivers; +static HashMap> s_loaded_drivers; ErrorOr> Driver::try_create(StringView driver_name) { diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index de64deca1d1..fed6a9d0af3 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -22,7 +22,7 @@ namespace GUI { NonnullRefPtr AboutDialog::create(String const& name, String version, RefPtr icon, Window* parent_window) { auto dialog = adopt_ref(*new AboutDialog(name, version, icon, parent_window)); - dialog->set_title(DeprecatedString::formatted("About {}", name)); + dialog->set_title(ByteString::formatted("About {}", name)); auto widget = dialog->set_main_widget(); MUST(widget->load_from_gml(about_dialog_gml)); diff --git a/Userland/Libraries/LibGUI/AbstractTableView.cpp b/Userland/Libraries/LibGUI/AbstractTableView.cpp index 180295c1b53..071cca279fe 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.cpp +++ b/Userland/Libraries/LibGUI/AbstractTableView.cpp @@ -73,7 +73,7 @@ void AbstractTableView::auto_resize_column(int column) } else if (cell_data.is_bitmap()) { cell_width = cell_data.as_bitmap().width(); } else if (cell_data.is_valid()) { - cell_width = font().width(cell_data.to_deprecated_string()); + cell_width = font().width(cell_data.to_byte_string()); } if (is_empty && cell_width > 0) is_empty = false; @@ -111,7 +111,7 @@ void AbstractTableView::update_column_sizes() } else if (cell_data.is_bitmap()) { cell_width = cell_data.as_bitmap().width(); } else if (cell_data.is_valid()) { - cell_width = font().width(cell_data.to_deprecated_string()); + cell_width = font().width(cell_data.to_byte_string()); } column_width = max(column_width, cell_width); } diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp index 9f43533d11f..5b2a9fb28d9 100644 --- a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp +++ b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp @@ -38,14 +38,14 @@ AbstractThemePreview::AbstractThemePreview(Gfx::Palette const& preview_palette) void AbstractThemePreview::load_theme_bitmaps() { - auto load_bitmap = [](DeprecatedString const& path, DeprecatedString& last_path, RefPtr& bitmap) { + auto load_bitmap = [](ByteString const& path, ByteString& last_path, RefPtr& bitmap) { if (path.is_empty()) { - last_path = DeprecatedString::empty(); + last_path = ByteString::empty(); bitmap = nullptr; } else if (last_path != path) { auto bitmap_or_error = Gfx::Bitmap::load_from_file(path); if (bitmap_or_error.is_error()) { - last_path = DeprecatedString::empty(); + last_path = ByteString::empty(); bitmap = nullptr; } else { last_path = path; diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.h b/Userland/Libraries/LibGUI/AbstractThemePreview.h index a73300b2383..d9249eea03f 100644 --- a/Userland/Libraries/LibGUI/AbstractThemePreview.h +++ b/Userland/Libraries/LibGUI/AbstractThemePreview.h @@ -70,20 +70,20 @@ private: RefPtr m_close_bitmap; RefPtr m_maximize_bitmap; RefPtr m_minimize_bitmap; - DeprecatedString m_last_close_path; - DeprecatedString m_last_maximize_path; - DeprecatedString m_last_minimize_path; + ByteString m_last_close_path; + ByteString m_last_maximize_path; + ByteString m_last_minimize_path; RefPtr m_active_window_shadow; RefPtr m_inactive_window_shadow; RefPtr m_menu_shadow; RefPtr m_taskbar_shadow; RefPtr m_tooltip_shadow; - DeprecatedString m_last_active_window_shadow_path; - DeprecatedString m_last_inactive_window_shadow_path; - DeprecatedString m_last_menu_shadow_path; - DeprecatedString m_last_taskbar_shadow_path; - DeprecatedString m_last_tooltip_shadow_path; + ByteString m_last_active_window_shadow_path; + ByteString m_last_inactive_window_shadow_path; + ByteString m_last_menu_shadow_path; + ByteString m_last_taskbar_shadow_path; + ByteString m_last_tooltip_shadow_path; }; } diff --git a/Userland/Libraries/LibGUI/AbstractView.cpp b/Userland/Libraries/LibGUI/AbstractView.cpp index 2b3dd167a76..fe60e404fc6 100644 --- a/Userland/Libraries/LibGUI/AbstractView.cpp +++ b/Userland/Libraries/LibGUI/AbstractView.cpp @@ -611,7 +611,7 @@ void AbstractView::keydown_event(KeyEvent& event) } auto index = find_next_search_match(sb.string_view()); if (index.is_valid()) { - m_highlighted_search = sb.to_deprecated_string(); + m_highlighted_search = sb.to_byte_string(); highlight_search(index); start_highlighted_search_timer(); } @@ -637,7 +637,7 @@ void AbstractView::keydown_event(KeyEvent& event) auto index = find_next_search_match(sb.string_view()); if (index.is_valid()) { - m_highlighted_search = sb.to_deprecated_string(); + m_highlighted_search = sb.to_byte_string(); highlight_search(index); start_highlighted_search_timer(); set_cursor(index, SelectionUpdate::None, true); diff --git a/Userland/Libraries/LibGUI/AbstractView.h b/Userland/Libraries/LibGUI/AbstractView.h index a1184f05cc8..947090b2b0f 100644 --- a/Userland/Libraries/LibGUI/AbstractView.h +++ b/Userland/Libraries/LibGUI/AbstractView.h @@ -199,7 +199,7 @@ private: RefPtr m_model; ModelSelection m_selection; - Optional m_highlighted_search; + Optional m_highlighted_search; RefPtr m_highlighted_search_timer; SelectionBehavior m_selection_behavior { SelectionBehavior::SelectItems }; SelectionMode m_selection_mode { SelectionMode::SingleSelection }; diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 1c22b832238..13c992ccdc2 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -15,52 +15,52 @@ namespace GUI { -NonnullRefPtr Action::create(DeprecatedString text, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create(ByteString text, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), move(callback), parent)); } -NonnullRefPtr Action::create(DeprecatedString text, RefPtr icon, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create(ByteString text, RefPtr icon, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), move(icon), move(callback), parent)); } -NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create(ByteString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), shortcut, move(callback), parent)); } -NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create(ByteString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(callback), parent)); } -NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create(ByteString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent)); } -NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create(ByteString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(icon), move(callback), parent)); } -NonnullRefPtr Action::create_checkable(DeprecatedString text, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create_checkable(ByteString text, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), move(callback), parent, true)); } -NonnullRefPtr Action::create_checkable(DeprecatedString text, RefPtr icon, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create_checkable(ByteString text, RefPtr icon, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), move(icon), move(callback), parent, true)); } -NonnullRefPtr Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create_checkable(ByteString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), shortcut, move(callback), parent, true)); } -NonnullRefPtr Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent) +NonnullRefPtr Action::create_checkable(ByteString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent) { return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent, true)); } @@ -78,27 +78,27 @@ RefPtr Action::find_action_for_shortcut(Core::EventReceiver& object, Sho return found_action; } -Action::Action(DeprecatedString text, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) +Action::Action(ByteString text, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) : Action(move(text), Shortcut {}, Shortcut {}, nullptr, move(on_activation_callback), parent, checkable) { } -Action::Action(DeprecatedString text, RefPtr icon, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) +Action::Action(ByteString text, RefPtr icon, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) : Action(move(text), Shortcut {}, Shortcut {}, move(icon), move(on_activation_callback), parent, checkable) { } -Action::Action(DeprecatedString text, Shortcut const& shortcut, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) +Action::Action(ByteString text, Shortcut const& shortcut, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) : Action(move(text), shortcut, Shortcut {}, nullptr, move(on_activation_callback), parent, checkable) { } -Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) +Action::Action(ByteString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) : Action(move(text), shortcut, alternate_shortcut, nullptr, move(on_activation_callback), parent, checkable) { } -Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) +Action::Action(ByteString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function on_activation_callback, Core::EventReceiver* parent, bool checkable) : Core::EventReceiver(parent) , on_activation(move(on_activation_callback)) , m_text(move(text)) @@ -284,31 +284,31 @@ void Action::set_icon(Gfx::Bitmap const* icon) }); } -void Action::set_text(DeprecatedString text) +void Action::set_text(ByteString text) { if (m_text == text) return; m_text = move(text); for_each_toolbar_button([&](auto& button) { - button.set_text(String::from_deprecated_string(m_text).release_value_but_fixme_should_propagate_errors()); + button.set_text(String::from_byte_string(m_text).release_value_but_fixme_should_propagate_errors()); }); for_each_menu_item([&](auto& menu_item) { menu_item.update_from_action({}); }); } -DeprecatedString Action::tooltip() const +ByteString Action::tooltip() const { return m_tooltip.value_or_lazy_evaluated([this] { return Gfx::parse_ampersand_string(m_text); }); } -void Action::set_tooltip(DeprecatedString tooltip) +void Action::set_tooltip(ByteString tooltip) { if (m_tooltip == tooltip) return; m_tooltip = move(tooltip); for_each_toolbar_button([&](auto& button) { - button.set_tooltip(MUST(String::from_deprecated_string(*m_tooltip))); + button.set_tooltip(MUST(String::from_byte_string(*m_tooltip))); }); for_each_menu_item([&](auto& menu_item) { menu_item.update_from_action({}); @@ -320,7 +320,7 @@ Optional Action::status_tip() const if (!m_status_tip.is_empty()) return m_status_tip; - auto maybe_parsed_action_text = String::from_deprecated_string(Gfx::parse_ampersand_string(m_text)); + auto maybe_parsed_action_text = String::from_byte_string(Gfx::parse_ampersand_string(m_text)); if (maybe_parsed_action_text.is_error()) return {}; return maybe_parsed_action_text.release_value(); diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index 298bf8a182a..207dda10e5e 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include #include @@ -66,26 +66,26 @@ public: WindowLocal, ApplicationGlobal, }; - static NonnullRefPtr create(DeprecatedString text, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create_checkable(DeprecatedString text, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create_checkable(DeprecatedString text, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create_checkable(DeprecatedString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent = nullptr); - static NonnullRefPtr create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create(ByteString text, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create(ByteString text, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create(ByteString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create(ByteString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create(ByteString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create(ByteString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create_checkable(ByteString text, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create_checkable(ByteString text, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create_checkable(ByteString text, Shortcut const& shortcut, Function callback, Core::EventReceiver* parent = nullptr); + static NonnullRefPtr create_checkable(ByteString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::EventReceiver* parent = nullptr); static RefPtr find_action_for_shortcut(Core::EventReceiver& object, Shortcut const& shortcut); virtual ~Action() override; - DeprecatedString text() const { return m_text; } - void set_text(DeprecatedString); + ByteString text() const { return m_text; } + void set_text(ByteString); - DeprecatedString tooltip() const; - void set_tooltip(DeprecatedString); + ByteString tooltip() const; + void set_tooltip(ByteString); Optional status_tip() const; void set_status_tip(String status_tip) { m_status_tip = move(status_tip); } @@ -136,19 +136,19 @@ public: HashTable const& menu_items() const { return m_menu_items; } private: - Action(DeprecatedString, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); - Action(DeprecatedString, Shortcut const&, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); - Action(DeprecatedString, Shortcut const&, Shortcut const&, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); - Action(DeprecatedString, Shortcut const&, Shortcut const&, RefPtr icon, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); - Action(DeprecatedString, RefPtr icon, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); + Action(ByteString, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); + Action(ByteString, Shortcut const&, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); + Action(ByteString, Shortcut const&, Shortcut const&, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); + Action(ByteString, Shortcut const&, Shortcut const&, RefPtr icon, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); + Action(ByteString, RefPtr icon, Function = nullptr, Core::EventReceiver* = nullptr, bool checkable = false); template void for_each_toolbar_button(Callback); template void for_each_menu_item(Callback); - DeprecatedString m_text; - Optional m_tooltip; + ByteString m_text; + Optional m_tooltip; String m_status_tip; RefPtr m_icon; Shortcut m_shortcut; diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 1e061e43af4..bc58cdcba68 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -373,7 +373,7 @@ void Application::update_recent_file_actions() void Application::set_most_recently_open_file(String new_path) { - Vector new_recent_files_list; + Vector new_recent_files_list; for (size_t i = 0; i < max_recently_open_files(); ++i) { static_assert(max_recently_open_files() < 10); @@ -386,7 +386,7 @@ void Application::set_most_recently_open_file(String new_path) return existing_path.view() == new_path; }); - new_recent_files_list.prepend(new_path.to_deprecated_string()); + new_recent_files_list.prepend(new_path.to_byte_string()); for (size_t i = 0; i < max_recently_open_files(); ++i) { auto& path = new_recent_files_list[i]; diff --git a/Userland/Libraries/LibGUI/Application.h b/Userland/Libraries/LibGUI/Application.h index ba27d165ec4..692291898dd 100644 --- a/Userland/Libraries/LibGUI/Application.h +++ b/Userland/Libraries/LibGUI/Application.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -52,8 +52,8 @@ public: void did_create_window(Badge); void did_delete_last_window(Badge); - DeprecatedString const& invoked_as() const { return m_invoked_as; } - Vector const& args() const { return m_args; } + ByteString const& invoked_as() const { return m_invoked_as; } + Vector const& args() const { return m_args; } Gfx::Palette palette() const; void set_palette(Gfx::Palette&); @@ -123,8 +123,8 @@ private: bool m_focus_debugging_enabled { false }; bool m_hover_debugging_enabled { false }; bool m_dnd_debugging_enabled { false }; - DeprecatedString m_invoked_as; - Vector m_args; + ByteString m_invoked_as; + Vector m_args; WeakPtr m_drag_hovered_widget; WeakPtr m_pending_drop_widget; diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index 585f948b9cc..c83a2a8f306 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -182,7 +182,7 @@ CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying Autoco return hide_when_done; auto suggestion_index = m_suggestion_view->model()->index(selected_index.row()); - auto completion = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Completion).to_deprecated_string(); + auto completion = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::Completion).to_byte_string(); size_t partial_length = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::PartialInputLength).to_i64(); auto hide_after_applying = suggestion_index.data((GUI::ModelRole)AutocompleteSuggestionModel::InternalRole::HideAutocompleteAfterApplying).to_bool(); diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp index 9d6ccbcac58..9cba948d51a 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp @@ -70,11 +70,11 @@ void Breadcrumbbar::clear_segments() m_selected_segment = {}; } -void Breadcrumbbar::append_segment(DeprecatedString text, Gfx::Bitmap const* icon, DeprecatedString data, String tooltip) +void Breadcrumbbar::append_segment(ByteString text, Gfx::Bitmap const* icon, ByteString data, String tooltip) { auto& button = add(); button.set_button_style(Gfx::ButtonStyle::Coolbar); - button.set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors()); + button.set_text(String::from_byte_string(text).release_value_but_fixme_should_propagate_errors()); button.set_icon(icon); button.set_tooltip(move(tooltip)); button.set_focus_policy(FocusPolicy::TabFocus); @@ -124,7 +124,7 @@ void Breadcrumbbar::remove_end_segments(size_t start_segment_index) m_selected_segment = {}; } -Optional Breadcrumbbar::find_segment_with_data(DeprecatedString const& data) +Optional Breadcrumbbar::find_segment_with_data(ByteString const& data) { for (size_t i = 0; i < segment_count(); ++i) { if (segment_data(i) == data) diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.h b/Userland/Libraries/LibGUI/Breadcrumbbar.h index 1721b3741aa..c53a3266692 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.h +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.h @@ -19,13 +19,13 @@ public: virtual ~Breadcrumbbar() override = default; void clear_segments(); - void append_segment(DeprecatedString text, Gfx::Bitmap const* icon = nullptr, DeprecatedString data = {}, String tooltip = {}); + void append_segment(ByteString text, Gfx::Bitmap const* icon = nullptr, ByteString data = {}, String tooltip = {}); void remove_end_segments(size_t segment_index); void relayout(); size_t segment_count() const { return m_segments.size(); } - DeprecatedString segment_data(size_t index) const { return m_segments[index].data; } - Optional find_segment_with_data(DeprecatedString const& data); + ByteString segment_data(size_t index) const { return m_segments[index].data; } + Optional find_segment_with_data(ByteString const& data); void set_selected_segment(Optional index); Optional selected_segment() const { return m_selected_segment; } @@ -48,8 +48,8 @@ private: struct Segment { RefPtr icon; - DeprecatedString text; - DeprecatedString data; + ByteString text; + ByteString data; int width { 0 }; int shrunken_width { 0 }; WeakPtr button; diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp index 6f64273bad3..0a1c992ea92 100644 --- a/Userland/Libraries/LibGUI/Button.cpp +++ b/Userland/Libraries/LibGUI/Button.cpp @@ -186,7 +186,7 @@ void Button::set_icon(RefPtr icon) update(); } -void Button::set_icon_from_path(DeprecatedString const& path) +void Button::set_icon_from_path(ByteString const& path) { auto maybe_bitmap = Gfx::Bitmap::load_from_file(path); if (maybe_bitmap.is_error()) { diff --git a/Userland/Libraries/LibGUI/Button.h b/Userland/Libraries/LibGUI/Button.h index 8dd50fa6750..e0e0e990195 100644 --- a/Userland/Libraries/LibGUI/Button.h +++ b/Userland/Libraries/LibGUI/Button.h @@ -29,7 +29,7 @@ public: virtual ~Button() override; void set_icon(RefPtr); - void set_icon_from_path(DeprecatedString const&); + void set_icon_from_path(ByteString const&); Gfx::Bitmap const* icon() const { return m_icon.ptr(); } void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; } diff --git a/Userland/Libraries/LibGUI/Calendar.cpp b/Userland/Libraries/LibGUI/Calendar.cpp index 5aa0c48c7b5..e02b94edc14 100644 --- a/Userland/Libraries/LibGUI/Calendar.cpp +++ b/Userland/Libraries/LibGUI/Calendar.cpp @@ -636,7 +636,7 @@ void Calendar::paint_tile(GUI::Painter& painter, GUI::Calendar::Tile& tile, Gfx: text_rect = Gfx::IntRect(tile_rect); } - auto display_date = DeprecatedString::number(tile.day); + auto display_date = ByteString::number(tile.day); if (tile.is_selected && (width < 30 || height < 30)) painter.draw_rect(tile_rect, palette().base_text()); @@ -659,7 +659,7 @@ void Calendar::paint_tile(GUI::Painter& painter, GUI::Calendar::Tile& tile, Gfx: set_font(*small_font); } - auto display_date = DeprecatedString::number(tile.day); + auto display_date = ByteString::number(tile.day); if (tile.is_selected) painter.draw_rect(tile_rect, palette().base_text()); @@ -820,7 +820,7 @@ void Calendar::doubleclick_event(GUI::MouseEvent& event) } } -size_t Calendar::day_of_week_index(DeprecatedString const& day_name) +size_t Calendar::day_of_week_index(ByteString const& day_name) { auto const& day_names = AK::long_day_names; return AK::find_index(day_names.begin(), day_names.end(), day_name); diff --git a/Userland/Libraries/LibGUI/Calendar.h b/Userland/Libraries/LibGUI/Calendar.h index a95d919665c..36d0a0c77ae 100644 --- a/Userland/Libraries/LibGUI/Calendar.h +++ b/Userland/Libraries/LibGUI/Calendar.h @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include #include @@ -104,7 +104,7 @@ protected: Calendar(Core::DateTime date_time = Core::DateTime::now(), Mode mode = Month); private: - static size_t day_of_week_index(DeprecatedString const&); + static size_t day_of_week_index(ByteString const&); virtual void resize_event(GUI::ResizeEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; @@ -127,14 +127,14 @@ private: bool is_day_in_weekend(DayOfWeek); struct Day { - DeprecatedString name; + ByteString name; int width { 0 }; int height { 16 }; }; Vector m_days; struct MonthTile { - DeprecatedString name; + ByteString name; Gfx::IntRect rect; int width { 0 }; int height { 0 }; diff --git a/Userland/Libraries/LibGUI/Clipboard.cpp b/Userland/Libraries/LibGUI/Clipboard.cpp index 4c4792e03fc..2f68dd4bf1a 100644 --- a/Userland/Libraries/LibGUI/Clipboard.cpp +++ b/Userland/Libraries/LibGUI/Clipboard.cpp @@ -24,7 +24,7 @@ private: { } - virtual void clipboard_data_changed(DeprecatedString const& mime_type) override + virtual void clipboard_data_changed(ByteString const& mime_type) override { Clipboard::the().clipboard_data_changed({}, mime_type); } @@ -131,8 +131,8 @@ ErrorOr Clipboard::DataAndType::from_json(JsonObject con return Error::from_string_literal("JsonObject does not contain necessary fields"); DataAndType result; - result.data = object.get_deprecated_string("data"sv)->to_byte_buffer(); - result.mime_type = *object.get_deprecated_string("mime_type"sv); + result.data = object.get_byte_string("data"sv)->to_byte_buffer(); + result.mime_type = *object.get_byte_string("mime_type"sv); // FIXME: Also read metadata return result; @@ -141,14 +141,14 @@ ErrorOr Clipboard::DataAndType::from_json(JsonObject con ErrorOr Clipboard::DataAndType::to_json() const { JsonObject object; - object.set("data", TRY(DeprecatedString::from_utf8(data.bytes()))); + object.set("data", TRY(ByteString::from_utf8(data.bytes()))); object.set("mime_type", mime_type); // FIXME: Also write metadata return object; } -void Clipboard::set_data(ReadonlyBytes data, DeprecatedString const& type, HashMap const& metadata) +void Clipboard::set_data(ReadonlyBytes data, ByteString const& type, HashMap const& metadata) { if (data.is_empty()) { connection().async_set_clipboard_data({}, type, metadata.clone().release_value_but_fixme_should_propagate_errors()); @@ -165,14 +165,14 @@ void Clipboard::set_data(ReadonlyBytes data, DeprecatedString const& type, HashM connection().async_set_clipboard_data(move(buffer), type, metadata.clone().release_value_but_fixme_should_propagate_errors()); } -void Clipboard::set_bitmap(Gfx::Bitmap const& bitmap, HashMap const& additional_metadata) +void Clipboard::set_bitmap(Gfx::Bitmap const& bitmap, HashMap const& additional_metadata) { - HashMap metadata = additional_metadata.clone().release_value_but_fixme_should_propagate_errors(); - metadata.set("width", DeprecatedString::number(bitmap.width())); - metadata.set("height", DeprecatedString::number(bitmap.height())); - metadata.set("scale", DeprecatedString::number(bitmap.scale())); - metadata.set("format", DeprecatedString::number((int)bitmap.format())); - metadata.set("pitch", DeprecatedString::number(bitmap.pitch())); + HashMap metadata = additional_metadata.clone().release_value_but_fixme_should_propagate_errors(); + metadata.set("width", ByteString::number(bitmap.width())); + metadata.set("height", ByteString::number(bitmap.height())); + metadata.set("scale", ByteString::number(bitmap.scale())); + metadata.set("format", ByteString::number((int)bitmap.format())); + metadata.set("pitch", ByteString::number(bitmap.pitch())); set_data({ bitmap.scanline(0), bitmap.size_in_bytes() }, "image/x-serenityos", move(metadata)); } @@ -181,7 +181,7 @@ void Clipboard::clear() connection().async_set_clipboard_data({}, {}, {}); } -void Clipboard::clipboard_data_changed(Badge, DeprecatedString const& mime_type) +void Clipboard::clipboard_data_changed(Badge, ByteString const& mime_type) { if (on_change) on_change(mime_type); diff --git a/Userland/Libraries/LibGUI/Clipboard.h b/Userland/Libraries/LibGUI/Clipboard.h index 95dc00b8b26..6a60c538db2 100644 --- a/Userland/Libraries/LibGUI/Clipboard.h +++ b/Userland/Libraries/LibGUI/Clipboard.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include #include @@ -26,13 +26,13 @@ public: ClipboardClient(); virtual ~ClipboardClient(); - virtual void clipboard_content_did_change(DeprecatedString const& mime_type) = 0; + virtual void clipboard_content_did_change(ByteString const& mime_type) = 0; }; struct DataAndType { ByteBuffer data; - DeprecatedString mime_type; - HashMap metadata; + ByteString mime_type; + HashMap metadata; RefPtr as_bitmap() const; @@ -44,19 +44,19 @@ public: static Clipboard& the(); DataAndType fetch_data_and_type() const; - DeprecatedString fetch_mime_type() const { return fetch_data_and_type().mime_type; } + ByteString fetch_mime_type() const { return fetch_data_and_type().mime_type; } - void set_data(ReadonlyBytes data, DeprecatedString const& mime_type = "text/plain", HashMap const& metadata = {}); + void set_data(ReadonlyBytes data, ByteString const& mime_type = "text/plain", HashMap const& metadata = {}); void set_plain_text(StringView text) { set_data(text.bytes()); } - void set_bitmap(Gfx::Bitmap const&, HashMap const& additional_metadata = {}); + void set_bitmap(Gfx::Bitmap const&, HashMap const& additional_metadata = {}); void clear(); - void clipboard_data_changed(Badge, DeprecatedString const& mime_type); + void clipboard_data_changed(Badge, ByteString const& mime_type); void register_client(Badge, ClipboardClient& client) { m_clients.set(&client); } void unregister_client(Badge, ClipboardClient& client) { m_clients.remove(&client); } - Function on_change; + Function on_change; private: Clipboard() = default; diff --git a/Userland/Libraries/LibGUI/ColorInput.cpp b/Userland/Libraries/LibGUI/ColorInput.cpp index d65abf4de47..d26e6bcb7f4 100644 --- a/Userland/Libraries/LibGUI/ColorInput.cpp +++ b/Userland/Libraries/LibGUI/ColorInput.cpp @@ -43,7 +43,7 @@ void ColorInput::set_color_internal(Color color, AllowCallback allow_callback, b return; m_color = color; if (change_text) - set_text(m_color_has_alpha_channel ? color.to_deprecated_string() : color.to_deprecated_string_without_alpha(), AllowCallback::No); + set_text(m_color_has_alpha_channel ? color.to_byte_string() : color.to_byte_string_without_alpha(), AllowCallback::No); update(); if (allow_callback == AllowCallback::Yes && on_change) on_change(); diff --git a/Userland/Libraries/LibGUI/ColorInput.h b/Userland/Libraries/LibGUI/ColorInput.h index 46705529e9e..1cb957f0afc 100644 --- a/Userland/Libraries/LibGUI/ColorInput.h +++ b/Userland/Libraries/LibGUI/ColorInput.h @@ -24,8 +24,8 @@ public: void set_color(Color, AllowCallback = AllowCallback::Yes); Color color() { return m_color; } - void set_color_picker_title(DeprecatedString title) { m_color_picker_title = move(title); } - DeprecatedString color_picker_title() { return m_color_picker_title; } + void set_color_picker_title(ByteString title) { m_color_picker_title = move(title); } + ByteString color_picker_title() { return m_color_picker_title; } Function on_change; @@ -42,7 +42,7 @@ private: void set_color_internal(Color, AllowCallback, bool change_text); Color m_color; - DeprecatedString m_color_picker_title { "Color Picker" }; + ByteString m_color_picker_title { "Color Picker" }; bool m_color_has_alpha_channel { true }; bool m_may_be_color_rect_click { false }; }; diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 9174c783018..59531413cf8 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -183,7 +183,7 @@ private: Color m_col; }; -ColorPicker::ColorPicker(Color color, Window* parent_window, DeprecatedString title) +ColorPicker::ColorPicker(Color color, Window* parent_window, ByteString title) : Dialog(parent_window) , m_original_color(color) , m_color(color) @@ -340,7 +340,7 @@ void ColorPicker::build_ui_custom(Widget& root_container) html_label.set_text("HTML:"_string); m_html_text = html_container.add(); - m_html_text->set_text(m_color_has_alpha_channel ? m_color.to_deprecated_string() : m_color.to_deprecated_string_without_alpha()); + m_html_text->set_text(m_color_has_alpha_channel ? m_color.to_byte_string() : m_color.to_byte_string_without_alpha()); m_html_text->on_change = [this]() { auto color_name = m_html_text->text(); auto optional_color = Color::from_string(color_name); @@ -435,7 +435,7 @@ void ColorPicker::update_color_widgets() { m_preview_widget->set_color(m_color); - m_html_text->set_text(m_color_has_alpha_channel ? m_color.to_deprecated_string() : m_color.to_deprecated_string_without_alpha()); + m_html_text->set_text(m_color_has_alpha_channel ? m_color.to_byte_string() : m_color.to_byte_string_without_alpha()); m_red_spinbox->set_value(m_color.red()); m_green_spinbox->set_value(m_color.green()); diff --git a/Userland/Libraries/LibGUI/ColorPicker.h b/Userland/Libraries/LibGUI/ColorPicker.h index 79db518d880..341786a8479 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.h +++ b/Userland/Libraries/LibGUI/ColorPicker.h @@ -29,7 +29,7 @@ public: Function on_color_changed; private: - explicit ColorPicker(Color, Window* parent_window = nullptr, DeprecatedString title = "Color Picker"); + explicit ColorPicker(Color, Window* parent_window = nullptr, ByteString title = "Color Picker"); void build_ui(); void build_ui_custom(Widget& root_container); diff --git a/Userland/Libraries/LibGUI/ColumnsView.cpp b/Userland/Libraries/LibGUI/ColumnsView.cpp index 461fd5283f1..6ec3c27ab14 100644 --- a/Userland/Libraries/LibGUI/ColumnsView.cpp +++ b/Userland/Libraries/LibGUI/ColumnsView.cpp @@ -158,7 +158,7 @@ void ColumnsView::paint_event(PaintEvent& event) icon_rect.right() + icon_spacing(), row * item_height(), column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - static_cast(s_arrow_bitmap.width()) - icon_spacing(), item_height() }; - draw_item_text(painter, index, is_selected_row, text_rect, index.data().to_deprecated_string(), font_for_index(index), Gfx::TextAlignment::CenterLeft, Gfx::TextElision::None); + draw_item_text(painter, index, is_selected_row, text_rect, index.data().to_byte_string(), font_for_index(index), Gfx::TextAlignment::CenterLeft, Gfx::TextElision::None); if (is_focused() && index == cursor_index()) { painter.draw_rect(row_rect, palette().color(background_role())); @@ -231,7 +231,7 @@ void ColumnsView::update_column_sizes() for (int row = 0; row < row_count; row++) { ModelIndex index = model()->index(row, m_model_column, column.parent_index); VERIFY(index.is_valid()); - auto text = index.data().to_deprecated_string(); + auto text = index.data().to_byte_string(); int row_width = icon_spacing() + icon_size() + icon_spacing() + font().width(text) + icon_spacing() + s_arrow_bitmap.width() + icon_spacing(); if (row_width > column.width) column.width = row_width; diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index fee48a11ee1..1e6cc2a25fb 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -150,7 +150,7 @@ void ComboBox::set_editor_placeholder(StringView placeholder) m_editor->set_placeholder(placeholder); } -DeprecatedString const& ComboBox::editor_placeholder() const +ByteString const& ComboBox::editor_placeholder() const { return m_editor->placeholder(); } @@ -179,7 +179,7 @@ void ComboBox::selection_updated(ModelIndex const& index) { if (index.is_valid()) { m_selected_index = index; - auto new_value = index.data().to_deprecated_string(); + auto new_value = index.data().to_byte_string(); m_editor->set_text(new_value); } else { m_selected_index.clear(); @@ -285,12 +285,12 @@ void ComboBox::close() m_list_window->hide(); } -DeprecatedString ComboBox::text() const +ByteString ComboBox::text() const { return m_editor->text(); } -void ComboBox::set_text(DeprecatedString const& text, AllowCallback allow_callback) +void ComboBox::set_text(ByteString const& text, AllowCallback allow_callback) { m_editor->set_text(text, allow_callback); } diff --git a/Userland/Libraries/LibGUI/ComboBox.h b/Userland/Libraries/LibGUI/ComboBox.h index 219aaec70e3..55c0a470e30 100644 --- a/Userland/Libraries/LibGUI/ComboBox.h +++ b/Userland/Libraries/LibGUI/ComboBox.h @@ -20,8 +20,8 @@ class ComboBox : public Frame { public: virtual ~ComboBox() override; - DeprecatedString text() const; - void set_text(DeprecatedString const&, AllowCallback = AllowCallback::Yes); + ByteString text() const; + void set_text(ByteString const&, AllowCallback = AllowCallback::Yes); void open(); void close(); @@ -42,12 +42,12 @@ public: void set_model_column(int); void set_editor_placeholder(StringView placeholder); - DeprecatedString const& editor_placeholder() const; + ByteString const& editor_placeholder() const; int max_visible_items() const { return m_max_visible_items; } void set_max_visible_items(int max) { m_max_visible_items = max; } - Function on_change; + Function on_change; Function on_return_pressed; protected: diff --git a/Userland/Libraries/LibGUI/Command.h b/Userland/Libraries/LibGUI/Command.h index a9a8ef25704..28cae113257 100644 --- a/Userland/Libraries/LibGUI/Command.h +++ b/Userland/Libraries/LibGUI/Command.h @@ -7,7 +7,7 @@ #pragma once -#include +#include namespace GUI { @@ -18,7 +18,7 @@ public: virtual void undo() { } virtual void redo() { } - virtual DeprecatedString action_text() const { return {}; } + virtual ByteString action_text() const { return {}; } virtual bool merge_with(Command const&) { return false; } protected: diff --git a/Userland/Libraries/LibGUI/CommandPalette.cpp b/Userland/Libraries/LibGUI/CommandPalette.cpp index 946d756249b..6578f691dd8 100644 --- a/Userland/Libraries/LibGUI/CommandPalette.cpp +++ b/Userland/Libraries/LibGUI/CommandPalette.cpp @@ -129,7 +129,7 @@ public: case Column::Shortcut: if (!action.shortcut().is_valid()) return ""; - return action.shortcut().to_deprecated_string(); + return action.shortcut().to_byte_string(); } VERIFY_NOT_REACHED(); @@ -141,21 +141,21 @@ public: if (needle.is_empty()) return { TriState::True }; - auto haystack = DeprecatedString::formatted("{} {}", menu_name(index), action_text(index)); + auto haystack = ByteString::formatted("{} {}", menu_name(index), action_text(index)); auto match_result = fuzzy_match(needle, haystack); if (match_result.score > 0) return { TriState::True, match_result.score }; return { TriState::False }; } - static DeprecatedString action_text(ModelIndex const& index) + static ByteString action_text(ModelIndex const& index) { auto& action = *static_cast(index.internal_data()); return Gfx::parse_ampersand_string(action.text()); } - static DeprecatedString menu_name(ModelIndex const& index) + static ByteString menu_name(ModelIndex const& index) { auto& action = *static_cast(index.internal_data()); if (action.menu_items().is_empty()) diff --git a/Userland/Libraries/LibGUI/CommonActions.cpp b/Userland/Libraries/LibGUI/CommonActions.cpp index dcc5a4119ef..bf907a670d9 100644 --- a/Userland/Libraries/LibGUI/CommonActions.cpp +++ b/Userland/Libraries/LibGUI/CommonActions.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace CommonActions { NonnullRefPtr make_about_action(String const& app_name, Icon const& app_icon, Window* parent) { auto weak_parent = AK::make_weak_ptr_if_nonnull(parent); - auto action = Action::create(DeprecatedString::formatted("&About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) { + auto action = Action::create(ByteString::formatted("&About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) { AboutDialog::show( app_name, Core::Version::read_long_version_string().release_value_but_fixme_should_propagate_errors(), diff --git a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp index 5928651cbd0..0c9afe3dd74 100644 --- a/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp +++ b/Userland/Libraries/LibGUI/CommonLocationsProvider.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -24,7 +24,7 @@ static void initialize_if_needed() if (s_initialized) return; - auto user_config = DeprecatedString::formatted("{}/CommonLocations.json", Core::StandardPaths::config_directory()); + auto user_config = ByteString::formatted("{}/CommonLocations.json", Core::StandardPaths::config_directory()); if (FileSystem::exists(user_config)) { auto maybe_error = CommonLocationsProvider::load_from_json(user_config); if (!maybe_error.is_error()) @@ -56,8 +56,8 @@ ErrorOr CommonLocationsProvider::load_from_json(StringView json_path) if (!entry_value.is_object()) continue; auto entry = entry_value.as_object(); - auto name = entry.get_deprecated_string("name"sv).value_or({}); - auto path = entry.get_deprecated_string("path"sv).value_or({}); + auto name = entry.get_byte_string("name"sv).value_or({}); + auto path = entry.get_byte_string("path"sv).value_or({}); TRY(s_common_locations.try_append({ name, path })); } diff --git a/Userland/Libraries/LibGUI/CommonLocationsProvider.h b/Userland/Libraries/LibGUI/CommonLocationsProvider.h index b094f8b4828..05785e46ece 100644 --- a/Userland/Libraries/LibGUI/CommonLocationsProvider.h +++ b/Userland/Libraries/LibGUI/CommonLocationsProvider.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -16,8 +16,8 @@ namespace GUI { class CommonLocationsProvider { public: struct CommonLocation { - DeprecatedString name; - DeprecatedString path; + ByteString name; + ByteString path; }; static ErrorOr load_from_json(StringView json_path); diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp index 81c29a85687..5217d61a54e 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp +++ b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.cpp @@ -21,7 +21,7 @@ ConnectionToWindowManagerServer& ConnectionToWindowManagerServer::the() void ConnectionToWindowManagerServer::window_state_changed(i32 wm_id, i32 client_id, i32 window_id, u32 workspace_row, u32 workspace_column, bool is_active, bool is_blocked, bool is_minimized, bool is_frameless, - i32 window_type, DeprecatedString const& title, Gfx::IntRect const& rect, Optional const& progress) + i32 window_type, ByteString const& title, Gfx::IntRect const& rect, Optional const& progress) { if (auto* window = Window::from_window_id(wm_id)) Core::EventLoop::current().post_event(*window, make(client_id, window_id, title, rect, workspace_row, workspace_column, is_active, is_blocked, static_cast(window_type), is_minimized, is_frameless, progress)); @@ -82,7 +82,7 @@ void ConnectionToWindowManagerServer::workspace_changed(i32 wm_id, u32 row, u32 Core::EventLoop::current().post_event(*window, make(wm_id, row, column)); } -void ConnectionToWindowManagerServer::keymap_changed(i32 wm_id, DeprecatedString const& keymap) +void ConnectionToWindowManagerServer::keymap_changed(i32 wm_id, ByteString const& keymap) { if (auto* window = Window::from_window_id(wm_id)) Core::EventLoop::current().post_event(*window, make(wm_id, keymap)); diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h index bee183c2ec0..143a5588289 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h +++ b/Userland/Libraries/LibGUI/ConnectionToWindowManagerServer.h @@ -29,7 +29,7 @@ private: } virtual void window_removed(i32, i32, i32) override; - virtual void window_state_changed(i32, i32, i32, u32, u32, bool, bool, bool, bool, i32, DeprecatedString const&, Gfx::IntRect const&, Optional const&) override; + virtual void window_state_changed(i32, i32, i32, u32, u32, bool, bool, bool, bool, i32, ByteString const&, Gfx::IntRect const&, Optional const&) override; virtual void window_icon_bitmap_changed(i32, i32, i32, Gfx::ShareableBitmap const&) override; virtual void window_rect_changed(i32, i32, i32, Gfx::IntRect const&) override; virtual void applet_area_size_changed(i32, Gfx::IntSize) override; @@ -38,7 +38,7 @@ private: virtual void super_d_key_pressed(i32) override; virtual void super_digit_key_pressed(i32, u8) override; virtual void workspace_changed(i32, u32, u32) override; - virtual void keymap_changed(i32, DeprecatedString const&) override; + virtual void keymap_changed(i32, ByteString const&) override; virtual void add_to_quick_launch(i32, pid_t) override; }; diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp index 3d9dd27f0e9..fe1c6fc51ee 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp +++ b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp @@ -57,7 +57,7 @@ ConnectionToWindowServer::ConnectionToWindowServer(NonnullOwnPtrclient_id(); } -void ConnectionToWindowServer::fast_greet(Vector const&, u32, u32, u32, Core::AnonymousBuffer const&, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, Vector const&, i32) +void ConnectionToWindowServer::fast_greet(Vector const&, u32, u32, u32, Core::AnonymousBuffer const&, ByteString const&, ByteString const&, ByteString const&, Vector const&, i32) { // NOTE: This message is handled in the constructor. } @@ -73,7 +73,7 @@ void ConnectionToWindowServer::update_system_theme(Core::AnonymousBuffer const& Application::the()->dispatch_event(*make()); } -void ConnectionToWindowServer::update_system_fonts(DeprecatedString const& default_font_query, DeprecatedString const& fixed_width_font_query, DeprecatedString const& window_title_font_query) +void ConnectionToWindowServer::update_system_fonts(ByteString const& default_font_query, ByteString const& fixed_width_font_query, ByteString const& window_title_font_query) { Gfx::FontDatabase::set_default_font_query(default_font_query); Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query); @@ -155,24 +155,24 @@ static Action* action_for_shortcut(Window& window, Shortcut const& shortcut) if (!shortcut.is_valid()) return nullptr; - dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, "Looking up action for {}", shortcut.to_deprecated_string()); + dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, "Looking up action for {}", shortcut.to_byte_string()); for (auto* widget = window.focused_widget(); widget; widget = widget->parent_widget()) { if (auto* action = widget->action_for_shortcut(shortcut)) { - dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Focused widget {} gave action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", *widget, action, action->text(), action->is_enabled(), action->shortcut().to_deprecated_string(), action->alternate_shortcut().to_deprecated_string()); + dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Focused widget {} gave action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", *widget, action, action->text(), action->is_enabled(), action->shortcut().to_byte_string(), action->alternate_shortcut().to_byte_string()); return action; } } if (auto* action = window.action_for_shortcut(shortcut)) { - dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Asked window {}, got action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", window, action, action->text(), action->is_enabled(), action->shortcut().to_deprecated_string(), action->alternate_shortcut().to_deprecated_string()); + dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Asked window {}, got action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", window, action, action->text(), action->is_enabled(), action->shortcut().to_byte_string(), action->alternate_shortcut().to_byte_string()); return action; } // NOTE: Application-global shortcuts are ignored while a blocking modal window is up. if (!window.is_blocking() && !window.is_popup()) { if (auto* action = Application::the()->action_for_shortcut(shortcut)) { - dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Asked application, got action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", action, action->text(), action->is_enabled(), action->shortcut().to_deprecated_string(), action->alternate_shortcut().to_deprecated_string()); + dbgln_if(KEYBOARD_SHORTCUTS_DEBUG, " > Asked application, got action: {} {} (enabled: {}, shortcut: {}, alt-shortcut: {})", action, action->text(), action->is_enabled(), action->shortcut().to_byte_string(), action->alternate_shortcut().to_byte_string()); return action; } } @@ -349,7 +349,7 @@ void ConnectionToWindowServer::applet_area_rect_changed(Gfx::IntRect const& rect }); } -void ConnectionToWindowServer::drag_dropped(i32 window_id, Gfx::IntPoint mouse_position, DeprecatedString const& text, HashMap const& mime_data) +void ConnectionToWindowServer::drag_dropped(i32 window_id, Gfx::IntPoint mouse_position, ByteString const& text, HashMap const& mime_data) { if (auto* window = Window::from_window_id(window_id)) { auto mime_data_obj = Core::MimeData::construct(mime_data); diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowServer.h b/Userland/Libraries/LibGUI/ConnectionToWindowServer.h index 13283cbcbc2..f041f492096 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowServer.h +++ b/Userland/Libraries/LibGUI/ConnectionToWindowServer.h @@ -24,7 +24,7 @@ public: private: ConnectionToWindowServer(NonnullOwnPtr); - virtual void fast_greet(Vector const&, u32, u32, u32, Core::AnonymousBuffer const&, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, Vector const&, i32) override; + virtual void fast_greet(Vector const&, u32, u32, u32, Core::AnonymousBuffer const&, ByteString const&, ByteString const&, ByteString const&, Vector const&, i32) override; virtual void paint(i32, Gfx::IntSize, Vector const&) override; virtual void mouse_move(i32, Gfx::IntPoint, u32, u32, u32, i32, i32, i32, i32, bool, Vector const&) override; virtual void mouse_down(i32, Gfx::IntPoint, u32, u32, u32, i32, i32, i32, i32) override; @@ -48,11 +48,11 @@ private: virtual void menu_visibility_did_change(i32, bool) override; virtual void screen_rects_changed(Vector const&, u32, u32, u32) override; virtual void applet_area_rect_changed(Gfx::IntRect const&) override; - virtual void drag_dropped(i32, Gfx::IntPoint, DeprecatedString const&, HashMap const&) override; + virtual void drag_dropped(i32, Gfx::IntPoint, ByteString const&, HashMap const&) override; virtual void drag_accepted() override; virtual void drag_cancelled() override; virtual void update_system_theme(Core::AnonymousBuffer const&) override; - virtual void update_system_fonts(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override; + virtual void update_system_fonts(ByteString const&, ByteString const&, ByteString const&) override; virtual void update_system_effects(Vector const&) override; virtual void window_state_changed(i32, bool, bool, bool) override; virtual void display_link_notification() override; diff --git a/Userland/Libraries/LibGUI/Desktop.cpp b/Userland/Libraries/LibGUI/Desktop.cpp index 1fa40eff4b0..9cfd331be08 100644 --- a/Userland/Libraries/LibGUI/Desktop.cpp +++ b/Userland/Libraries/LibGUI/Desktop.cpp @@ -49,7 +49,7 @@ void Desktop::set_wallpaper_mode(StringView mode) ConnectionToWindowServer::the().async_set_wallpaper_mode(mode); } -DeprecatedString Desktop::wallpaper_path() const +ByteString Desktop::wallpaper_path() const { return Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv); } diff --git a/Userland/Libraries/LibGUI/Desktop.h b/Userland/Libraries/LibGUI/Desktop.h index 4a6808d9094..ae1aa33226b 100644 --- a/Userland/Libraries/LibGUI/Desktop.h +++ b/Userland/Libraries/LibGUI/Desktop.h @@ -7,7 +7,7 @@ #pragma once -#include +#include #include #include #include @@ -31,7 +31,7 @@ public: void set_wallpaper_mode(StringView mode); - DeprecatedString wallpaper_path() const; + ByteString wallpaper_path() const; RefPtr wallpaper_bitmap() const; bool set_wallpaper(RefPtr wallpaper_bitmap, Optional path); diff --git a/Userland/Libraries/LibGUI/DragOperation.cpp b/Userland/Libraries/LibGUI/DragOperation.cpp index 4ce9b1045ea..5170bb8c18c 100644 --- a/Userland/Libraries/LibGUI/DragOperation.cpp +++ b/Userland/Libraries/LibGUI/DragOperation.cpp @@ -73,7 +73,7 @@ void DragOperation::notify_cancelled(Badge) s_current_drag_operation->done(Outcome::Cancelled); } -void DragOperation::set_text(DeprecatedString const& text) +void DragOperation::set_text(ByteString const& text) { if (!m_mime_data) m_mime_data = Core::MimeData::construct(); @@ -86,7 +86,7 @@ void DragOperation::set_bitmap(Gfx::Bitmap const* bitmap) if (bitmap) m_mime_data->set_data("image/x-raw-bitmap"_string, bitmap->serialize_to_byte_buffer().release_value_but_fixme_should_propagate_errors()); } -void DragOperation::set_data(String const& data_type, DeprecatedString const& data) +void DragOperation::set_data(String const& data_type, ByteString const& data) { if (!m_mime_data) m_mime_data = Core::MimeData::construct(); diff --git a/Userland/Libraries/LibGUI/DragOperation.h b/Userland/Libraries/LibGUI/DragOperation.h index 160f25ecb38..ad7186d141f 100644 --- a/Userland/Libraries/LibGUI/DragOperation.h +++ b/Userland/Libraries/LibGUI/DragOperation.h @@ -27,9 +27,9 @@ public: virtual ~DragOperation() override = default; void set_mime_data(RefPtr mime_data) { m_mime_data = move(mime_data); } - void set_text(DeprecatedString const& text); + void set_text(ByteString const& text); void set_bitmap(Gfx::Bitmap const* bitmap); - void set_data(String const& data_type, DeprecatedString const& data); + void set_data(String const& data_type, ByteString const& data); Outcome exec(); Outcome outcome() const { return m_outcome; } diff --git a/Userland/Libraries/LibGUI/DynamicWidgetContainer.cpp b/Userland/Libraries/LibGUI/DynamicWidgetContainer.cpp index 0deeaafc73d..115bb8acf52 100644 --- a/Userland/Libraries/LibGUI/DynamicWidgetContainer.cpp +++ b/Userland/Libraries/LibGUI/DynamicWidgetContainer.cpp @@ -144,7 +144,7 @@ void DynamicWidgetContainer::restore_view_state() order_or_error.value().as_array().for_each([&](auto& section_label) { for (auto& container : containers) { - if (container.section_label() == section_label.to_deprecated_string()) + if (container.section_label() == section_label.to_byte_string()) new_child_order.append(container); } }); @@ -227,7 +227,7 @@ ErrorOr DynamicWidgetContainer::detach_widgets() { if (!m_detached_widgets_window.has_value()) { auto detached_window = TRY(GUI::Window::try_create()); - detached_window->set_title(section_label().to_deprecated_string()); + detached_window->set_title(section_label().to_byte_string()); detached_window->set_window_type(WindowType::Normal); if (has_detached_size()) detached_window->resize(detached_size()); diff --git a/Userland/Libraries/LibGUI/EditingEngine.cpp b/Userland/Libraries/LibGUI/EditingEngine.cpp index 9b62133ab2f..1f3192017a1 100644 --- a/Userland/Libraries/LibGUI/EditingEngine.cpp +++ b/Userland/Libraries/LibGUI/EditingEngine.cpp @@ -423,7 +423,7 @@ bool MoveLineUpOrDownCommand::merge_with(GUI::Command const&) return false; } -DeprecatedString MoveLineUpOrDownCommand::action_text() const +ByteString MoveLineUpOrDownCommand::action_text() const { return "Move a line"; } diff --git a/Userland/Libraries/LibGUI/EditingEngine.h b/Userland/Libraries/LibGUI/EditingEngine.h index 8a6d25859aa..4a3be585001 100644 --- a/Userland/Libraries/LibGUI/EditingEngine.h +++ b/Userland/Libraries/LibGUI/EditingEngine.h @@ -92,7 +92,7 @@ public: virtual void undo() override; virtual void redo() override; bool merge_with(GUI::Command const&) override; - DeprecatedString action_text() const override; + ByteString action_text() const override; static bool valid_operation(EditingEngine& engine, VerticalDirection direction); diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp index 86bab699cbf..22f0659e9d7 100644 --- a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp +++ b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp @@ -67,7 +67,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window) for (auto const& category : s_emoji_groups) { auto name = Unicode::emoji_group_to_string(category.group); - DeprecatedString tooltip = name; + ByteString tooltip = name; auto set_filter_action = Action::create_checkable( category.representative_emoji, @@ -126,7 +126,7 @@ auto EmojiInputDialog::supported_emoji() -> Vector builder.append_code_point(*code_point); code_points.append(*code_point); }); - auto text = builder.to_deprecated_string(); + auto text = builder.to_byte_string(); auto emoji = Unicode::find_emoji_for_code_points(code_points); if (!emoji.has_value()) { @@ -135,7 +135,7 @@ auto EmojiInputDialog::supported_emoji() -> Vector emoji->display_order = NumericLimits::max(); } - auto button = Button::construct(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors()); + auto button = Button::construct(String::from_byte_string(text).release_value_but_fixme_should_propagate_errors()); button->set_fixed_size(button_size, button_size); button->set_button_style(Gfx::ButtonStyle::Coolbar); button->on_click = [this, text](auto) mutable { diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.h b/Userland/Libraries/LibGUI/EmojiInputDialog.h index 82e0be40560..86353c23b06 100644 --- a/Userland/Libraries/LibGUI/EmojiInputDialog.h +++ b/Userland/Libraries/LibGUI/EmojiInputDialog.h @@ -19,11 +19,11 @@ class EmojiInputDialog final : public Dialog { struct Emoji { RefPtr