1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

AK+Everywhere: Rename String to DeprecatedString

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

View file

@ -6,10 +6,10 @@
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/DateConstants.h>
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
#include <AK/SourceGenerator.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
@ -36,7 +36,7 @@ struct TimeZoneOffset {
i64 offset { 0 };
Optional<DateTime> until;
Optional<String> dst_rule;
Optional<DeprecatedString> dst_rule;
Optional<i32> dst_rule_index;
i64 dst_offset { 0 };
@ -56,17 +56,17 @@ struct DaylightSavingsOffset {
struct TimeZoneData {
UniqueStringStorage unique_strings;
HashMap<String, Vector<TimeZoneOffset>> time_zones;
Vector<String> time_zone_names;
HashMap<DeprecatedString, Vector<TimeZoneOffset>> time_zones;
Vector<DeprecatedString> time_zone_names;
Vector<Alias> time_zone_aliases;
HashMap<String, Vector<DaylightSavingsOffset>> dst_offsets;
Vector<String> dst_offset_names;
HashMap<DeprecatedString, Vector<DaylightSavingsOffset>> dst_offsets;
Vector<DeprecatedString> dst_offset_names;
HashMap<String, TimeZone::Location> time_zone_coordinates;
HashMap<DeprecatedString, TimeZone::Location> time_zone_coordinates;
HashMap<String, Vector<size_t>> time_zone_regions;
Vector<String> time_zone_region_names;
HashMap<DeprecatedString, Vector<size_t>> time_zone_regions;
Vector<DeprecatedString> time_zone_region_names;
};
}
@ -110,10 +110,10 @@ struct AK::Formatter<DaylightSavingsOffset> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, DaylightSavingsOffset const& dst_offset)
{
auto format_time = [&](auto year) {
return String::formatted("AK::Time::from_timestamp({}, 1, 1, 0, 0, 0, 0)", year);
return DeprecatedString::formatted("AK::Time::from_timestamp({}, 1, 1, 0, 0, 0, 0)", year);
};
static String max_year_as_time("max_year_as_time"sv);
static DeprecatedString max_year_as_time("max_year_as_time"sv);
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {} }}"sv,
@ -422,7 +422,7 @@ static void set_dst_rule_indices(TimeZoneData& time_zone_data)
}
}
static String format_identifier(StringView owner, String identifier)
static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
{
constexpr auto gmt_time_zones = Array { "Etc/GMT"sv, "GMT"sv };
@ -431,9 +431,9 @@ static String format_identifier(StringView owner, String identifier)
auto offset = identifier.substring_view(gmt_time_zone.length());
if (offset.starts_with('+'))
identifier = String::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1));
identifier = DeprecatedString::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1));
else if (offset.starts_with('-'))
identifier = String::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1));
identifier = DeprecatedString::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1));
}
}
@ -441,9 +441,9 @@ static String format_identifier(StringView owner, String identifier)
identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
return String::formatted("{}_{}", owner[0], identifier);
return DeprecatedString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
return String::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@ -551,14 +551,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", String::number(offsets.size()));
generator.set("size", DeprecatedString::number(offsets.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {
)~~~");
for (auto const& offset : offsets)
generator.append(String::formatted(" {},\n", offset));
generator.append(DeprecatedString::formatted(" {},\n", offset));
generator.append("} };\n");
};
@ -580,7 +580,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", String::number(time_zones.size()));
generator.set("size", DeprecatedString::number(time_zones.size()));
generator.append(R"~~~(
static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~");
@ -588,14 +588,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(String::number(time_zone));
generator.append(DeprecatedString::number(time_zone));
first = false;
}
generator.append(" } };");
});
generator.set("size", String::number(time_zone_data.time_zone_names.size()));
generator.set("size", DeprecatedString::number(time_zone_data.time_zone_names.size()));
generator.append(R"~~~(
static constexpr Array<Location, @size@> s_time_zone_locations { {
)~~~");
@ -603,12 +603,12 @@ static constexpr Array<Location, @size@> 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(String::formatted(" {},\n", location));
generator.append(DeprecatedString::formatted(" {},\n", location));
}
generator.append("} };\n");
auto append_string_conversions = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector<Alias> const& aliases = {}) {
HashValueMap<String> hashes;
HashValueMap<DeprecatedString> hashes;
hashes.ensure_capacity(values.size());
auto hash = [](auto const& value) {
@ -731,10 +731,10 @@ Optional<Array<NamedOffset, 2>> get_named_time_zone_offsets(TimeZone time_zone,
auto const& time_zone_offset = find_time_zone_offset(time_zone, time);
Array<NamedOffset, 2> named_offsets;
auto format_name = [](auto format, auto offset) -> String {
auto format_name = [](auto format, auto offset) -> DeprecatedString {
if (offset == 0)
return decode_string(format).replace("{}"sv, ""sv, ReplaceMode::FirstOnly);
return String::formatted(decode_string(format), decode_string(offset));
return DeprecatedString::formatted(decode_string(format), decode_string(offset));
};
auto set_named_offset = [&](auto& named_offset, auto dst_offset, auto in_dst, auto format, auto offset) {